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


 function calculate_total_taxamount(id)
{
   	var taxname=parseFloat(document.getElementById('taxname_'+id).value);
	var totalrate=parseFloat(document.getElementById('totalrate_'+id).value);
  	var	tax=(taxname*totalrate)/100;
	var num= parseFloat(tax);	
 	document.getElementById('taxamount_rate_'+id).value=num ;
}

 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 showsite_name(str)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	receivetype = document.getElementById('receive_type').value;
	//alert("1. "+receivetype);

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

}
 
 
 function total_charges(val,cnt)
 {
	
	 
 }
function calculate_totalamount(id)
{
	var  total_Item_Amount = 0;
 	var  count= document.getElementById('rowcount').value;
 	var i;
	
 	for(i=1; i<=count; i++)
	{
 		var totalrate = document.getElementById('totalrate_'+i).value;
 		if(i!=''){
			total_Item_Amount  = parseInt(totalrate)+parseInt(total_Item_Amount) ;
			 
			document.getElementById('total_Item_Amount').value = total_Item_Amount;
			
			}
			else{document.getElementById('total_Item_Amount').value = '0'; }
	}
	
	
 }
 
  function tax_calcutate(str,j)
 {  
	var amount= document.getElementById('totalrate_'+j).value;
	 
	var divid="divTaxAmount"+j;
   	if (str=="")
	{
		document.getElementById(divid).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(divid).innerHTML=xmlhttp.responseText;
		}
	}
 	xmlhttp.open("GET","CountTaxAmount.php?TaxAmount="+amount+"&Taxid="+str+"&id="+j,true);
	xmlhttp.send();

 }