


function showEl(el) {
		el = document.getElementById('bg' + el);
		if (el != null) {
			el.style.visibility = 'visible';
		}
	}

	function hideEl(el) {
		el = document.getElementById('bg' + el);
		if (el != null) {
			el.style.visibility = 'hidden';
		}
	}

	function toggleBg(el) {
		el = document.getElementById('bg' + el);
		if (el != null) {
			if (el.style.visibility == 'visible') {
				el.style.visibility = 'hidden';
			} else {
				el.style.visibility = 'visible';
			}
		} else {
			//alert('invalid!');	
		}
	}


	// function that makes the nav column the same height as the content or right column, but only if the nav col
	// height is less than the content or right column
	function levelHeights (objidLeft,objidCentre,objidRight) {
        var lHeight = xHeight(objidLeft);
		var cHeight = xHeight(objidCentre);
		var rHeight = xHeight(objidRight);
		
		obj = document.getElementById(objidLeft);
		var maxHeight = (Math.max(cHeight,Math.max(lHeight,rHeight)));

		xHeight(objidLeft,maxHeight);

	}

	function levelCols() {
		levelHeights('navcol','content','rightcol');
	}

	function loginUser(frm) {
		if (getCheckedValue(frm.theService)=="email") {
			document.getElementById("theUser").name="login_username";
			document.getElementById("thePass").name="secretkey";
			frm.action = "http://webmail.loadedtechnologies.com/webmail/src/redirect.php";
		} else {
			frm.action = "http://js.loadedtechnologies.com/Default.asp";
		}
	}

	function getCheckedValue(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	}
	
	function processAJAXRequest(method,script,vars,outputEl) {
		try {
			xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			return;
		}

		el = outputEl;
		xmlhttp.onreadystatechange = handleResponse;

		if (method == 'get') {
			xmlhttp.open("get", script + "?" + vars,true);
			xmlhttp.send(null);
		} else {
			xmlhttp.open("post",script,true);
			xmlhttp.send(vars);
		}
	}

	function handleResponse() {
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			document.getElementById(el).innerHTML = xmlhttp.responseText;
		}
	}
	
	// AJAX Functions
	function addSubscriber(frm) {
		processAJAXRequest("post","/scripts/addSubscriber.asp","name=" + frm.nName.value + "&" + frm.nEmail.value,"subscribePanel");
	}

/**************************
	Steps to automatically resize all iframes
****************************/
	var iframeids=["guideFrame","contactFrame"];
	
	function resizeCaller() {
		for (i=0; i<iframeids.length; i++){
			resizeIframe(iframeids[i]);
		}
	}

	function resizeIframe(frameId) {
		var f = document.getElementById(frameId);
		var h = "";
		if (f== null) return false;
		
		if ( f.contentDocument ) {
			h = f.contentDocument.documentElement.offsetHeight + 20 + "px";
			f.setAttribute( "height", h );
			f.parentNode.setAttribute( "height", h );
		} else if ( f.contentWindow ) {
			h = f.contentWindow.document.body.scrollHeight + 5 + "px";
			f.setAttribute( "height", h );
			f.parentNode.setAttribute( "height", h );
		} 
	}


/**********************************************************************

***********************************************************************/
function highlightWord(node,word) {
	// Iterate into this nodes childNodes
	if (node.hasChildNodes) {
		var hi_cn;
		for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
			highlightWord(node.childNodes[hi_cn],word);
		}
	}
	
	// And do this node itself
	if (node.nodeType == 3) { // text node
		tempNodeVal = node.nodeValue.toLowerCase();
		tempWordVal = word.toLowerCase();
		if (tempNodeVal.indexOf(tempWordVal) != -1) {
			pn = node.parentNode;
			if (pn.className != "searchword") {
				// word has not already been highlighted!
				nv = node.nodeValue;
				ni = tempNodeVal.indexOf(tempWordVal);
				// Create a load of replacement nodes
				before = document.createTextNode(nv.substr(0,ni));
				docWordVal = nv.substr(ni,word.length);
				after = document.createTextNode(nv.substr(ni+word.length));
				hiwordtext = document.createTextNode(docWordVal);
				hiword = document.createElement("span");
				hiword.className = "searchword";
				hiword.appendChild(hiwordtext);
				pn.insertBefore(before,node);
				pn.insertBefore(hiword,node);
				pn.insertBefore(after,node);
				pn.removeChild(node);
			}
		}
	}
}

