
var aMenuChoices; // needs to have each layer name in an array for hiding purposes
var LayerTimeoutID = null;
var ButtonTimeoutID = null;
var MatchChoices = 'and';

aMenuChoices = new 	Array("popup_about_us","popup_products","popup_services","popup_press","popup_customer_support","popup_jobs","popup_contact_us");
function SelectMatchChoice(radiobutton){
	if (radiobutton == 'all')
		MatchChoices = 'and';
	if (radiobutton == 'any')
		MatchChoices = 'or';
}

function popupmenu(sMyLayerName,sState,sMyImageName,sMyNewSource){
	switchimage(sMyImageName,sMyNewSource);
	togglelayer(sMyLayerName,sState);
}

function switchimage(sMyImageName,sMyNewSource){
	if (document.images){
		document.images[sMyImageName].src = sMyNewSource;
	}
}

function switchlayerimage(sMyLayerName,sMyImageName,sMyNewSource){
	//alert(document.layers[sMyLayerName].document.images.length)
	if (document.images){
		if (document.layers && document.layers[sMyLayerName]){
			document.layers[sMyLayerName].document.images[sMyImageName].src = sMyNewSource;
		}
		else{
			document.images[sMyImageName].src = sMyNewSource;
		}
		return;
	}
}

function hideall(myLayerName){
	for (var i = 0; i < aMenuChoices.length; i++) {   
		if (aMenuChoices[i] != myLayerName ){
		togglelayer(aMenuChoices[i],"hide");
		}
	}
}

function togglelayer(layername,state){
// states are hide or show
	// Internet Explorer
	if (document.all && window.document.all[layername]) {
		state=(state=='show')?'visible':(state='hide')?'hidden':state;
		window.document.all[layername].style.visibility = state;
	}
	// Netscape Navigator
	if (document.layers && document.layers[layername]){
		state=(state=='show')?'visible':(state='hide')?'hide':state;
		document.layers[layername].visibility =  state
	}
}

function overLayer() {
	if ( LayerTimeoutID )
		clearTimeout(LayerTimeoutID);
	LayerTimeoutID = null;
}

function leaveLayer() {
	if ( LayerTimeoutID )
		clearTimeout(LayerTimeoutID);
	LayerTimeoutID = setTimeout('hideall()', 1);
}

function overButton(sJsFunctionName) {
	if ( ButtonTimeoutID )
		clearTimeout(ButtonTimeoutID);
	ButtonTimeoutID = setTimeout(sJsFunctionName, 100);
}

function leaveButton() {
	if ( ButtonTimeoutID )
		clearTimeout(ButtonTimeoutID);
	ButtonTimeoutID = null;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
 
 
function SwitchQuote(myName,myNewImageSrc,myQuoteName,myQuoteSrc,andy, andy2) {
	if (document.images){
		document.images[myName].src = myNewImageSrc;
		document.images[myQuoteName].src = myQuoteSrc;
		return;
	}
}


function popup_window(sUrl, nWidth, nHeight) {
	tmp = "width="+ nWidth + ",height=" + nHeight + ",resizeable=no, scrollbars=yes"
	smallwin = window.open(sUrl, '__render', tmp);
	if (smallwin.opener) {
		if (smallwin.opener.top) {
			smallwin.opener.top.name = 'smallwindow';
		}
	}
	if (smallwin) {
		smallwin.focus();
	}
}

function doform(sFormName,sRadioName,sTextboxName){
//alert(sFormName + "," + sRadioName + "," + sTextboxName + "," + sRadioSearchName);
myForm = eval("document." + sFormName);
myRadio = eval("document." + sFormName +"."+ sRadioName);
//alert (myRadio.value)
myTextbox = eval("document." + sFormName +"."+ sTextboxName);
strvalue = stateChecker(myRadio);
//alert(strvalue);
if(strvalue.indexOf("~replace~")){
	strfront = strvalue.slice(0,strvalue.indexOf("~replace~"));
	strback = strvalue.slice(strvalue.indexOf("~replace~")+9);
	strnewurl = strfront + escape(myTextbox.value) + strback + '&msmatch=' + MatchChoices;
	//alert(strnewurl);
	//window.open(strnewurl,"","titlebar='yes',toolbar='yes',resizable='yes'")
	//window.location.href = strnewurl;
	//window.location.href="http://yahoo.com";
	
	demowindow = window.open(strnewurl,"","titlebar=yes,scrollbars=yes,toolbar=yes,status=yes,location=yes,menubar=yes,resizable=yes")
	demowindow.opener = window
	if (demowindow){
		demowindow.focus();
	}
}
}

function stateChecker(oForm) { 
	//alert(oForm.length);
	//alert(oForm.value) 
	var checkedButton = ""   
	if (oForm.length){
		for (var i = 0; i < oForm.length; i++) {      
			if (oForm[i].checked==true) {         		
				checkedButton=oForm[i].value 
				//alert(checkedButton);
				return checkedButton;     
			}   
		}
	}
	else{
		checkedButton = oForm.value;
		return checkedButton;
	}
}


function showcaseRadioClick (sProjectName,sTopImageType, sImageName,sFormName, sTextboxName, sSampleQuery){
myForm = eval("document." + sFormName + "." + sTextboxName);
myForm.value = sSampleQuery;
sBasepath = "images\\";
switchimage(sImageName, sBasepath + "logo_" + sProjectName + "." + sTopImageType)
}

function openPopup(myWidth,myHeight,myUrl){
	mylocation = "screenX=0,screenY=0"
	temp = "height=" + myHeight + ",width=" + myWidth + ",scrollbars=no,resizable=no," + mylocation; 
	ms_popup = window.open(myUrl,'popup',temp)
	ms_popup.focus();
}
