//general site js functions

//submits a search from the main site search 
//currently disabled for internal site search. use this for atmoz search only.
function submitSearch() {
	var searchText = document.getElementById("fSearch").value;
	location.href=('http://search.storactive.com/search/?sp-a=sp100159cd&sp-q='+ searchText +'');
}

// Collapses the requested area
function doCollapse(elemId) {
	targetElement = document.getElementById(elemId);

	if (targetElement.style.display == "none") {
		targetElement.style.display = "";
	} else {
		targetElement.style.display = "none";
	}
}

//analyzes and sets routing for system mailer based from form_countrySelect.asp
//displays the state/province selector if the country is US or Canada
//if the form has hidden value _recipientsOff, the original value will not be altered (routing override feature)
function countrySelect(name) {
	
	switch(name){
	case "United States": case "Canada":
	if (!document.multiForm._recipientsOff) {document.multiForm._recipients.value = "info.us@atempo.com";}
	showState(1);
	break;
	case "Austria": case "Germany":
	if (!document.multiForm._recipientsOff) {document.multiForm._recipients.value = "info.de@atempo.com";}
	showState(0);
	break;
	case "France":
	if (!document.multiForm._recipientsOff) {document.multiForm._recipients.value = "info.fr@atempo.com";}
	showState(0);
	break;
	case "United Kingdom":
	if (!document.multiForm._recipientsOff) {document.multiForm._recipients.value = "info.uk@atempo.com";}
	showState(0);
	break;
	default:
	showState(0);
	}
	
	//shows or hides the state selector in multiForm
	function showState(tf) {
		if (tf == 1) {
			document.getElementById("stateDis").style.display = "";
			document.getElementById("stateDiv").style.display = "";
		} else {
			document.getElementById("stateDis").style.display = "none";
			document.getElementById("stateDiv").style.display = "none";
		}
	}
}

//submits a form named multiForm to salesforce.com as well as the default system mailer
function multiSubmit() {
	//set the action to the default system mailer
	document.multiForm.action = "/inc/systemMailer.asp";
	document.multiForm.target = "systemMailer";
    document.multiForm.submit();
	//set the action to salesforce.com
    document.multiForm.action = "http://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8";
    document.multiForm.target = "salesForceSub";
    document.multiForm.submit();
	//redirect to page specified in form as "_returnPage". if none specified, home page will be used
	if (!document.multiForm._returnPage) {
		location.href = '/default.asp';
	} else {
		location.href = document.multiForm._returnPage.value;
	}
}