// JavaScript Document
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function validateFormFrontPage()
{
	if($('#first_name').val()=='')
	{
		alert('Name field can not be empty.');
		$('#first_name').focus();
		return false;
	}	
	if($('#day_phone').val()=='')
	{
		alert('Day Phone field can not be empty.');
		$('#day_phone').focus();
		return false;
	}	
	if($('#date_requested').val()=='')
	{
		alert('Enter the date of appointment.');
		$('#date_requested').focus();
		return false;
	}	
	if($('#appt_preference').val()=='')
	{
		alert('Select your appointment preference.');
		$('#appt_preference').focus();
		return false;
	}	
	if($('#service_requested').val()=='')
	{
		alert('Select the service you would like to request.');
		$('#service_requested').focus();
		return false;
	}	
	return true;
	

}

function validateFormAppointment()
{
	if($('#first_name').val()=='')
	{
		alert('First Name field can not be empty.');
		$('#first_name').focus();
		return false;
	}	
	if($('#last_name').val()=='')
	{
		alert('Last Name field can not be empty.');
		$('#last_name').focus();
		return false;
	}	
	if($('#day_phone').val()=='')
	{
		alert('Day Phone field can not be empty.');
		$('#day_phone').focus();
		return false;
	}	
	if($('#address').val()=='')
	{
		alert('Address field can not be empty.');
		$('#address').focus();
		return false;
	}	

	if($('#city').val()=='')
	{
		alert('City field can not be empty.');
		$('#city').focus();
		return false;
	}	
	if($('#state').val()=='')
	{
		alert('State field can not be empty.');
		$('#state').focus();
		return false;
	}	
	if($('#zip').val()=='')
	{
		alert('Zip field can not be empty.');
		$('#zip').focus();
		return false;
	}	
	if(!echeck($('#email').val()))
	{
		$('#email').focus();
		return false;
	}
/*	if($('#car_year').val()=='')
	{
		alert('Enter your vehicle year information');
		$('#car_year').focus();
		return false;
	}	
	if($('#car_make').val()=='')
	{
		alert('Enter the make of your vehicle');
		$('#car_make').focus();
		return false;
	}	
	if($('#car_model').val()=='')
	{
		alert('Enter the model of your vehicle.');
		$('#car_model').focus();
		return false;
	}
	if($('#engine_size').val()=='')
	{
		alert('Enter the engine size of your vehicle.');
		$('#engine_size').focus();
		return false;
	}			
*/	if($('#date_requested').val()=='')
	{
		alert('Enter the date of appointment.');
		$('#date_requested').focus();
		return false;
	}	
	if($('#appt_preference').val()=='')
	{
		alert('Select your appointment preference.');
		$('#appt_preference').focus();
		return false;
	}	
	if($('#service_requested').val()=='')
	{
		alert('Select the service you would like to request.');
		$('#service_requested').focus();
		return false;
	}	
	if($('#captchastring').val()=='')
	{
		alert('Please enter the sucurity text.');
		$('#captchastring').focus();
		return false;
	}	
	
	return true;
}

function validateFormEmployment()
{
	if($('#first_name').val()=='')
	{
		alert('Name field can not be empty.');
		$('#first_name').focus();
		return false;
	}	
	if($('#day_phone').val()=='')
	{
		alert('Day Phone field can not be empty.');
		$('#day_phone').focus();
		return false;
	}	
	if($('#address').val()=='')
	{
		alert('Address field can not be empty.');
		$('#address').focus();
		return false;
	}	

	if($('#city').val()=='')
	{
		alert('City field can not be empty.');
		$('#city').focus();
		return false;
	}	
	if($('#state').val()=='')
	{
		alert('State field can not be empty.');
		$('#state').focus();
		return false;
	}	
	if($('#zip').val()=='')
	{
		alert('Zip field can not be empty.');
		$('#zip').focus();
		return false;
	}	
	if(isNaN($('#zip').val()))
	{
		alert('Zip field should have a numeric value.');
		$('#zip').focus();
		return false;
	}	

	if(!echeck($('#email').val()))
	{
		$('#email').focus();
		return false;
	}
	if($('#desired_position').val()=='')
	{
		alert('Please let us know what is your desired position');
		$('#desired_position').focus();
		return false;
	}
	
	if($('#certification').val()=='')
	{
		alert('Plese let us know about your certifications');
		$('#certification').focus();
		return false;
	}	
	if($('#desired_income').val()=='')
	{
		alert('Please let us know what is your desired income');
		$('#desired_income').focus();
		return false;
	}	
	if(isNaN($('#desired_income').val()))
	{
		alert('Desired income should have a numeric value.');
		$('#desired_income').focus();
		return false;
	}	
	if($('#captchastring').val()=='')
	{
		alert('Please enter the sucurity text.');
		$('#captchastring').focus();
		return false;
	}	
	
	
	return true;
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function validateSubscriptionForm()
{
	if(document.getElementById('f_name').value=='')
	{
		alert('First Name field can not be empty.');
		document.getElementById('f_name').focus();
		return false;
	}
	if(document.getElementById('l_name').value=='')
	{
		alert('Last Name field can not be empty.');
		document.getElementById('l_name').focus();
		return false;
	}	
	if(!echeck(document.getElementById('email_addr').value))
	{
		document.getElementById('email_addr').focus();
		return false;
	}
	return true;
}

function makeBlank(id,val,check)
	{
		
		var trimmed = val.replace(/^\s+|\s+$/g, '') ;
		if(trimmed==check)
		{
			eval("document.getElementById('"+id+"').value=''");
		}
	}
	function putValue(id,val,check)
	{
		
		var trimmed = val.replace(/^\s+|\s+$/g, '') ;
		
		if(trimmed=='')
		{
			eval("document.getElementById('"+id+"').value='"+check+"'");

		}	
		
	}

function validateFormContact()
{
	if($('#first_name').val()=='')
	{
		alert('Name field can not be empty.');
		$('#first_name').focus();
		return false;
	}	
	if(!echeck($('#email').val()))
	{
		$('#email').focus();
		return false;
	}	
	if($('#captchastring').val()=='')
	{
		alert('Enter the security string please.');
		$('#captchastring').focus();
		return false;
	}	
	return true;
	

}



