/* TOP CARRIERS SLIDE SHOW */
//set image paths
src = ["images/randomimages/logo-auto-owners-insurance.gif", "images/randomimages/logo-aetna.gif", "images/randomimages/logo-bcbs.gif", "images/randomimages/logo-accident-fund.gif", "images/randomimages/logo-farmers-insurance.gif", "images/randomimages/logo-citizens-insurance.gif", "images/randomimages/logo-chubb.gif", "images/randomimages/logo-firemans-fund.gif", "images/randomimages/logo-gmac-insurance.gif", "images/randomimages/logo-golden-rule.gif", "images/randomimages/logo-grange-insurance.gif", "images/randomimages/logo-hagerty.gif", "images/randomimages/logo-inmar-marine-insurance.gif", "images/randomimages/logo-allied-insurance.gif", "images/randomimages/logo-humana.gif", "images/randomimages/logo-metlife.gif", "images/randomimages/logo-michigan-millers.gif", "images/randomimages/logo-state-auto.gif", "images/randomimages/logo-aig.gif", "images/randomimages/logo-progressive.gif", "images/randomimages/logo-ski-safe.gif", "images/randomimages/logo-cna.gif"]

//set corresponding urls - THIS IS NOT BEING USED RIGHT NOW
url = ["http://www.zerohoursparts.com", "http://zerohoursparts.com", "http://zerohoursparts.com", "http://www.zerohoursparts.com"]

//set duration for each image
duration = 4;

//Please do not edit below
ads=[]; ct=0;
function switchAd() {
var n=(ct+1)%src.length;
if (ads[n] && (ads[n].complete || ads[n].complete==null)) {
document["Ad_Image"].src = ads[ct=n].src;
}
ads[n=(ct+1)%src.length] = new Image;
ads[n].src = src[n];
setTimeout("switchAd()",duration*1000);
}
function doLink(){
location.href = url[ct];
} onload = function(){
if (document.images)
switchAd();
}

/*TO SET THE CURRENT YEAR FOR THE COPYRIGHT*/
var curdate = new Date()
var year = curdate.getYear()

/*THIS IS THE VALIDATION FOR THE NEWSLETTER FORM*/
function ValidateFormNewsletter(form)
{
	if(!check_email(document.form1.email.value))
	{
	    alert("Please make sure your Email Address is Correct");
		document.form1.email.focus();
		return false;
	}

	return true;
} 

