﻿$(document).ready(function () {
    t = setTimeout("changeSplash(1, 2)", 7000);
    $('#homeSplash2').hide();
	rotatorURL(1);
});

function rotatorURL(n)
{
	$('#homeSplashSwoosh').unbind('click');
	switch(n)
	{
		case 1:
			$('#homeSplashSwoosh').bind('click', function() {
				//alert("click 1");
			window.location = getSiteURL() + "services/automotive.aspx";
			});
			break;
		case 2:
			$('#homeSplashSwoosh').bind('click', function() {
				//alert("click 2");
			window.location = getSiteURL() + "services/rv.aspx";
			});
			break;
		case 3:
			$('#homeSplashSwoosh').bind('click', function() {
				//alert("click 3");
				window.location = getSiteURL() + "become-a-rep/start-your-career.aspx";
			});
			break;
		case 4:
			$('#homeSplashSwoosh').bind('click', function() {
				//alert("click 4");
			window.location = getSiteURL() + "services/automotive.aspx";
			});
			break;
	}
}

function changeSplash(divout, divnext) {
	rotatorURL(divnext);
	
	if (divnext < 4) {
        divnext = divnext + 1;
	}
    else {
        divnext = 1;
    }

    if (divout == 1) divin = 2;
    if (divout == 2) divin = 1;

    $("#homeSplash" + divout).fadeOut("fast", function () {
        $('#homeSplash' + divin).fadeIn("slow");
        $('#homeSplash' + divout).css('background-image', 'url(Libraries/Splash/splash-home-0' + divnext + '.sflb.ashx)');
    });
    clearTimeout(t);
    t = setTimeout("changeSplash(" + divin + ", " + divnext + ")", 7000);
}

