$(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"});
	
	
	/* 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:"652",
		height:"572",
		opacity:0.50,
		iframe:true,
		current: "foto: {current} / {total}"
	});

	$("a[rel='colorboxIframeForoDown']").colorbox({
		width:"675",
		height:"320",
		opacity:0.50,
		iframe:true,
		current: "foto: {current} / {total}"
	});


	$("a[rel='colorboxIframeForoUp']").colorbox({
		width:"675",
		height:"320",
		opacity:0.50,
		iframe:true,
		current: "foto: {current} / {total}"
	});

	$("a[rel='colorboxIframeFicha'],a[rel='colorboxIframeFichaTXT'],").colorbox({
		width:"500",
		height:"320",
		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");
		});
	});
	
	/* para iniciar jrMiniGaleria ---------------------------------------------------------*/
	$("#minigaleria_1 , #minigaleria_2 , #minigaleria_3").jrMiniGaleria({
		autoMovimiento : false,
        retardoEntreFotos : 8000
	});
	
	/* para colapsar o descolapsar algún contenedor ---------------------------------------*/
	
	$("a.js_crtl_colapsa").each(function(){
		var js_crtl_colapsa = $(this);
		var contenedor = $(js_crtl_colapsa.attr("href"));
		var bullet = js_crtl_colapsa.find("span:fist");
		contenedor.css({
			"overflow":"hidden",
			"position":"relative"
		});
		contenedor.css({ "height":contenedor.height()+"px" });
		js_crtl_colapsa.attr({"href":"javascript:void(0);"})
		
		if( bullet.is(".js_bulletColpsd") ){
			contenedor.hide();
			this.conColapsd = true;
		}else{
			this.conColapsd = false;
		}
		
		js_crtl_colapsa.bind("click", function(){
			if( !this.conColapsd ){
				contenedor.slideUp("slow");
				bullet.removeClass("js_bulletDescolpsd").addClass("js_bulletColpsd");
				this.conColapsd = true;
			}else{
				contenedor.slideDown("slow");
				bullet.removeClass("js_bulletColpsd").addClass("js_bulletDescolpsd");
				this.conColapsd = false;
			}
		});
		
	});
	
	/* color alterno en tablas del foro ---------------------------------------*/
	$("table.tblTrAlternColor tr:even td").addClass("even");
	
	/* marcar todos los checkbox del formulario donde se encuentre este -------*/
	$("input[type='checkbox'][name='js_marcarTodos']").bind("click", function(){
		var checkbox = this;
		var formulario = $(checkbox.form);
		var checkbox_ar = formulario.find("input[type='checkbox']");
		checkbox_ar.each(function(){
			this.checked = checkbox.checked;
		});
	});
	
	/* select que refresca la página de mensajes privados flitrando por fecha --*/
	$("select[name='js_filtroTmpMsgs']").bind("change",function(){
		var elemento = $(this);
		var opcionSelect = $(this).val();
		alert("refresca la página de mensajes privados filtrando por los de "+opcionSelect);
	});

	$(".cita").click(function(){
		
	});
		
});

