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 keychange(key)
{

    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 close_form()
{
    self.close();
}



function add_tmp()
{

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



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

    url = url + "&itemcode=" + document.getElementById('itemd_hidden').value;

    url = url + "&item=" + document.getElementById('itemd').value;
    url = url + "&partno=" + document.getElementById('partno').value;
    url = url + "&qty=" + document.getElementById('qty').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;





        //document.getElementById('invno').value="";
        document.getElementById('itemd_hidden').value = "";
        document.getElementById('itemd').value = "";
        document.getElementById('partno').value = "";
        document.getElementById('qty').value = "";

        document.getElementById('searchcust').focus();
    }
}




function shownavyresult()
{
    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("navy_table");
        document.getElementById('tblnavy').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;
    }
}




function new_customer()
{
    clear_customer();
}

function save_customer()
{


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

    var url = "search_custom_data.php";
    url = url + "?Command=" + "save_customer";
    url = url + "&txt_cuscode=" + document.getElementById('txt_cuscode').value;
    url = url + "&txtCNAME=" + document.getElementById('txtCNAME').value;
    url = url + "&txtBADD1=" + document.getElementById('txtBADD1').value;
    url = url + "&txtBADD2=" + document.getElementById('txtBADD2').value;
    url = url + "&txtTEL=" + document.getElementById('txtTEL').value;
    url = url + "&txttel2=" + document.getElementById('txttel2').value;
    url = url + "&txtFAX=" + document.getElementById('txtFAX').value;
    url = url + "&TXTEMAIL=" + document.getElementById('TXTEMAIL').value;
    url = url + "&DTbankgrdate=" + document.getElementById('DTbankgrdate').value;
    url = url + "&DTOPDATE=" + document.getElementById('DTOPDATE').value;
    url = url + "&txtcper=" + document.getElementById('txtcper').value;
    url = url + "&txtACCno=" + document.getElementById('txtACCno').value;
    url = url + "&txtcrlimt=" + document.getElementById('txtcrlimt').value;
    url = url + "&txtbal=" + document.getElementById('txtbal').value;
    url = url + "&txtover=" + document.getElementById('txtover').value;
    url = url + "&txtvatno=" + document.getElementById('txtvatno').value;
    url = url + "&txtcat=" + document.getElementById('txtcat').value;
    url = url + "&txttype=" + document.getElementById('txttype').value;
    url = url + "&txtarea=" + document.getElementById('txtarea').value;
    url = url + "&TXT_REP=" + document.getElementById('TXT_REP').value;
    url = url + "&txtInc=" + document.getElementById('txtInc').value;
    url = url + "&chkgarant=" + document.getElementById('chkgarant').value;
    url = url + "&txtMsg=" + document.getElementById('txtMsg').value;


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

}

function save_customer_result()
{
    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 delete_customer()
{


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

    var url = "search_custom_data.php";
    url = url + "?Command=" + "delete_customer";
    url = url + "&txt_cuscode=" + document.getElementById('txt_cuscode').value;



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

}

function delete_customer_result()
{
    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 save_inv(inv_status)
{




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

    if (document.getElementById('lblReciptNo').value == "") {
        alert("Please Click New !!!");
    } else {
        if (document.getElementById('txtChequeNo').value == "") {
            alert("Cheque no Is not Entered");
        } else if (document.getElementById('txtChequeAmount').value == "") {
            alert("Cheque Amount Is Invalid");
        } else if (document.getElementById('cheq_dpo_bank').value == "") {
            alert("Deposit Bank is EMPTY !!!");
        } else if (document.getElementById('reason').value == "") {
            alert("Reason is EMPTY !!!");
        } else {

            if (document.getElementById('accno').value != "") {
                var url = "ret_cheque_entry_data.php";
                url = url + "?Command=" + "save_item";

                url = url + "&Txtcusco=" + document.getElementById('Txtcusco').value;
                url = url + "&lblReciptNo=" + document.getElementById('lblReciptNo').value;
                url = url + "&accno=" + document.getElementById('accno').value;
                url = url + "&acc_name=" + document.getElementById('acc_name').value;
                url = url + "&txtChequeNo=" + document.getElementById('txtChequeNo').value;
                url = url + "&txt_stat=" + document.getElementById('txt_stat').value;
                url = url + "&DTPicker1=" + document.getElementById('DTPicker1').value;
                url = url + "&Txtcusco=" + document.getElementById('Txtcusco').value;
                url = url + "&txtcusname=" + document.getElementById('txtcusname').value;
                url = url + "&txtRetChCha=" + document.getElementById('txtRetChCha').value;
                url = url + "&cmbBankname=" + document.getElementById('cmbBankname').value;
                url = url + "&txtremark=" + document.getElementById('txtremark').value;
                url = url + "&reason=" + document.getElementById('reason').value;
                url = url + "&txtChequeAmount=" + document.getElementById('txtChequeAmount').value;
                url = url + "&txtChequeNo=" + document.getElementById('txtChequeNo').value;
                url = url + "&com_dep=" + document.getElementById('com_dep').value;
                url = url + "&com_rep=" + document.getElementById('com_rep').value;
                url = url + "&txtChequeAmount=" + document.getElementById('txtChequeAmount').value;
                url = url + "&DTPicker2=" + document.getElementById('DTPicker2').value;
                url = url + "&Check1=" + document.getElementById('Check1').checked;
                //url=url+"&Txtacco="+document.getElementById('Txtacco').value;
                url = url + "&cheq_dpo_bank=" + document.getElementById('cheq_dpo_bank').value;

                url = url + "&lblRET_chno=" + document.getElementById('lblRET_chno').value;
                url = url + "&lblretdate=" + document.getElementById('lblretdate').value;

                url = url + "&lblnoof=" + document.getElementById('lblnoof').value;
                url = url + "&lblretrefno=" + document.getElementById('lblretrefno').value;
                url = url + "&txtforwhat=" + document.getElementById('txtforwhat').value;

                url = url + "&txtcrenoteno=" + document.getElementById('txtcrenoteno').value;
                url = url + "&txtcrenoteamo=" + document.getElementById('txtcrenoteamo').value;
                url = url + "&op_computer=" + document.getElementById('op_computer').checked;
                url = url + "&chk_crenote=" + document.getElementById('chk_crenote').checked;
                url = url + "&bank_st_date=" + document.getElementById('bank_st_date').value;
                url = url + "&mcount=" + document.getElementById('mcount').value;

                url = url + "&txtretcount=" + document.getElementById('txtretcount').value;
                url = url + "&txtoriginal=" + document.getElementById('txtoriginal').value;



                var i = 1;
                var mcount = document.getElementById('mcount').value;
                while (mcount > i) {
                    REF_NO = "REF_NO_" + i;
                    SDATE = "SDATE_" + i;
                    GRAND_TOT = "GRAND_TOT_" + i;
                    st_amou = "st_amou_" + i;

                    url = url + "&" + REF_NO + "=" + document.getElementById(REF_NO).innerHTML;
                    url = url + "&" + SDATE + "=" + document.getElementById(SDATE).innerHTML;
                    url = url + "&" + GRAND_TOT + "=" + document.getElementById(GRAND_TOT).innerHTML;
                    url = url + "&" + st_amou + "=" + document.getElementById(st_amou).innerHTML;

                    i = i + 1;
                }

//alert(url);

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

} else {
    alert("Please enter Debit Account");
}
}
}

}

function salessaveresult()
{
    var XMLAddress1;

    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
        if (xmlHttp.responseText == "no") {
            alert("Please Login Again !!!");
        } else {
            alert(xmlHttp.responseText);
            new_inv();
        }
        //setTimeout("location.reload(true);",500);
        //if (xmlHttp.responseText=="exist"){
        //	alert("Already Exists");	
        //}

    }
}

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

    var url = "ret_cheque_entry_data.php";
    url = url + "?Command=" + "cancel_inv";

    url = url + "&lblReciptNo=" + document.getElementById('lblReciptNo').value;
    url = url + "&Txtcusco=" + document.getElementById('Txtcusco').value;
    url = url + "&cmbBankname=" + document.getElementById('cmbBankname').value;
    url = url + "&txtChequeNo=" + document.getElementById('txtChequeNo').value;

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

function salescancelresult()
{
    var XMLAddress1;

    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
        alert(xmlHttp.responseText);
        //setTimeout("location.reload(true);",500);
        //if (xmlHttp.responseText=="exist"){
        //	alert("Already Exists");	
        //}

    }
}

