// JavaScript Document
function reload_dat(ids)
{
	var lob = document.getElementById('finishing_date').value;
	if(ids=='')
	{
		window.location = 'mas_finishing_upd.php?finishing_date='+lob;
	}
	else
	{
		window.location = 'mas_finishing_upd.php?finishing_date='+lob+"&cat_id="+ids;
	}
}

function checkTheBox()
{
	
	/*if(document.getElementById('hdes_name').value=='')
	{
		alert('Please Select the CAM Designer Name');  
		document.getElementById('hdes_name').focus();  
		return false; 
	}*/
	
	
	/*var letters=/^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/;
	if(document.getElementById('lob').value=='')
	{
		alert('Please Enter Finishing Date');  
		document.getElementById('lob').focus();  
		return false; 
	}
	else if(letters.test(document.getElementById('lob').value)==false)  
	{
		alert('Finishing Date must be in the given Format');  
		document.getElementById('lob').focus();  
		return false;  
	}*/
	
	if(document.getElementById('mat_name').value=='')
	{
		alert('Please Select the Material for row ');  
		document.getElementById('mat_name').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)
		{
			
			var letters=/^\d+(?:\.\d+)?$/;
			if(document.getElementById('mas_wt1').value=='')
			{
				alert('Please Enter Gold Weight ');  
				document.getElementById('mas_wt1').focus();  
				return false; 
			}
			else if(letters.test(document.getElementById('mas_wt1').value)==false)  
			{
				alert('Gold Weight Should have only Decimal');  
				document.getElementById('mas_wt1').focus();  
				return false;  
			}
			
			flag++;
			
		}
		else
		{
			flag=0;
		}
	}
	else
	{
	for (var i = 0; i < len; i++)
	{
		if(document.checklist["category[]"][i].checked)
		{
			var j=i+1;
			
			
			
			var letters=/^\d+(?:\.\d+)?$/;
			if(document.getElementById('mas_wt'+j).value=='')
			{
				alert('Please Enter Gold Weight for Design '+j);  
				document.getElementById('mas_wt'+j).focus();  
				return false; 
			}
			else if(letters.test(document.getElementById('mas_wt'+j).value)==false)  
			{
				alert('Gold Weight Should have only Decimal for row '+j);  
				document.getElementById('mas_wt'+j).focus();  
				return false;  
			}
			
			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() //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";
}

