var flashvars = {};

var params = {
 // wmode: "transparent"

};

var attributes = {};



indexImg = 1;

function moveAtList(lastItem){
		$("#Proyectos").hide();
		$("#Proyectos").load("portafolioList.php?area="+area+"&index="+lastItem, {}, function(){
			doneList();
			insideMoves();
		});
}

function loadProject(elID, elArea){
	$("#loading").show();
	$("#Proyectos").hide();
	$("#nav a").removeClass("on");
	$("#"+elArea).toggleClass("on");
	$("#Proyectos").load("project_details.php?id="+elID, {}, doneList);
	}

$.fn.image = function(src, f){
  return this.each(function(){
    $("<img />").appendTo(this).each(function(){
			$(this).hide();
			//'images/proyectos/'.$proyecto->folder_images.'/medium/'.$imgs[$i]; 
			$(this).attr({ 
			        src: src,
					id :"newImage",
					onload:f,
					rel:""
			        });
			});
  });
}
function doneList(){
	$("#loading").hide();
	$("#Proyectos").hide();
	$("#Proyectos").fadeIn("slow");
	}
function loadDetails(id){
	$("#Proyectos").load("project_details.php?id="+id, {}, doneList);
	}







function insideDetails(){
	//$("#overLupa").hide();
	$("#overLupa").animate({opacity: 1.0}, 3000)
    .fadeOut('slow');
			
	$("#imgMedium").hover(function(){ $("#overLupa").fadeIn(); }, function(){ $("#overLupa").fadeOut();});
	boxy(0); 
	$("#linksThumbs1 a:first").addClass("opacidad"); //activo primer link 
	
	$("#linksThumbs1 a, #linksThumbs2 a").click(function(){ //function para links en thumbnails
			//$("#linksThumbs1 a, #linksThumbs2 a").removeClass("opacidad");
			
			$("#loading").show();
			$("#imgMedium").empty();
			$("#imgMedium").image(
			   $(this).attr("rel"),
			   function(){	
			    	$("#loading").hide();				
					$("#newImage").fadeIn("slow");
			   }
			 );
			$("#newImage").wrap("<a href='"+$(this).attr("name")+"' id='openBig'></a>");
			$("#openBig").prepend("<div id='overLupa' class='theLupa'><div><img src='images/icons/lupaIcon.png' alt='Lupa' width='64' height='64' /></div></div>");
			//$(".theLupa").hide();
			$("#overLupa").animate({opacity: 1.0}, 3000)
    		.fadeOut('slow');
			
			boxy(parseInt($(this).attr("id"))); //inicializa fancybox
			$(this).toggleClass("opacidad");
			return false;
	});
		//slider en project detail
	$('#Slider').serialScroll({
				items:'li',
				prev:'#contSlider a.link_previous',
				next:'#contSlider a.link_next',
				axis:'x',
				duration:500,
				easing:'easeOutQuart'
	});
	$(".Alterno li:even").addClass("colorAlt");
	
	if ($('#fancy_wrap').length>0){
	$(window).resize(function(){
	  $.fn.fancybox.changeItem(0); //reacomoda el boxy
	});
	}

}