function clear()
{
    document.getElementById('lblReciptNo').value = "";
    document.getElementById('lab_cancel').innerHTML="";
    document.getElementById('com_dep').value = "01";
    document.getElementById('com_rep').value = "1";
    document.getElementById('com_costcent').value = "01";




    document.getElementById('Txtcusco').value = "";
    document.getElementById('txtcusname').value = "";
    document.getElementById('txtChequeNo').value = "";
    document.getElementById('Check1').checked = false;
    document.getElementById('DTPicker2').value = "";
    document.getElementById('cmbBankname').value = "";
    document.getElementById('reason').value = "";

    //var objsalesrep = document.getElementById("cmbBankname");
    //objsalesrep.options[0].selected=true;

    document.getElementById('txtChequeAmount').value = "";
    document.getElementById('cheq_dpo_bank').value = "";
    document.getElementById('txtcrenoteno').value = "";
    document.getElementById('txtcrenoteamo').value = "";
    document.getElementById('lblretdate').value = "";
    document.getElementById('lblRET_chno').value = "";
    document.getElementById('lblnoof').value = "";
    document.getElementById('txtRetChCha').value = "";
    document.getElementById('txtforwhat').value = "";
    document.getElementById('txtremark').value = "";
    document.getElementById('itemdetails').innerHTML = "";
    document.getElementById('op_computer').checked = false

    document.getElementById('txtoriginal').value = "";
    document.getElementById('txtretcount').value = "";
}

function new_inv()
{

    clear();

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

    document.getElementById('txt_stat').value = "NEW";
    var url = "ret_cheque_entry_data.php";
    url = url + "?Command=" + "new_inv";
    url = url + "&chk_crenote=" + document.getElementById('chk_crenote').checked;
    url = url + "&txt_stat=" + document.getElementById('txt_stat').value;
    //alert(url);
    xmlHttp.onreadystatechange = assign_invno;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);

}

function assign_invno() {

    //alert(xmlHttp.responseText);
    //document.getElementById('lblReciptNo').value=xmlHttp.responseText;	

    if (xmlHttp.responseText == "no") {
        alert("Please Login Again !!!");
    } else {
        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("invno");
        document.getElementById('lblReciptNo').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("curdate");
        document.getElementById('DTPicker1').value = XMLAddress1[0].childNodes[0].nodeValue;
    }
    //document.getElementById('txtcper').focus();

}


function print_inv()
{
    var url = "report_cheque_history.php";
    url = url + "?txtChequeNo=" + document.getElementById('txtChequeNo').value;
    url = url + "&che_date=" + document.getElementById('DTPicker2').value;
    window.open(url);

}

function passprintresult()
{
    var XMLAddress1;

    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
        //alert(xmlHttp.responseText);
        if (xmlHttp.responseText == 1) {
            var url = "rep_inv.php";
            url = url + "?invno=" + document.getElementById('invno').value;
            window.open(url);
        } else {
            alert("Invoice is not available");
        }
    }
}