function initPage() {
//	highlightWord(document.getElementsByTagName("body")[0],"bpay");
	resizeCaller();
	levelCols();
}

/* added functions for advance search */

function viewAdvSearch(){
	var objAdvSearch = document.getElementById('advSearch');
	if(objAdvSearch){
		if(objAdvSearch.className=="hidden"){
			objAdvSearch.className="visible";
		}else{
			objAdvSearch.className="hidden";
		}
	}
}

function ifUseAdvSearch(){
	var url = window.location.href;
	url = url.toLowerCase();
	
	var objAdvSearch = document.getElementById('advSearch');
	if(objAdvSearch){
		if(url.indexOf("action=advsearch")>0 || url.indexOf("action/advsearch")>0){
			objAdvSearch.className = "visible";
		}else{
			objAdvSearch.className = "hidden";
		}
	}
}

function clearMe(obj){
	if(obj){
		var objEW = document.getElementsByName('ew')[0];
		var objBW = document.getElementsByName('bw')[0];
		var objOW = document.getElementsByName('ow')[0];
	
		switch(obj.id){
			case "imgOW":
				if(objEW){objEW.value="";}if(objBW){objBW.value="";}
				break;
			case "imgBW":
				if(objEW){objEW.value="";}if(objOW){objOW.value="";}
				break;
			case "imgEW":
				if(objBW){objBW.value="";}if(objOW){objOW.value="";}
				break;
			case "oWord":
				if(objEW){objEW.value="";}if(objBW){objBW.value="";}
				break;
			case "bWord":
				if(objEW){objEW.value="";}if(objOW){objOW.value="";}
				break;
			case "eWord":
				if(objBW){objBW.value="";}if(objOW){objOW.value="";}
				break;
		}
	}
}

function searchMe(e,obj){
	var frmobj = document.getElementById('advSearch');
	var keynum;

	if(window.event) {
		keynum = e.keyCode; // IE
	}else if(e.which) {
		keynum = e.which;   // Netscape/Firefox/Opera
	}

	if(keynum==13){
		clearMe(obj);
		frmobj.submit();
	}
}

	function addLoadEvent(func) {
 		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				oldonload();
				func();
			}
		}

	}

/****************************************/



/*if (window.addEventListener)
window.addEventListener("load", initPage, false)
else if (window.attachEvent)
window.attachEvent("onload", initPage)
else
window.onload=initPage*/

	function addRoundedCorners() {
		if (!NiftyCheck()) return;
		
		RoundedBottom("div.alertPanel","#FFFFFF","#cd613f");
		Rounded("div.rounded","#FFFFFF","#a6cdeb");
		RoundedBottom("div.roundedbottom","#FFFFFF","#a6cdeb");
		RoundedTop("div.roundedtop","#FFFFFF","#a6cdeb");
		
		Rounded("div.grayrounded","#FFFFFF","#b3b4b3");
		RoundedBottom("div.grayroundedbottom","#FFFFFF","#b3b4b3");
		RoundedTop("div.grayroundedtop","#FFFFFF","#b3b4b3");
		
		Rounded("div.beigerounded","#FFFFFF","#eaead8");
		
		//RoundedBottom("div.alertPanel","#FFFFFF","#a6cdeb");
      
//		RoundedBottom("form.roundedbottom","#FFFFFF","#a6cdeb");
//		RoundedTop("form.roundedtop","#FFFFFF","#a6cdeb");	
//		Rounded("form.rounded","#FFFFFF","#a6cdeb");	
		
//		Rounded("div.rounded","#FFFFFF","#a6cdeb");	
//		RoundedBottom("div.roundedbottom","#FFFFFF","#a6cdeb");	

	}
	addLoadEvent(addRoundedCorners);
	addLoadEvent(ifUseAdvSearch);
	addLoadEvent(initPage);
