// JavaScript Document
jQuery(document).ready(function() {
    SearchText();
    EnableMainMenu();
    EnableSubMenu();
});

function SearchText() {
    var searchBox = jQuery(".searchHolder input[type=text]");
    if (searchBox.attr("value") == "") {
        searchBox.attr("value", jQuery(".searchHolder label").html());
    }
    searchBox.bind('focus', function() {
        if (jQuery(this).attr("value") == jQuery(".searchHolder label").html()) {
            jQuery(this).attr("value", "");
        }
    })
	.bind('blur', function() {
	    if (jQuery(this).attr("value") == "") {
	        jQuery(this).attr("value", jQuery(".searchHolder label").html());
	    }
	});
}

function EnableMainMenu() {
    $("ul.sf-menu").supersubs({
        minWidth: 12,   // minimum width of sub-menus in em units 
        maxWidth: 27,   // maximum width of sub-menus in em units 
        extraWidth: 1     // extra width can ensure lines don't sometimes turn over 
        // due to slight rounding differences and font-family
    }).superfish({
        delay: 1000,// one second delay on mouseout 
        animation: { height: 'show' }// fade-in and slide-down animation 
    }); 
}

Cufon.replace('.sf-menu li a.replaceFont', {
    hover: true
});

function EnableSubMenu() {
    jQuery(".subMenu li.parent a").not("a.sub").bind('click', function(event) {
        var ul = jQuery(this.parentNode).children("ul");
        if (ul.hasClass("expanded") && ul.children("li").children("a.selected").length == 0) {
            ul.stop().slideUp();
            ul.removeClass("expanded");
            if (ul.hasClass("expand")) {
                ul.removeClass("expand");
            }
            jQuery(this.parentNode).children(".arrow").removeClass("arrowSelected");
        } else {
            ul.addClass("expanded");
            ul.stop().slideDown();
            jQuery(this.parentNode).children(".arrow").addClass("arrowSelected");
        }
        //return false;
    });
}

function OpenWindow(obj, width, height) {
    window.open(obj.href, "Window1", "width=" + width + ",height=" + height + ",toolbar=no,menubar=no,");
    return false;
}
