$(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 inicio(){
/*	debug("_globalApartado: " + "menu_" +_globalApartado,true )
	debug("elemento: " + $("a[id~='menu_"+_globalApartado+"']").length,true )*/
	
	 $("a[id~='menu_"+_globalApartado+"']").each( function() {
		$(this).addClass("actual");
		PutLeyenda($(this).get(0).id);
	})
	
	if($("a[id~='menu_"+_globalApartado+"']").length == 0) PutLeyenda("menu_noticias");
	
	$("a[href*=#ancla_],a[href=#contingut],a[href=#top]").click(function(e) { 
		e.preventDefault(); 
		goToByScroll($(this).attr("href"));           
	});	

	if( $(".top_up").length > 0 ){
		$.globalIsYouTube = true;
		$.globalYouTubeElem = $("iframe[src*=youtube]");
	}
	$(".top_up").click(function(e) { 
		$.globalYouTubeElem.hide();
	});	
	
	$("li[id^='apart_']").click(function(e) { 
		e.preventDefault(); 
		HideAllApartados();
		$("#apartado_" + GetID_number(this) ).show();          
	});	

}

function HideAllApartados(){
	$("li[id^='apart_']").each( function(){
			$("#apartado_" + GetID_number(this) ).hide();
		});
}
function GetID_number(e){
	var id = $(e).attr("id").split("_")
	var n = id[id.length-1];
	return n;
}
function PutLeyenda(apartado){
	var leyenda = {texto:"",float:'left',aling:'left'}
	
	if( !jQuery.browser.msie ) $("#leyendas").hide("fast")
	leyenda.texto = $.leyendas[apartado];
	leyenda.float = "left";
	leyenda.aling = "left";
	/*debug( "cabeceraMenu: " + $("#cabeceraMenu").get(0).className ,true)
	debug( "toggleClass: " + apartado ,true)*/
	$("#cabeceraMenu").toggleClass(apartado)


		if( !jQuery.browser.msie ) $("#leyendas").show("slow")
		$("#leyendas").html("<span>"+ leyenda.texto + "</span>");
		$("#leyendas").css('text-align',leyenda.aling);
}

function goToByScroll(id){
	id = id.replace("#", "");
//	debug(id,true)
	$('html,body').animate({scrollTop: $('*[id*='+id+']').offset().top},'slow');
}	