function update_list(stname)
{


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


    var url = "search_inv_data.php";
    url = url + "?Command=" + "search_inv";

    if (document.getElementById('invno').value != "") {
        url = url + "&mstatus=invno";
    } else if (document.getElementById('customername').value != "") {
        url = url + "&mstatus=customername";
    }

    url = url + "&invno=" + document.getElementById('invno').value;
    url = url + "&customername=" + document.getElementById('customername').value;
    url = url + "&stname=" + stname;
    //alert(url);

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

}

function showinvresult()
{
    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("inv_table");	
        //document.getElementById('filt_table').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        document.getElementById('filt_table').innerHTML = xmlHttp.responseText;
    }
}

function update_cust_list(stname)
{


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


    var url = "search_custom_data.php";
    url = url + "?Command=" + "search_custom";

    if (document.getElementById('cusno').value != "") {
        url = url + "&mstatus=cusno";
    } else if (document.getElementById('customername').value != "") {
        url = url + "&mstatus=customername";
    }

    url = url + "&cusno=" + document.getElementById('cusno').value;
    url = url + "&customername=" + document.getElementById('customername').value;
    url = url + "&stname=" + stname;


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


}

function showcustresult()
{
    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("inv_table");	
        //document.getElementById('filt_table').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        document.getElementById('filt_table').innerHTML = xmlHttp.responseText;
    }
}

function update_item_list()
{


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


    var url = "search_item_data.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";
    }

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


}

function showitemresult()
{
    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("inv_table");	
        //document.getElementById('filt_table').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        document.getElementById('filt_table').innerHTML = xmlHttp.responseText;
    }
}


function assignbrand()
{


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

    var url = "search_inv_data.php";
    url = url + "?Command=" + "assign_brand";
    url = url + "&brand=" + document.getElementById('brand').value;
    url = url + "&salesrep=" + document.getElementById('salesrep').value;
    url = url + "&txt_cuscode=" + document.getElementById('firstname_hidden').value;

    //alert(url);

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

}

function barand_details_result()
{
    //alert(xmlHttp.responseText);

    XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txt_crelimi");
    document.getElementById('creditlimit').value = XMLAddress1[0].childNodes[0].nodeValue;

    XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txt_crebal");
    document.getElementById('balance').value = XMLAddress1[0].childNodes[0].nodeValue;

    XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("dis");
    document.getElementById('discount1').value = XMLAddress1[0].childNodes[0].nodeValue;

    XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table");
    document.getElementById('storgrid').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;
}


function assignbrand_search(brand, salesrep, txt_cuscode)
{


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

    var url = "search_inv_data.php";
    url = url + "?Command=" + "assign_brand";
    url = url + "&brand=" + brand;
    url = url + "&salesrep=" + salesrep;
    url = url + "&txt_cuscode=" + txt_cuscode;

    //alert(url);

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

}

function barand_details_result_search()
{
    //alert(xmlHttp.responseText);

    XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txt_crelimi");
    opener.document.form1.creditlimit.value = XMLAddress1[0].childNodes[0].nodeValue;

    XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txt_crebal");
    opener.document.form1.balance.value = XMLAddress1[0].childNodes[0].nodeValue;

    XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("dis");
    opener.document.form1.discount1.value = XMLAddress1[0].childNodes[0].nodeValue;

    XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table");
    window.opener.document.getElementById('storgrid').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

}

function purord(invno, stname)
{

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



    if (stname == 'ord') {
        var url = "pur_ord_data.php";
        url = url + "?Command=" + "purord";
        url = url + "&invno=" + invno;

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

    } else if (stname == 'arn') {
        var url = "arn_data.php";
        url = url + "?Command=" + "arn";
        url = url + "&invno=" + invno;

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






}

function passpurordresult()
{
    var XMLAddress1;

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

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("REFNO");
        opener.document.form1.invno.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SUP_CODE");
        opener.document.form1.supplier_code.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SUP_NAME");
        opener.document.form1.supplier_name.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SDATE");
        opener.document.form1.dte_shedule.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("REMARK");
        opener.document.form1.remarks.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DEP_CODE");
        opener.document.form1.department.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("REP_CODE");
        opener.document.form1.salesrep.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("S_date");
        opener.document.form1.invdate.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("LC_No");
        opener.document.form1.lc_no.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("Brand");
        opener.document.form1.brand.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table");
        window.opener.document.getElementById('itemdetails').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        self.close();
    }
}


function passarnresult()
{
    var XMLAddress1;

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

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("REFNO");
        opener.document.form1.orderno1.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SUP_CODE");
        opener.document.form1.supplier_code.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SUP_NAME");
        opener.document.form1.supplier_name.value = XMLAddress1[0].childNodes[0].nodeValue;

        //XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SDATE");
        //opener.document.form1.dte_shedule.value = XMLAddress1[0].childNodes[0].nodeValue;

        //XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("REMARK");
        //opener.document.form1.remarks.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DEP_CODE");
        opener.document.form1.department.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("REP_CODE");
        opener.document.form1.salesrep.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("S_date");
        opener.document.form1.orderdate.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("LC_No");
        opener.document.form1.lc_no.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("count");
        opener.document.form1.count.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("Brand");
        opener.document.form1.brand.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table");
        window.opener.document.getElementById('itemdetails').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        self.close();
    }
}

