function noCache(uri){return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567)};
function loadNotices(){
	lang = getLang();
	if( document.getElementById("noticias_content") != undefined ){
		tipo = getType();
		$("#noticias_content").load(noCache( "/proxynoticias.asp?type="+tipo+"&lang="+lang ), { }, function(){
			irNoticia();
		});
	}
	if( document.getElementById("noticias_thumbs") != undefined ){
		$("#noticias_thumbs").load(noCache( "/proxynoticiasthumb.asp?lang="+lang ));
	}
}
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }

    return vars;
}
function getType(){
	var vars = getUrlVars();
	
	if( vars['page'].indexOf('prensa') > 0 ){
		return 1; //prensa
	} else  {
		return 2; //eventos
	}
}
function getLang(){
	var vars = getUrlVars();
	
	if( vars['lang'] ){
		return vars['lang'];
	} else  {
		if( vars['page'].length > 2 ) {
			return vars['page'].substring(0,2);
		} else {
			return 'es'; //default
		}
	}
}
function irNoticia(){
	var redirect = window.location.href.indexOf( "#" );
	if( redirect > 0 ){
		var id_noticia = window.location.href.substring(redirect+1);
		var dest = 'anchor_noticia_'+id_noticia;
		var destination = $('#'+dest).offset().top;
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100, function() {
			window.location.hash = id_noticia;
		});
		return false;
	}
}