var browser=navigator.appName;
var xmlHttp;
function searchMsg(str) { 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="ajax_calls/search_call.php";
	url=url+"?search_msg="+str+"&sugg_limit="+sugg_limit;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("POST",url,true); // 4-22-09 This was "GET"
	xmlHttp.send(null);
}
function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById("result").innerHTML=xmlHttp.responseText;
	} 
}

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;
}

// functional functions
var currentMsg = '';
function goToDropdown(e){ // in original php file
	var unicode=e.keyCode? e.keyCode : e.charCode
	//alert (unicode);
	if (unicode == 40) {
		currentMsg = document.landing_page.s.value;
		if (currentMsg != '') document.landing_page.result_dropdown.focus();
	}
}
function exitDropdown(e,id,name){ // in ajax file
	var unicode=e.keyCode? e.keyCode : e.charCode
	//var position = document.landing_page.result_dropdown.selectedIndex;
	if (unicode == 38 && id == 0) {
		document.landing_page.s.value = currentMsg;
		document.landing_page.s.focus();
	//} else if (unicode == 40 && id == (sugg_limit-1)) {
	//	document.landing_page.s.value = currentMsg;
	//	document.landing_page.s.focus();
	// to make this else if work, you need to pass the actual size of the dropdown box as sugg_limit, what if there are only 2 results?
	} else if (unicode == 13) {
		document.landing_page.s.value = name;
		document.landing_page.submit.focus();
	}
}
function exportOption(choose) { // in ajax file
	document.landing_page.s.value = choose;
}
function performSearch(choose) { // in ajax file
	document.landing_page.s.value = choose;
	window.location = "http://www.simplegreen.com/search.php?s=" + choose;
}

