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 print_inv1()
{
	//alert("ok");
//	var XMLAddress1;
	
	//if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	//{
		//alert(xmlHttp.responseText);
		//if (xmlHttp.responseText==1){
			var url="rep_item_claim.php";			
			url=url+"?txtrefno="+document.getElementById('txtrefno').value;
			url=url+"&txtCRD_no="+document.getElementById('txtCRD_no').value;
			url=url+"&txtCRE_date="+document.getElementById('txtCRE_date').value;
			url=url+"&txtCRE_amount="+document.getElementById('txtCRE_amount').value;
			url=url+"&txtCRD_no2="+document.getElementById('txtCRD_no2').value;
			url=url+"&txtCRE_date2="+document.getElementById('txtCRE_date2').value;
			url=url+"&txtCRE_amount2="+document.getElementById('txtCRE_amount2').value;
			url=url+"&txtCRD_no3="+document.getElementById('txtCRD_no3').value;
			url=url+"&txtCRE_date3="+document.getElementById('txtCRE_date3').value;
			url=url+"&txtCRE_amount3="+document.getElementById('txtCRE_amount3').value;
			url=url+"&Prn_md="+document.getElementById('Prn_md').checked;
			url=url+"&Cmb_refund="+document.getElementById('Cmb_refund').value;
			url=url+"&txtag_code="+document.getElementById('txtag_code').value;
			
			window.open(url,'_blank');
  		//} else {
		//	alert("Invoice is not available");  
  		//}
	//}
}

function show_hide()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 		
	
	if (document.getElementById('Check1').checked==true){		
		document.getElementById('additional').innerHTML="1.<input type='text' size='20' name='txtadd_ref1' id='txtadd_ref1' value='' onkeypress='keyset('salesrep',event);' class='text_purchase3'/>2.<input type='text' size='20' name='txtadd_ref2' id='txtadd_ref2' value='' onkeypress='keyset('salesrep',event);' class='text_purchase3'/>";
	} else {
		document.getElementById('additional').innerHTML="1.<input type='hidden' size='20' name='txtadd_ref1' id='txtadd_ref1' value='' onkeypress='keyset('salesrep',event);' class='text_purchase3'/>2.<input type='hidden' size='20' name='txtadd_ref2' id='txtadd_ref2' value='' onkeypress='keyset('salesrep',event);' class='text_purchase3'/>";	
	}
}

