// GENERAL JAVASCRIPT FUNCTIONS
function searchBarState(obj, mode){
	var val = obj.value;
	if(mode=='onclick'){
		if(val=='SEARCH...'){
			obj.value = '';
		}
		return;
	}else if(mode=='blurred'){
		if(val.length==0){
			obj.value = 'SEARCH...';
		}
		return;
	}
	return;
}

this.blankwin = function(){ // Opens External Sites in a New Window
	var hostname = window.location.hostname;
	hostname = hostname.replace("www.","").toLowerCase();
	var a = document.getElementsByTagName("a");	
	this.check = function(obj){
		var href = obj.href.toLowerCase();
		return (href.indexOf("http://")!=-1 && href.indexOf(hostname)==-1) ? true : false;				
	};
	this.set = function(obj){
		obj.target = "_blank";
		obj.className = "external";
	};	
	for (var i=0;i<a.length;i++){
		if(check(a[i])) set(a[i]);
	};		
};



// script initiates on page load. 

this.addEvent = function(obj,type,fn){
	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]);
	} else {
		obj.addEventListener(type,fn,false);
	};
};
addEvent(window,"load",blankwin);


// ajax

function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
	// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
	//Internet Explorer
		try	{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

// toggle visiblity on faq

function showAnswer(value){ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
					alert ("Browser does not support AJAX - Please update");
	}
	var url="../Includes/ajax_faq.php";
		url=url+"?phpValue="+value;
	xmlHttp.onreadystatechange=function () { bstateChanged("displayAnswer"+value); };
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function bstateChanged(divName) { 
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
                                document.getElementById(divName).innerHTML=xmlHttp.responseText 
                } 
}

function show(id, question) {
	if (document.getElementById(id).style.display != 'none') {
		document.getElementById(id).style.display = 'none';
		document.getElementById(question).style.fontWeight = 'normal';
	} else {
		document.getElementById(id).style.display = 'block';
		document.getElementById(question).style.fontWeight = 'bold';
	}
}

function showCat(id, imgId, type) {
		var relational = (type==0) ? '../../../' : '../';
		if (document.getElementById(id).style.display != 'block') {
		document.getElementById(id).style.display = 'block';
		document.getElementById(imgId).src = relational + 'images/faq_arrow1.gif';
		} else {
		document.getElementById(id).style.display = 'none';
		document.getElementById(imgId).src = relational + 'images/faq_arrow2.gif';
		}
}

function hide(id) {
	document.getElementById(id).style.display = 'none';

}

function update(type) {
	if(type==1) {
		var form = document.forms.comp.rad_website[0].checked;
		var show = document.getElementById("webaddress");
	} else if(type==2) {
		var form = document.forms.comp.sel_existing_customer[0].checked;
		var show = document.getElementById("product");	
	} else if(type==3) {
		document.getElementById("comp").style.display = 'none';
		var form = true;
		var show = document.getElementById("tell-a-friend");
	} else if(type==4) {
		document.getElementById("tell-a-friend").style.display = 'none';
		var show = document.getElementById("comp");
		var form = true;
	}
	show.style.display = (form==true) ? 'block' : 'none';
}


function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=730,height=700');");
}
// End -->