(function($) {
	$.fn.ajaxDialog = function(url, params, callback) {

		// If the second parameter was provided
		if ( params ) {
			// If it's a function
			if ( jQuery.isFunction( params ) ) {
				// We assume that it's the callback
				callback = params;
				params = null;

			// Otherwise, build a param string
			} else if( typeof params === "object" ) {
				params = jQuery.param( params );
				type = "POST";
			}
		}

		var self = this;

		$('#ajaxDialog').html('<div></div>')
		$('#ajaxDialog > div').load(url, params, function(responseText, textStatus, XMLHttpRequest){
			if( callback ) {
				self.each(callback, [responseText, textStatus, XMLHttpRequest]);
			}
			$('#ajaxDialog > div').dialog({modal: true}).dialog('open');
		})
	}

	$.fn.iframeDialog = function(url, options, callback) {
		var frameClassName = options.frameClassName ? options.frameClassName : '';

		var self = this;

		$('#iframeDialog').html('<div><iframe></iframe></div>')
		self.element = $('#iframeDialog > div'); 
		self.iframe = $('#iframeDialog > div > iframe'); 
		self.element.load(function(){
			if( callback ) {
				self.each(callback);
			}
			self.element.dialog('option', 'width', self.iframe.width());
		});
		options.resize = function(event, ui) {
			var newWidth = self.element.width();
			var newHeight = self.element.height();
			self.iframe.width(newWidth + 'px');
			self.iframe.height(newHeight + 'px');
		};
		self.iframe.addClass('dialogIframe');
		self.iframe.addClass(frameClassName);
		self.iframe.attr('src', url);
		self.element.dialog(options).dialog('open');
	}
})(jQuery); // Call and execute the function immediately passing the jQuery object

function closeDialog()
{
	parent.$('iframe.dialogIframe').parent().dialog('close');
}

function refreshParentWindow()
{
	parent.location.href = parent.location.href;
}

function redirectParentWindow(href)
{
	parent.location.href = href;
}
	
function setZIndexes(element)
{
	$('.setZIndex').removeClass('zIndexBigger').addClass('zIndexSmaller');
	$(element).parents('.setZIndex').removeClass('zIndexSmaller').addClass('zIndexBigger');
}