function Go_Search(){
	if (document.MyForm.ProductID.value != "" ) {
		document.MyForm.submit();
	}
}

function getElementPosition(elemID){
	var offsetTrail = document.getElementById(elemID);
	var offsetLeft = 0;
	var offsetTop = 0;
	while (offsetTrail){
	offsetLeft += offsetTrail.offsetLeft;
	offsetTop += offsetTrail.offsetTop;
	offsetTrail = offsetTrail.offsetParent;
	}
	if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined'){
	offsetLeft += document.body.leftMargin;
	offsetTop += document.body.topMargin;
	}
	return {left:offsetLeft,top:offsetTop};
}

function show_mark() {
	apDiv1.style.left = getElementPosition('go_img').left + 120; 
	apDiv1.style.top 	= getElementPosition('go_img').top + 30;
	apDiv1.style.display = "block";
}

function Go_RetrieveSubCategory(str) {
				
	var strCategory = str.value;
	if (strCategory!="") {
		CreateRequest();
		//Retrieve Option List
	  var URL = "/support/getSelectedCategory.asp?Process=RetrieveMenu&Category="+strCategory;
	  httpRequest.onreadystatechange = DisplaySubCategoryResult;
	  httpRequest.open("GET", URL, true);
	  httpRequest.send(null);	
	}
}

function Go_RetrieveMainCategory(str) {

    var strCategory = str.value;
    if (strCategory != "") {
        CreateRequest();
        //Retrieve Option List
        var URL = "/support/getSelectedCategory.asp?Process=RetrieveMainMenu&Category=" + strCategory;
        httpRequest.onreadystatechange = DisplayMainCategoryResult;
        httpRequest.open("GET", URL, true);
        httpRequest.send(null);
    }
}

function DisplaySubCategoryResult() {
  if (httpRequest.readyState == 4) {	//it is okay to continue processing  	  
  
  	if(httpRequest.status == 200) {  	//Perfect			
  		var responseResult = httpRequest.responseText;  	
  		var strOptionList = "";
  		
			if (window.ActiveXObject) {
				var doc = new ActiveXObject("Microsoft.XMLDOM");
				doc.async	= "false";
				doc.loadXML(responseResult);
			}			
			else { // code for Mozilla, Firefox, Opera, etc.
			  var parser = new DOMParser();
			  var doc = parser.parseFromString(responseResult,"text/xml");
			}
			var strXml = doc.documentElement;			
			var strArrayLength = strXml.getElementsByTagName('ProductID').length;
			var strTempArrayLength = 0;
			var strArrayTotalLength = eval(strArrayLength)+1;
			
			strProductList = new Array(strArrayTotalLength); 
			strProductName = new Array(strArrayTotalLength);	

			document.forms['MyForm'].elements['ProductID'].length = strArrayTotalLength;			
			document.forms['MyForm'].elements['ProductID'].options[0].value = "";
			document.forms['MyForm'].elements['ProductID'].options[0].text = "Select a Product";

			for (var i=0; i < strArrayLength; i++) {					
				var j = i+1;
				strProductList[i] = strXml.getElementsByTagName('ProductID')[i].firstChild.data;																							
				strProductName[i] = strXml.getElementsByTagName('ProductName')[i].firstChild.data;
														
				document.forms['MyForm'].elements['ProductID'].options[j].value = strProductList[i];
				document.forms['MyForm'].elements['ProductID'].options[j].text = strProductName[i];							
			}											
			document.MyForm.ProductID.value = "";										
		}
		else  {
			alert('There was a problem with the request.');
		}
	}
}

function DisplayMainCategoryResult() {
    if (httpRequest.readyState == 4) {	//it is okay to continue processing  	  

        if (httpRequest.status == 200) {  	//Perfect			
            var responseResult = httpRequest.responseText;
            var strOptionList = "";

            if (window.ActiveXObject) {
                var doc = new ActiveXObject("Microsoft.XMLDOM");
                doc.async = "false";
                doc.loadXML(responseResult);
            }
            else { // code for Mozilla, Firefox, Opera, etc.
                var parser = new DOMParser();
                var doc = parser.parseFromString(responseResult, "text/xml");
            }
            var strXml = doc.documentElement;
            var strArrayLength = strXml.getElementsByTagName('CategoryID').length;
            var strTempArrayLength = 0;
            var strArrayTotalLength = eval(strArrayLength) + 1;

            strProductList = new Array(strArrayTotalLength);
            strProductName = new Array(strArrayTotalLength);

            document.forms['MyForm'].elements['CategoryID'].length = strArrayTotalLength;
            document.forms['MyForm'].elements['CategoryID'].options[0].value = "";
            document.forms['MyForm'].elements['CategoryID'].options[0].text = "Select a Category";

            for (var i = 0; i < strArrayLength; i++) {
                var j = i + 1;
                strProductList[i] = strXml.getElementsByTagName('CategoryID')[i].firstChild.data;
                strProductName[i] = strXml.getElementsByTagName('CategoryName')[i].firstChild.data;

                document.forms['MyForm'].elements['CategoryID'].options[j].value = strProductList[i];
                document.forms['MyForm'].elements['CategoryID'].options[j].text = strProductName[i];
            }
            document.MyForm.CategoryID.value = "";
        }
        else {
            alert('There was a problem with the request.');
        }
    }
}	

function Go_SearchProduct(str) {
	var strProduct = str.value;
	alert(strProduct);
	if (strProduct!="") {
		document.MyForm.submit();
	}
}