﻿// Hover Buttons
function hoverButton(buttonTable)
{
    buttonTable.rows[0].cells[0].className = 'HoverButton_Left';
    buttonTable.rows[0].cells[1].className = 'HoverButton_Middle';
    buttonTable.rows[0].cells[2].className = 'HoverButton_Right';
}
function unHoverButton(buttonTable)
{
    buttonTable.rows[0].cells[0].className = 'NormalButton_Left';
    buttonTable.rows[0].cells[1].className = 'NormalButton_Middle';
    buttonTable.rows[0].cells[2].className = 'NormalButton_Right';
}
// Hover Buy Buttons
function hoverBuyButton(buttonTable, hoverBox) {
    buttonTable.rows[0].cells[0].className = 'BuyButtonHover_Left';
    buttonTable.rows[0].cells[1].className = 'BuyButtonHover_Middle';
    buttonTable.rows[0].cells[2].className = 'BuyButtonHover_Right';
    hoverBox.style.display = '';
}
function unHoverBuyButton(buttonTable, hoverBox) {
    buttonTable.rows[0].cells[0].className = 'BuyButton_Left';
    buttonTable.rows[0].cells[1].className = 'BuyButton_Middle';
    buttonTable.rows[0].cells[2].className = 'BuyButton_Right';
    hoverBox.style.display = 'none';
}

