var xmlHttp
function addmoresales(str)
{
	
	
		
	document.getElementById('totcnt_box').value=str;
	//alert(document.getElementById('totcntw').value);
	var k = parseInt(str)-parseInt(1);
	//alert(document.getElementById('editcnt').value.length);
	if(document.getElementById('branch'+k).value!=''){
	
		if(document.getElementById('literqty'+k).value!=''){
			
			if(document.getElementById('kg_liter'+k).value!=''){
				
				if(document.getElementById('boxqty'+k).value!=''){
					
					if(document.getElementById('ratebox'+k).value!=''){
						
						
						if(document.getElementById('editcnt'))
						{
						
							var q = document.getElementById('editcnt').value;
							if(q > 0)
							{
								q = parseInt(q)+parseInt(1);
								document.getElementById('editcnt').value= q;
							}
						}
					
						if(document.getElementById('s'+k)){
							if(document.getElementById('s'+k).value==''){
							alert("enter the valuesss to this row");
							return false;
							}
						}
							if(document.getElementById('t'+k)){
							if(document.getElementById('t'+k).value=='' || document.getElementById('t'+k).value==0){
							alert("enter the bill values to this row");
							return false;
							}
						}
						
						
						if(document.getElementById('min'+k)){
							document.getElementById('min'+k).style.display='none';
						}
						if(document.getElementById('max'+k)){
							document.getElementById('max'+k).style.display='block';
						}
						var container_drp_val='';
					if (str.length==0)
					{ 
					return
					}
					xmlHttp=GetXmlHttpObject()
					if (xmlHttp==null)
					{
					alert ("Browser does not support HTTP Request")
					return
					} 
					var url="php/addmoresales.php"
					nid	=str
					if(document.getElementById('divcnt')){
					document.getElementById('divcnt').value=str;	
					}
					for(i=1;i<str;i++){
					if(document.getElementById('s'+i)){
					container_drp_val+="'"+document.getElementById('s'+i).value+"'"+',';	
					}
					}
					url=url+"?div="+str;
					if(container_drp_val && container_drp_val!=''){
					url=url+"&container_drp_val="+container_drp_val;	
					}
					
					url=url+"&sid="+Math.random()
					xmlHttp.onreadystatechange=stateChanged 
					xmlHttp.open("GET",url,true)
					xmlHttp.send(null)
					

				}
					else{
						alert("Please Fill Rate");
						document.getElementById('ratebox'+k).focus();
						}
			}else{
						alert("Please Fill Box Quantity");
						document.getElementById('boxqty'+k).focus();
						}
		}else{
						alert("Please Fill Kg value");
						document.getElementById('kg_liter'+k).focus();
						}
	}else{
						alert("Please Fill Litre value");
						document.getElementById('literqty'+k).focus();
						}
}else{
						alert("Please Fill Brand ");
						document.getElementById('branch'+k).focus();
						}
} 

function stateChanged() 
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{	
	if(document.getElementById('divcnt')){
	var divcnt=document.getElementById('divcnt').value;
	//alert(divcnt);
	var txtData="div"+divcnt;
	if(document.getElementById(txtData))
	document.getElementById(txtData).innerHTML=xmlHttp.responseText
	}else{
	var txtData="div2";
	if(document.getElementById(txtData))
	document.getElementById(txtData).innerHTML=xmlHttp.responseText
	}

	
} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
} 