// global namespaces
var otsuka = otsuka || {};
otsuka.corporate = otsuka.corporate || {};

// init method
otsuka.corporate.initFlash = function () {
    if (typeof (swfobject) !== 'undefined') {
        swfobject.embedSWF("/Style%20Library/Flash/tomato_animation_7_13.swf", "flash_intro", "292", "211", "9.0.0", false, { menu: "false" });
    }
}

otsuka.corporate.navigation = function () {

    // Since 2nd/3rd level links collapse to the least possible width with the inline-block style,
    // loop through and find the largest width and apply it to all the items so the hit areas and
    // backgrounds all fill up 100% of the width

    $('.AspNet-Menu > li').each(function () {
        var largestWidth = 0;
        $(this).children('ul').css({ display: 'block' });
        $(this).children('ul').children('li').each(function () {
            if ($(this).children('a').innerWidth() > largestWidth) {
                largestWidth = $(this).children('a').innerWidth();
            }
        });
        $(this).children('ul').css({ display: 'none' }); // possibly do visibility instead of display none to prevent having to hide/show for widths
        $(this).children('ul').children('li').each(function () {
            $(this).children('a').css({ width: largestWidth });
        });
    });

    // Hover function to display a child <ul> of an <li>
    $('.AspNet-Menu li:has(ul)').hover(function () {
        $(this).children('ul').css({ display: 'block' });
    }, function () {
        $(this).children('ul').css({ display: 'none' });
    });

}

otsuka.corporate.defaultInputText = function () {
    $(".defaultText").focus(function (srcc) {
        if ($(this).val() == $(this)[0].title) {
            $(this).removeClass("defaultTextActive");
            $(this).val("");
        }
    });

    $(".defaultText").blur(function () {
        if ($(this).val() == "") {
            $(this).addClass("defaultTextActive");
            $(this).val($(this)[0].title);
        }
    });

    $(".defaultText").blur();
}


$(function () {

    otsuka.corporate.navigation();
    otsuka.corporate.initFlash();
    otsuka.corporate.defaultInputText();
});