function keyset(key, e)
{	

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

function calc_rem()
{
	
	if (document.getElementById('txtremin1').value!=""){
		txtremin1=document.getElementById('txtremin1').value;	
	} else {
		txtremin1=0;	
	}
	
	if (document.getElementById('txtremin2').value!=""){
		txtremin2=document.getElementById('txtremin2').value;	
	} else {
		txtremin2=0;	
	}
	
	if (document.getElementById('txtremin3').value!=""){
		txtremin3=document.getElementById('txtremin3').value;	
	} else {
		txtremin3=0;	
	}
	
	if (document.getElementById('txtremin4').value!=""){
		txtremin4=document.getElementById('txtremin4').value;	
	} else {
		txtremin4=0;	
	}
	
	if (document.getElementById('txtremin5').value!=""){
		txtremin5=document.getElementById('txtremin5').value;	
	} else {
		txtremin5=0;	
	}
	
	
	
	if (document.getElementById('txtorigin1').value!=""){
		txtorigin1=document.getElementById('txtorigin1').value;	
	} else {
		txtorigin1=0;	
	}
	
	if (document.getElementById('txtorigin2').value!=""){
		txtorigin2=document.getElementById('txtorigin2').value;	
	} else {
		txtorigin2=0;	
	}
	
	if (document.getElementById('txtorigin3').value!=""){
		txtorigin3=document.getElementById('txtorigin3').value;	
	} else {
		txtorigin3=0;	
	}
	
	if (document.getElementById('txtorigin4').value!=""){
		txtorigin4=document.getElementById('txtorigin4').value;	
	} else {
		txtorigin4=0;	
	}
	
	if (document.getElementById('txtorigin5').value!=""){
		txtorigin5=document.getElementById('txtorigin5').value;	
	} else {
		txtorigin5=0;	
	}
	
	
		
    	var totremain = parseFloat(txtremin1) + parseFloat(txtremin2) + parseFloat(txtremin3) + parseFloat(txtremin4) + parseFloat(txtremin5);
    	var totorigin = parseFloat(txtorigin1) + parseFloat(txtorigin2) + parseFloat(txtorigin3) + parseFloat(txtorigin4) + parseFloat(txtorigin5);
		
		if (totorigin!=0){
			var rep_per=new Number(totremain / totorigin * 100);
    		document.getElementById('txtrem_per').value = rep_per.toPrecision(4);
		}
		
	
}

function chngcomm()
{
	if (document.getElementById('cmb_comm').value=="Not Allowed"){
		
		document.getElementById("apprby").style.visibility="hidden";
		document.getElementById("approvedby").style.visibility="hidden";
		
	} else if (document.getElementById('cmb_comm').value=="Allowed"){
		
		document.getElementById("apprby").style.visibility="visible";
		document.getElementById("approvedby").style.visibility="visible";
		
	}
}


function clear_item()
{
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 		
			
			
	document.getElementById('txtrefno').value="";
	document.getElementById('txtentdate').value="";
	document.getElementById('dtf').value="";
	document.getElementById('txtcl_no').value="";
	
	document.getElementById('DTPicker_recdate').value="";
	document.getElementById('dtto').value="";
	
	document.getElementById('txtag_code').value="";
	document.getElementById('txtag_name').value="";
	document.getElementById('txtcus_name').value="";
	
	document.getElementById('txtagadd').value="";
	document.getElementById('txtcus_add').value="";
	document.getElementById('txtstk_no').value="";
	document.getElementById('txtdes').value="";
	
	document.getElementById('txtbrand').value="";
	document.getElementById('txtpatt').value="";
	document.getElementById('txtseri_no').value="";
	document.getElementById('Combo1').value="";
	
	
	document.getElementById('txttc_ob').value="";
	document.getElementById('Cmb_refund').value="";
	document.getElementById('txtremin1').value="";
	document.getElementById('txtremin2').value="";
	document.getElementById('txtremin3').value="";
	document.getElementById('txtremin4').value="";
	document.getElementById('txtremin5').value="";
	document.getElementById('txtorigin1').value="";
	document.getElementById('txtorigin2').value="";
	document.getElementById('txtorigin3').value="";
	document.getElementById('txtorigin4').value="";
	document.getElementById('txtorigin5').value="";
	document.getElementById('txtrem_per').value="";
	document.getElementById('txtspec').value="";
	document.getElementById('txtremming').value="";
	document.getElementById('txtref_per').value="";
	document.getElementById('cmb_comm').value="";
	document.getElementById('txtadd_ref1').value="";
	document.getElementById('txtadd_ref2').value="";
	document.getElementById('txtmn_ob').value="";
	document.getElementById('txtCRD_no').value="";
	document.getElementById('txtCRD_no2').value="";
	document.getElementById('txtCRD_no3').value="";
	document.getElementById('txtCRE_date').value="";
	document.getElementById('txtCRE_date2').value="";
	document.getElementById('txtCRE_date3').value="";
	document.getElementById('txtCRE_amount').value="";
	document.getElementById('txtCRE_amount2').value="";
	document.getElementById('txtCRE_amount3').value="";
	
    
}

function new_inv1()
{   
	
			
			xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request");
				return;
			} 		
			
			
			clear_item();
			
			//document.getElementById('invdate').value=Date();
			
			var url="item_claim_gin_data.php";			
			url=url+"?Command="+"new_inv";
			xmlHttp.onreadystatechange=new_inv_invresult;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
			
}

