function calculate_taxamount()
{
   var  qty = 0;
	var  count= document.getElementById('rowcount').value;
   	var i;
 	for(i=0; i<count; i++)
	{
 		var taxamount = document.getElementById('taxamount_rate_'+i).value;
			var rate= document.getElementById('totalrate_'+i).value;
		
 			if(!isNaN(taxamount) && taxamount!='' ){
				Totaltax  =parseFloat(rate)+  parseFloat(taxamount);
  			}
 	}
document.getElementById('total_amt_with_tax_').value = Totaltax.toFixed(2);
}
function CountTotalQty()
{
	var  qty = 0;
	var  count= document.getElementById('rowcount').value;
   	var i;
 	for(i=0; i<count; i++)
	{
 		var totalqty = document.getElementById('reciveqty_'+i).value;
 			if(!isNaN(totalqty) && totalqty!='' ){
				qty  =parseInt(qty)+  parseInt(totalqty);
  			}
 	}
  	document.getElementById('totalqty').value = qty.toFixed(2);
 }


function calculate_totalrate_direct(id)
{
 
 	var qnty = document.getElementById('reciveqty_'+id).value;
 	var itemrate = document.getElementById('itemrate_'+id).value;
  	var total = parseFloat(qnty) * parseFloat(itemrate);
  	document.getElementById("totalrate_"+id).value =total.toFixed(2);
}

function calculate_TotalTaxAmount()
{
 	var  itemamount = 0;
 	var  count= document.getElementById('rowcount').value;
	alert(count);
 	for(var i=0; i<count; i++)
	{
 		var totalrate = document.getElementById('taxamount_rate_'+i).value;
 			if(!isNaN(totalrate) && totalrate!='' ){
				itemamount  =parseFloat(itemamount)+  parseFloat(totalrate);
  			}
 	}
  	document.getElementById('tax_chargeamount').value = itemamount.toFixed(2);
  }
 
 
 function calculate_total_taxamount(id)
{
 	var itemamount = 0;
	var count= document.getElementById('rowcount').value;
	var i;
   	for(i=0; i<=count; i++)
	{
	 var totalrate = document.getElementById('taxamount_rate_'+i).value;
  	 	 if(i!='') 
		 {
			itemamount   =parseFloat(itemamount)+  parseFloat(totalrate);
			
 			document.getElementById('tax_chargeamount').value = itemamount.toFixed(2);
			  
		}
		else
		{
			document.getElementById('tax_chargeamount').value = 0; 
		}
	}
}




function PurchaseOrderNumber()
{
	var receiviedagaist=document.getElementById("receiviedagaist").value;
	location.replace("AddMRN.php?type="+receiviedagaist);
}




var xmlHttp
function PO_order(str)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var orderno=document.getElementById("orderno").value;
	var url="purchase_order.php";
	url=url+"?item="+str+'&orderno='+orderno;

	xmlHttp.onreadystatechange=Po_change;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function Po_change()
{
	if (xmlHttp.readyState==4)
	{
		document.getElementById("poqty").innerHTML=xmlHttp.responseText;
	}
}
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;
}
var xmlHttp

function changestorename(str)
{
	if (str=="")
	{
		document.getElementById("txtid").innerHTML="";
		return;
	}
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("txtid").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","storename.php?store_code="+str,true);
	xmlhttp.send();
}



function showsitename(str)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	receivetype = document.getElementById('receive_type').value;
	document.getElementById('hidden_form_site').value=str; 
	//alert("1. "+receivetype);

	var url="sitename.php";
	url=url+"?site_name="+str+"&receive_type="+receivetype;
	xmlHttp.onreadystatechange=change1;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function change1()
{
	if (xmlHttp.readyState==4)
	{
		document.getElementById("txtsite").innerHTML=xmlHttp.responseText;
	}
}
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 showsitename111(str)
{
	if (str=="")
	{
		document.getElementById("txtsite").innerHTML="";
		return;
	}
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("txtsite").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","get_sitename.php?site="+str,true);
	xmlhttp.send();
}