function invno(invno, stname)
{


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

    if (stname == "grn") {
        var url = "search_inv_data.php";
        url = url + "?Command=" + "pass_grn";
        url = url + "&invno=" + invno;

        //alert(url);
        xmlHttp.onreadystatechange = passinvresult_grn;
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    } else if (stname == "crn") {
        var url = "search_inv_data.php";
        url = url + "?Command=" + "pass_crn";
        url = url + "&invno=" + invno;

        //alert(url);
        xmlHttp.onreadystatechange = passinvresult_crn;
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    } else {
        var url = "search_inv_data.php";
        url = url + "?Command=" + "pass_invno";
        url = url + "&invno=" + invno;
        url = url + "&custno=" + opener.document.form1.firstname_hidden.value;
        url = url + "&brand=" + opener.document.form1.brand.value;
        url = url + "&department=" + opener.document.form1.department.value;


        xmlHttp.onreadystatechange = passinvresult;
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }
    //alert(url);




}

function passinvresult_grn()
{
    var XMLAddress1;

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

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("REF_NO");
        opener.document.form1.invno.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SAL_EX");
        opener.document.form1.salesrep.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SDATE");
        opener.document.form1.invdate.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("Brand");
        var objSalesrep = opener.document.getElementById("brand");
        var salesrep = XMLAddress1[0].childNodes[0].nodeValue;
        var i = 0;
        while (i < objSalesrep.length)
        {
            if (XMLAddress1[0].childNodes[0].nodeValue == objSalesrep.options[i].value)
            {
                objSalesrep.options[i].selected = true;

            }
            i = i + 1;
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DEPARTMENT");
        var objSalesrep = opener.document.getElementById("department");
        var salesrep = XMLAddress1[0].childNodes[0].nodeValue;
        var i = 0;
        while (i < objSalesrep.length)
        {
            if (XMLAddress1[0].childNodes[0].nodeValue == objSalesrep.options[i].value)
            {
                objSalesrep.options[i].selected = true;

            }
            i = i + 1;
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("TYPE");
        if (XMLAddress1[0].childNodes[0].nodeValue == "CR") {
            opener.document.form1.paymethod_0.checked = true;
        } else {
            opener.document.form1.paymethod_1.checked = true;
        }


        //	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DISCOU");
        //	opener.document.form1.totdiscount.value = XMLAddress1[0].childNodes[0].nodeValue;

        //	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("GRAND_TOT");
        //	opener.document.form1.invtot.value = XMLAddress1[0].childNodes[0].nodeValue;


        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table");
        window.opener.document.getElementById('itemdetails').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;



        self.close();
    }

}





function passinvresult_crn()
{
    var XMLAddress1;

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

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("REF_NO");
        opener.document.form1.invno.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SDATE");
        opener.document.form1.inv_date.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("C_CODE");
        opener.document.form1.cus_code.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("CUS_NAME");
        opener.document.form1.cus_name.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SAL_EX");
        var objSalesrep = opener.document.getElementById("salesrep");

        var salesrep = XMLAddress1[0].childNodes[0].nodeValue;
        var i = 0;
        while (i < objSalesrep.length)
        {
            if (XMLAddress1[0].childNodes[0].nodeValue == objSalesrep.options[i].value)
            {
                objSalesrep.options[i].selected = true;

            }
            i = i + 1;
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DEPARTMENT");
        var objSalesrep = opener.document.getElementById("department");
        var salesrep = XMLAddress1[0].childNodes[0].nodeValue;
        var i = 0;
        while (i < objSalesrep.length)
        {
            if (XMLAddress1[0].childNodes[0].nodeValue == objSalesrep.options[i].value)
            {
                objSalesrep.options[i].selected = true;

            }
            i = i + 1;
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SDATE");
        opener.document.form1.inv_date.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("inv_amt");
        opener.document.form1.invamount.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("TOTPAY");
        opener.document.form1.totpay.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("balance");
        opener.document.form1.invbal.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("Brand");
        var objSalesrep = opener.document.getElementById("brand");
        var salesrep = XMLAddress1[0].childNodes[0].nodeValue;
        var i = 0;
        while (i < objSalesrep.length)
        {
            if (XMLAddress1[0].childNodes[0].nodeValue == objSalesrep.options[i].value)
            {
                objSalesrep.options[i].selected = true;

            }
            i = i + 1;
        }
        self.close();
    }

}

function passinvresult()
{
    var XMLAddress1;

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

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_invoiceno");
//		document.getElementById('invno1').value = XMLAddress1[0].childNodes[0].nodeValue;
        //alert(XMLAddress1[0].childNodes[0].nodeValue);
        opener.document.form1.invno.value = XMLAddress1[0].childNodes[0].nodeValue;
        //opener.document.form1.invno.value = "111111111";


        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_crecash");

        if (XMLAddress1[0].childNodes[0].nodeValue == 'CR')
        {
            opener.document.form1.paymethod_0.checked = true;

        } else if (XMLAddress1[0].childNodes[0].nodeValue == 'CA')
        {
            opener.document.form1.paymethod_1.checked = true;

        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_customecode");
        opener.document.form1.firstname_hidden.value = XMLAddress1[0].childNodes[0].nodeValue;
        var txt_cuscode = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_customername");
        opener.document.form1.firstname.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_address");
        opener.document.form1.cus_address.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_vatno1");
        opener.document.form1.vat1.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_vatno2");
        opener.document.form1.vat2.value = XMLAddress1[0].childNodes[0].nodeValue;


        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_salesrep");
        var objSalesrep = opener.document.getElementById("salesrep");

        var salesrep = XMLAddress1[0].childNodes[0].nodeValue;
        var i = 0;
        while (i < objSalesrep.length)
        {
            if (XMLAddress1[0].childNodes[0].nodeValue == objSalesrep.options[i].value)
            {
                objSalesrep.options[i].selected = true;

            }
            i = i + 1;
        }

        //alert(objSalesrep.length);



        //	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_salesorder1");	
        //	opener.document.form1.salesord1.value = XMLAddress1[0].childNodes[0].nodeValue;

        //	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_salesorder2");	
        //	opener.document.form1.salesord2.value = XMLAddress1[0].childNodes[0].nodeValue;


        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("dte_deliverdate");
        opener.document.form1.dte_dor.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_orderno1");
        opener.document.form1.salesord1.value = XMLAddress1[0].childNodes[0].nodeValue;
        opener.document.form1.orderno1.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_orderno2");
        opener.document.form1.orderdate.value = XMLAddress1[0].childNodes[0].nodeValue;

        //	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cur_credit");	
        //	opener.document.form1.creditlimit.value = XMLAddress1[0].childNodes[0].nodeValue;

        //	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cur_balance");	
        //	opener.document.form1.balance.value = XMLAddress1[0].childNodes[0].nodeValue;


        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_department");
        var objDepartment = opener.document.getElementById("department");

        var i = 0;
        while (i < objDepartment.length)
        {
            if (XMLAddress1[0].childNodes[0].nodeValue == objDepartment.options[i].value)
            {
                objDepartment.options[i].selected = true;

            }
            i = i + 1;
        }


        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_brand");
        var objBrand = opener.document.getElementById("brand");

        var i = 0;
        var brand = XMLAddress1[0].childNodes[0].nodeValue;
        while (i < objBrand.length)
        {
            if (XMLAddress1[0].childNodes[0].nodeValue == objBrand.options[i].value)
            {
                objBrand.options[i].selected = true;

            }
            i = i + 1;
        }


        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_vat");

        if (XMLAddress1[0].childNodes[0].nodeValue == 'vat')
        {
            opener.document.form1.vatgroup_0.checked = true;

        } else if (XMLAddress1[0].childNodes[0].nodeValue == 'svat')
        {
            opener.document.form1.vatgroup_2.checked = true;

        } else if (XMLAddress1[0].childNodes[0].nodeValue == 'evat')
        {
            opener.document.form1.vatgroup_3.checked = true;

        } else {
            opener.document.form1.vatgroup_1.checked = true;
        }

        //else if(XMLAddress1[0].childNodes[0].nodeValue=='svat')
        //{
        //	opener.document.form1.vatgroup_2.checked=true;

        //}

        //	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cur_discount1");	
        //	opener.document.form1.discount1.value = XMLAddress1[0].childNodes[0].nodeValue;

        //	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cur_discount2");	
        //	opener.document.form1.discount2.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cur_subtotal");
        opener.document.form1.subtot.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cur_discount");
        opener.document.form1.totdiscount.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cur_tax");
        opener.document.form1.tax.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cur_invoiceval");
        opener.document.form1.invtot.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table");
        window.opener.document.getElementById('itemdetails').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;



        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txt_crelimi");
        opener.document.form1.creditlimit.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txt_crebal");
        opener.document.form1.balance.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("dis");
        opener.document.form1.discount1.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("dis1");
        opener.document.form1.discount2.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("dis2");
        opener.document.form1.discount3.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table_acc");
        window.opener.document.getElementById('storgrid').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        opener.document.form1.credper.value = 65;
        //window.opener.document.getElementById("test").innerHTML="TESTNBMSVMS"
        //opener.document.forminv.invno.value = "123";
        //myWindow.opener.document.invno.value = "123";
        self.close();
        //alert(myWindow.opener.document.getElementById('invno').value);
        //forminv.getElementById('invno').value="125";

        //setTimeout("location.reload(true);",500);
        //if (xmlHttp.responseText=="exist"){
        //	alert("Already Exists");	
        //}

        //XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("inv_table");	
        //document.getElementById('filt_table').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        //document.getElementById('filt_table').innerHTML=xmlHttp.responseText;
    }
}

function ass_lim(credit_lim, rep, credit, balance, cat, brand)
{
    document.getElementById('txtlimit').value = credit_lim;


    var objSalesrep = document.getElementById("Com_rep");

    var i = 0;
    objSalesrep.options[i].selected = true;
    while (i < objSalesrep.length)
    {
        if (rep == objSalesrep.options[i].value)
        {
            objSalesrep.options[i].selected = true;

        }
        i = i + 1;
    }

    var objBrand = document.getElementById("cmbbrand");

    var i = 0;
    objBrand.options[i].selected = true;
    while (i < objBrand.length)
    {
        if (brand == objBrand.options[i].value)
        {
            objBrand.options[i].selected = true;

        }
        i = i + 1;
    }

    var objCat = document.getElementById("cmbCAt");

    var i = 0;
    objCat.options[i].selected = true;
    while (i < objCat.length)
    {
        if (cat == objCat.options[i].value)
        {
            objCat.options[i].selected = true;

        }
        i = i + 1;
    }

}

function suppno(suppno)
{
    //alert(stname);

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



    var url = "search_supplier_data.php";
    url = url + "?Command=" + "pass_suppno";
    url = url + "&suppno=" + suppno;
    //url=url+"&brand="+opener.document.form1.brand.value;
    //url=url+"&salesrep="+opener.document.form1.salesrep.value;
    xmlHttp.onreadystatechange = passsuppresult;


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


}

function passsuppresult()
{
    var XMLAddress1;

    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
        //alert(xmlHttp.responseText);
        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("code");
        opener.document.form1.supplier_code.value = XMLAddress1[0].childNodes[0].nodeValue;
        ;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("name");
        opener.document.form1.supplier_name.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("address");
        opener.document.form1.address.value = XMLAddress1[0].childNodes[0].nodeValue;

        self.close();
        opener.document.form1.salesrep.focus();
    }
}

function passcusresult_crn()
{
    var XMLAddress1;

    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
        //alert(xmlHttp.responseText);
        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("id");
        opener.document.form1.cus_code.value = XMLAddress1[0].childNodes[0].nodeValue;
        ;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("NAME");
        opener.document.form1.cus_name.value = XMLAddress1[0].childNodes[0].nodeValue;

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

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

        opener.document.form1.cus_address.value = add1 + " " + add2;

        self.close();
    }
}

