// JavaScript Document
function checkTheBox()
{
	/*if(document.getElementById('co_cod').value=='')
	{
		alert('Please Select the Company Code');  
		window.scrollTo(10,10);
		document.getElementById('co_cod').focus();  
		return false; 
	}*/
	
	/*var letters=/^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/;
	if(document.getElementById('pdd').value=='')
	{
		alert('Please Enter Delivery Date');  
		document.getElementById('pdd').focus();  
		return false; 
	}
	else if(letters.test(document.getElementById('pdd').value)==false)  
	{
		alert('Delivery Date must be in the given Format');  
		document.getElementById('pdd').focus();  
		return false;  
	}*/
	
	var chk = document.getElementsByName('category[]');
    var len = chk.length;
	//alert(len);
	var flag = 0;
	if(len==1)
	{
		if(document.checklist["category[]"].checked)
		{
			flag++;			
		}
		else
		{
			flag=0;
		}
	}
	else
	{
		for (var i = 0; i < len; i++)
		{
			if(document.checklist["category[]"][i].checked)
			{
				flag ++;	
			}			
		}
	}
	
	if (flag <1)
	{
		alert ("Please Select the items");
		return false;
	}
	else
	{
		var item1="";
		if(flag==1)
		{
			item1="Item";
		}
		else
		{
			item1="Items";
		}
		if(document.getElementById("tot_cost").value=="NaN" || document.getElementById("tot_cost").value==0)
		{
			alert("The Cost Should Not Empty");
			return false;
		}
		else
		{
			var where_to= confirm("You Have Selected "+ flag +" "+item1+"\n Do you really want to Submit the selected items?");
			if (where_to== true)
			{
				document.checklist.submit();
			}
			else
			{
				return false;		
			}
		}
	}
}

function tot_admt_cal(lop)
{
	var tot_cst = document.getElementById("tot_cost").value.trim();
	if(tot_cst!='')
	{
		tot_cst = tot_cst;
	}
	else
	{
		tot_cst = 0;
	}
	if(document.getElementById("category"+lop).checked==true)
	{		
		var cs_val=document.getElementById("cost_val"+lop).value;
		var bill_amt=parseInt(tot_cst)+parseInt(cs_val);
	}
	else
	{
		var cs_val=document.getElementById("cost_val"+lop).value;
		var bill_amt=parseInt(tot_cst)-parseInt(cs_val);
	}
	document.getElementById("tot_cost").value=bill_amt;
}	
/*function tot_admt_cal()
{
	var chk = document.getElementsByName('category[]');
    var len = chk.length;
	var tot= "";
	var bill_amt=0;
	var cs_val=0;
	for (var i = 1; i <=len; i++)
	{
		
		if(document.getElementById("category"+i).checked)
		{
			
			cs_val=document.getElementById("cost_val"+i).value;
			bill_amt=parseInt(bill_amt)+parseInt(cs_val);
			cs_val=0;
		}
	}
	//alert(bill_amt);
	document.getElementById("tot_cost").value=bill_amt;
}*/

function tot_admt_cal1()
{
	var chk = document.getElementsByName('category[]');
    var len = chk.length;
	var tot= "";
	var bill_amt=0;
	var cs_val=0;
	for (var i = 1; i <=len; i++)
	{
		
		if(document.getElementById("titleCheck").checked)
		{
			
			cs_val=document.getElementById("cost_val"+i).value;
			bill_amt=parseInt(bill_amt)+parseInt(cs_val);
			cs_val=0;
		}
	}
	//alert(bill_amt);
	document.getElementById("tot_cost").value=bill_amt;
}


function reload_page() //this is for reloadin the page when selecting the comapny code
{
	var po_id = document.getElementById('co_cod').value;
	var dat = document.getElementById('pod').value;
	
	window.location = 'po_entry_add.php?party_id='+ po_id +"&dat=" + dat;
}

function form_rest() //this is for reset the forms
{
	var where_to= confirm("Do you really want to Reset the Data?");
	if (where_to== true)
	{
		window.location.reload();
	}
	else
	{
	 	return false;	
	}
}

function foc(ids)
{
	document.getElementById(ids).style.border="2px solid #0099FF";
	
}

function stnon(ids)
{
	document.getElementById(ids).style.border="thin solid #CCCCCC";
}