﻿var t;
var currentStep = 1;
var ie6 = (jQuery.browser.msie && jQuery.browser.version == "6.0") ? 1 : 0;

$(document).ready(function () {
    step1Show();
});

function step1Show() {
    currentStep = 1;
    clearTimeout(t);

    if (ie6) {
        $("#hpStepsWrapper").removeClass('step2');
        $("#hpStepsWrapper").removeClass('step3');
        $("#hpStepsWrapper").removeClass('step4');
        $("#hpStepsWrapper").addClass('step1');
    } else {
        $(".step2").css("display", "none");
        $(".step3").css("display", "none");
        $(".step4").css("display", "none");
        $(".step1").fadeIn(1000);
    }
    t = setTimeout(step1Hide, 4000);
}
function step1Hide() {
    clearTimeout(t);
    if (!ie6) { $(".step1").fadeOut(500); }
    t = setTimeout(step2Show, 500);
}
function step2Show() {
    currentStep = 2;
    clearTimeout(t);

    if (ie6) {
        $("#hpStepsWrapper").removeClass('step1');
        $("#hpStepsWrapper").removeClass('step3');
        $("#hpStepsWrapper").removeClass('step4');
        $("#hpStepsWrapper").addClass('step2');
    } else {
        $(".step1").css("display", "none");
        $(".step3").css("display", "none");
        $(".step4").css("display", "none");
        $(".step2").fadeIn(1000);
    }
    t = setTimeout(step2Hide, 5000);
}
function step2Hide() {
    clearTimeout(t);
    if (!ie6) { $(".step2").fadeOut(500); }
    t = setTimeout(step3Show, 500);
}
function step3Show() {
    currentStep = 3;
    clearTimeout(t);

    if (ie6) {
        $("#hpStepsWrapper").removeClass('step1');
        $("#hpStepsWrapper").removeClass('step2');
        $("#hpStepsWrapper").removeClass('step4');
        $("#hpStepsWrapper").addClass('step3');
    } else {
        $(".step1").css("display", "none");
        $(".step2").css("display", "none");
        $(".step4").css("display", "none");
        $(".step3").fadeIn(1000);
    }
    t = setTimeout(step3Hide, 5000);
}
function step3Hide() {
    clearTimeout(t);
    if (!ie6) { $(".step3").fadeOut(500); }
    t = setTimeout(step4Show, 500);
}

function step4Show() {
    currentStep = 4;
    clearTimeout(t);

    if (ie6) {
        $("#hpStepsWrapper").removeClass('step1');
        $("#hpStepsWrapper").removeClass('step2');
        $("#hpStepsWrapper").removeClass('step3');
        $("#hpStepsWrapper").addClass('step4');
    } else {
        $(".step1").css("display", "none");
        $(".step2").css("display", "none");
        $(".step3").css("display", "none");
        $(".step4").fadeIn(1000);
    }
    //t = setTimeout(step4Hide, 5000);
    pause();
}
function step4Hide() {
    //clearTimeout(t);
    //$(".step4").fadeOut(500);
    //t = setTimeout(step1Show, 500);
}

function pause() {
    clearTimeout(t);
}
