/// <reference path="jquery-1.4.1-vsdoc.js" />

var current = 0;
switch (document.location.pathname) {
    case "/Products/Color/shellac-hello.aspx":
        current = 0;
        break;
    case "/Products/Color/shellac-hybrid.aspx":
        current = 0;
        break;
    case "/Products/Color/shellac-hybrid-con.aspx":
        current = 0;
        break;
    case "/Products/Color/shellac-hybrid-pro.aspx":
        current = 0;
        break;
    case "/Products/Color/shellac-meet-products.aspx":
        current = 1;
        break;
    case "/Products/Color/shellac-colors.aspx":
        current = 1;
        break;
    case "/Products/Color/shellac-base-top-coat.aspx":
        current = 1;
        break;
    case "/Products/Color/shellac-uv-lamp.aspx":
        current = 1;
        break;
    case "/Products/Color/shellac-remover-wraps.aspx":
        current = 1;
        break;
    case "/Products/Color/shellac-science.aspx":
        current = 2;
        break;
    case "/Products/Color/shellac-scorecard.aspx":
        current = 3;
        break;
    case "/Products/Color/shellac-hype.aspx":
        current = 4;
        break;
    case "/Products/Color/shellac-before-after.aspx":
        current = 5;
        break;
    case "/Products/Color/shellac-video.aspx":
        current = 6;
        break;
    default:
        current = 0;
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") !== -1) {
        return window[movieName];
    }
    else {
        return document[movieName];
    }
}

function SubmitSurvey(b1, b2, b3, b4, b5) {
    $.getJSON("/Products/Color/Vote.aspx?v1=" + b1 + "&v2=" + b2 + "&v3=" + b3 + "&v4=" + b4 + "&v5=" + b5, function(data) {
        thisMovie("shellac").displaySurveyResults(data.v1, data.v2, data.v3, data.v4, data.v5);
    });

}
var ii = 0;
function GoTo(index) {
    if (index !== current) {
        if (index === 0) {
           window.location = "/Products/Color/shellac-hello.aspx";
        } else if (index === 1) {
            window.location = "/Products/Color/shellac-meet-products.aspx";
        } else if (index === 2) {
            window.location = "/Products/Color/shellac-science.aspx";
        } else if (index === 3) {
            window.location = "/Products/Color/shellac-scorecard.aspx";
        } else if (index === 4) {
            window.location = "/Products/Color/shellac-hype.aspx";
        } else if (index === 5) {
            window.location = "/Products/Color/shellac-before-after.aspx";
        } else if (index === 6) {
            window.location = "/Products/Color/shellac-video.aspx";
        }
    } else if (index === 1 && document.location.pathname !== "/Products/Color/shellac-meet-products.aspx" && ii > 0) {
		window.location = "/Products/Color/shellac-meet-products.aspx";
	}
   	ii += 1;
}
function NavigateTo(index) {
        if (index === 0) {
           window.location = "/Products/Product.aspx/1227";
        } else if (index === 1) {
           window.location = "/Products/Color/shellac-colors.aspx";
        } else if (index === 2) {
            window.location = "/Products/Color/shellac-base-top-coat.aspx";
        } else if (index === 3) {
            window.location = "/Products/Color/shellac-uv-lamp.aspx";
        } else if (index === 4) {
            window.location = "/Products/Color/shellac-remover-wraps.aspx";
        }
}


var slideshow = {

    rotationSpeed: 5000,
    transitionSpeed: 1000,
    currentslide: 1,

    getIndicatorLocation: function (index) {
        if (index === 0) {
            return 16;
        } else if (index === 1) {
            return 66;
        } else if (index === 2) {
            return 117;
        } else if (index === 3) {
            return 167;
        } else if (index === 4) {
            return 219;
        } else if (index === 5) {
            return 269;
        }
    },

    rotateSlides: function (newslide) {
        $("#before-after img").fadeOut(slideshow.transitionSpeed);
        $("#before-after img#img" + newslide).fadeIn(slideshow.transitionSpeed);
        $("#indicator").animate({ top: slideshow.getIndicatorLocation(newslide) + "px" }, 500);
        $("#current").html("0" + (newslide + 1));
        slideshow.currentslide = 0;
        if (newslide < slidecount - 1) {
            slideshow.currentslide = newslide + 1;
        }
        rt = setTimeout("slideshow.rotateSlides(" + slideshow.currentslide + ")", slideshow.rotationSpeed);
    },

    initializeNav: function () {
        $("#before-after-thumbs p:not(#before-after-thumbs div p)").click(function () {
            clearTimeout(rt);
            var id = this.id.replace("nav", "");
            if (parseInt(slideshow.currentslide - 1) !== parseInt(id)) {
                slideshow.rotateSlides(parseInt(id));
            }
        });
        $("#prev").click(function () {
            if (parseInt(slideshow.currentslide) !== 1) {
                clearTimeout(rt);
                if (slideshow.currentslide === 0) {
                    slideshow.rotateSlides(4);
                } else {
                    slideshow.rotateSlides(slideshow.currentslide - 2);
                }
            }
        });
        $("#next").click(function () {
            if (parseInt(slideshow.currentslide) > 0) {
                clearTimeout(rt);
                slideshow.rotateSlides(slideshow.currentslide);
            }
        });
    },

    initialize: function () {
        var i = 0;
        $("#before-after img").each(function () {
            $(this).attr("id", "img" + i).css("position", "absolute").css("top", "0px");
            if (i > 0) {
                $(this).css("display", "none");
            }
            i++;
        });
        slidecount = i;
        slideshow.initializeNav();
        rt = setTimeout("slideshow.rotateSlides(1)", slideshow.rotationSpeed);
    }

}

if ($("#before-after").length) {
    slideshow.initialize();
}
function selectNav() {
	if (thisMovie("nav").setSelected) {
		thisMovie("nav").setSelected(current);
	} else {
		setTimeout('selectNav()', 250);
	}
}

$(window).load(function() {
	selectNav();
});
