// JavaScript Document
function ftl_reload_page() //this is for reloadin the page when FILTER THE CATEGORY
{
	var cat_name = document.getElementById('cat_name').value;
	var dno = document.getElementById('dno').value;	
	var po_id = document.getElementById('po_id').value;
	var flg = document.getElementById('flg').value;
	
	window.location = 'po_entry_upd.php?po_id='+po_id+'&flg='+flg+"&master_cat_id="+cat_name+"&dno="+dno;
}
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('pod').value=='')
	{
		alert('Please Enter Order Date');  
		document.getElementById('pod').focus();  
		return false; 
	}
	else if(letters.test(document.getElementById('pod').value)==false)  
	{
		alert('Order Date must be in the given Format');  
		document.getElementById('pod').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";
		}
		 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 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 cnt_chk_fn(i)
{
	var vl = document.getElementById('cnt_chk').value;

	if(document.getElementById("category"+i).checked == true)
	{
		if(vl == ''){ vl = 0; }
		vl = parseInt(vl)+1;

	}
	else if(document.getElementById("category"+i).checked == false)
	{
		vl = parseInt(vl)-1;
		if(vl < 1){ vl = ''; }
	}
	document.getElementById('cnt_chk').value = vl;	
		
}
function ckall()
{
	if(document.getElementById("titleCheck").checked == true)
	{
		var tto_ct = document.getElementById('des_tot_cnt').value;
		var j=0;
		for(i=1;i<=tto_ct;i++)
		{
			if(document.getElementById('category'+i).checked == false)
			{
				j++;
			}
		}
		
		var vl = document.getElementById('cnt_chk').value;
		var tot_ct = parseInt(vl)+parseInt(j)
		document.getElementById('cnt_chk').value = tot_ct;	
	}
	else if(document.getElementById("titleCheck").checked == false)
	{
		document.getElementById('cnt_chk').value = 0;	
	}
}

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

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

