// JavaScript Document
function checkTheBox()
{
	
	
	
	
	if (document.getElementById('cnt_chk').value==0)
	{
		alert ("Please Select the items");
		return false;
	}
	else
	{
		var item1=document.getElementById('cnt_chk').value;
		
		 var where_to= confirm("You Have Selected "+item1+"\n Do you really want to Submit the selected items?");
         if (where_to== true)
         {
			 document.checklist.submit();			 
           
         }
         else
         {
			 return false;
          
          }
	}
}
	


function ftl_reload_page() //this is for reloadin the page when FILTER THE CATEGORY
{
	//var party_id = document.getElementById('co_cod').value;
	//var dat = document.getElementById('pod').value;
	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 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";
}

// PO DESIGN AJAX FUNCTION
function check_ajax(ids,vls)
{
	if(document.getElementById('category'+ids).checked==true)
	{
		var flg=1;
	}
	else if(document.getElementById('category'+ids).checked==false)
	{
		var flg=2;
	}
	var pa_id = document.getElementById("party_id").value
	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)
		{
			//alert(xmlhttp.responseText);						
		}
	}
	
	var qurl ="?ajax_id=1&flg="+flg+"&vls="+vls+"&pa_id="+pa_id;
	//alert(qurl);
	xmlhttp.open("GET","ajax/po_temp_AJAX.php"+qurl,true);
	xmlhttp.send();	
	
}

function check_all_cnt()
{
	if(document.getElementById('titleCheck').checked==true)
	{
		var flg=1;
	}
	else if(document.getElementById('titleCheck').checked==false)
	{
		var flg=2;
	}
	
	var tto_ct = document.getElementById('des_tot_cnt').value;
	var ids = new Array();
	for(i=1;i<=tto_ct;i++)
	{
		if(flg==1)
		{
			if(document.getElementById('category'+i).checked == false)
			{
				ids[i] = document.getElementById('category'+i).value;
			}
		}
		else
		{
			ids[i] = document.getElementById('category'+i).value;
		}
	}
	var vls = ids.join();
		
	
	var pa_id = document.getElementById("party_id").value
	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)
		{
			//alert(xmlhttp.responseText);					
		}
	}
	
	var qurl ="?ajax_id=2&flg="+flg+"&vls="+vls+"&pa_id="+pa_id;
	//alert(qurl);
	xmlhttp.open("GET","ajax/po_temp_AJAX.php"+qurl,true);
	xmlhttp.send();	
}


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)
	{
		var stat_cnt = document.getElementById('stat_cnt').value;
		document.getElementById('cnt_chk').value = stat_cnt;	
	}
}