function new_inv_invresult(){
	//alert("okkkk");
	//alert(xmlHttp.responseText);
	
	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("invno");	
	document.getElementById('txtrefno').value = XMLAddress1[0].childNodes[0].nodeValue;		
	
	document.getElementById('Cmb_refund').value ="Not Recommended";
	document.getElementById('cmb_comm').value ="Not Allowed";
	
	document.getElementById("apprby").style.visibility="hidden";
	document.getElementById("approvedby").style.visibility="hidden";
	
	document.getElementById('approvedby').value="";
	
	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cur_date");	
	document.getElementById('txtentdate').value = XMLAddress1[0].childNodes[0].nodeValue;		
	
	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("cur_date2");	
	document.getElementById('DTPicker_recdate').value = XMLAddress1[0].childNodes[0].nodeValue;		
	
	//document.getElementById('txtrefno').value=xmlHttp.responseText;	
	document.getElementById('txtcl_no').focus();
}


function settec_obs()
{
	document.getElementById('txttc_ob').value=document.getElementById('Combo1').value;	
}

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

  if (document.getElementById('txtrefno').value==""){
	alert("Please Click New !!!");	  
  } else {
	
	var url="item_claim_gin_data.php";	
	
	url=url+"?Command="+"save_inv";
	//$_FILES["image"]["name"][$key] ;
	
	
			
	url=url+"&txtrefno="+document.getElementById('txtrefno').value;
	url=url+"&txtentdate="+document.getElementById('txtentdate').value;
	url=url+"&dtf="+document.getElementById('dtf').value;
	url=url+"&txtcl_no="+document.getElementById('txtcl_no').value;
	url=url+"&DTPicker_recdate="+document.getElementById('DTPicker_recdate').value;
	url=url+"&dtto="+document.getElementById('dtto').value;
	url=url+"&txtag_code="+document.getElementById('txtag_code').value;
	url=url+"&txtphotono="+document.getElementById('txtphotono').value;
	
	txtag_name=document.getElementById('txtag_name').value;
	txtag_name = txtag_name.replace(/&/g,"~");
	url=url+"&txtag_name="+txtag_name;
	
	txtcus_name=document.getElementById('txtcus_name').value;
	txtcus_name = txtcus_name.replace(/&/g,"~");
	url=url+"&txtcus_name="+txtcus_name;
	
	txtagadd=document.getElementById('txtagadd').value;
	txtagadd = txtagadd.replace(/&/g,"~");
	url=url+"&txtagadd="+txtagadd;
	
	txtcus_add=document.getElementById('txtcus_add').value;
	txtcus_add = txtcus_add.replace(/&/g,"~");
	url=url+"&txtcus_add="+txtcus_add;
	
	url=url+"&txtstk_no="+document.getElementById('txtstk_no').value;
	url=url+"&txtdes="+document.getElementById('txtdes').value;
	url=url+"&txtbrand="+document.getElementById('txtbrand').value;
	url=url+"&txtpatt="+document.getElementById('txtpatt').value;
	url=url+"&txtseri_no="+document.getElementById('txtseri_no').value;
	url=url+"&Combo1="+document.getElementById('Combo1').value;
	
	myString=document.getElementById('txttc_ob').value;
	myString = myString.replace(/[\r\n]/g, "<br/>");
	myString = myString.replace(/\s/g, "&nbsp;");
	myString = myString.replace(/'/g, "''");
	myString = myString.replace(/&/g,"~");
			
	url=url+"&txttc_ob="+myString;
	
	url=url+"&Cmb_refund="+document.getElementById('Cmb_refund').value;
	url=url+"&txtremin1="+document.getElementById('txtremin1').value;
	url=url+"&txtremin2="+document.getElementById('txtremin2').value;
	url=url+"&txtremin3="+document.getElementById('txtremin3').value;
	url=url+"&txtremin4="+document.getElementById('txtremin4').value;
	url=url+"&txtremin5="+document.getElementById('txtremin5').value;
	url=url+"&txtorigin1="+document.getElementById('txtorigin1').value;
	url=url+"&txtorigin2="+document.getElementById('txtorigin2').value;
	url=url+"&txtorigin3="+document.getElementById('txtorigin3').value;
	url=url+"&txtorigin4="+document.getElementById('txtorigin4').value;
	url=url+"&txtorigin5="+document.getElementById('txtorigin5').value;
	url=url+"&txtrem_per="+document.getElementById('txtrem_per').value;
	url=url+"&txtspec="+document.getElementById('txtspec').value;
	url=url+"&txtremming="+document.getElementById('txtremming').value;
	url=url+"&txtref_per="+document.getElementById('txtref_per').value;
	url=url+"&cmb_comm="+document.getElementById('cmb_comm').value;
	url=url+"&txtadd_ref1="+document.getElementById('txtadd_ref1').value;
	url=url+"&txtadd_ref2="+document.getElementById('txtadd_ref2').value;
	url=url+"&txtmn_ob="+document.getElementById('txtmn_ob').value;
	url=url+"&txtCRD_no="+document.getElementById('txtCRD_no').value;
	url=url+"&txtCRD_no2="+document.getElementById('txtCRD_no2').value;
	url=url+"&txtCRD_no3="+document.getElementById('txtCRD_no3').value;
	url=url+"&txtCRE_date="+document.getElementById('txtCRE_date').value;
	url=url+"&txtCRE_date2="+document.getElementById('txtCRE_date2').value;
	url=url+"&txtCRE_date3="+document.getElementById('txtCRE_date3').value;
	url=url+"&txtCRE_amount="+document.getElementById('txtCRE_amount').value;
	url=url+"&txtCRE_amount2="+document.getElementById('txtCRE_amount2').value;
	url=url+"&txtCRE_amount3="+document.getElementById('txtCRE_amount3').value;
	url=url+"&approvedby="+document.getElementById('approvedby').value;
	
   
	xmlHttp.onreadystatechange=item_save_results;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
  }
}

