﻿
jQuery.fn.center = function($w)
{
    this.css("position", "absolute");
    this.css("top", ($w.height() - this.height()) / 2 + $w.scrollTop() + "px");
    this.css("left", ($w.width() - this.width()) / 2 + $w.scrollLeft() + "px");
    return this;
};

jQuery.fn.disable = function()
{
    this.attr('disabled', 'disabled');
};

jQuery.fn.enable = function()
{
    this.removeAttr('disabled');
};

jQuery.fn.dropdownloading = function()
{
    this.disable();
    this.html('<option>' + $('#LoadingString').val() + '...</option>');
};

jQuery.fn.explanationText = function(text)
{
    if ($(this).val() == '')
    {
        $(this).val(text);
    }

    $(this).focus(function()
    {
        if ($(this).val() == text)
        {
            $(this).val('');
        }
    });

    $(this).blur(function()
    {
        var trimmedValue = $(this).val().trim();

        if (trimmedValue == '')
        {
            $(this).val(text);
        }
        else
        {
            $(this).val(trimmedValue);
        }
    });
};

