jQuery.noConflict();

var confirmBox_cfg =
	{
	enable: false,
	resizable: false,
	draggable: false,
	width: '60%',
	modal: false,
	show: 'fade',
	button_confirm: '',
	button_cancel: '',
	button_close: ''
	};

jQuery(document).ready(function($) {

	if (confirmBox_cfg.enable) {
		var $dialogHTML = $('<div />');
		$dialogHTML.attr('id', 'dialog').css('display', 'none');
		$dialogHTML.attr('title', 'Title Confirm Box');
		$dialogHTML.html('Content Confirm Box<br />Styl pouzit z jQuery UI<br /><br />Nacita se defaultne ted na kazde strance, jen kvuli testu. Viz prvni radek /socialnet/js/m.confirmbox.js');

		$('body').append($dialogHTML);

		$('#dialog').dialog(
			{
			width: confirmBox_cfg.width,
			resizable: confirmBox_cfg.resizable,
			draggable: confirmBox_cfg.draggable,
			modal: confirmBox_cfg.modal,
			show: confirmBox_cfg.show,
			hide: confirmBox_cfg.show,
			autoOpen: false,
			dialogClass: 'snConfirmBox'
			});
	}
});
function snConfirmBox(cbTitle, cbText, callbackConfirm, callbackLoad) {
	jQuery(function($) {

		if (confirmBox_cfg.enable) {

			$('#ui-dialog-title-dialog').html(cbTitle);
			$('#dialog').html(cbText);
			$('#dialog').children('div').remove();
			$('#dialog').children('span').remove();

			if (callbackConfirm == null || !$.isFunction(callbackConfirm)) {
				$('#dialog').dialog('option',
					{
					open: function() {
						if (callbackLoad != null && $.isFunction(callbackLoad)) {
							callbackLoad.apply();
						}
					},
					buttons: [
							{
							text: confirmBox_cfg.button_close,
							click: function() {
								$(this).dialog('close');
							}
							}
					]
					}).dialog('open');

			} else {
				$('#dialog').dialog('option',
					{
					open: function() {
						if (callbackLoad != null && $.isFunction(callbackLoad)) {
							callbackLoad.apply();
						}
					},
					buttons: [
						{
						text: confirmBox_cfg.button_confirm,
						click: function() {
							if ($.isFunction(callbackConfirm)) {
								callbackConfirm.apply();
							}
							$(this).dialog('close');
						}
						},
						{
						text: confirmBox_cfg.button_cancel,
						click: function() {
							$(this).dialog('close');
						}
						}
					]
					}).dialog('open');
			}
		} else if (callbackConfirm != null && $.isFunction(callbackConfirm)) {
			callbackConfirm.apply();
		}
	});
}

function snConfirmBox_confirmTest() {
	jQuery(function($) {
		alert('You have confirmed the confirm dialog box');
	});
}

function snConfirmBox_confirmLoad() {
	jQuery(function($) {
		$('#ui-dialog-title-dialog').html('Onload trigger');
	});
}

