// JavaScript Document
function validate()
{

var why1 = "";
if(document.appointment.name.value == ""){
 
 why1+='Please enter Your Name <br/>';	
 
 }

 
if(validate_phone(document.appointment.telephone.value)==false){
why1+='Please enter primary phone number <br/>';
}

if(validate_email(document.appointment.email.value)==false){
why1+='Please enter valid email <br/>';
}
if(document.appointment.service.value == ""){
 why1+='Please select service reqired<br/>';	
 
 }
 
 
 if(document.appointment.text_question.value == ""){
 why1+='Please enter your question<br/>';	
 
 }
if(why1!="")
	{
	showDialog('Appointment Form',why1,'warning');
	return false;
	}
 
}
function  gotofocus()
	{
		
		
		    if(document.appointment.name.value=="")	
		    document.appointment.name.focus();
			else if(validate_phone(document.appointment.telephone.value)==false)
			 document.appointment.telephone.focus();
			else if(validate_email(document.appointment.email.value)==false)
			 document.appointment.email.focus();
			 else if(document.appointment.service.value=="")	
		    document.appointment.service.focus();
		    else if(document.appointment.preferred_practice.value=="")	
		    document.appointment.preferred_practice.focus();
			 else if(document.appointment.text_question.value=="")	
		    document.appointment.text_question.focus();
			
			
	
	}
	function validate_email(emailid) {
	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   if(reg.test(emailid) == false) {     
		  return false;
	   }else{
			return true;
	   }
	}
	function trim(str)
		{
			return str.replace(/^\s*|\s*$/g,'');
		}
	function validate_phone(phone){
		var reg = /^[0-9-. ]+$/;
		if(reg.test(phone)){
			return true;
		}else{		
			return false;
		}
	}
