$.fn.serializeObject = function()
{
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};

$.fn.watch = function(property, callback) {
   return $(this).each(function() {
       var self = this;
       var old_property_val = this[property];
       var timer;

       function watch() {
          if($(self).data(property + '-watch-abort') == true) {
             timer = clearInterval(timer);
             $(self).data(property + '-watch-abort', null);
             return;
          }

          if(self[property] != old_property_val) {
             old_property_val = self[property];
             callback.call(self);
          }
       }
       timer = setInterval(watch, 40);
   });
};

$.fn.unwatch = function(property) {
   return $(this).each(function() {
       $(this).data(property + '-watch-abort', true);
   });
};

$.fn.reverse = [].reverse;

function openModalDialog(obj,w,h)
{
$.ajax({
		dataType: 'html',
		type:'post',
		url : obj.attr('href'),
		context: document.body,
		success: function(data){
			
			$('body').append(data);
			$( ".dialog" ).dialog({
				autoOpen: true,
				height: h,
				width: w,
				modal: true,
				dialogClass : 'shadow15',
				buttons: {
				},
				close: function() {
					$( ".dialog" ).remove();
				}
			});
			}
		});
}