function passcusresult_cash_rec()
{
    var XMLAddress1;

    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
        //alert(xmlHttp.responseText);
        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("mcount");
        opener.document.form1.hiddencount.value = XMLAddress1[0].childNodes[0].nodeValue;
        ;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("code");
        opener.document.form1.cuscode.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("name");
        opener.document.form1.cusname.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("address");
        opener.document.form1.cus_address.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table_acc");
        //alert( XMLAddress1[0].childNodes[0].nodeValue);
        window.opener.document.getElementById('inv_details').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;


        self.close();
        //opener.document.form1.txtdetar.focus();
    }
}

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

    var url = "inv_data.php";
    url = url + "?Command=" + "setord";
    url = url + "&custno=" + document.getElementById('firstname_hidden').value;
    //url=url+"&salesord1="+document.getElementById('salesord1').value;
    url = url + "&salesrep=" + document.getElementById('salesrep').value;
    url = url + "&brand=" + document.getElementById('brand').value;
    url = url + "&department=" + document.getElementById('department').value;
//alert(url);
xmlHttp.onreadystatechange = setord_result_inv;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}

function setord_result_inv() {


    var XMLAddress1;

    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
        //alert(xmlHttp.responseText);
        //XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("salesord");	
        //document.getElementById('salesord1').value = XMLAddress1[0].childNodes[0].nodeValue;



        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txt_crelimi");
        document.getElementById('creditlimit').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txt_crebal");
        document.getElementById('balance').value = XMLAddress1[0].childNodes[0].nodeValue;



        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table_acc");
        document.getElementById('storgrid').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

    }


}

