// JavaScript Document

//AJUSTE COLORES
function ajustarcliente(){
	
	if(document.getElementById("tituloTrabajo")){
	//document.body.style.backgroundColor = varColor;
	//document.getElementById("list_trabajos").style.backgroundColor=varColor;
	document.getElementById("tituloTrabajo").style.color=varColor;
	//document.getElementById("barraTitulo").style.backgroundColor=varColor;
	$('.barraTitulo').css("background-color", varColor);
	
	
	
	if(varOscuro){
		document.getElementById("img_categoria").src="../images/interfaz/subnav_" + varCategoria +"_claro.png";
		document.getElementById("img_footer").src="../images/interfaz/footer_claro.png";
		//document.getElementById("list_trabajos").style.color="#ECEADA";
		//document.getElementById("list_trabajos").style.borderColor="#ECEADA";
	} else {
		document.getElementById("img_categoria").src="../images/interfaz/subnav_" + varCategoria +"_oscuro.png";
	
	}
	}
	

};

// AJUSTE COLOR JQUERY

$(document).ready(function(){
	
	
	$("body").stop().animate({ backgroundColor: varColor}, 750); //FADE IN FONDO
	$('.slideshow').cycle({	fx: 'fade' });	//CICLO DE FADES				   
						   
	$('.dropdown li a:hover').css("color", varColor);
	$('.dropdown').css("background-color", varColor);
	
	if(varOscuro){
		$('.nav_works a').css("background-image", "url(../images/interfaz/subnav_flch_claro.png)");
		$('.nav_works a').css("color", "#ECEADA");
		$('.nav_works a').css("border-color", "#ECEADA");
		$('.dropdown').css("border-color", "#ECEADA");
		
		$('.dropdown li a').css("background-image", "none");
		$('.dropdown li a:hover').css("background-color", "#ECEADA");
	}
	
	ajustarcliente();
			
});



//ROLLOVER
jQuery(function(){
     $(".nav-swap").hover(
          function(){this.src = this.src.replace("_norm","_roll");},
          function(){this.src = this.src.replace("_roll","_norm");
     });
});


jQuery(function(){
     $(".wrk_brnd").hover(
          function(){
			  	var varID = $(this).attr("id");
				this.src = "images/nav_mascaras/md_" + varID + ".gif";
		  },
          function(){
			  	this.src = "images/nav_mascaras/brand_vacia.gif";
     	  });

     $(".wrk_ch").hover(
          function(){
			  	var varID = $(this).attr("id");
				this.src = "images/nav_mascaras/ch_" + varID + ".gif";
		  },
          function(){
			  	this.src = "images/nav_mascaras/chica_vacia.gif";
     	  });
	 
	 $(".wrk_gd").hover(
          function(){
			  	var varID = $(this).attr("id");
				this.src = "images/nav_mascaras/gd_" + varID + ".gif";
		  },
          function(){
			  	this.src = "images/nav_mascaras/grande_vacia.gif";
     	  });
	 
	 
});

// BACKGROUND FADE
(function(jQuery){
 
	jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
		jQuery.fx.step[attr] = function(fx){
			if ( fx.state == 0 ) {
				fx.start = getColor( fx.elem, attr );
				fx.end = getRGB( fx.end );
			}
 
			fx.elem.style[attr] = "rgb(" + [
				Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
				Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
				Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
			].join(",") + ")";
		}
	});
 
	function getRGB(color) {
		var result;
 
		if ( color && color.constructor == Array && color.length == 3 )
			return color;
		if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
			return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
		if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
			return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
		if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
			return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
		if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
			return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
 
		return colors[jQuery.trim(color).toLowerCase()];
	}
 
	function getColor(elem, attr) {
		var color;
 
		do {
			color = jQuery.curCSS(elem, attr);
 
			if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
				break; 
 
			attr = "backgroundColor";
		} while ( elem = elem.parentNode );
 
		return getRGB(color);
	};
 
})(jQuery);

// MENU DESPLEGABLE 
//$(function () {
//$('.dropdown').each(function () {
//$('.nav_works').hover(function () {
//$('.dropdown:eq(0)', this).show();
//}, function () {
//$('.dropdown:eq(0)', this).hide();
//});
//});
//});


// MENU DESPLEGABLE 2
$(function () {
	$(".nav_works").click(function() { //When trigger is clicked...  
	 
		//Following events are applied to the subnav itself (moving subnav up and down)  
		$('.dropdown').slideDown('fast').show(); //Drop down the subnav on click  
	
		$('.nav_works').hover(function() {  
		}, function(){  
			$('.dropdown').slideUp('fast'); //When the mouse hovers out of the subnav, move it back up  
		});  
	  
	});  
});

// ANIM DE WORKS

$(document).ready(function(){  
	$('.work_chico').hover(function(){  
		$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});  
	}, function() {  
		$(".cover", this).stop().animate({left:'-420px'},{queue:false,duration:300});  
	});
	$(".work_chico .cover", this).stop().animate({left:'-420px'},{queue:false,duration:100});    

	$('.work_brand').hover(function(){  
		$(".cover", this).stop().animate({top:'155px'},{queue:false,duration:200}); 
		$(".coverback", this).fadeIn(200);  
	}, function() {  
		$(".cover", this).stop().animate({top:'230px'},{queue:false,duration:200});  
		$(".coverback", this).fadeOut(200); 
	});
	$(".work_brand .cover", this).stop().animate({top:'230px'},{queue:false,duration:100});
	$(".work_brand .coverback", this).fadeOut(20);    


});  

jQuery(function(){
     $("#idPrint").click(function(){
          for (x in wrksCategorias){
			  nameX = "#" +  wrksIds[x];
			  if (verPrn){
				  if (wrksCategorias[x] == "print"){
					  $(nameX).css("display","none");
				  } else {
					  $(nameX).css("display","block");
				  }
				  verPrn=false;
			  }
			  console.log(nameX);
			  
		  }
     });
});



