// JavaScript Document
function reload_page(ids)
{
	var po_id = document.getElementById("cat_name").value;
	if(ids==1)
	{
		var val = document.getElementById("piece_trc_1").value;
		window.location='po_multi_finishing_stock_add.php?master_cat_id='+po_id+'&piece_trc='+val;
	}
	else if(ids==2)
	{
		var val = document.getElementById("piece_trc_2").value;
		window.location='po_multi_finishing_stock_add.php?master_cat_id='+po_id+'&piece_trc='+val;
	}
	else if(ids==3)
	{
		var val = document.getElementById("piece_trc_2").value;
		var trc_typ = document.getElementById("trc_type_0").value;
		var to_po = document.getElementById("to_po").value;
		window.location = 'po_multi_finishing_stock_add.php?master_cat_id='+po_id+'&piece_trc='+val+'&trc_typ='+trc_typ+'&to_po='+to_po;
	}
	else if(ids==4)
	{
		var val = document.getElementById("piece_trc_3").value;
		window.location = 'po_multi_finishing_stock_add.php?master_cat_id='+po_id+'&piece_trc='+val;
	}
}
function hide_page(ids)
{
	var po_id = document.getElementById("cat_name").value;
	var val = document.getElementById("piece_trc_2").value;
	if(ids==1)
	{
		document.getElementById("to_po_div").style.display='block';
	}
	else if(ids==2)
	{
		document.getElementById("to_po_div").style.display='none';
		var trc_typ = document.getElementById("trc_type_1").value;
		window.location='po_multi_finishing_stock_add.php?master_cat_id='+po_id+'&piece_trc='+val+'&trc_typ='+trc_typ;
	}
}
function checkTheBox()
{
	if(document.getElementById('piece_trc_3').checked==true)
	{
		if(document.getElementById('pack_name').value=='')
		{
			alert('Please Select the Packer Name');  
			document.getElementById('pack_name').focus();
			window.scroll(0,100);  
			return false; 
		}
		var letters=/^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/;
		if(document.getElementById('cut_dt').value=='')
		{
			alert('Please Enter Packing Date');  
			document.getElementById('cut_dt').focus();  
			return false; 
		}
		else if(letters.test(document.getElementById('cut_dt').value)==false)  
		{
			alert('Packing Date must be in the given Format');  
			document.getElementById('cut_dt').focus();  
			return false;  
		}
		if(document.getElementById('cut_name').value=='')
		{
			alert('Please Select the Cutter Name');  
			document.getElementById('cut_name').focus(); 
			window.scroll(0,100); 
			return false; 
		}
		var letters=/^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/;
		if(document.getElementById('fin_dt').value=='')
		{
			alert('Please Enter Cutting Date');  
			document.getElementById('fin_dt').focus();  
			return false; 
		}
		else if(letters.test(document.getElementById('fin_dt').value)==false)  
		{
			alert('Cutting Date must be in the given Format');  
			document.getElementById('fin_dt').focus();  
			return false;  
		}
	}
	var letters=/^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/;
	if(document.getElementById('lod_dt').value=='')
	{
		alert('Please Enter the Date');  
		document.getElementById('lod_dt').focus();  
		return false; 
	}
	else if(letters.test(document.getElementById('lod_dt').value)==false)  
	{
		alert('Date must be in the given Format');  
		document.getElementById('lod_dt').focus();  
		return false;  
	}
	var chk = document.getElementsByName("category[]");
	var len = chk.length;
	var flag = 0;
	if(len==1)
	{
		if(document.check_list["category[]"].checked)
		{
			flag++;			
		}
		else
		{
			flag=0;
		}
	}
	else
	{
	for (var i = 0; i < len; i++)
	{
		if(document.check_list["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.check_list.submit();
		}
		else
		{
			return false;		
		}
	}
}

function reload_page_cat() //this is for reloadin the page when selecting the comapny code
{
	var des_cd = document.getElementById('cat_name').value;
	window.location = 'po_multi_finishing_stock_add.php?master_cat_id='+ des_cd;
}



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";
}