 $(function () {  
	 
	$("#nav_mas").hide();
	$("#nav_menos").hide();
	$("#pages").hide();
	
	$("#btn_menos").click(function () {  
	   $("#nav_mas").hide();
	   $("#nav_menos").show();
	   $("#video_present").hide();
	});  
	
	$("#btn_mas").click(function () {  
	   $("#nav_menos").hide();
	   $("#nav_mas").show();	   
	   $("#video_present").hide();
	});
	
	box_txt = {};	
	
	$(".frase_negro").mouseenter(function () {     	   	   
	   var i = $(this).index(".frase_negro");
	   var txt = $(".frase_claro").eq(i).html();	   		   
	   box_txt.frase_negro =  $(".frase_negro").eq(i).html();
	   box_txt.frase_claro =  $(".frase_claro").eq(i).html();
	   $(this).html(box_txt.frase_claro);
	   
	});
	
	$(".frase_negro").mouseout(function () {
	  $(this).html(box_txt.frase_negro);
	});
	
	$(".frase_claro").mouseenter(function () {     	   	   
	   var i = $(this).index(".frase_claro");
	   var txt = $(".frase_claro").eq(i).html();	   		   
	   box_txt.frase_negro =  $(".frase_negro").eq(i).html();
	   box_txt.frase_claro =  $(".frase_claro").eq(i).html();
	   $(this).html(box_txt.frase_negro);
	   
	});
	
	$(".frase_claro").mouseout(function () {
	  $(this).html(box_txt.frase_claro);
	}); 	
	
	
	$(".workItem.internal").click(function () { 								   	  
	  var url = $("a", this).attr("href");
	  if (url) {document.location.href=url;}
	});
	
	$(".workItem.external").click(function () { 								   	  
	  var url = $("a", this).attr("href");
	  if (url) {window.open(url);}
	});	
	
	$(".workItemInnerDiv").mouseenter(function () {  
	   $(".workItemTexts", this).animate({opacity:1}, 'fast');
	});	

	$(".workItem").mouseleave(function () {  
	   $(".workItemTexts", this).animate({opacity:0}, 'fast');
	});	
	
	//target="_blank"
    $('a[rel*=external]').click( function() {
        window.open(this.href);
        return false;
    });	
	

	
 }); 
 
 
 
//anchor navigation
//http://yensdesign.com/2008/11/creating-ajax-websites-based-on-anchor-navigation/

//On load page, init the timer which check if the there are anchor changes each 300 ms
$().ready(function(){
	setInterval("checkAnchor()", 300);
});
var currentAnchor = null;
//Function which chek if there are anchor changes, if there are, sends the ajax petition
function checkAnchor(){
	//Check if it has changes
	if(currentAnchor != document.location.hash){
		currentAnchor = document.location.hash;
		//if there is not anchor, the loads the default section
		if(!currentAnchor)
			//query = "section=home";
			section = "home";
		else
		{
			//Creates the  string callback. This converts the url URL/#main&id=2 in URL/?section=main&id=2
			var splits = currentAnchor.substring(1).split('&');
			//Get the section
			var section = splits[0];
			delete splits[0];
			//Create the params string
			var params = splits.join('&');
			var query = "section=" + section + params;
		}
		
		if (section == "home"){
			$(".footer").css("margin-top", "344px");
		}
		
		else if (section == "quienes-no-somos" ||  section == "que-no-ofrecemos" ||  section == "que-no-hacemos"){
		   $("#video_present").remove();	
		   $("#nav_mas").hide();
		   $("#nav_menos").show();
		   $(".content").hide();
		   $("#"+section).show();
		   $("#pages").show();
		   $(".footer").css("margin-top", "35px");
		}
		
		else if (section == "quienes-somos" ||  section == "que-ofrecemos" ||  section == "que-hacemos"){
		   $("#video_present").remove();
		   $("#nav_menos").hide();
		   $("#nav_mas").show();
		   $("#pages").show();
		   $(".content").hide();
		   $(".submenu").hide();
		   $(".footer").css("margin-top", "35px");		   
		   $("#"+section).show();		   		   
			   if (section == "que-hacemos") {
				  $(".submenu").show();			  
			   }		   
		}
		//proyectos
		else {
			alert("ERROR " + section);
		}
		
		
		//$("#"+section).html(section);
	}
}	


