// JavaScript Document
var RE_EMAIL = /^(\w+[\-\.])*\w+@(\w+\.)+[A-Za-z]+$/;
var RE_PHONE=/^(1\s*[-\/\.]?)?(\((\d{3})\)|(\d{3}))\s*[-\/\.]?\s*(\d{3})\s*[-\/\.]?\s*(\d{4})\s*(([xX]|[eE][xX][tT])\.?\s*(\d+))*$/



colorchange=function(obj)
				{
				if(obj.value=="")
							{
							$('#'+obj.id+'').animate({backgroundColor:'#f00',color:'#ffffff'},500)	
							}
				else if(obj.id=='state' && obj.value=="null")
							{
							$('#'+obj.id+'').animate({backgroundColor:'#f00',color:'#ffffff'},500)	
							}		
				else if(obj.id=='service' && obj.value=="null")
							{
							$('#'+obj.id+'').animate({backgroundColor:'#f00',color:'#ffffff'},500)	
							}		
							else{$('#'+obj.id+'').animate({backgroundColor:'#fff',color:'#666'},500)}
				}
				
colorset=function(obj1)
				{		
				$('#'+obj1.id+'').animate({backgroundColor:'#fff',color:'#666'},500)
				}
				
validate=function()
					{
					var errors = [];
					var email = document.getElementById('email').value;
					var phone=document.getElementById('telephone').value;
					var first=document.getElementById('first_name').value
					var last=document.getElementById('last_name').value
					//var city=document.getElementById('city').value
					var state=document.getElementById('state').value
					var call=document.getElementById('calltime').value
					var service=document.getElementById('service').value
					var eventype=document.getElementById('typevent').value
					var date=document.getElementById('date').value
					var start=document.getElementById('startime').value
					var amount=document.getElementById('amount').value
					
					
						if (!RE_PHONE.test(phone)) {errors[errors.length] = "You must enter a valid phone number.";result=false}
						if (!RE_EMAIL.test(email)) {errors[errors.length] = "You must enter a valid email address.";result=false}
						if(first==""){errors[errors.length]="You must type in first name";result=false}
						if(last==""){errors[errors.length]="You must type in last name";result=false}
						//if(city==""){errors[errors.length]="You must type in city";result=false}
						if(state=="null"){errors[errors.length]="You must choose a state";result=false}
						if(call==""){errors[errors.length]="You must type in a call time";result=false}
						if(service=="null"){errors[errors.length]="You must choose a service";result=false}
						if(eventype==""){errors[errors.length]="You must identify the type of event";result=false}
						if(date==""){errors[errors.length]="You must identify the date of event";result=false}
						if(start==""){errors[errors.length]="You must type in the start time";result=false}
						if(amount==""){errors[errors.length]="You must type in the amount of people in party";result=false}
						
						if (errors.length > 0){reportErrors(errors);}
						else{result=true}
						return result
					}
		function reportErrors(errors)
			{
			var msg = "There were some problems...\n";
 			for (var i = 0; i<errors.length; i++) 
				{
  				var numError = i + 1;
  				msg += "\n" + numError + ". " + errors[i];
 				}
 			alert(msg);
			}
