﻿function AttachWatermark(controlId, hint) {
    // Define what happens when the textbox comes under focus
    // Remove the watermark class and clear the box
    if ($('#' + controlId).val() != "" && $('#' + controlId).val() != hint) {
        $('#' + controlId).removeClass("watermarkOn");        
    }

    $('#' + controlId).focus(function () {
        $(this).filter(function () {
            // We only want this to apply if there's not
            // something actually entered
            return $(this).val() == "" || $(this).val() == hint
        }).removeClass("watermarkOn").val("");
    });
        

    // Define what happens when the textbox loses focus
    // Add the watermark class and default text
    $('#' + controlId).blur(function () {
        $(this).filter(function () {
            // We only want this to apply if there's not
            // something actually entered
            return $(this).val() == ""
        }).addClass("watermarkOn").val(hint);
    });
}

$(document).ready(function () {
    if ($('#ctl00_txtSearchBox').length != 0)
        AttachWatermark("ctl00_txtSearchBox", "Search for products");
    else if ($('#ctl00_ctl00_txtSearchBox').length != 0)
        AttachWatermark("ctl00_ctl00_txtSearchBox", "Search for products");

    if ($('#ctl00_ContentMain_plProducts_msgNoProducts').length != 0) {
        $("#ctl00_ContentMain_SortBy").hide();
    } else {
        $("#ctl00_ContentMain_SortBy").show();
    }

});