function item_save_results()
{
	var XMLAddress1;
	//alert(xmlHttp.responseText);
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 	
		//alert(xmlHttp.responseText);
						
		//	document.getElementById("message").innerHTML=xmlHttp.responseText;
		//	setTimeout("location.reload(true);",1000);
			alert("Successfully Saved");
			
			clear_item();
		}
}

function cancel_inv()
{
	
  var msg=confirm("Are you sure to DELETE ? ");
  if (msg==true){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 		
			
	var url="item_claim_gin_data.php";	
	
	url=url+"?Command="+"cancel_inv";
	//$_FILES["image"]["name"][$key] ;
	
	url=url+"&txtrefno="+document.getElementById('txtrefno').value;
	xmlHttp.onreadystatechange=cancel_inv_results;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
 
  }
}

function cancel_inv_results()
{
	var XMLAddress1;
	//alert(xmlHttp.responseText);
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 	
						
		//	document.getElementById("message").innerHTML=xmlHttp.responseText;
		//	setTimeout("location.reload(true);",1000);
			alert(xmlHttp.responseText);
			
			//clear_item();
		}
}

function chk_number()
{
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 		
			
	var url="item_data.php";	
	
	url=url+"?Command="+"chk_number";
	//$_FILES["image"]["name"][$key] ;
	
	url=url+"&txtSTK_NO="+document.getElementById('txtSTK_NO').value;
	//alert(url);
	xmlHttp.onreadystatechange=chk_number_results;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function chk_number_results()
{
	var XMLAddress1;
	//alert(xmlHttp.responseText);
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 	
						
		//	document.getElementById("message").innerHTML=xmlHttp.responseText;
		//	setTimeout("location.reload(true);",1000);
			if (xmlHttp.responseText=="included"){
				alert("Already Included Stock No ! ");
				location.reload(true);
			}
			
			
		}
}

function item_delete_results()
{
	var XMLAddress1;
	//alert(xmlHttp.responseText);
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 	
						
		//	document.getElementById("message").innerHTML=xmlHttp.responseText;
		//	setTimeout("location.reload(true);",1000);
			alert("Successfully Deleted");
			
			clear_item();
		}
}

function stores_update()
{
		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 		
			
	var url="item_data.php";	
	
	xmlHttp.onreadystatechange=stores_update_results;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stores_update_results()
{
	var XMLAddress1;
	//alert(xmlHttp.responseText);
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 	
			
			alert(xmlHttp.responseText);
		}
}

function itno_claim(refno, stname)
{   
	
			
			xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request");
				return;
			} 		
			
			
			var url="item_claim_gin_data.php";			
			url=url+"?Command="+"pass_invno";
			url=url+"&refno="+refno;
			url=url+"&stname="+stname;
			
			
			xmlHttp.onreadystatechange=passitemresult;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
