
// broadband what you need page - image toggle

function toggleWireless()
		{
			var obj;
			obj = document.getElementById("wirelessSetup");
			obj.style.display = 'block';
			
			var obj;
			obj = document.getElementById("standardSetup");
			obj.style.display = 'none';
		}
		
function toggleStandard()
		{
			var obj;
			obj = document.getElementById("standardSetup");
			obj.style.display = 'block';
			
			var obj;
			obj = document.getElementById("wirelessSetup");
			obj.style.display = 'none';
		}

function productPopup(url) {
	var width = 525;
	var height = 350;
	var left = (screen.width-width)/2;
	var top = (screen.height*0.8-height)/2;
		
	newWin = window.open(url, "popup", "width="+width+",height="+height+",toolbar=no,location=no,directories=no,resizable=no,status=no,menubar=no,screenX=100,screenY=100, left="+left+", top="+top);
}

function openpopup(strUrl, intWidth, intHeight, showToolBars) {
	var left = (screen.width-intWidth)/2;
	var top = (screen.height*0.8-intHeight)/2;
	var toolCode;
	if(showToolBars != true) toolCode = "toolbar=no,location=no,directories=no,resizable=no,status=no,menubar=no,";
		else toolCode = "toolbar=yes,location=yes,directories=yes,resizable=yes,status=yes,menubar=yes,scrollbars=yes,";
	
	newWin = window.open(strUrl, "popup", "width="+intWidth+",height="+intHeight+","+toolCode+"screenX=100,screenY=100, left="+left+", top="+top);
}

function knowledgebasepopup(article_id) {
	var width = 600;
	var height = 450;
	var left = (screen.width-width)/2;
	var top = (screen.height*0.8-height)/2;

	newWin = window.open("http://www.fasthosts.co.uk/knowledge-base/?article_id=" + article_id, "popup", "width="+width+",height="+height+",scrollbars=yes,toolbar=no,location=no,directories=no,resizable=no,status=no,menubar=no,screenX=100,screenY=100, left="+left+", top="+top);
}
// Animates a button when clicked.
// To call, use onClick="startAnim(this);"

var objClickedBtn = '';
var i = 0;
var bolAnimating = false;

function startAnim(btn) {
	if (!bolAnimating) {
		objClickedBtn = btn;
		objClickedBtn.className = 'btndisabled';
		objClickedBtn.disabled = true;
		objClickedBtn.value = 'Please wait   ';
		bolAnimating = true;
		btnanim = setInterval('moretext()', 250);
	}
}
 
function moretext() {
	if (i == 0) {
		objClickedBtn.value = 'Please wait.  ';
	}
	else if (i == 1) {
		objClickedBtn.value = 'Please wait.. ';
	}
	else if (i == 2) {
		objClickedBtn.value = 'Please wait...';
	}
	else if (i == 3) {
		objClickedBtn.value = 'Please wait   ';
		i = -1;
	}
	i++;
}

function bookMarkPage() {
	window.external.AddFavorite(location.href, document.title);
}

function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
	begin = dc.indexOf(prefix);
	if (begin != 0) return null;
	} else
	begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
	
}

function rememberLoginCheck(strCheckID, strInputID) {
	if (document.getElementById(strCheckID).checked) {
		var dtExpires = new Date();
		deleteCookie('remembercplogin');
		dtExpires.setTime(dtExpires.getTime() + 2678400000); // 31 days
		//alert(dtExpires);
		setCookie('remembercplogin', document.getElementById(strInputID).value, dtExpires);
	}
	else {
		deleteCookie('remembercplogin');
	}
	
	return true;
}

function highlighter(element_id, state) {
	element = document.getElementById(element_id);
	
	if(state == 1) {
		element.className = 'highlight'
	}else{
		element.className = '';
	}
}


function gotoUrl(url) {
	window.location = url;
}

function trim(s) {
	// Remove leading spaces and carriage returns
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')) {
		s = s.substring(1,s.length);
	}
	
	// Remove trailing spaces and carriage returns
	while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')) {
		s = s.substring(0,s.length-1);
	}
	return s;
}

function enableObject(objId, state){
	obj = $(objId);
	if (obj) {
		if(state){
			obj.disabled = false;
			obj.blur();
			obj.style.color = "#000";
			obj.style.backgroundColor = "#fff";
		}
		else{
			obj.disabled = true;
			obj.style.color = "#999";
			obj.style.backgroundColor = "#eee";
		}
	}
}

function regExCheck(strToCheck, arrItem) {
	var pattern = new RegExp(arrItem);
		return (pattern.test(strToCheck));
}

function requestPW(){
	pwReminder = window.open('/login/forgotten-login/popup.asp', "reminder",'width=499,height=246,status=no');
}



function knowledgeBasePopup(strURL){
	kbPopUp = window.open('/knowledge-base/?'+strURL, "kbpopup",'width=600,height=450,status=no,scrollbars=yes');
}

function newfrompopup(strURL){
	kbPopUp = window.open('/new-from-fasthosts/'+strURL, "kbpopup",'width=750,height=650,status=no,scrollbars=yes');
}

function addEvent(obj,type,fn) {

	if (obj.addEventListener) obj.addEventListener(type,fn,false);

	else if (obj.attachEvent)	{

		obj["e"+type+fn] = fn;

		obj[type+fn] = function() {obj["e"+type+fn](window.event);}

		obj.attachEvent("on"+type, obj[type+fn]);

	}

}

addEvent(window, "load", function() {	

	objForms = document.getElementsByTagName("form")

	for (var i = 0; i < objForms.length; i++) {	
		if(objForms[i].className.indexOf("submitter") != -1) {
			Event.observe(objForms[i], 'keypress', function(event) {
	
				if (event.keyCode == Event.KEY_RETURN) {
	
					Event.element(event).form.submit();
	
				}
	
			}.bind(this), true);
		}
	}

});

function toggleTab(tabId) {
	resetTabs();
	if($('paypal_' + tabId)) $('paypal_' + tabId).style.display = "block"; 
	if($(tabId)) $(tabId).className = "selected"; 
}

function resetTabs() {
	$('paypal_express').style.display = "none"; 
	$('paypal_standard').style.display = "none"; 
	$('paypal_pro').style.display = "none"; 
	$('express').className = "";
	$('standard').className = "";
	$('pro').className = ""; 
}

function slideme(element_id) {
	if($(element_id)) {
		Effect.toggle(element_id,'blind', {afterFinish: slideIndicator, duration: 0.3});
	}
}

function hideme(element_id) {
	if($(element_id)) {
		$(element_id).style.display = "none";
		if($('hdr_' + element_id)) $('hdr_' + element_id).className = "collapsed";
	}
}

function slideIndicator(obj) {
		element_id = obj.element.id;
		
		if($('hdr_' + element_id)) {
			if($(element_id).visible()) $('hdr_' + element_id).className = "expanded";
				else $('hdr_' + element_id).className = "collapsed";
		}
}

