 $(document).ready(function(){ 
			
	// Preload all rollovers
	$("#menu img").each(function() {
		// Set the original src
		rollsrc = $(this).attr("src");
		rollON = rollsrc.replace(/.gif$/ig,"-over.gif");
		$("<img>").attr("src", rollON);
	});
	
	// Navigation rollovers
	$("#menu a").mouseover(function(){		
		imgsrc = $(this).children("img").attr("src");
		matches = imgsrc.match(/-over/);
		
		// don't do the rollover if state is already ON
		if (!matches) {			
			imgsrcON = imgsrc.replace(/.gif$/ig,"-over.gif"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			
			$("#menu a").mouseout(function(){
				$(this).children("img").attr("src", imgsrc);								 
			});		
		}
	});
					
	/* Hacer Clickable el logo */
	$("#headerimg h1").click(function () { 
      	window.location="/";
    });
	
	/** AVISO LEGAL **/
	$("#aviso").fancybox({
		'hideOnContentClick': false,
		'frameWidth':500,
		'callbackOnClose':function () { $("#bienvenidos").css("display","block"); 	}
	});
	
	$("#aviso").click(function () {
		$("#bienvenidos").css("display","none");
	});
	
	$(window).bind('resize', CambiarMarginLeft);

}); 
 
function CambiarMarginLeft()
{
	ancho = $(window).width();
	if (ancho<1074 && ancho >975)
		nuevoMargin = 537-parseInt((49*(1074-ancho))/111);	
	else if (ancho>=1074)
		nuevoMargin = 537;
	else
		nuevoMargin = 488;

	$("#page").css("margin-left",-nuevoMargin); 
}