//*****************************************************************************
function showbalance(str)
{
	var StockBalance=document.getElementById("stockbal").value;
	var Issuequantity=document.getElementById("issueqty").value;
	var RemaningBalance =StockBalance-Issuequantity;
	document.getElementById('remaningbalance').value =RemaningBalance;

}
//*************************************************************************************
function LRdate()
{
	var str1 = document.getElementById("MRNdate").value;
	var str2 = document.getElementById("lrdate").value;
	var date1 = str1.split('/');
	var compstr1 = date1[2]+date1[1]+date1[0];
	var date2 = str2.split('/');
	var compstr2 = date2[2]+date2[1]+date2[0];

	if(compstr1 >compstr2)
	{
		alert("Date Not Less Than MRN Date.");
		document.getElementById("lrdate").focus();
		return false;
	}
}
 function select_order(str)
{
	if (str=="")
	{
		document.getElementById("txt_order").innerHTML="";
		return;
	}
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("txt_order").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","getorder.php?q="+str,true);
	xmlhttp.send();
}

//**********************************************************************************
function valdate()
{
	var str1 = document.getElementById("MRNdate").value;
	var str2 = document.getElementById("datepicker").value;
	var date1 = str1.split('/');
	var compstr1 = date1[2]+date1[1]+date1[0];

	var date2 = str2.split('/');
	var compstr2 = date2[2]+date2[1]+date2[0];

	if(compstr1 >compstr2)
	{
		alert("Please Choose Correct Date! Bill Date Cannot Be Less Than MRN Date");
		document.getElementById("Billdate").focus();
		return false;
	}

}

function inwardvalidate()
{
	var str1 = document.getElementById("MRNdate").value;
	var str3 = document.getElementById("datepicker1").value;
	var date1 = str1.split('/');
	var compstr1 = date1[2]+date1[1]+date1[0];
	var date3 = str3.split('/');
	var compstr3 = date3[2]+date3[1]+date3[0];

	if(compstr1 >compstr3)
	{
		alert("Please Choose Correct Date! Inwards Gate Pass Date Cannot Be Less Than MRN Date");
		document.getElementById("inwarddate").focus();
		return false;
	}

}

var TotalPercent=0;
var TotalAmnt=0;
var finalAmount=0;

/*function ChargeCalculater(Amt,Amtid)
  {
 	 
	 var myCars=new Array();
 	  for(i=0;i<myCars.length; i++)
	  {
		 myCars[i]=Amtid;
		  
	  }
     var AsPerActual=document.getElementById(Amtid).value;
 	 var ActualType=document.getElementById("AsPerActual_" +Amtid).value;
  	 if(AsPerActual !='')
	 {
 	     document.getElementById("actual_"+Amtid).value=AsPerActual; 
		  TotalAmnt=parseFloat(TotalAmnt) + parseFloat(AsPerActual) ;
  		  document.getElementById("chargeamount").value=parseFloat(TotalAmnt);
		 
		  
	}
	return true;
  
  }*/

function get_order(str)
{
	var type=document.getElementById("receive_type").value;
	var sitename=document.getElementById("sitename").value;
	if (str=="")
	{
		document.getElementById("order").innerHTML="";
		return;
	}
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("order").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","find_order_number.php?vendor="+str+"&site="+sitename+"&type="+type,true);
	xmlhttp.send();
}
function getreqitemdata(str)
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	 var data=xmlhttp.responseText.split("__");	
	
	document.getElementById("txtsite").innerHTML=data[0];
	document.getElementById("storedata").innerHTML=data[1];
	document.getElementById("transpName").innerHTML=data[2];	
    }
  }
  xmlhttp.open("GET","getsitenamedata.php?site="+str,true);
xmlhttp.send();
}


function getreqitemdata1(str)
{

var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	 var data=xmlhttp.responseText.split("__");	
	
	//document.getElementById("txtsite1").innerHTML=data[0];
	document.getElementById("storedata12").innerHTML=data[1];
	
    }
  }
  
  xmlhttp.open("GET","getsitenamedataFordealer.php?site="+str,true);
xmlhttp.send();

//xmlhttp.open("GET","getSort.php?s="+str+"&cat="+cat,true);

}






