jQuery(document).ready( function()
{
 //posicionarObjetos ();
 //jQuery(window).resize(function(){ posicionarObjetos (0); });
 
 //efectoLogo ();
 
 efectoMenu ();
 
 efectoBotonesEntrenamieto ();
 
 efectoBotonesInicio ();

 //ajustarAlturas (0);

});

//
// POSICIONAR Y DIMENSIONAR TODOS LOS OBJETOS
//
function posicionarObjetos ( tipo )
{
 var altura = jQuery(window).height();
 var alturaContent = jQuery('#content').height() +12 +12 +20; // top + bottom + footer
 
 if (altura >= alturaContent)
 {
  altura = (altura - alturaContent)/2; 
  jQuery('#footer').css('margin-bottom', altura+'px');
  jQuery('#top').css('margin-top', altura+'px');
 }
  else
 {
  jQuery('#footer').css('margin-bottom', '10px');
  jQuery('#top').css('margin-top', '0px');
 }
 
 if (tipo == 0)
  window.setTimeout( function(){posicionarObjetos (1);},500); 
}

//
// EFECTO DEL LOGO
//
function efectoLogo() {
	jQuery('#logo').hover (
	 function () { jQuery(this).attr('src',templateUrl+'/img/logo-hover.png'); },
	 function () { jQuery(this).attr('src',templateUrl+'/img/logo.png');} );	
}

//
// EFECTO DEL MENU
//
function efectoMenu ()
{
	jQuery('#menu ul li a').hover (
	 function () { jQuery(this).stop().animate({ paddingTop: 20 },200); },
	 function () { jQuery(this).stop().animate({ paddingTop: 10 },200); } );
}

function ajustarAlturas (tipo)
{
 // Ajusta las alturas del sidebar y el contenido
 var alturaSidebar = jQuery('#sidebar').height();
 var alturaContenido = jQuery('#contenido').height();
 alturaContenido = alturaContenido + (jQuery('.post h3').height()+17+3);
 
 if ( alturaContenido < alturaSidebar ) 
  jQuery('#contenido').height (alturaSidebar-(jQuery('#sidebar h2').height()+18+3)+11);
 else if ( alturaContenido > alturaSidebar )
 {
  var nuevaAltura = alturaContenido-50+10;
  jQuery('#sidebar').height (nuevaAltura);
  
  //var nuevaAltura = nuevaAltura-(jQuery('#sidebar h2').height()+18+3)-(jQuery('.post h3').height()+17+3);
  //jQuery('#sidebar').height(nuevaAltura);
 }
 
 jQuery('#contenido').css('margin-bottom','10px');
 
 // RECARGAR THICKBOX
 
 if (tipo < 10)
   window.setTimeout( function(){ ajustarAlturas (tipo+1); },200);
}

//
// ENTRENAMIENTOS
//
function efectoBotonesEntrenamieto ()
{
	jQuery('.boton_entrenamiento').hover (
	 function () { jQuery(this).stop().animate({ width: 390 },650); },
	 function () { jQuery(this).stop().animate({ width: 190 },650); } );
}

//
// INICIO
//
function efectoBotonesInicio ()
{	
	
	jQuery('.botonlateral').hover (
	 function () {
		 		  jQuery("#botonera_lateral").css("z-index","20");
				  jQuery("#botonera_arriba").css("z-index","10");
				  
		 		  jQuery(this).stop().animate({ width: 300 },500);
				 },
	 function () {
				  // Obtenemos la clase
		 		  var clase = jQuery(this).attr('class');
				  
				  // Realizamos la animación dependiendo de si es cirrent o no
		 		  if ( clase.indexOf ('actual') == -1 )
		 		   jQuery(this).stop().animate({ width: 70 },500);
				  else
				   jQuery(this).stop().animate({ width: 85 },500);
				 } );
	
	jQuery('.botonvertical').hover (
	 function () {		 
		 		  jQuery("#botonera_lateral").css("z-index","10");
				  jQuery("#botonera_arriba").css("z-index","20");
		 		  jQuery(this).stop().animate({ height: 300 },500);
				 },
	 function () {				  
				  var clase = jQuery(this).attr('class');
		 		  if ( clase.indexOf ('actual') == -1 )
		 		   jQuery(this).stop().animate({ height: 70 },500);
				  else
				   jQuery(this).stop().animate({ height: 85 },500);
				 } );
}







