﻿/// <reference path="jquery-1.4.2-vsdoc.js" />

function deselectTabs() {
    var items = $("#menu").find("li");
    items.each(function() {
        $(this).removeClass("active");
    });
}

function selectTab(id) {
    var items = $("#newTabs").find("div");
    items.each(function() {
        if ($(this).hasClass("on")) {
            $(this).removeClass("on");
        }

        if ($(this).attr("id") == id) {
            $(this).addClass("on");
        }
    });
}



function selectMenuItem(id) {
    var items = $("#menu").find("li");
    items.each(function() {
        if ($(this).hasClass("active")) {
            $(this).removeClass("active");
        }

        if ($(this).attr("id") == id) {
            $(this).addClass("active");
        }
    });
}

function setClass2Item(cssClass, item) {
    var obj = document.getElementById(item);
    obj.className = cssClass;
}


function toggleWatermark(pTargetID, pWatermarkClass) {

    var el = document.getElementById(pTargetID);

    if (el != null) {

        if (el.value == '') {
            toggleClassName(pTargetID, pWatermarkClass, '');
        }
        else {
            return;
        }

    }

}

function toggleClassName(pElementID, pClassName1, pClassName2) {
    var el = document.getElementById(pElementID)

    if (el != null) {

        if (el.className == pClassName1) {
            el.className = pClassName2;
            return false;
        }

        el.className = pClassName1;

    }

    return false;

}



$(function () {
    deselectTabs(); // promo code check
    /*

    $('#menu ul > li').bind('mouseover', jsddm_open)
    $('#menu ul > li').bind('mouseout', jsddm_timer)

    document.onclick = jsddm_close;

    
    */
    /*
    $.each($(":input"), function (index, value) {

        var item = $("[id=" + value.id + "]");

        if (item.attr('type') == 'text') {

            item.keypress(function (event) {


                if (event.keyCode == '13') {
                    event.preventDefault();
                    event.keyCode = 0;

                    alert("EnterPresss");
                }
            });
        }
    });*/



    $('.dropdown').each(function () {
        $(this).parent().eq(0).hover(function () {
            $('.dropdown:eq(0)', this).slideDown(150);
        }, function () {
            $('.dropdown:eq(0)', this).slideUp(200);
        });
    });

    $("ul.subnav, #menu > ul > li > span").hover(function () {
        $(this).parent().addClass("menuHover");
    }, function () {	//On Hover Out
        $(this).parent().removeClass("menuHover");
    });


    $(".codeBubbleLink").click(function () {
        $(".promoBubble").toggle();
    });

    $(".promoBubble .close").click(function () {
        $(".promoBubble").toggle();
    });

    /*
    $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav

    var isOpen = false;

    $("#menu li span").click(function () { //When trigger is clicked...

    //Following events are applied to the subnav itself (moving subnav up and down)

    if (!isOpen) {
    $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
    isOpen = true;
    }
    else {
    $(this).parent().find("ul.subnav").slideUp('slow'); //Drop down the subnav on click
    isOpen = false;
    }

    $(this).parent().hover(function () {
    }, function () {
    $(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
    isOpen = false;
    });

    //Following events are applied to the trigger (Hover events for the trigger)
    }).hover(function () {
    $(this).addClass("subhover");
    $(this).parent().addClass("menuHover");
    }, function () {	//On Hover Out
    $(this).removeClass("subhover"); //On hover out, remove class "subhover"
    $(this).parent().removeClass("menuHover");
    });

    $("ul.subnav").hover(function () {
    $(this).parent().addClass("menuHover");
    }, function () {	//On Hover Out
    $(this).parent().removeClass("menuHover");
    });
    */
});


