$(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").mouseout( function(){$("#leyendas").css('left','-10000px');})
	if( typeof( $.global_mapaweb ) == "undefined" ){
		$("#mainLeft .mnLf").click(	function(e){
											 $("#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 "mn_municipi":
			leyenda.texto = "Municipi del Pont de Suert";
			leyenda.float = "left";
			leyenda.aling = "right";
		break;
		case "mn_ajuntament":
			leyenda.texto = "Ajuntament del Pont de Suert";
			leyenda.float = "left";
			leyenda.aling = "center";
		break;
		case "mn_serveis":
			leyenda.texto = "Serveis del Pont de Suert";
			leyenda.float = "left";
			leyenda.aling = "left";
		break;
		case "mn_eventos":
			leyenda.texto = "Esdeveniments del Pont de Suert";
			leyenda.float = "left";
			leyenda.aling = "left";
		break;
		case "mn_contacte":
			leyenda.texto = "Contacte";
			leyenda.float = "left";
			leyenda.aling = "center";
		break;
	}
	$("#leyendas").html("<span>"+ leyenda.texto + "</span>");
	$("#leyendas").css('text-align',leyenda.aling)
}
function inicio(){
	IniMenuPral();

	if($("#tabs").length > 0 ) $("#tabs").tabs();
	
	
	//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');
}	

