/* Configuració FancyBox */
/* Elements que enllacen a un lightframe */

jQuery(document).ready(function() {
	$(".rb_enllas_lightframe").fancybox({
		'width' : 684,
		'height': '75%',
		'autoScale' : false,
		'transitionIn' : 'none',
		'transitionOut'	: 'none',
		'scrolling'	: 'auto',
		'type' : 'iframe'
	});

	$(".rb_enllas_seccio_lightframe").fancybox({
		'width' : 684,
		'height': '75%',
		'autoScale' : false,
		'transitionIn' : 'none',
		'transitionOut'	: 'none',
		'type' : 'iframe'
	});
	
	$(".rb_enllas_llista_lightframe").fancybox({
		'width' : 654,
		'height': 280,
		'autoScale' : false,
		'transitionIn' : 'none',
		'transitionOut'	: 'none',
		'scrolling'	: 'auto',
		'type' : 'iframe'
	});

	$("#f_bustia_noticies").bind("submit", function() {
		$.ajax({
			type	: "POST",
			cache	: false,
			url	: "/noticies/bustia.xsp",
			data	: $(this).serializeArray(),
			success: function(data) {
				$.fancybox(data);
				}
		});
		return false;
	});
	$("#f_noticia_corregeix").bind("submit", function() {
		$.ajax({
			type	: "POST",
			cache	: false,
			url	: "/noticies/corregeix.xsp",
			data	: $(this).serializeArray(),
			success: function(data) {
					$.fancybox(data,{onClosed: function() {
							if (tanquem == -1) {
								document.getElementById("noticia_form_corregeix").style.display = "none";
								document.getElementById("noticia_form_corregeix_text").value = "";
							}
						}
					});
					var tanquem = document.getElementById("msg_resultat_correccio").innerHTML.indexOf("Error");
					if (tanquem == -1) {
						document.getElementById("noticia_form_corregeix").style.display = "none";
						document.getElementById("noticia_form_corregeix_text").value = "";
					}
				}
		});
		return false;
	});
	$("#f_noticia_comenta").bind("submit", function() {
		$.ajax({
			type	: "POST",
			cache	: false,
			url	: "/noticies/comenta.xsp",
			data	: $(this).serializeArray(),
			success: function(data) {
					$.fancybox(data,{onClosed: function() {
							if (tanquem == -1) {
								window.location.reload();
							}
						}
					});
					var tanquem = document.getElementById("msg_resultat_comentari").innerHTML.indexOf("Error");
					if (tanquem == -1) {
						var RC = setTimeout(window.location.reload(),3000);
					}
				}
		});
		return false;
	});
	
	/* Publicitat que s'obre automàticament */
	$(".publicitat_splash").fancybox({
		'width' : 720,
		'height': 720,
		'autoScale' : false,
		'transitionIn' : 'none',
		'transitionOut'	: 'none',
		'scrolling'	: 'auto',
		'type' : 'iframe',
		'onClosed':function() {clearTimeout(PC);}
	});
	if (document.getElementById("obre_publicitat_lightframe")) {
		$("#obre_publicitat_lightframe").trigger("click");
		var PC = setTimeout($.fancybox.close,20000);
	}

	$(".patum_enllas_lightframe").fancybox({
		'width' : 684,
		'height': '54%',
		'autoScale' : false,
		'transitionIn' : 'none',
		'transitionOut'	: 'none',
		'scrolling'	: 'auto',
		'type' : 'iframe'
	});

});


