$(window).load(function(){
	//preload();
	inicio();
})
$(window).resize(function() {
		
});
function preload(){
	$(document).cdzPreloadImages(
		function(total){/*alert("Preloader has started")*/},
		function(loaded, total){/*$('#loadingstatus').hide();$('#loadingstatus').html("Progreso de precarga : " + loaded + " / " + total)*/}, 
		function(){/*$('#_loadingstatus').hide(); $('#mainpage').show();*/inicio();},
		_globalImgsCss
		
	);
}
function IniMenuPral(){
	$("#mainmenu li").mouseover( function(){$("li",this).show(500); PutLeyenda(this.className);})
	$("#mainmenu li").mouseover( function(){$("#leyendas").css('left','0px');})
	$("#mainmenu li img").mouseover( function(){ $(this).stop().animate({ opacity:0.0 }, 100);})
	$("#mainmenu li img").mouseout( function(){ $(this).stop().animate({ opacity:1.0 }, 200);})
	//$("#mainmenu").mouseout( function(){$("#leyendas").css('left','-10000px');})
	$("#mainLeft .mnLf").click(	function(){ 
										 $("#mainLeft ul").each(function(){$(this).css('display','none');} )
										 $("ul",this).css('display','block') 
										 })
}
function PutLeyenda(apartado){

	var leyenda = {texto:"",float:'left',aling:'left'}
	switch(apartado){
		case "manvert_manvert":
			leyenda.texto = menuempresa;
		break;
		case "manvert_quienes_somos":
			leyenda.texto = "Qui&eacute;nes somos";
			break;
		case "manvert_donde_estamos":
			leyenda.texto = menusituacion;
			break;
		case "manvert_politica":
			leyenda.texto = menupolitica;
			break;
		case "manvert_instalaciones":
			leyenda.texto = menuinstalaciones;
			break;
		case "manvert_calidad":
			leyenda.texto = menucalidad;
			break;
		case "manvert_medioambiente":
			leyenda.texto = menumedioambiente;	
			break;
		case "manvert_productos":
			leyenda.texto = menuproductos;	
			break;
		case "manvert_red":
			leyenda.texto = menured;				
			break;
		case "manvert_noticias":
			leyenda.texto = menunoticias;							
			break;
		case "manvert_clientes":
			leyenda.texto = "Clientes";							
			break;
		case "manvert_faq":
			leyenda.texto = menufaqs;							
			break;
		case "manvert_contacto":
			leyenda.texto = menucontacto;							
			break;
		case "manvert_id":
			leyenda.texto = "I + D";							
			break;	
		case "manvert_croptology":
			leyenda.texto = "Croptology";							
			break;				
		default: leyenda.texto = "Manvert";
	}
	$("#leyendas").html("<span>"+ leyenda.texto + "</span>");
	//$("#leyendas").css('text-align',leyenda.aling)

}
function inicio(){
	IniMenuPral();

	
	PutLeyenda(_globalSubApartado);
	
	//serveis_promoEco_documentos
	$("a[id~='menu_"+_globalSubApartado+"']").each( function() {
		$(this).parent().parent().addClass("actual");						
		$(this).addClass("actual");
	})

	$("a[class=ancla]").click(function(e) { 
		e.preventDefault(); 
		goToByScroll($(this).attr("href"));           
	});	
	$("area[class=ancla]").click(function(e) { 
		e.preventDefault(); 
		goToByScroll($(this).attr("href"));           
	});	
	
}

function goToByScroll(id){
	id = id.replace("#", "");
	$('html,body').animate({scrollTop: $('*[name*='+id+']').offset().top},'slow');
}	

$(document).ready(function() {
	$('#idioma' + _globalLang).css('display','none');
 });


