$(document).ready(function(){	   
	
	/* para que la barra de scroll siempre sume ancho ------------------------------------- */
	$("html").css({"overflow-y":"scroll","overflow-x":"auto" });
	
	/* añade target="_black" a enlaces con class="js_targetBlank" --------------------------- */
	$("a.js_targetBlank").each(function(){
		var js_targetBlank = $(this);
		var HREF = js_targetBlank.attr("href");
		js_targetBlank.bind("click", function(e){
			window.open(HREF);
			return false;
		});
		js_targetBlank.bind("keypress", function(e){
			if( e.which == 13 ){
				window.open(HREF);
				return false;
			}
		});
	});
	
	/* quita el borde que crea firefox en el onFocus --------------- */
	$("a").css({ "outline":"none"});

	
	/* resalta todos los contenedores que se pintan sin contenido --*/
	/*
	$("a, p, h1, h2, h3, h4, ul, ol, li").each(function(){
		var elemento = $(this);
		var contenido = elemento.html();
		contenido = contenido.replace(/<br>|<\/ *br>| |\s|&nbsp;|\n|\r/ig, "");
		if( contenido == "" ){
			elemento.html("soy un contenedor vacío :(");
			elemento.css({
				"background-color":"#cccccc",
				"margin":"0px",
				"color":"red"
			});
		}
	});
	*/
	
	/* para los formularios colapsables de envío de pésames */
	
	$(document).ready(function(){
		var pestanaVisible = null;
		var itemActivo = null;
		var altoContenedor = 0;
		$("#js_menuFormPesame").show();
		$("#js_menuFormPesame li a").each( function(i){
			var control = $(this);
			this.id_contenedor = control.attr("href");
			control.attr({"href":"javascript:void(0);"});
			var contenedor = $(this.id_contenedor);
			contenedor.find("legend").hide();
			if( contenedor.height() > altoContenedor ){
				altoContenedor = contenedor.height();
				contenedor.parent().css({"height": (altoContenedor +52) +"px"});
			}
			
			if( control.is(".itemActivo") ){
				itemActivo = control;
				pestanaVisible = contenedor;
			}else{
				contenedor.hide();
			}
			control.bind("click", function(){
				var thisControl = $(this);
				var thisContenedor = $(this.id_contenedor);
				if( pestanaVisible != null ){
					pestanaVisible.hide();
					itemActivo.removeClass("itemActivo");
				}
				thisContenedor.show();
				thisControl.addClass("itemActivo");
				pestanaVisible = thisContenedor;
				itemActivo = thisControl;
			});
		});
	}); 
	
	
	/* para iniciar colorBox ------------------------------------------------------------ */
	$("a[rel='colorbox_1'], a[rel='colorbox_2'], a[rel='colorbox_3'], a[rel='colorbox']").colorbox({
		transition:"true",
		maxWidth:900,
		maxHeight:( $("body").height() - 20 ),
		opacity:0.50,
		current: "foto: {current} / {total}"
	});
	
	$("a[rel='colorboxIframe']").colorbox({
		width:"600",
		height:"780",
		opacity:0.50,
		iframe:true,
		current: "foto: {current} / {total}"
	});
	
	/* complemento del colorbox para los enlaces de texto de las fotos --------------------*/
	$(".js_itemGaleria").each(function(){
		var js_itemGaleria =  $(this);
		var enlaceSecundario = js_itemGaleria.find("p a:first");
		enlaceSecundario.attr({ "href":"javascript:void(0);" });
		enlaceSecundario.bind("click", function(){
			js_itemGaleria.find("a[rel='colorbox'], a[rel='colorboxIframe']").trigger("click");
		});
	});
	
});







