// JavaScript Document
function formvalid(thisform)
{
	
	
	with (thisform)
	{
		
		if(emptyvalidation(fname,"Woops! You forgot to fill in your Name")==false) 
			{
			fname.focus();
			return false;
			}
		//if (email.value==email.defaultValue)email.value=""; 
		if(emptyvalidation(email,"Woops! You forgot to fill in your Email Address")==false) 
			{
			email.focus();
			return false;
			}
		if(validate_email(email)==false)
		{
			email.select();
			email.focus();
			return false;
		}
		//if(phone.value==phone.defaultValue)phone.value=""; 
		if (emptyvalidation(phone,"Woops! You forgot to fill in your Phone Number")==false) 
				{
					
					phone.focus();
					return false;
				}
	//	}
			if (emptyvalidation(state,"Woops! You forgot to select Day Time")==false) 
				{
					
					state.focus();
					return false;
				}

		
		
	if(thisform.comment.value=='Comments' || thisform.comment.value=='' ) 
	{	
				var agree=confirm("Continue Without Any Comments?");
				if(agree)
					{
						
									thisform.submit();
								
					}
					else
					{
						thisform.comment.focus();
						return false;
					}		
		}
		thisform.submit();
	}
	
}

function validate_email(entered) {

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = entered.value;
   if(reg.test(address) == false) {
      alert('Woops! You have entered an invalid Email Address');
      return false;
   }
   }
   
   function emptyvalidation(entered, alertbox)
{
		
	with (entered)
	{
		while (value.charAt(0) == ' ')
			value = value.substring(1);
		while (value.charAt(value.length - 1) == ' ')
			value = value.substring(0, value.length - 1);
		if (value==null || value=="")
		{
			if (alertbox!="") alert(alertbox);
			return false;
		}
		else return true;
	}
}