function passcusresult_rep_mast_s()
{
    var XMLAddress1;

    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
        //alert(xmlHttp.responseText);
        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("code");
        opener.document.form1.txt_cuscode_s.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("name");
        opener.document.form1.txt_cusname_s.value = XMLAddress1[0].childNodes[0].nodeValue;

        opener.document.form1.txtdetar_s.value = "";


        self.close();
        opener.document.form1.txtdetar.focus();
    }
}

function passcusresult_rep_mast()
{
    var XMLAddress1;

    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
        //alert(xmlHttp.responseText);
        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("code");
        opener.document.form1.txt_cuscode.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("name");
        opener.document.form1.txt_cusname.value = XMLAddress1[0].childNodes[0].nodeValue;

        opener.document.form1.txtdetar.value = "";


        self.close();
        opener.document.form1.txtdetar.focus();
    }
}



function passcusresult_cust_mast()
{
    var XMLAddress1;

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

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("blacklist");

        if (XMLAddress1[0].childNodes[0].nodeValue == "1") {
            opener.document.form1.check1.checked = true;
        } else {
            opener.document.form1.check1.checked = false;
        }

        opener.document.form1.txt_cuscode.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("id");
        opener.document.form1.txt_cuscode.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("NAME");
        opener.document.form1.txtCNAME.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("ADD1");
        opener.document.form1.txtBADD1.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("ADD2");
        opener.document.form1.txtBADD2.value = XMLAddress1[0].childNodes[0].nodeValue;

        //	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("OPBAL");	
        //	opener.document.form1.txt_crelimi.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("TELE1");
        opener.document.form1.txtTEL.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("TELE2");
        opener.document.form1.txttel2.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("CONT");
        opener.document.form1.txtcper.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("CUR_BAL");
        opener.document.form1.txtbal.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("LIMIT");
        opener.document.form1.txtcrlimt.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("PEN");
        opener.document.form1.txtover.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("FAX");
        opener.document.form1.txtFAX.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("acno");
        opener.document.form1.txtACCno.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("EMAIL");
        opener.document.form1.TXTEMAIL.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("CAT");
        opener.document.form1.txtcat.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("rep");
        opener.document.form1.TXT_REP.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("vatno");
        opener.document.form1.txtvatno.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("OPDATE");
        opener.document.form1.DTOPDATE.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("area");
        opener.document.form1.txtarea.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("CUS_TYPE");
        opener.document.form1.txttype.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("note");
        opener.document.form1.txtnote.value = XMLAddress1[0].childNodes[0].nodeValue;

        //XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("temp_limit");	
        //opener.document.form1.txt_tmeplimit.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("bank_gr_date");
        opener.document.form1.DTbankgrdate.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("AltMessage");
        opener.document.form1.txtMsg.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table");
        window.opener.document.getElementById('creditlim').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cre_lim");
        opener.document.form1.txtcrlimt.value = XMLAddress1[0].childNodes[0].nodeValue;

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


    }
}

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


    var url = "search_custom_data.php";
    url = url + "?Command=" + "update_limit";
    url = url + "&txt_cuscode=" + document.getElementById('txt_cuscode').value;
    url = url + "&rep=" + document.getElementById('Com_rep').value;
    url = url + "&brand=" + document.getElementById('cmbbrand').value;
    url = url + "&txtlimit=" + document.getElementById('txtlimit').value;
    url = url + "&cmbCAt=" + document.getElementById('cmbCAt').value;
    url = url + "&stopinv=" + document.getElementById('check1').checked;

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


}

