﻿$(document).ready(function() {
    $("#contactUsDirectlyBox .input:nth(0)").example(TRANSLATE_YOUR_NAME);
    $("#contactUsDirectlyBox .input:nth(1)").example(TRANSLATE_YOUR_EMAIL);
    $("#contactUsDirectlyBox .input:nth(2)").example(TRANSLATE_YOUR_COUNTRY);

    $("#startMedia IMG:first").show();
    if ($("#startMedia IMG").length > 1) {
        runStartAnimation($("#startMedia IMG:first"), 5000, 1000);
    }

    $("#productImageContainer UL LI IMG").click(function() {
        $("#productImageContainer UL LI").removeClass("selected");
        $(this).closest("li").addClass("selected");

        $("#productImageContainer img:first").attr("src", $(this).attr("src"));
    });

    $("#tellAFriendToggle").click(function() {
        $("#tellAFriend").toggle();
        return false;
    });

    $("#clientLogin, #distributorLogin").click(function() {
        $("#loginWindow").toggle();
        return false;
    });

    $(".modalClose").click(function() {
        $(this).parent().hide();
    });
});

function runStartAnimation(jElement, delay, fadeTime) {
    $(jElement).delay(delay, function() {
        $(jElement).fadeOut(fadeTime, function() {
            if ($(this).next().length > 0) {
                $(this).next().fadeIn(fadeTime, function() {
                    runStartAnimation($(this), delay, fadeTime);
                });
            } else {
                $(this).prev(":first").fadeIn(fadeTime, function() {
                    runStartAnimation($(this), delay, fadeTime);
                });
            }
        });
    });
}

function addToFavorites(url, title) { 
    if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); 
    }
}

function checkTerms() {
    if ($("#IAgreeCheckBox").attr("checked") != true) {
        alert(TRANSLATE_YOU_NEED_TO_AGREE_TO_TERMS);
        return false;
    }
}