﻿
//IS IN LuceneSearchBox sublayout
//function doClear(inputField) {
//    if (inputField.value == inputField.defaultValue) {
//        inputField.value = "";
//        inputField.style.color = "black";
//    }
//}

Cufon.replace('.en h1, .en h2, .en h3', { fontFamily: 'GothamBook' });
Cufon.replace('.en .GothamBook', { fontFamily: 'GothamBook' });
Cufon.replace('.en .GothamLight', { fontFamily: 'GothamLight' });
Cufon.replace('.en .GothamMedium', { fontFamily: 'GothamMedium' });

Cufon.replace('.en .home-intro h1, .en .home-intro h2, .en .home-intro h3', { fontFamily: 'GothamBook', textShadow: '1px 1px 3px #000000' });


$(document).ready(function () {

    //On Hover Over
    function megaHoverOver() {
        $(this).find(".sub").stop().fadeTo('fast', 1).show();
        (function ($) {

            jQuery.fn.calcSubWidth = function () {
                rowWidth = 0;

                //console.log($(this).val() + 'find(.navrow2 li).size()=' + $(this).find(".navrow2 li").size());

                if ($(this).find(".navrow2 li").size() > 0) {
                    rowWidth = 470;
                }
                else if ($(this).find("img").size() > 0) {
                    rowWidth = 400;
                }
                else {
                    rowWidth = 230;
                }


            };
        })(jQuery);

        $(this).calcSubWidth();

        var o = $(this).find('.sub').offset();
        if (o) {
            var p = $("#main-nav").offset();
            var pw = document.getElementById("main-nav").clientWidth;
            var tw = rowWidth;
            o.left = o.left - p.left;
            var tml = (tw + o.left) - pw;


            $(this).find(".sub").css({ 'width': rowWidth }).css({ 'margin-left': '-' + tml + 'px' });
        }


    }

    function megaHoverOut() {

        $(this).find(".sub").stop().fadeTo('fast', 0, function () {
            $(this).hide().css({ 'margin-left': '0' });
        });
    }

    var config = {
        sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
        interval: 100, // number = milliseconds for onMouseOver polling interval
        over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
        timeout: 500, // number = milliseconds delay before onMouseOut
        out: megaHoverOut // function = onMouseOut callback (REQUIRED)
    };

    $("ul#main-nav-list li .sub").css({ 'opacity': '0' }); //Fade sub nav to 0 opacity on default
    $("ul#main-nav-list li").hoverIntent(config); //Trigger Hover intent with custom configurations

    function subHoverOver() {
        $(this).find(".sub2").stop().fadeTo('fast', 1).show();
    }

    function subHoverOut() {
        $(this).find(".sub2").stop().fadeTo('fast', 0).hide();

    }
    var config = {
        sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
        interval: 100, // number = milliseconds for onMouseOver polling interval
        over: subHoverOver, // function = onMouseOver callback (REQUIRED)
        timeout: 500, // number = milliseconds delay before onMouseOut
        out: subHoverOut // function = onMouseOut callback (REQUIRED)
    };
    $("ul#main-nav-list li .sub-col ul > li").hoverIntent(config); //Trigger Hover intent with custom configurations



    //all hover and click logic for ui-state buttons
    $("a.ui-state").hover(function () {

        $(this).addClass("ui-state-hover");

    }, function () {

        $(this).removeClass("ui-state-hover");

    }).mousedown(function () {

        var marginL = parseInt($(this).css("margin-left").replace("px", ""));
        $(this).css("margin-left", (marginL + 1) + "px");

        var marginT = parseInt($(this).css("margin-top").replace("px", ""));
        $(this).css("margin-top", (marginT + 1) + "px");

        $(this).addClass("ui-state-active");

    }).mouseup(function () {

        var marginL = parseInt($(this).css("margin-left").replace("px", ""));
        $(this).css("margin-left", (marginL - 1) + "px");

        var marginT = parseInt($(this).css("margin-top").replace("px", ""));
        $(this).css("margin-top", (marginT - 1) + "px");

        $(this).removeClass("ui-state-active");
    });


    //Content styling
    $('#Content ol li').wrapInner('<span></span>');

    //Image loaded check for accessibility
    $('.top-logo').load(function () {
        $("html").removeClass('noimages');
    });


    //Footer
    var v = $('#bottom-content > div').size();

    if (v == 4) {
        $('#bottom-content').css('width', '990px');

    }
    else if (v == '3') {
        $('#bottom-content').css('width', '740px');
        $('#bottom-content div:last-child').css('margin-right', '0');
    }
    else if (v == '2') {
        $('#bottom-content').css('width', '490px');
        $('#bottom-content div:last-child').css('margin-right', '0');
    }
    else if (v == '1') {
        $('#bottom-content').css('width', '240px');
        $('#bottom-content div:last-child').css('margin-right', '0');
    }
    else if (v == '0') {
        $('#bottom-container').css('padding', '0');
        $('#bottom-container').css('background-color', 'none');
        $('#bottom-container').css('border', '0');
    }


});



