// JavaScript Document
function checkTheBox(ids)
{
	document.getElementById("page_id").value = ids.trim();
	var chk = document.getElementsByName("category[]");
	var len = chk.length;
	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 form_rest(ids)
{
	document.getElementById("page_id").value = ids.trim();
	var where_to= confirm(" Do you really want to clear the items?");
	if (where_to== true)
	{
		document.checklist.submit();
	}
	else
	{
		return false;		
	}
}
function hid_show() //this is for hide and show the bottom button dives
{
	var cnt = document.getElementById("cnt_chk").value;
	
	if(cnt!='')
	{
		document.getElementById("top_por").style.display = 'block';
	}
	else
	{
		document.getElementById("top_por").style.display = 'none';
	}
	if(cnt!='')
	{
		document.getElementById("sub_but_dv").style.display = 'block';
	}
	else
	{
		document.getElementById("sub_but_dv").style.display = 'none';
	}
}

function vad_date_fm()
{
	var where_to= confirm("Do you really want to Submit the selected items?");
	if (where_to== true)
	{
		document.checklist.submit();			 
	}
	else
	{
	 return false;
	
	}
}
// 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();	
	
	cnt_chk_fn(ids);
	hid_show();
}

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 foc(ids)
{
	document.getElementById(ids).style.border="2px solid #0099FF";	
}

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