var menuArray = ['dummy', 'tecnocampus', 'estrategia', 'xarxa', 'innovacio', 'historic', 'noticies', 'parc', 'normativa', 'emprenedoria', 'serveis_empreses', 'rdi'];

var loadingImg = "<img src='img/loading.gif'>";
var sw = 0;

//función que se llama cuando se han terminado de cargar los resultados
//de la consulta
function yasta(target){ 
	if(sw==0){ //necessita uns moments per poder llegir el contingut del iframe una vegada carregat
		sw=1;
		setTimeout("yasta('" + target + "')", 50);
   }
   else{
       if(document.all){
		  document.getElementById(target).innerHTML=document.frames['loader'].document.body.innerHTML;
       }
       else{
		  document.getElementById(target).innerHTML=window.frames['loader'].document.body.innerHTML;
       }
   }
   
}

//función que carga la url suministrada en el buffer oculto y
//muestra la img de "cargando" en la capa indicada
function fload(url, target){
	document.getElementById(target).innerHTML = loadingImg;
	
   if(document.all){	   
       document.frames['loader'].location.href = url;
   }
   else{
       window.frames['loader'].location.href = url;
   }
   sw=0;
} 

// funcio per afegir events onload addicionals
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function getWindowWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myWidth;
  
}

function centraDiv(id, width){
	var win_width=getWindowWidth();
	var left=(win_width/2)-(width/2)

	$(id).style.left=left+"px";
}

// funcio que amaga el banner de la intro en la home i mostra el que toqui
function fhideBanner(){ 
	document.getElementById('banner_intro').style.display = 'none';
	document.getElementById('banner_campanya').style.display = 'inline';
}

function init(){
//	if(menu){ /
		// mostra la capa del menu que toca
		document.getElementById(menuArray[menu]).style.display = 'inline';
		
		//poso el estil "seleccionat" en el menu que toca
		document.getElementById('menu_' + menuArray[menu]).className = 'menu_on';

		//poso el estil "seleccionat" en el submenu que toca
		document.getElementById(menuArray[menu] + '_' + submenu).className = 'submenu_on';
//}
	
	//poso el estil "seleccionat" en el menu de idioma que toca
	//document.getElementById(idioma).className = 'idiomes_on';
	
	// despres de 1 segon, trec el banner de la intro en la home i mostro el que toqui
	// (nomes si estem a la home)
	/*if(document.getElementById('banner_intro')){
		setTimeout('fhideBanner()', 1000);
	}*/
		
}

function $(id){
	return document.getElementById(id)	
}

window.defaultStatus = 'TecnoCampusMataró';

//window.onload = init;