// Nav Menu
function hoverNavMenuItem(NavMenuItemTable)
{
    NavMenuItemTable.rows[0].cells[0].className = 'SelectedMenuItem_Left';
    NavMenuItemTable.rows[0].cells[1].className = 'SelectedMenuItem_Middle';
    NavMenuItemTable.rows[0].cells[1].childNodes[0].childNodes[0].className = 'SelectedMenuItem_Text';
    NavMenuItemTable.rows[0].cells[2].className = 'SelectedMenuItem_Right';
}
function unHoverNavMenuItem(NavMenuItemTable)
{
    NavMenuItemTable.rows[0].cells[0].className = 'UnselectedMenuItem_Left';
    NavMenuItemTable.rows[0].cells[1].className = 'UnselectedMenuItem_Middle';
    NavMenuItemTable.rows[0].cells[1].childNodes[0].childNodes[0].className = 'UnselectedMenuItem_Text';
    NavMenuItemTable.rows[0].cells[2].className = 'UnselectedMenuItem_Right';
}
// Homepage
function nextProduct() {
    unHoverProducts();

    if (currentProduct == 0 || currentProduct == 5) {
        hoverProduct1(false);
        currentProduct = 1;
    } else if (currentProduct == 1) {
        hoverProduct2(false);
        currentProduct++;
    } else if (currentProduct == 2) {
        hoverProduct6(false);
        currentProduct++;
    } else if (currentProduct == 3) {
        hoverProduct4(false);
        currentProduct++;
    } else if (currentProduct == 4) {
        hoverProduct5(false);
        currentProduct++;
    }

    productTimer = setTimeout("nextProduct()", 3000);
}
function unHoverProducts() {
    document.getElementById('Product1a').style.backgroundColor = '';
    document.getElementById('Product2a').style.backgroundColor = '';
    document.getElementById('Product4a').style.backgroundColor = '';
    document.getElementById('Product5a').style.backgroundColor = '';
    document.getElementById('Product6a').style.backgroundColor = '';
    
    document.getElementById('Product1b').style.backgroundColor = '';
    document.getElementById('Product2b').style.backgroundColor = '';
    document.getElementById('Product4b').style.backgroundColor = '';
    document.getElementById('Product5b').style.backgroundColor = '';
    document.getElementById('Product6b').style.backgroundColor = '';
    
    document.getElementById('Product1c').style.display = 'none';
    document.getElementById('Product2c').style.display = 'none';
    document.getElementById('Product4c').style.display = 'none';
    document.getElementById('Product5c').style.display = 'none';
    document.getElementById('Product6c').style.display = 'none';
    
    document.getElementById('NoProduct').style.display = '';
}
function hoverProduct1(cancelTimer) {
    document.getElementById('Product1a').style.backgroundColor = '#ECF3FF';
    document.getElementById('Product1b').style.backgroundColor = '#ECF3FF';
    document.getElementById('Product1c').style.display = '';
    document.getElementById('NoProduct').style.display = 'none';
}
function hoverProduct2(cancelTimer) {
    document.getElementById('Product2a').style.backgroundColor = '#ECF3FF';
    document.getElementById('Product2b').style.backgroundColor = '#ECF3FF';
    document.getElementById('Product2c').style.display = '';
    document.getElementById('NoProduct').style.display = 'none';
}
function hoverProduct4(cancelTimer) {
    document.getElementById('Product4a').style.backgroundColor = '#ECF3FF';
    document.getElementById('Product4b').style.backgroundColor = '#ECF3FF';
    document.getElementById('Product4c').style.display = '';
    document.getElementById('NoProduct').style.display = 'none';
}
function hoverProduct5(cancelTimer) {
    document.getElementById('Product5a').style.backgroundColor = '#ECF3FF';
    document.getElementById('Product5b').style.backgroundColor = '#ECF3FF';
    document.getElementById('Product5c').style.display = '';
    document.getElementById('NoProduct').style.display = 'none';
}
function hoverProduct6(cancelTimer) {
    document.getElementById('Product6a').style.backgroundColor = '#ECF3FF';
    document.getElementById('Product6b').style.backgroundColor = '#ECF3FF';
    document.getElementById('Product6c').style.display = '';
    document.getElementById('NoProduct').style.display = 'none';
}
function changeLanguage(newLang) {
    var currentLang = document.getElementsByName("Language")[0].content;

    pageTracker._trackEvent('Language', 'Changed', currentLang + ' to ' + newLang);

    document.getElementById("LanguageHeaderDiv").style.display = "";
    
    Microsoft.Translator.translate(document.getElementById("MainTbl"), currentLang, newLang);
    SetCookie("currentLang", newLang);
    document.getElementsByName("Language")[0].content = newLang;
    //document.getElementById("LanguageDropDown").value = newLang;
}
function SetCookie(cookieName, cookieValue) {
    var today = new Date();
    var expire = new Date();
    expire.setTime(today.getTime() + 3600000 * 24 * 7);
    document.cookie = cookieName + "=" + escape(cookieValue)
                 + ";expires=" + expire.toGMTString();
}
function GetCurrentLangFromCookie() {
    try
    {
        var cookieName = "currentLang";
        var theCookie = "" + document.cookie;
        var ind = theCookie.indexOf(cookieName);
        if (ind == -1 || cookieName == "") return "en";
        var ind1 = theCookie.indexOf(';', ind);
        if (ind1 == -1) ind1 = theCookie.length;
        return unescape(theCookie.substring(ind + cookieName.length + 1, ind1));
    }
    catch (ex) { return "en"; }
}
function initLanguage() {
    var currentLang = GetCurrentLangFromCookie();
    var queryStringLang = GetQueryStr("lang");
    if (queryStringLang != "") {
        currentLang = queryStringLang;
    }
    if (currentLang != "en") {
        changeLanguage(currentLang);
        document.getElementById("LanguageDropDown").value = currentLang;
    }
}
function GetQueryStr(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
    return "";
}
function linkClick(navUrl, trackUrl) {
    if (trackUrl != "") {
        pageTracker._trackPageview(trackUrl);
    }       
    location.href = navUrl;
}

function revealModal(divID) {
    window.onscroll = function() { document.getElementById(divID).style.top = document.body.scrollTop; };
    document.getElementById(divID).style.display = "block";
    document.getElementById(divID).style.top = document.body.scrollTop;
}

function hideModal(divID) {
    document.getElementById(divID).style.display = "none";
}
