// JavaScript Document

$(document).ready(function(){
	/*$(document).pngFix();
	$('.png').pngFix();*/
	//DD_belatedPNG.fix(#content li);
	//DD_belatedPNG.fix(".png");

	/*$("a.fancy[rel]").fancybox({
		'zoomSpeedIn'		: 500,
		'zoomSpeedOut'		: 200,
		'overlayShow'		: true,
		'easingIn'			: 'easeOutBack',
		'easingOut'			: 'easeInBack',
		'overlayOpacity'	: 0.70,
		'centerOnScroll'	: true
	});*/

})

////////////// Modal ////////////////


function abrirModal (idbloque, url) {
	$('#'+idbloque).modal({
		close: false,
		overlayId: 'fw_overlay',
		containerId: 'fw_contenedor',
		onOpen: fw.open,
		onClose: fw.close
	});
		if(url){
		$('#destino').attr({
			src: url
		});
	}
}

function cerrarModal(dialog) {
	dialog.data.fadeOut(200, function () {
		dialog.container.fadeOut(200, function () {
			dialog.overlay.fadeOut(200, function () {
				$.modal.close();
			});
		});
	});
}
var fw = {
	message: null,
	open: function (dialog) {
		$("#fw_overlay").css({'opacity': 0.7});
		dialog.overlay.fadeIn(200, function () {
			$("iframe").remove();
			dialog.container.fadeIn(200, function () {
				dialog.data.fadeIn(200, function () {
				});
			});
		});
	},

	close: function (dialog) {
		cerrarModal(dialog)
	},
	error: function (xhr) {
		alert(xhr.statusText);
	}
};


function confirmar (mensaje, funcion) {

	var dialog = $("<div id='confirmar' title='Confirmaci&oacute;n'>"+mensaje+"</div>").insertAfter('body');
	$(dialog).dialog({
		resizable: false,
		modal: true,
		overlay: {
				opacity: 0.5,
				background: "black"
		},
		width: 400,
		height: 200,
		buttons: {
				"Confirmar": function() {
						$(this).dialog('destroy').remove();
						eval(funcion);
				},
				"Cancelar": function() {
						$(this).dialog('destroy').remove();
				}
		}
	});

	$('.ui-dialog-titlebar-close').click(function() {
		$("#confirmar").dialog('destroy').remove();
	})

}