//		  alert(url);
	
}



function passitemresult()
{
	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=='credit')
		{
			opener.document.form1.paymethod_0.checked=true;
		
		} else if(XMLAddress1[0].childNodes[0].nodeValue=='cash')
		{
			opener.document.form1.paymethod_1.checked=true;
			
		}*/
		
		
					
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtrefno");	
		opener.document.form1.txtrefno.value = XMLAddress1[0].childNodes[0].nodeValue;
		//alert("ok");
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtentdate");	
		opener.document.form1.txtentdate.value = XMLAddress1[0].childNodes[0].nodeValue;

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

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

		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtag_name");	
		opener.document.form1.txtag_name.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtagadd");	
		opener.document.form1.txtagadd.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("TXTCUS_NAME");	
		opener.document.form1.txtcus_name.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtcus_add");	
		opener.document.form1.txtcus_add.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtstk_no");	
		opener.document.form1.txtstk_no.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtdes");	
		opener.document.form1.txtdes.value = XMLAddress1[0].childNodes[0].nodeValue;

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

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

		//XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtpr");	
		//opener.document.form1.txtpr.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtpatt");	
		opener.document.form1.txtpatt.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtseri_no");	
		opener.document.form1.txtseri_no.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txttc_ob");	
		text = XMLAddress1[0].childNodes[0].nodeValue;
		myString = text.replace(/<br\s*\/?>/mg,"\n");
		
		opener.document.form1.txttc_ob.value=myString;
		
		
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtmn_ob");	
		opener.document.form1.txtmn_ob.value = XMLAddress1[0].childNodes[0].nodeValue;
		
				
	//	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtremin");	
	//	opener.document.form1.txtremin.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtspec");	
		opener.document.form1.txtspec.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtremming");	
		opener.document.form1.txtremming.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtref_per");	
		opener.document.form1.txtref_per.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtCRD_no");	
		opener.document.form1.txtCRD_no.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtCRE_date");	
		opener.document.form1.txtCRE_date.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtCRE_amount");	
		opener.document.form1.txtCRE_amount.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtorigin1");	
		opener.document.form1.txtorigin1.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtorigin2");	
		opener.document.form1.txtorigin2.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtorigin3");	
		opener.document.form1.txtorigin3.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtorigin4");	
		opener.document.form1.txtorigin4.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtorigin5");	
		opener.document.form1.txtorigin5.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtremin1");	
		opener.document.form1.txtremin1.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtremin2");	
		opener.document.form1.txtremin2.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtremin3");	
		opener.document.form1.txtremin3.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtremin4");	
		opener.document.form1.txtremin4.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtremin5");	
		opener.document.form1.txtremin5.value = XMLAddress1[0].childNodes[0].nodeValue;
				
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtrem_per");	
		opener.document.form1.txtrem_per.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("Cmb_refund");	
		opener.document.form1.Cmb_refund.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("Commercialy");	
		var Commercialy = XMLAddress1[0].childNodes[0].nodeValue;
		if ((Commercialy == "0") || (Commercialy == "")){
			opener.document.form1.cmb_comm.value = "Not Allowed";	
    		opener.document.form1.approvedby.style.visibility="hidden";
			opener.document.form1.apprby.style.visibility="hidden";
		} else if ((Commercialy == "1") || (Commercialy == "2") || (Commercialy == "3")){
			opener.document.form1.cmb_comm.value = "Allowed";
			opener.document.form1.approvedby.style.visibility="visible";
			opener.document.form1.apprby.style.visibility="visible";
		}
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DGRN_NO");	
		opener.document.form1.txtCRD_no.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DGRN_NO2");	
		opener.document.form1.txtCRD_no2.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("DGRN_NO3");	
		opener.document.form1.txtCRD_no3.value = XMLAddress1[0].childNodes[0].nodeValue;
			
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtCRE_date");	
		opener.document.form1.txtCRE_date.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtCRE_amount");	
		opener.document.form1.txtCRE_amount.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtCRE_date2");	
		opener.document.form1.txtCRE_date2.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtCRE_amount2");	
		opener.document.form1.txtCRE_amount2.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtCRE_date3");	
		opener.document.form1.txtCRE_date3.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("txtCRE_amount3");	
		opener.document.form1.txtCRE_amount3.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("dtf");	
		opener.document.form1.dtf.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("dtto");	
		opener.document.form1.dtto.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("approvedby");	
		
		if (XMLAddress1[0].childNodes[0].nodeValue!=""){
			opener.document.form1.approvedby.value = XMLAddress1[0].childNodes[0].nodeValue;
			opener.document.form1.approvedby.style.visibility="visible";
			opener.document.form1.apprby.style.visibility="visible";
			
		} else {
			
			opener.document.form1.approvedby.style.visibility="hidden";
			opener.document.form1.apprby.style.visibility="hidden";
		}
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("add_ref1");	
		opener.document.form1.txtadd_ref1.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("add_ref2");	
		opener.document.form1.txtadd_ref2.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		if ((opener.document.form1.txtadd_ref1.value!="") || (opener.document.form1.txtadd_ref2.value!="")){
			opener.document.form1.Check1.checked=true;
		} else {
			opener.document.form1.Check1.checked=false;
		}
		
		//if (opener.document.form1.txtadd_ref1.value!="") {
			opener.document.form1.txtadd_ref1.style.visibility="visible";
			opener.document.form1.txtadd_ref2.style.visibility="visible";
		//} else {
		//	opener.document.form1.txtadd_ref1.style.visibility="hidden";	
			
		//}

		
	
			
		
		
		/*opener.document.form1.txtcl_no.disabled=true;
		opener.document.form1.txtseri_no.disabled=true;
		opener.document.form1.Combo1.disabled=true;
		opener.document.form1.txttc_ob.disabled=true;
		opener.document.form1.Cmb_refund.disabled=true;
		opener.document.form1.txtremin1.disabled=true;
		opener.document.form1.txtremin2.disabled=true;
		opener.document.form1.txtremin3.disabled=true;
		opener.document.form1.txtremin4.disabled=true;
		opener.document.form1.txtremin5.disabled=true;
		opener.document.form1.txtorigin1.disabled=true;
		opener.document.form1.txtorigin2.disabled=true;
		opener.document.form1.txtorigin3.disabled=true;
		opener.document.form1.txtorigin4.disabled=true;
		opener.document.form1.txtorigin5.disabled=true;*/
		
	  if ((opener.document.form1.txtCRD_no.value!="") && (opener.document.form1.txtCRD_no.value!="0")){	
		if (opener.document.form1.cmb_comm.value=="Allowed"){
			opener.document.form1.cmb_comm.disabled=true;
		} else {
			opener.document.form1.cmb_comm.disabled=false;	
		}
		opener.document.form1.txtrem_per.disabled=true;
	  } else {
		opener.document.form1.cmb_comm.disabled=false;	
		opener.document.form1.txtrem_per.disabled=false
	  }
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("commercial_enable");	
		var commercial_enable = XMLAddress1[0].childNodes[0].nodeValue;
		
		if (commercial_enable=="1"){
			opener.document.form1.cmb_comm.disabled=false;
		} else {
			opener.document.form1.cmb_comm.disabled=true;	
		}
	//	opener.document.form1.cmb_comm.disabled=true;
		
				///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		if (opener.document.form1.Cmb_refund.value=="Not Recommended"){ 
			
			if (opener.document.form1.cmb_comm.value=="Not Allowed"){ 
				//opener.document.form1.Cmb_refund.disabled=false;
				//opener.document.form1.cmb_comm.disabled=false;
				opener.document.form1.Cmb_refund.disabled=false;
				opener.document.form1.cmb_comm.disabled=false;
							
			} else if (opener.document.form1.cmb_comm.value=="Allowed"){ 
			
				if (opener.document.form1.txtCRD_no.value=="0"){
					opener.document.form1.Cmb_refund.disabled=false;
					opener.document.form1.cmb_comm.disabled=false;
				} else {
					opener.document.form1.Cmb_refund.disabled=true;
					opener.document.form1.cmb_comm.disabled=true;
				}
				
				
			} 
		}
		
		if (opener.document.form1.Cmb_refund.value=="Recommended"){ 
			if (opener.document.form1.cmb_comm.value=="Not Allowed"){ 
				if (opener.document.form1.txtCRD_no.value=="0"){ 
					opener.document.form1.Cmb_refund.disabled=false;
					opener.document.form1.cmb_comm.disabled=false;
				} else {
					opener.document.form1.Cmb_refund.disabled=true;
					opener.document.form1.cmb_comm.disabled=false;	
				}
							
			} else if (opener.document.form1.cmb_comm.value=="Allowed"){ 
				opener.document.form1.Cmb_refund.disabled=true;
				
				if ((opener.document.form1.txtCRD_no2.value=="0")&& (opener.document.form1.txtadd_ref1.value=="")){
					opener.document.form1.cmb_comm.disabled=false;
				} else {
					opener.document.form1.cmb_comm.disabled=true;
					opener.document.form1.txtCRD_no2.disabled=true;
				}
				
				if ((opener.document.form1.txtCRD_no3.value=="0")&& (opener.document.form1.txtadd_ref2.value=="")){
					opener.document.form1.txtCRD_no2.disabled=false;
				} else {
					
					opener.document.form1.txtCRD_no2.disabled=true;
				}
				
				
			} 
		} 
		
		
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		self.close();
	}
}

