// External link
$(document).ready(function() {
  $('#extlinks a').filter(function() {
	return this.hostname && this.hostname !== location.hostname;
  }).after(' <img src="/templates/v1/images/external-trans.png" alt="External link">');
});


// Precarga images
var i;
var images = new Array("/templates/v1/images/headerBack.jpg", "/templates/v1/images/logo-trans.png", "/templates/v1/images/png-trans.png");
var imagesList = new Array();
for(i in images){
	imagesList[i] = new Image();
	imagesList[i].src = images[i];
}


// Map Classes
function spreadOut(elem)
{
	if(document.getElementById(elem).className == 'hd')
		document.getElementById(elem).className='sp';
	else
		document.getElementById(elem).className = 'hd';
}		
function hide(elem)
{
	document.getElementById(elem).className = 'hd';
}		

function spreadOutMap(elem)
{
	document.getElementById(elem).className='sp';
}		


/// Fonts
var newsfont = 1; 
function changeFont(id)
{
	if(document.getElementById) 
		document.getElementById(id).style.fontSize = newsfont+"em"; 
	else if(document.layers)
		document.layers[id].fontSize = newsfont+"em"; 
	else if(document.all)
		eval("document.all." + id + ".style.fontSize = \"" + newsfont + "em \""); 
} 
function larger()
{ 
    if (newsfont < 1.4)
        newsfont= newsfont +0.2; 
        changeFont('wrapper');
} 
function smaller()
{ 
    if (newsfont > 1)
		newsfont= newsfont -0.2; 
		changeFont('wrapper'); 
} 


// Favorite
function bookmarkLink(url,titulo) {
	if (window.sidebar)
		window.sidebar.addPanel(titulo, url,"");
	else if(window.external)
		window.external.AddFavorite( url, titulo); 
	else if(window.opera && window.print)
		window.external.AddFavorite( url, titulo); 
}

// Validación del buscador
function validateSearch(params,programme,speciality){
	
	if( (params=='undefined' || params==null || params=='')  && (programme=='undefined' || programme==null || programme=='') && (speciality=='undefined' || speciality==null || speciality=='') ) {
		document.getElementById('searchStatus').innerHTML='You must enter some keywords, or filter by programme/speciality';
	} else {
		document.getElementById('searchStatus').innerHTML='';
		document.getElementById('search').submit();
	}
	
}