/*THIS IS THE VALIDATION FOR THE LEAD FORM*/
function ValidateContact(form)
{
	if (document.contact.realname.value=="")
	{
	alert("Please enter your Name.");
	document.contact.realname.focus();
	return false;
	}

	if (document.contact.Company.value=="")
	{
	alert("Please enter your Company Name.");
	document.contact.Company.focus();
	return false;
	}
	
	if(!check_email(document.contact.email.value))
	{
	    alert("Please make sure your Email Address is Correct");
		document.contact.email.focus();
		return false;
	}

	if (document.contact.Comments.value=="")
	{
	alert("Please let us know why you would like for us to contact you.");
	document.contact.Comments.focus();
	return false;
	}
	//alert("Worked"); 
	//return false;
	return true;
}
/*THIS IS THE VALIDATION FOR THE HOME INSURNACE QUOTE FORM*/
function ValidateHome(form)
{
	if (document.home.realname.value=="")
	{
	alert("Please enter your Name.");
	document.home.realname.focus();
	return false;
	}
	
	if(!check_email(document.home.email.value))
	{
	    alert("Please make sure your Email Address is Correct");
		document.home.email.focus();
		return false;
	}
	
	if (document.home.Address1.value=="")
	{
	    alert("Please enter your Address");
		document.home.Address1.focus();
		return false;
	}
	
	if (document.home.City.value=="")
	{
	    alert("Please enter your city");
		document.home.City.focus();
		return false;
	}
	
	if (document.home.State.value=="")
	{
	    alert("Please enter your state");
		document.home.State.focus();
		return false;
	}
	
	if (document.home.Zip.value=="")
	{
	    alert("Please enter your zip");
		document.home.Zip.focus();
		return false;
	}
	
	if (document.home.Phone.value=="")
	{
	    alert("Please enter your phone number");
		document.home.Phone.focus();
		return false;
	}
	
	if (document.home.PresentInsurer.value=="")
	{
	    alert("Please enter your Present Insurer");
		document.home.PresentInsurer.focus();
		return false;
	}
	
	if (document.home.AnnualPremium.value=="")
	{
	    alert("Please enter your Annual Premium");
		document.home.AnnualPremium.focus();
		return false;
	}
	
	if (document.home.Deductible.value=="")
	{
	    alert("Please enter your deductible");
		document.home.Deductible.focus();
		return false;
	}
	
	if (document.home.ClaimsInPastYears.selectedIndex == "" )
    {
        alert ( "Please enter if you have had any claims in the past 3 years" );
		document.home.ClaimsInPastYears.focus();
        return false;
    }
	
	if (document.home.YearBuilt.value=="")
	{
	    alert("Please enter the year your house was built");
		document.home.YearBuilt.focus();
		return false;
	}
	
	if (document.home.ConstructionType.selectedIndex == "" )
    {
        alert ( "Please enter the construction type of your home" );
		document.home.ConstructionType.focus();
        return false;
    }
	
	if (document.home.NumberOfStories.value=="")
	{
	    alert("Please enter how many stories your house has");
		document.home.NumberOfStories.focus();
		return false;
	}
	
	if (document.home.HomeSpecifications.selectedIndex == "" )
    {
        alert ( "Please tell us your home specifications" );
		document.home.HomeSpecifications.focus();
        return false;
    }
	 
	
	if (document.home.Pets.selectedIndex == "" )
    {
        alert ( "Please tell us if you have pets" );
		document.home.Pets.focus();
        return false;
    }
	
	if (document.home.Tramploine.selectedIndex == "" )
    {
        alert ( "Please tell us if you have a Tramploine" );
		document.home.Tramploine.focus();
        return false;
    }
	
	if (document.home.FullBaths.selectedIndex == "" )
    {
        alert ( "Please tell us how many full bathrooms you have" );
		document.home.FullBaths.focus();
        return false;
    }
	
	/*if (document.home.HalfBaths.selectedIndex == "" )
    {
        alert ( "Please tell us how many half bathrooms you have" );
		document.home.HalfBaths.focus();
        return false;
    }*/
	
	if (document.home.Garage.selectedIndex == "" )
    {
        alert ( "Please tell us about the garage" );
		document.home.Garage.focus();
        return false;
    }
	
	if (document.home.AlarmSystem.selectedIndex == "" )
    {
        alert ( "Please tell us if you have an alarm system" );
		document.home.AlarmSystem.focus();
        return false;
    }
	
	if (document.home.FireExtinguisher.selectedIndex == "" )
    {
        alert ( "Please tell us if you have a fire extinguisher" );
		document.home.FireExtinguisher.focus();
        return false;
    }
	
	if (document.home.DeadboltLocks.selectedIndex == "" )
    {
        alert ( "Please tell us if you have deadbolts" );
		document.home.DeadboltLocks.focus();
        return false;
    }
	
	if (document.home.NonSmoker.selectedIndex == "" )
    {
        alert ( "Please tell us if you are a non-smoker" );
		document.home.NonSmoker.focus();
        return false;
    }
	 
	return true;
	//alert("worked");	   
	//return false;
} 

/*THIS IS THE VALIDATION FOR THE HOME INSURNACE QUOTE FORM*/
function ValidateAuto(form)
{
	if (document.auto.realname.value=="")
	{
	alert("Please enter your Name.");
	document.auto.realname.focus();
	return false;
	}
	
	if(!check_email(document.auto.email.value))
	{
	    alert("Please make sure your Email Address is Correct");
		document.auto.email.focus();
		return false;
	}
	
	if (document.auto.Address1.value=="")
	{
	    alert("Please enter your Address");
		document.auto.Address1.focus();
		return false;
	}
	
	if (document.auto.City.value=="")
	{
	    alert("Please enter your city");
		document.auto.City.focus();
		return false;
	}
	
	if (document.auto.State.value=="")
	{
	    alert("Please enter your state");
		document.auto.State.focus();
		return false;
	}
	
	if (document.auto.Zip.value=="")
	{
	    alert("Please enter your zip");
		document.auto.Zip.focus();
		return false;
	}
	
	if (document.auto.Phone.value=="")
	{
	    alert("Please enter your phone number");
		document.auto.Phone.focus();
		return false;
	}
	
	if (document.auto.VehicleYear1.value=="")
	{
	    alert("Please enter the year of your vehicle");
		document.auto.VehicleYear1.focus();
		return false;
	}
	
	if (document.auto.VehicleMake1.value=="")
	{
	    alert("Please enter the make of your vehicle");
		document.auto.VehicleMake1.focus();
		return false;
	}
	
	if (document.auto.VehicleModel1.value=="")
	{
	    alert("Please enter the model of your vehicle");
		document.auto.VehicleModel1.focus();
		return false;
	}
	
	if (document.auto.VehicleDriver1.value=="")
	{
	    alert("Please enter the driver of your vehicle");
		document.auto.VehicleDriver1.focus();
		return false;
	}
	
	if (document.auto.MilesToWork1.value=="")
	{
	    alert("Please enter how many miles it is one way to work");
		document.auto.MilesToWork1.focus();
		return false;
	}
	 
	return true;
	//alert("worked");	   
	//return false;
} 




function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0) return (false);	
	}
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) return (-1);
	}
}



