$(document).ready(function() {

    resizeColumns("#topnav_services div.mega-column");
    resizeColumns("#topnav_portfolio div.mega-column");
    /* resizeColumns("#col0, #col1"); */

    textFieldEraser("#footerEmailField");
    textFieldEraser("#searchquery");




    // IE6 fixes
    if(jQuery.browser.msie && parseInt(jQuery.browser.version) <= 6) {

        // IE6 doesn't support transparent PNGs
        //$("#header").pngFix();

        // IE6 doesn't support :last-child
        $("div.mega-column:last-child").addClass("last-child");

        // add :hover pseudoclass support to certain things
        /*$("ul.topnav li, #contents-table td.horizontal-seperator, table.ystore-cross-sell-table tr.ystore-cross-sell-row td, #yahoo-store-checkout input.ys_submitLinkBtn").hover(function() {
            $(this).addClass("ie6_hovering");
        }, function() {
            $(this).removeClass("ie6_hovering");
        });*/
    }

    // IE7 fixes
    if(jQuery.browser.msie && parseInt(jQuery.browser.version) == 7) {

        // IE7 doesn't support :last-child
        $("div.mega-column:last-child").addClass("last-child");
    }
});







function resizeColumns(columnSelector) {

    var curHeight = 0;
    var maxHeight = 0;

    // find height of tallest column
    $(columnSelector).each(function() {
        curHeight = $(this).height();
        if(curHeight > maxHeight) {
            maxHeight = curHeight;
        }
    });

    // set all columns to height of tallest column
    $(columnSelector).height(maxHeight);
}






function textFieldEraser(textFieldSelector) {
    textFieldSelector = $(textFieldSelector);
    var defaultText = textFieldSelector.val();

    textFieldSelector.focus(function() {
        if ($(this).val() == defaultText) {
            $(this).val("");
        }
    }).blur(function() {
        if ($.trim($(this).val()) == "") {
            $(this).val(defaultText);
        }
    });

    $(textFieldSelector).parents("form").submit(function() {
        if($.trim(textFieldSelector.val()) == "" || $.trim(textFieldSelector.val()) == $.trim(defaultText)) {
            return false;
        }
    });

}
