$(document).ready(function(){
	//calculando resolucion de pantalla
	var mainWelcomeHeight = ($(window).height())-26;//26px of #color-bar
	//alert("mainWelcomeHeight: "+mainWelcomeHeight);
	// #headerSeparate H = 20
	// #container-menu H = 31
	// #footer-info H = 41
	// #color-bar H = 26
	// Total = 128
	var welcomeFyaHeight = $(window).height() - 128;
	//alert("welcomeFyaHeight: "+welcomeFyaHeight);
	//$('body').css("Overflow","Hidden");
	$("#main-welcome").css("height",mainWelcomeHeight+'px');
	$("#welcome-fya").css("height",welcomeFyaHeight+'px');
	var HeightImageFyaWelcome = 254;
	var marginFyaLogo = Math.round((welcomeFyaHeight - 254)/2);
	//alert("marginFyaLogo: "+marginFyaLogo);
	$("#fya-logo").css("margin",marginFyaLogo+"px 0 "+marginFyaLogo+"px 0");
	
	if($("#fya-logo")!=null)
	{
		$("#fya-logo").fadeTo("slow", 1);
		//$("#fya-logo").delay(3000).html("<div align='center'><iframe width='505' height='287' src='http://www.youtube.com/embed/pYkMff8qBvQ&autoplay=1' frameborder='0' allowfullscreen></iframe></center>");
		//$("#fya-logo").delay(3000).html("<div align='center'><embed src='http://www.youtube.com/v/pYkMff8qBvQ&autoplay=1' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='505' height='255'></center>");
	}
	
	
	//CHANGE VIDEO FYA
	/*var use = 0;
	setInterval(function() {
          // Do something every 2 seconds
		  //alert("^^");
		  var htmlValue = $("#fya-logo").html();
		  //alert("htmlValue = "+htmlValue);
		  if(use=="")
		  {
			  //alert("use1 = "+use);
		  //$("#fya-logo").html("<div align='center'><embed src='http://www.youtube.com/v/pYkMff8qBvQ&autoplay=1' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='505' height='255'></center>");
		  $("#fya-logo").html("<div align='center'><div id='videoDiv'>Loading...</div></div>");
		  }
		  return use = 1;
		  //alert("use2 = "+use);
    }, 3000);*/
	
	if($("#fya-logo-index")!=null)
	{
		//$("#fya-logo-index").fadeTo("slow", 1);
		
		$("#fya-logo-index").delay(1000).animate(500, function() {
			// Animation complete.
			$("#fya-logo-index").animate({backgroundPosition: '+=130'}, 500);
			$("#fya-logo-index").animate({backgroundPosition: '-=20'}, 500);
		});
		$("#fya-logo-index").click(function(){
		  window.location = "http://www.funesyasociados.com/";
		}); 
		
	}
	
	if($("#Comunidad-fya-empresas")!=null)
	{
		$("#leo-burnett-img").delay(500).fadeIn(400);
		$("#starcom-mediavest-img").delay(1500).fadeIn(400);
		$("#aditss-img").delay(2000).fadeIn(400);
		$("#advocacy-img").delay(2500).fadeIn(400);
		$("#adtivity-img").delay(3000).fadeIn(400);
	}
	
	if($("#creemos-right")!=null)
	{
		//$("#creemos-topic").delay(500).css("marginLeft", '+=25');
		$("#creemos-topic").delay(500).animate({marginLeft:'+=25'},1000);
	}
	
	if($("#creemos-text")!=null)
	{
		$("#creemos-text").delay(500).fadeTo(1000, 1);
	}
	
	if($("#human-kind-right #page #text")!=null)
	{
		$("#human-kind-right #page #text").delay(500).fadeTo(1000, 1);
	}
	
	
	if($(".panel .thumbClient")!=null)
	{
		//alert("existo!");
		/*$(".panel .thumbClient").click(function() {
		  evento.preventDefault();
		  alert('Handler for .click() called.');
		  
		});*/
		$(".panel .thumbClient").click(function () { 
		  var image = $(this).attr("title");
		  //alert("I works! image: "+image);
		  $("#imagen-complete").addClass("loading-image");
		  $("#imagen-complete").html("<div align='center'><img src='images/casos-exitos/thumbs/"+image+"'/></div>");
		  $("#imagen-complete").removeClass("loading-image");
		});

	}
	
	
	
	if($("#footer-info")!=null)
	{
		$("#footer-info").html("<div style='width:50%; height:20px; padding-top: 21px; float:left;'>&copy; 2011 Funes y Asociados</div><div style='width:50%; height:21px; float:left; text-align: right; padding-top:20px;'><!--<a href='#'>Cont&aacute;ctanos</a> / <a href='#'>Noticias</a> / <a href='#'>Blog</a> / --> Tel: 2500-2100 / <a href='mailto:info@funesyasociados.com'>info@funesyasociados.com</a> <a href='http://www.facebook.com/fyapublicidad' target='_blank'><img src='images/facebook-fya.png' border='0' width='15px' height='15px'></a> <a href='http://twitter.com/#!/funesyasociados' target='_blank'><img src='images/twitter-fya.png' border='0' width='15px' height='15px'></a></div>");
	}
	
});
