function FullScreenBackgroundOnLoad() {    
	FullScreenBackground('.slide');
	
	$(function () {
		var $pxs_bgHead = $('#pxs_HeadImage')
		var $pxs_container = $('#pxs_container');
		var $pxs_bg = $('.pxs_bg DIV');
		var $pxs_container = $('#pxs_container');
		var $pxs_destacado = $('.pxs_slider .destacado img');
		
		$pxs_bgHead.fadeIn(2000,function(){
			$pxs_container.show();			
			$pxs_bg.fadeIn('fast', function() {												
				$pxs_bgHead.addClass('pxs_HideHeadImageNo');				
				$pxs_container.parallaxSlider();
				$pxs_destacado.fadeIn('fast', function(){										
					//
				});							
			});		
		});
	}); 
}

function FullScreenBackground(theItem){
	var winWidth=$(window).width();
	var winHeight=$(window).height();
	var imageWidth=$(theItem).width();
	var imageHeight=$(theItem).height();
	var picHeight = imageHeight / imageWidth;
	var picWidth = imageWidth / imageHeight;

	if ((winHeight / winWidth) < picHeight) {
		$(theItem).css("width",winWidth);
		$(theItem).css("height",picHeight*winWidth);
	} else {
		$(theItem).css("height",winHeight);
		$(theItem).css("width",picWidth*winHeight - 51);
	};

	$(theItem).css("margin-left",winWidth / 2 - $(theItem).width() / 2);
	$(theItem).css("margin-top",winHeight / 2 - $(theItem).height() / 2);
};

//OnLoad
_spBodyOnLoadFunctionNames.push("FullScreenBackgroundOnLoad"); 

$(window).resize(function() {
    FullScreenBackground('.slide');
});

$(window).load(function() {
    FullScreenBackground('.slide');
});

$(document).ready(function() {		
	/**/	
    $('.highlights ul li').hide();
	
    /*** Muestra los destacados abiertos por 10Seg ***/
	$('a.plus').click();
		setTimeout(function () {
			$('a.plus').click();
		}, 5000);
    /******/
  
    /*** Manejador del la palabra "Destacados" ***/
    $('a.plus').click(function() {
 	    $('.highlights ul li').slideToggle('slow', 'swing', 
	      function() {
			    if ($('a.plus span').hasClass('up'))
			    {
			        $('a.plus span').removeClass('up');
			        $('a.plus span').addClass('down');
			        $('#text-content').stop(true,true).fadeOut("slow");
			    }
			    else{
			        $('a.plus span').removeClass('down');
			        $('a.plus span').addClass('up');
			        $('#text-content').stop(true,true).fadeIn("slow");
			    }
		    }
	    );	
	    return false;	
    });
  
    /*** Manejo de laws flechas del slider ***/
	$('.highlights ul li').click(function() {
		$('.dest').slideToggle(1000, "linear");
	});	  
	$('span.pxs_next').click ( function (){
	FullScreenBackground('img.slide');
	}); 	  
	$('span.pxs_prev').click ( function (){
	FullScreenBackground('img.slide');
    }); 
    /******/
    
	/*** Manejador de las solapas de destacados de la home***/
    $('.highlights #a1').mouseover(function() {
      $('#caja-cont1').stop(true,true).animate({"margin-top":"80px"});
	});
	//console.log($('.highlights #a1'));
	$('.highlights #a1').mouseout(function() {
       $('#caja-cont1').stop(true,true).animate({"margin-top":"130px"});
	});	
	$('.highlights #a2').mouseover(function() {
	    $('#caja-cont2').stop(true, true).animate({ "margin-top": "80px" });
	});	
	$('.highlights #a2').mouseout(function() {
       $('#caja-cont2').stop(true,true).animate({"margin-top":"130px"});
	});	
	$('.highlights #a3').mouseover(function() {
	    $('#caja-cont3').stop(true, true).animate({ "margin-top": "80px" });
	});	
	$('.highlights #a3').mouseout(function() {
       $('#caja-cont3').stop(true,true).animate({"margin-top":"130px"});//131
	});
    /******/ 
});