function passitresult_update_limit()
{
    //alert(xmlHttp.responseText);

    XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("totcr");
    document.getElementById('txtcrlimt').value = XMLAddress1[0].childNodes[0].nodeValue;

    XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cre_table");
    //alert(XMLAddress1[0].childNodes[0].nodeValue);
    document.getElementById('creditlim').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

    alert("Updated");

}

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


    var url = "search_custom_data.php";
    url = url + "?Command=" + "delete_limit";
    url = url + "&txt_cuscode=" + document.getElementById('txt_cuscode').value;
    url = url + "&rep=" + document.getElementById('Com_rep').value;
    url = url + "&brand=" + document.getElementById('cmbbrand').value;
    url = url + "&txtlimit=" + document.getElementById('txtlimit').value;
    url = url + "&cmbCAt=" + document.getElementById('cmbCAt').value;
    url = url + "&stopinv=" + document.getElementById('check1').checked;

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


}

function passitresult_delete_limit()
{
    //alert(xmlHttp.responseText);

    XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("totcr");
    document.getElementById('txtcrlimt').value = XMLAddress1[0].childNodes[0].nodeValue;

    XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cre_table");
    document.getElementById('creditlim').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

    alert("Deleted");

}

function passcusresult()
{
    var XMLAddress1;

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

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("id");
        opener.document.form1.firstname_hidden.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_customername");
        opener.document.form1.firstname.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_address");
        opener.document.form1.cus_address.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_vatno");
        opener.document.form1.vat1.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_svatno");
        opener.document.form1.vat2.value = XMLAddress1[0].childNodes[0].nodeValue;

        if ((opener.document.form1.vat1.value == '') && (opener.document.form1.vat2.value == '')) {
            opener.document.form1.vatgroup_1.checked = true;
        } else if ((opener.document.form1.vat1.value != '') && (opener.document.form1.vat2.value == '')) {
            opener.document.form1.vatgroup_0.checked = true;
        } else if ((opener.document.form1.vat1.value != '') && (opener.document.form1.vat2.value != '')) {
            opener.document.form1.vatgroup_2.checked = true;
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txt_crelimi");
        opener.document.form1.creditlimit.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txt_crebal");
        opener.document.form1.balance.value = XMLAddress1[0].childNodes[0].nodeValue;

        //XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("dis");	
        //opener.document.form1.discount1.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table_acc");
        window.opener.document.getElementById('storgrid').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;


        self.close();
        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("AltMessage");
        if (XMLAddress1[0].childNodes[0].nodeValue != "") {
            alert(XMLAddress1[0].childNodes[0].nodeValue);
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("bank_message");
        if (XMLAddress1[0].childNodes[0].nodeValue != "") {
            alert(XMLAddress1[0].childNodes[0].nodeValue);
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("over60_message");
        if (XMLAddress1[0].childNodes[0].nodeValue != "") {
            alert(XMLAddress1[0].childNodes[0].nodeValue);
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("chq_message");
        if (XMLAddress1[0].childNodes[0].nodeValue != "") {
            alert(XMLAddress1[0].childNodes[0].nodeValue);
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("chq_message_que");
        if (XMLAddress1[0].childNodes[0].nodeValue != "") {
            var ans = confirm(XMLAddress1[0].childNodes[0].nodeValue);
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("msg_return");
        if (XMLAddress1[0].childNodes[0].nodeValue != "") {
            alert(XMLAddress1[0].childNodes[0].nodeValue);
        }



        opener.document.form1.salesrep.focus();


    }
}

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


    var url = "search_item_bincard_data.php";
    url = url + "?Command=" + "pass_bincard";
    url = url + "&itno=" + document.getElementById('invno').value;
    url = url + "&department=" + document.getElementById('department').value;
    url = url + "&department=" + document.getElementById('department').value;
    url = url + "&department=" + document.getElementById('department').value;
    url = url + "&department=" + document.getElementById('department').value;
    url = url + "&department=" + document.getElementById('department').value;



    //alert(url);
    xmlHttp.onreadystatechange = pass_display_dataresult;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}

function pass_display_dataresult()
{
    var XMLAddress1;

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



        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("PART_NO");
        opener.document.form1.partno.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("unsold");
        window.opener.document.getElementById('unsold').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        if (window.opener.document.getElementById('unsold').innerHTML != "") {
            window.opener.document.getElementById('day90').innerHTML = "90 Days Stock";
        } else {
            window.opener.document.getElementById('day90').innerHTML = "";
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE01");
        opener.document.form1.sal1.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE02");
        opener.document.form1.sal2.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE03");
        opener.document.form1.sal3.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE04");
        opener.document.form1.sal4.value = XMLAddress1[0].childNodes[0].nodeValue;



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



    }
}

function itno_bin(itno)
{


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


    var url = "search_item_bincard_data.php";
    url = url + "?Command=" + "pass_itno";
    url = url + "&itno=" + itno;
    url = url + "&department=" + document.getElementById('department').value;
    url = url + "&dte_from=" + document.getElementById('dte_from').value;


    //	alert(url);
    xmlHttp.onreadystatechange = passit_purordresult_bin;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);

}

function passit_purordresult_bin()
{
    var XMLAddress1;

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

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("STK_NO");
        document.getElementById('invno').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DESCRIPT");
        document.getElementById('itemname').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SELLING");
        document.getElementById('selling').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("PART_NO");
        document.getElementById('partno').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("unsold");
        document.getElementById('unsold').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        if (document.getElementById('unsold').innerHTML != "") {
            document.getElementById('day90').innerHTML = "90 Days Stock";
        } else {
            document.getElementById('day90').innerHTML = "";
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE01");
        document.getElementById('sal1').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE02");
        document.getElementById('sal2').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE03");
        document.getElementById('sal3').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE04");
        document.getElementById('sal4').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE05");
        document.getElementById('sal5').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE06");
        document.getElementById('sal6').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE07");
        document.getElementById('sal7').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE08");
        document.getElementById('sal8').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE09");
        document.getElementById('sal9').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE10");
        document.getElementById('sal10').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE11");
        document.getElementById('sal11').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE12");
        document.getElementById('sal12').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("avg");
        document.getElementById('avg').value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table");
        document.getElementById('stock_det').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("bin_table");
        document.getElementById('itemdetails').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("ord_table");
        document.getElementById('orddetails').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        /*	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DESCRIPT");	
         opener.document.form1.itemname.value = XMLAddress1[0].childNodes[0].nodeValue;
         
         XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DESCRIPT");	
         opener.document.form1.itemname.value = XMLAddress1[0].childNodes[0].nodeValue;
         
         XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DESCRIPT");	
         opener.document.form1.itemname.value = XMLAddress1[0].childNodes[0].nodeValue;*/







     }
 }


 function itno(itno)
 {


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


    var url = "search_item_bincard_data.php";
    url = url + "?Command=" + "pass_itno";
    url = url + "&itno=" + itno;
    url = url + "&department=" + opener.document.form1.department.value;
    url = url + "&dte_from=" + opener.document.form1.dte_from.value;


    //alert(url);
    xmlHttp.onreadystatechange = passit_purordresult;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);

}

function passit_purordresult()
{
    var XMLAddress1;

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

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

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

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SELLING");
        opener.document.form1.selling.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("PART_NO");
        opener.document.form1.partno.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("unsold");
        window.opener.document.getElementById('unsold').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        if (window.opener.document.getElementById('unsold').innerHTML != "") {
            window.opener.document.getElementById('day90').innerHTML = "90 Days Stock";
        } else {
            window.opener.document.getElementById('day90').innerHTML = "";
        }

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE01");
        opener.document.form1.sal1.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE02");
        opener.document.form1.sal2.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE03");
        opener.document.form1.sal3.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE04");
        opener.document.form1.sal4.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE05");
        opener.document.form1.sal5.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE06");
        opener.document.form1.sal6.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE07");
        opener.document.form1.sal7.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE08");
        opener.document.form1.sal8.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE09");
        opener.document.form1.sal9.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE10");
        opener.document.form1.sal10.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE11");
        opener.document.form1.sal11.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("SALE12");
        opener.document.form1.sal12.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("avg");
        opener.document.form1.avg.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("sales_table");
        window.opener.document.getElementById('stock_det').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("bin_table");
        window.opener.document.getElementById('itemdetails').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("ord_table");
        window.opener.document.getElementById('orddetails').innerHTML = XMLAddress1[0].childNodes[0].nodeValue;

        /*	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DESCRIPT");	
         opener.document.form1.itemname.value = XMLAddress1[0].childNodes[0].nodeValue;
         
         XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DESCRIPT");	
         opener.document.form1.itemname.value = XMLAddress1[0].childNodes[0].nodeValue;
         
         XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DESCRIPT");	
         opener.document.form1.itemname.value = XMLAddress1[0].childNodes[0].nodeValue;*/



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



     }
 }

 function assignbrandsession()
 {

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


    var url = "search_item_data.php";
    url = url + "?Command=" + "pass_assignbrand";

    url = url + "&brand=" + document.getElementById('brand').value;
    url = url + "&department=" + document.getElementById('department').value;


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


function passassignbrand()
{
    var XMLAddress1;

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




function passitresult()
{
    var XMLAddress1;

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

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_code");
        opener.document.form1.itemd_hidden.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_description");
        opener.document.form1.itemd.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_selpri");
        opener.document.form1.rate.value = XMLAddress1[0].childNodes[0].nodeValue;

        XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("qtyinhand");
        opener.document.form1.stklevel.value = XMLAddress1[0].childNodes[0].nodeValue;
        //	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("dis");	
        //	opener.document.form1.discount.value = XMLAddress1[0].childNodes[0].nodeValue;


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



    }
}

function chk_opener()
{
    //alert("ok");
    //self.close();	
    //opener.document.form1.invno.value = document.bull.lon.value;
    opener.document.form1.invno.value = "123";
}




function tmp_crelimit()
{

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


    var url = "search_custom_data.php";
    url = url + "?Command=" + "tmp_crelimit";
    url = url + "&Com_rep1=" + document.getElementById('Com_rep1').value;
    url = url + "&txt_cuscode=" + document.getElementById('txt_cuscode').value;
    url = url + "&cmbbrand1=" + document.getElementById('cmbbrand1').value;
    url = url + "&txt_templimit=" + document.getElementById('txt_templimit').value;
    //alert(url);

    if (document.getElementById('check1').checked == true)
    {
        var mcheck = 1;
    } else {
        var mcheck = 0;
    }
    url = url + "&check1=" + mcheck;


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

}

function result_tmp_crelimit()
{
    var XMLAddress1;

    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
        alert(xmlHttp.responseText);
    }
}
function upremark1()
{
    if ((document.getElementById('lblReciptNo').value != "")) {
        var msg = confirm("Do you want to Update  this Reason ! ");
        if (msg == true) {
            xmlHttp = GetXmlHttpObject();
            if (xmlHttp == null)
            {
                alert("Browser does not support HTTP Request");
                return;
            }

            var url = "ret_cheque_entry_data.php";
            url = url + "?Command=" + "up_remark";

            url = url + "&lblReciptNo=" + document.getElementById('lblReciptNo').value;
            url = url + "&reason=" + document.getElementById('reason').value;

            xmlHttp.onreadystatechange = result_remark;
            xmlHttp.open("GET", url, true);
            xmlHttp.send(null);
        }
    } else {
        alert("Entry No is Empty...! ");
    }
}
function result_remark()
{
    var XMLAddress1;

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