function custno(custno, stname)
{   
//	alert(stname);
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 		
	
	
		var url="item_claim_gin_data.php";			
		url=url+"?Command="+"pass_item_claim";
		url=url+"&custno="+custno;
		//alert(url);
		xmlHttp.onreadystatechange=passcusresult_item_claim;
	
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
		
}

function passcusresult_item_claim()
{
	var XMLAddress1;
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("id");	
		opener.document.form1.txtag_code.value=XMLAddress1[0].childNodes[0].nodeValue;;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("NAME");	
		opener.document.form1.txtag_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.txtagadd.value =add1+" "+add2;
		
		self.close();
	}
}


function update_item_list_claim()
{   
	
			
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 		
	
	
	var url="item_claim_gin_data.php";			
	url=url+"?Command="+"search_item";
	url=url+"&itno="+document.getElementById('itno').value;
	url=url+"&itemname="+document.getElementById('itemname').value;
	url=url+"&brand="+document.getElementById('brand').value;
	url=url+"&jobno="+document.getElementById('jobno').value;
	url=url+"&checkbox="+document.getElementById('checkbox').checked;
	
	if ((document.getElementById('itemname').value!="") && (document.getElementById('brand').value!="")){
		url=url+"&mstatus=itemname_brand";
		
	} else if (document.getElementById('itemname').value!=""){
		url=url+"&mstatus=itemname";
	} else if (document.getElementById('brand').value!=""){
		url=url+"&mstatus=brand";
	} else if (document.getElementById('itno').value!=""){
		url=url+"&mstatus=itno";
	} else if (document.getElementById('jobno').value!=""){
		url=url+"&mstatus=jobno";
	}
	
	url=url+"&mstatus2=claim_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")
	{
		//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 itno_claim(itno, stname)
{   
			
			xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request");
				return;
			} 		
			
			
			var url="item_claim_gin_data.php";			
			url=url+"?Command="+"pass_itno_claim";
			url=url+"&itno="+itno;
			url=url+"&stname="+stname;
			
			//alert(url);
			xmlHttp.onreadystatechange=itno_claim_result;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		
		
	
}

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

		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("str_description");	
		opener.document.form1.txtdes.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("BRAND_NAME");	
		opener.document.form1.txtbrand.value = XMLAddress1[0].childNodes[0].nodeValue;
		
		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("PART_NO");	
		opener.document.form1.txtpatt.value = XMLAddress1[0].childNodes[0].nodeValue;
	//	XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("dis");	
	//	opener.document.form1.discount.value = XMLAddress1[0].childNodes[0].nodeValue;

 		XMLAddress1 = xmlHttp.responseXML.getElementsByTagName("NSD");	
		opener.document.form1.txtorigin1.value = XMLAddress1[0].childNodes[0].nodeValue;               
                
		
		self.close();
		opener.document.form1.Combo1.focus();
		
	
		
	}
}