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 custno(code)
{
  
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert("Browser does not support HTTP Request");
        return;
    }
    var url = "itemthreadup_data.php";
    url = url + "?Command=" + "pass_quot";
    url = url + "&custno=" + code;

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

}


function passcusresult_quot()
{
    var XMLAddress1;

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

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("id");
        var obj = JSON.parse(XMLAddress1[0].childNodes[0].nodeValue);

        opener.document.getElementById('invno').value = obj.REF_NO;  
        opener.document.getElementById('txtcusname').value = obj.CUS_NAME;     
        opener.document.getElementById('repfrom').value = obj.SAL_EX;
        opener.document.getElementById('repto').value = obj.SAL_EX;     
         


        self.close();
    }

}


   function custno1(code)
{
  
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null)
    {
        alert("Browser does not support HTTP Request");
        return;
    }
    var url = "itemthreadup_data.php";
    url = url + "?Command=" + "pass_quot1";
    url = url + "&custno=" + code;

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

}


function passcusresult_quot1()
{
    var XMLAddress1;

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

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("id");
        var obj = JSON.parse(XMLAddress1[0].childNodes[0].nodeValue);

        opener.document.getElementById('stkno').value = obj.STK_NO;      
         opener.document.getElementById('th1').value = obj.th1;      
          opener.document.getElementById('th2').value = obj.th2;      
           opener.document.getElementById('th3').value = obj.th3;      
            opener.document.getElementById('th4').value = obj.th4;      
         
opener.document.getElementById('brand').value = obj.BRAND_NAME;  
opener.document.getElementById('des').value = obj.DESCRIPT;  

        self.close();
    }

}

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

    if (document.getElementById('stkno').value == "") {
        document.getElementById('msg_box').innerHTML = "<div class='alert alert-warning' role='alert'><span class='center-block'>Please Select Item..</span></div>";
        return false;
    }

    var url = "itemthreadup_data.php";
    url = url + "?Command=" + "uprep";
    url = url + "&stkno=" + document.getElementById('stkno').value;
    url = url + "&th1=" + document.getElementById('th1').value;
    url = url + "&th2=" + document.getElementById('th2').value;
    url = url + "&th3=" + document.getElementById('th3').value;
    url = url + "&th4=" + document.getElementById('th4').value;

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

}


function re_up()
{
    var XMLAddress1;

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

       alert(xmlHttp.responseText);
       setTimeout("location.reload(true);", 1200);
    }

}