﻿(function($) {
    $.fn.intValue = function() {
        var intVal = parseInt(this.val());
        return (isNaN(intVal)) ? null : intVal;
    };
    $.fn.showIf = function(condition) {
        this.css('visibility', (condition) ? 'visible' : 'hidden');
    };
    $.fn.parentIs = function(selector) {
        var p = this.parent();
        if (p.length == 0) {
            return null;
        }
        while (!p.is(selector)) {
            p = p.parent();
            if (p.length == 0) {
                return null;
            }
        }
        return p;
    };
    $.fn.assertOne = function() {
        if (this.length != 1) {
            alert('Elements count: ' + this.length);
            throw new 'assertion failed';
        }
        return this;
    };
})(jQuery);

function clone(obj) {
    return jQuery.extend(true, {}, obj);
}
function postJSON(url, param, callback) {
    var p = jQuery.param(params);
    jQuery.post(url, p, callback, 'json');
}
