
/* Page Entry */
$(document).ready(function() {
    // Set up the home page rotator
    $("#rotator").tabs({ fx: { opacity: "toggle"} }).tabs("rotate", 5000);
    // Set up the input setters for the input elements on the page
    $("#txt_search, #msign").inputSetter(0);
    // Set up the cmd_search button click to redirect to /search.aspx?sText=[txt_search]
    $("#cmd_search").click(function() { window.location = '/search.aspx?sText=' + $("#txt_search").val(); });
    // Set up the cmd_signup button click to redirect to /contact_center_registration.aspx?id=1288&EM=[txt_signup]
    $("#msign_submit").click(function() { window.location = '/contact_center_registration.aspx?id=1288&EM=' + $("#msign").val(); });
    // Watch for enter key and redirect the user
    $('#txt_search').keyup(function(event) { if (event.keyCode == '13') { $('#cmd_search').click(); } });
    $('#msign').keyup(function(event) { if (event.keyCode == '13') { $('#msign_submit').click(); } });
});

// Input Setter function for input element labels and hide-on-click
jQuery.fn.inputSetter = function(lower) {
    return this.each(function() {
        var $input = $(this);
        var $label = $("label[for='" + $input.attr("id") + "']");
        var labeltext = lower && lower == 1 ? $label.text().toLowerCase() : $label.text();
        $label.hide();
        $input.val(labeltext);
        $input.focus(function() { if (this.value == labeltext) { this.value = ""; } })
			  .blur(function() { if (!this.value.length) { this.value = labeltext; } });
    });
};