function insideMoves(){

$(".contactOpen").fancybox({
		'frameWidth': 690,
		'frameHeight': 420,
		'overlayShow':	true,
		'zoomSpeedIn':	0, 
		'zoomSpeedOut':	0,
		'middleCenter': true
	});
 $("#interesado").hover(
      function () {
        $(this).animate( { backgroundColor:"#FF0000"}, 750 );
		$("#interesado h1").animate( { color:"#8E0000"}, 750 );
		$("#interesado h2").animate( { color:"#000"}, 750 );
          
      },
      function () {
		$(this).animate( { backgroundColor:"#FFF"}, 750 );
		$("#interesado h1").animate( { color:"#666666"}, 750 );
		$("#interesado h2").animate( { color:"#FF0000"}, 750 );
      }
    );	
	
	$(".dverdetalle").hide();
	$(".theFrame").hide();

	$(".lista_proyectos li").hover(
	function(){
		x=$(this).find(".dverdetalle");
    	$(x).animate( { opacity:"show"}, 600 );
		x=$(this).find(".theFrame");
    	$(x).animate( { opacity:"show"}, 600 );
		x=$(this).find("a");
    	$(x).animate( { opacity:"show"}, 600 );
		x=$(this).find(".moreDetails");
    	$(x).animate( { opacity:"show"}, 600 );
		

		},function(){
		$(this).fadeTo(1,1);
		x=$(this).find(".dverdetalle");
    	$(x).animate( { opacity:"hide"}, 200 );
		x=$(this).find(".theFrame");
		$(x).animate( { opacity:"hide"}, 200 );
		x=$(this).find(".moreDetails");
		$(x).animate( { opacity:"hide"}, 200 );

	});
		
	$(".Alterno li:even").addClass("colorAlt");
	

	$(".lista_proyectos a").click(function(){
	$("#loading").show();
	$("#Proyectos").hide();
	area = this.name;
	var hash = $(this).attr('href');
	hash = hash.replace(/^.*#/, '');
			if($.browser.msie){
			$("#Proyectos").load(hash, {}, function(){
				$("#nav a").removeClass("on");
				$("#"+area).toggleClass("on");
				insideMoves();
				doneList();
			});
		}else{
		$.historyLoad(hash);
		doneList();
		}
return false; 	
	});	
	
	$("#nextProjects").click(function(){
		$("#loading").show();
		$("#Proyectos").hide();
		var hash = $(this).attr('href');
		hash = hash.replace(/^.*#/, '');
		if($.browser.msie){
			$("#Proyectos").load(hash, {}, function(){
				insideMoves();
				doneList();
			});
		}else{
		$.historyLoad(hash);
		}
	});
	
	$("#prevProject").click(function(){
		$("#loading").show();
		$("#Proyectos").hide();
		var hash = $(this).attr('href');
		hash = hash.replace(/^.*#/, '');
		if($.browser.msie){
			$("#Proyectos").load(hash, {}, function(){
				insideMoves();
				doneList();
			});
		}else{
		$.historyLoad(hash);
		}
	});
	
	$(".link_previous_disable, .link_next_disable").click(function(){ return false; });
	

	}

	function pageload(hash) {
		$("#loading").show();
		$("#Proyectos").hide();
		
		if(hash.search(/web/)>0) area = "web";
		else if(hash.search(/branding/)>0) area = "branding";
		else if(hash.search(/print/)>0) area = "print";
		else if(hash.search(/todos/)>0) area = "todos";
		
		if(hash) {
			$("#Proyectos").load(hash, function(){
				$("#nav a").removeClass("on");
				$("#"+area).toggleClass("on");
				insideMoves();
				doneList();	
			});
		} else {
				//
				$("#nav a").removeClass("on");
				$("#todos").toggleClass("on");
			  	$("#Proyectos").load("portafolioList.php", {}, function(){
				insideMoves();
				doneList();
																		});
			}
		}
		
$(document).ready(function() { 
	
	area = "todos";	
	if(!$.browser.msie){
	$.historyInit(pageload);
	}
	//$('div, a').pngFix();
	
	$("#loading").hide();
	$('.dproyesp').hover(function() {
  		$(this).addClass('hoverLi');
		}, function() {
  		$(this).removeClass('hoverLi');
		});
	$("a#contactanosTop").fancybox({
		'frameWidth': 690,
		'frameHeight': 420,
		'overlayShow':	true,
		'zoomSpeedIn':	0, 
		'zoomSpeedOut':	0,
		'middleCenter': true
	});
	$("#imgMedium").hover(function(){ $("#overLupa").fadeIn(); }, function(){ $("#overLupa").fadeOut();});


		$("#tab_branding a, #tab_todos a, #tab_print a, #tab_web a").click( function(){
		$("#loading").show();
		$("#Proyectos").hide();
		$("#nav a").removeClass("on");
		$(this).toggleClass("on");
		area = this.id;
		if($.browser.msie){
		$("#Proyectos").load("portafolioList.php?area="+area, {}, function(){
				insideMoves();
				doneList();
		});
		}else{
		$.historyLoad("portafolioList.php?area="+area+"&index=0");	
		}
		
		return false; 	
		});


	insideMoves();
	
 var originalBG = $(".animate").css("background-color");

 $(".animate").hover(
      function () {
        $(this).animate( { backgroundColor:"#8C0000"}, 750 );
		$("#blogTop h1").animate( { color:"#FFF"}, 750 );
		$("#blogTop h2").animate( { color:"#E60E11"}, 750 );
		$("#blogTop h3").animate( { color:"#7D4141"}, 750 );
          
      },
      function () {
		$(this).animate( { backgroundColor:originalBG}, 750 );
		$("#blogTop h1").animate( { color:"#FF0000"}, 750 );
		$("#blogTop h2").animate( { color:"#FF9900"}, 750 );
		$("#blogTop h3").animate( { color:"#999999"}, 750 );
      }
    );

	//neww


	

	
});

