function openDialogWindow(windowTitle, url, width, height, isModal)
{
	var $dialog = $('<div></div>')
		.dialog({
			title: windowTitle,
			width: width,
			height: height,
			position: ['center', 'center'],
			modal: isModal,
			close: function(ev, ui) {
				$(this).remove();
			}
		});
	$dialog.load(url, function(){
		bindDialogForm($dialog, url);
		$(this).dialog("option", "position", ['center', 'center'] );
	});
	return false;
}
function bindDialogForm(dialogWindow, url)
{
	$('form', dialogWindow).bind('submit', function(){
		
		// Before getting form data we need to update CKeditor instances linked fields.
		// It fills up linked fields with values of the CKeditor instances.
		if (typeof CKEDITOR != 'undefined')
			for (instance in CKEDITOR.instances)
				CKEDITOR.instances[instance].updateElement();
		
		dialogWindow.load(url, $(this).serializeArray(), function(){
			bindDialogForm(dialogWindow, url);
			$(this).dialog("option", "position", ['center', 'center'] );
		});
		return false;
		
	});
}
function openLinkInWindow(obj, target, params)
{
	if (params)
	{
		window.open(obj.href, target, params);
	}
	else
	{
		window.open(obj.href, target);
	}
	return false;
}

