// JavaScript Document
//des_cd,pack_name,cut_name,pfd

// IF flsg = 1; THERE IS NO PURCHASE ORDER EXIST FOR THE DESIGN
// IF flsg = 2; THEN THE PURCHASE ORDER EXIST FOR THE DESIGN AND ALSO THE PARTICULAR DESIGN EXIST IN STOCK
// IF flsg = 3; THEN THE PURCHASE ORDER EXIST FOR THE DESIGN AND ALSO NO STOCK FOR PARTICULAR DESIGN
		
function checkTheBox()
{
	
	var flsg = document.getElementById('flsg').value
	
	if(flsg == 1 || flsg == 3) 
	{
		
		if(document.getElementById('pack_name').value=='')
		{
			alert('Please Select the Packer Name');  
			window.scrollTo(10,10);
			document.getElementById('pack_name').focus();  
			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');  
			window.scrollTo(10,10);
			document.getElementById('cut_name').focus();  
			return false; 
		}
		
		var letters=/^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/;
		if(document.getElementById('pfd').value=='')
		{
			alert('Please Enter Cutting Date');  
			document.getElementById('pfd').focus();  
			return false; 
		}
		else if(letters.test(document.getElementById('pfd').value)==false)  
		{
			alert('Cutting Date must be in the given Format');  
			document.getElementById('pfd').focus();  
			return false;  
		}
		
	}
	
	if(flsg == 2 || flsg == 3) 
	{
	
		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;
		}
	}
	
	var where_to= confirm("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 des_cd = document.getElementById('des_cd').value;
	var pfd = document.getElementById('pfd').value;
	
	window.location = 'po_finishing_add.php?design_id='+ des_cd +"&dat=" + pfd;
}

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