﻿$(function() {
    $.fn.clearForm = function() {
        return this.each(function() {
            var type = this.type, tag = this.tagName.toLowerCase();
            if (tag == 'form')
                return $(':input', this).clearForm();
            if (type == 'text' || type == 'password' || tag == 'textarea')
                this.value = '';
            else if (type == 'checkbox') {
                if ($(this).is(':checked')) {
                    $(this).click();
                }
                this.checked = false;
            }
            else if (type == 'radio') {
                this.checked = false;
            }
            else if (tag == 'select')
                this.selectedIndex = 0;
        });
    };

    $.fn.delay = function(time, callback) {
        // Empty function:
        jQuery.fx.step.delay = function() { };
        // Return meaningless animation, (will be added to queue)
        return this.animate({ delay: 1 }, time, callback);
    }
});


function ResolveUrl(url) {
    if (url.indexOf("~/") == 0) {
        url = "/" + url.substring(2);
    }
    return url;
}


