$(document).ready(function(){	   
	
	/* para que la barra de scroll siempre sume ancho ------------------------------------- */
	$("html").css({"overflow-y":"scroll","overflow-x":"auto" });
	
	
	/* para galerias de info */
    $('.slideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});	
	
	/* 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 --------------- */
	$(".linkmais").bind("click", function(){
			if ($("span.linkmais_ver").css("display")=="none"){
				$("span.linkmais_ver").css("display","inline");
				$("span.linkmais").html("(-)");
			}else{
				$("span.linkmais_ver").css("display","none");
				$("span.linkmais").html("(+)");
			}
		});
	
	$("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;
			}
		});
	});
	
	
	
	

	/* 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}"
	});
	
	/* 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");
		});
	});
	

	/* reproductor de video js_videoIframe */
	
	
	$("a.js_ctrlVideoIframe").each(function( i ){
		$.js_videoIframe = $("#js_videoIframe");
		var js_ctrlVideoIframe = $(this);
		js_ctrlVideoIframe.attr({
			"rel":js_ctrlVideoIframe.attr("href"),
			"href":"javascript:void(0);"
		});
		js_ctrlVideoIframe.bind("click", function(){
			$.js_videoIframe.hide();
			$.js_videoIframe.after('<iframe id="js_videoIframe" frameborder="0" src="'+$(this).attr("rel")+'" />');
			$.js_videoIframe.remove();
			$.js_videoIframe = $("#js_videoIframe");
		}); 
	});
	$("div.js_itemVideoteca").each(function(){
		var js_itemVideoteca =  $(this);
		var enlaceSecundario = js_itemVideoteca.find("p a:first");
		enlaceSecundario.attr({ "href":"javascript:void(0);" });
		enlaceSecundario.bind("click", function(){
			js_itemVideoteca.find("a.js_ctrlVideoIframe").trigger("click");
		});
	});

});
