$(document).ready(function() {

    //$('.kpmgsearch').defaultvalue('Search KPMG.com');

    //hide the module title table at the top of modules
    $("div#dnn_ContentPane table[summary='Module Title Table']").hide()

    SetMinDocHeight();

    //fix the h1 widths in preview when editing
    $("#column2 span[id $= 'lblPreview'] h1").css('width', '100%');

    //Fix the width of settings table.
    $('table.Settings').width(710);
    $('table.Settings td:eq(0)').width(600);

    //edit tab fix width
    $("table[summary='Manage Tabs Design Table']").width(710);
    $("table[summary='Basic Settings Design Table']").width(600);
    $("table[summary='Basic Settings Design Table'] tr:eq(1) td:eq(1)").width(600);

    //fix extensions table fonts
    $("table[id$='grdExtensions'] td").css('font-size', '68.9%');

});

function searchText(e, searchBoxClientID) {
    var keynum = 0;
    if (window.event) //IE
    {
        keynum = window.event.keyCode;
    } else if (e.which) //Netscape/FF/Opera
    {
        keynum = e.which;
    }
    if (keynum == 13) {
        doSearch(searchBoxClientID);
        return false;
    }
}

function doSearch(searchBoxClientID) {
    var searchUrl = "http://www.kpmg.com/Global/Pages/Results.aspx";
    var query = document.getElementById(searchBoxClientID).value;
    document.location.href = searchUrl + "?k=" + query;
}

/// set the space under the left nav menu to be white
function SetLeftNavSpace() {
    var column1 = $('div#column1').height();
    var column2 = $('div#column2').height();
    var column3 = $('div#column3').height();
    var max = 0;
    var newHeight = 24;

    if (column1 > max)
    { max = column1; }

    if (column2 > max)
    { max = column2; }

    if (column3 > max)
    { max = column3; }

    newHeight = max - $('table.menu-width').height() + $('td.leftNavFooterCell').height();

    $('td.leftNavFooterCell').height(newHeight);

}

function SetMinDocHeight() {
    var pageHeight, windowHeight, col1Height, col2Height, col3Height, longestColHeight, longestCol;
    pageHeight = parseInt($('#mainwrapper').height());
    windowHeight = parseInt($(window).height());
    col1Height = parseInt($('#column1').height());
    col2Height = parseInt($('#column2').height());
    col3Height = parseInt($('#column3').height());
    //col2Height = 200;
    //alert(col2Height);
    longestColHeight = col1Height;
    longestCol = '#column1';

    if (col2Height > longestColHeight) {
        longestColHeight = col2Height;
        longestCol = '#column2';
    }
    if (col3Height > longestColHeight) {
        longestColHeight = col3Height;
        longestCol = '#column3';
    }


    //alert('col1Height: ' + col1Height + ' col2Height: ' + col2Height + ' col3Height: ' + col3Height);

    //col3Height = longestColHeight;
    //alert('pageHeight: ' + pageHeight + ' windowHeight: ' + windowHeight + ' longestColHeight: ' + longestColHeight);

    if (pageHeight < windowHeight) {
        $(longestCol).height(longestColHeight + windowHeight - pageHeight);

        SetLeftNavSpace();
    }

    if ($('#column2').width() > 520) {
        //two col format. Check that column2 is longer than the menu.
        if ($('#column2').height() < $('#column1').height()) {
            $('#column2').height($('#column1').height());
        }
    }
}


