jQuery.cookie = function(name, value, options) {
	if (typeof value != 'undefined') { // name and value given, set cookie
		options = options || {};
		if (value === null) {
			value = '';
			options.expires = -1;
		}
		var expires = '';
		if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
			var date;
			if (typeof options.expires == 'number') {
				date = new Date();
				date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
			} else {
				date = options.expires;
			}
			expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
		}
		// CAUTION: Needed to parenthesize options.path and options.domain
		// in the following expressions, otherwise they evaluate to undefined
		// in the packed version for some reason...
		var path = options.path ? '; path=' + (options.path) : '';
		var domain = options.domain ? '; domain=' + (options.domain) : '';
		var secure = options.secure ? '; secure' : '';
		document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');

	} else { // only name given, get cookie
		var cookieValue = null;
		if (document.cookie && document.cookie != '') {
			var cookies = document.cookie.split(';');
			for (var i = 0; i < cookies.length; i++) {
				var cookie = jQuery.trim(cookies[i]);
				// Does this cookie string begin with the name we want?
				if (cookie.substring(0, name.length + 1) == (name + '=')) {
					cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
					break;
				}
			}
		}
		return cookieValue;
	}
};

jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

jQuery.openPopup = function(URL, name, width, height, scrollbars) {
	window.open(URL, name, 'toolbar=0,scrollbars=' + (scrollbars ? 1 : 0) + ',location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + ((screen.width - width)/2) + ',top=' + ((screen.height - height)/2));
}

$.fn.inlineLabel = function(settings) {
	this.each(function(i) {
		if ($(this).val() != '') {
			jQuery.data(this, 'inline_label', $(this).val());
			$(this).focus(function() {
				if ($(this).val() == jQuery.data(this, 'inline_label')) {
					$(this).val('');
				}
			});	
			$(this).blur(function() {
				if ($(this).val().match(/^\s*$/gi)) {
					$(this).val(jQuery.data(this, 'inline_label'));
				}
			});	
		}
	});
	return this;
}

jQuery.extend( {
        interval:function(frequency, fn) {
            this.currentlyExecuting = false;
            setInterval(function() {$.onTimerEvent(fn);}, frequency * 1000);
        },
        onTimerEvent: function(callback) {
            if (!this.currentlyExecuting) {
              try {
                this.currentlyExecuting = true;
                callback();
              } finally {
                this.currentlyExecuting = false;
              }
            }
        }
});