function findPosX(obj){var curleft = 0;if (obj.offsetParent){while (obj.offsetParent){curleft += obj.offsetLeft;obj = obj.offsetParent;}}else if (obj.x) curleft += obj.x;return curleft;}
function findPosY(obj){var curtop = 0;if (obj.offsetParent){while (obj.offsetParent){curtop += obj.offsetTop;obj = obj.offsetParent;}}else if (obj.y) curtop += obj.y;return curtop;}

var xmlHttp;

function submitSearchWithn() { 
	if (document.frmSearchWithn.txtkey.value.indexOf(" ") == 0) {
		alert("Search string should not start with spaces.");
		document.frmSearchWithn.txtkey.focus();
		return false;
	}
	if (document.frmSearchWithn.txtkey.value == "") {
		alert("Please enter a search string.");
		document.frmSearchWithn.txtkey.focus();
		return false;
	}
	document.frmSearchWithn.submit();
	return true;
}

function submitSearchWithn2() { 
	if (document.frmSearchWithn2.txtkey.value.indexOf(" ") == 0) {
		alert("Search string should not start with spaces.");
		document.frmSearchWithn2.txtkey.focus();
		return false;
	}
	if (document.frmSearchWithn2.txtkey.value == "") {
		alert("Please enter a search string.");
		document.frmSearchWithn2.txtkey.focus();
		return false;
	}
	document.frmSearchWithn2.submit();
	return true;
}

function submitSearchWithn3() { 
	if (document.frmSearchWithn3.cc.options(document.frmSearchWithn3.cc.selectedIndex).value == '0') {
		alert("Please select a category.");
		document.frmSearchWithn3.cc.focus();
		return false;
	}	
	document.frmSearchWithn3.submit();
	return true;
}

function popManufs(str) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url;
	if (str != '')
		url = "/includes/custom_includes/getallmanufs.asp?" + str + "&sid="+Math.random();
	else
		url = "/includes/custom_includes/getallmanufs.asp?sid="+Math.random();
	xmlHttp.onreadystatechange = function() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			document.getElementById("LNMfExpansion").innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function getLNBrands() {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="/includes/custom_includes/getLNbrands.asp?sid="+Math.random();
	xmlHttp.onreadystatechange = function() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			document.getElementById("divBrands").innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function popBrands(str) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url;
	if (str != '')
		url = "/includes/custom_includes/getallbrands.asp?" + str + "&sid="+Math.random();
	else
		url = "/includes/custom_includes/getallbrands.asp?sid="+Math.random();

	xmlHttp.onreadystatechange = function() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			document.getElementById("LNBrExpansion").innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function GetXmlHttpObject() {
	var objXMLHttp=null;
	try {
		objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP"); //later IE
	} catch (e) {
		try {
			objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); //earlier IE
		} catch (e) {
			objXMLHttp = null;
		}
	}
	if (objXMLHttp==null) {
		objXMLHttp=new XMLHttpRequest(); //IE7, Firefox, Safari
	}
	return objXMLHttp;
}
