﻿function FormatCMSStandardTables()
{
    $(".cms_standard_table").each(function() {

        $("table").each(function() {
            if ($(this).is('table')) {
                $('tbody td:first-child', this).each(function(i) {
                    $(this).css("white-space", "nowrap");
                    $(this).css("font-weight", "bold");
                });

                $('tbody th', this).each(function(i) {
                    $(this).css("white-space", "nowrap");
                });                

                $("tr:even").css("background-color", "#f5f8fa");
                $("tr:odd").css("background-color", "#edf3f7");
            }
        });

    });
}

function ValidateSearchQuery(id, message)
{
    var go;
    var selector = "#" + id;

    var l = $(selector).val().length;
    
    if(l > 0)
    {
        go = true;
    }      

    if(go)
    {
        return true;
    }
    else
    {
        alert(message);
        $(selector).focus();
        return false;
    }    
}

function PrintPage()
{
    var url = window.location + "?print=true";
    
    window.open(url);
}

function preloadImages() {
    for (var i = 0; i < arguments.length; i++) {
        if (arguments[i] != "none") {
            $("<img>").attr("src", arguments[i]);
        }
    }
}

$(function() {
    $('a.toggle').click(function() {
    $($(this).attr('href')).slideToggle();
        return false;
    });
});
