// JavaScript Document  
// this validation is for product form ///

function validate_chk()
{ 
	//alert(document.getElementById('name').value);
	if( trim_string (document.getElementById('name').value)=="")
	{
		alert('Please Enter Name !');
		document.getElementById('name').focus();
		
		return false;
		
	}
		else if(trim_string(document.getElementById('email').value) =="")
   {
	   alert('Please Enter Email Address !');
	   document.getElementById('email').focus();
	   return false;
   }
	
	else if(checkMail(document.getElementById('email').value)==false)
	{
					alert('Please Enter Proper Email Address !');
      				document.getElementById('email').focus();
					return false;
	}
	else if(trim_string(document.getElementById('cname').value)=="")
	{
		alert('Please Enter Company Name !');
		document.getElementById('cname').focus();
		return false;

	}

	else if(trim_string(document.getElementById('cno').value)=="")
	{
		alert('Please Enter Contact No !');
		document.getElementById('cno').focus();
		return false;

	}
	
	else if(IsPhoneNo(trim_string(document.getElementById('cno').value))==false)
   {
      alert("Please Enter proper Contact No !");
      document.getElementById('cno').focus();
	  return false;
   }
   
	
	else if( trim_string(document.getElementById('comments').value)=="")
   {
   		
		alert('Please Enter Comments/Requirements !');
		document.getElementById('comments').focus();
		return false;   
	}
	/*else if( trim_string(document.getElementById('location').value)=="")
   {
   		
		alert('Please Enter Kit Location !');
		document.getElementById('location').focus();
		return false;
	
   }*/
	
	//else if(!(document.getElementById('condition_new').checked  || document.getElementById('condition_refurbished').checked))
// 	{
// 		alert('Please Select Condition !');
//		document.getElementById('condition_new').focus();
//	
//		return false;
//	
// 	}
// 	else if(! (document.getElementById('when_required_ASAP').checked || document.getElementById('when_required_Weeks').checked || document.getElementById('when_required_Months').checked || document.getElementById('When_Required_Months6').checked ) )
// 	{
// 		alert('Please Select When Required !');
//		document.getElementById('when_required_ASAP').focus();
//		return false;
//	
// 	}
// 	else if(!(document.getElementById('support_yes').checked || document.getElementById('support_no').checked))
// 	{
//	 	alert('Please Select Support / maintenance !');
//		document.getElementById('support_yes').focus();
//	 
//	 	return false;
// 	}
 	else
 	{ 
		/*if(document.getElementById('email').value !="")
		{
   	 		 	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
   	  			var address = document.getElementById('email').value;
   	
				if(filter.test(address) == false) {
      				alert('Invalid Email Address');
      				document.getElementById('email').focus();
					return false;
		   		
				}
		

		}*/
   
		return true;
 	}
	

}
function IsPhoneNo(sNo)
	{
	   var ValidChars = '1234567890';
	   var IsNum=true;
	   var Char;
	
		for (i = 0; i < sNo.length && IsNum == true; i++) 
		{ 
		Char = sNo.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		   {
		   IsNum = false;
		   }
		}
		
		return IsNum;
	   
	}
function checkMail(email)
	{
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(email)) 
		{
			return true;
		}
		return false;
	}
function trim_string(str)
{
	var str_return = str.replace(/^\s+|\s+$/g, '');
	return str_return;
}


