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


function keyset(key, e)
{

    if (e.keyCode == 13) {
        document.getElementById(key).focus();
    }
}

function got_focus(key)
{
    document.getElementById(key).style.backgroundColor = "#000066";

}

function lost_focus(key)
{
    document.getElementById(key).style.backgroundColor = "#000000";

}




function itno_grn(itno)
{


    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert("Browser does not support HTTP Request");
        return;
    }


    var url = "search_arnData.php";
    url = url + "?Command=" + "pass_itno";
    url = url + "&itno=" + itno;
    
    
    xmlHttp.onreadystatechange = passitresult;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);



}

function passitresult()
{
    var XMLAddress1;
 


    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
        alert(xmlHttp.responseText);

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("STK_NO");	
        opener.document.form1.item_code.value = XMLAddress1[0].childNodes[0].nodeValue;
        
      XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DESCRIPT");	
        opener.document.form1.itemdescript.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_Flagdesc");
        var str_Flagdesc = XMLAddress1[0].childNodes[0].nodeValue;

        if (str_Flagdesc == "yess") {  
            opener.document.form1.itemdescript.disabled = false;

        } else if (str_Flagdesc == "Noo") {  
            opener.document.form1.itemdescript.disabled = true;


        }


        
        opener.document.form1.qty1.focus();
self.close();


    }
}

function add_tmp()
{

    //alert("ok");
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert("Browser does not support HTTP Request");
        return;
    }



    var url = "search_arnData.php";
    url = url + "?Command=" + "add_tmp";
    url = url + "&invno=" + document.getElementById('invno').value;

    url = url + "&item_code=" + document.getElementById('item_code').value;
    url = url + "&itemdescript=" + document.getElementById('itemdescript').value;
    url = url + "&orderQty=" + document.getElementById('orderQty').value;
    url = url + "&fob=" + document.getElementById('fob').value;
    url = url + "&qty1=" + document.getElementById('qty1').value;
    url = url + "&cost1=" + document.getElementById('cost1').value;
    url = url + "&selling1=" + document.getElementById('selling1').value;
    url = url + "&margin1=" + document.getElementById('margin1').value;
    url = url + "&subtot_new=" + document.getElementById('subtot_new').value;
    //alert(url);

    xmlHttp.onreadystatechange = showarmyresult_addtmp;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);


}

function showarmyresult_addtmp()
{
    var XMLAddress1;

    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
        //alert(xmlHttp.responseText);
        //setTimeout("location.reload(true);",500);
        //if (xmlHttp.responseText=="exist"){
        //	alert("Already Exists");	
        //}
        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table");
        document.getElementById('itemdetails').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;


    }
}

function update_item_list()
{   
	
			
			xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request");
				return;
			} 		
			
			
			var url="search_arnData.php";			
			url=url+"?Command="+"search_item";
			url=url+"&itno="+document.getElementById('itno').value;
			url=url+"&itemname="+document.getElementById('itemname').value;
			
			if (document.getElementById('itno').value!=""){
				url=url+"&mstatus=itno";
			} else if (document.getElementById('itemname').value!=""){
				url=url+"&mstatus=itemname";
			}
			//url=url+"&mstatus2=ord_item";
			//alert(url);		
			xmlHttp.onreadystatechange=showitemresult;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		
	
}

function showitemresult()
{
	var XMLAddress1;
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById('filt_table').innerHTML=xmlHttp.responseText;
	}
}




