function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;if(!d) d=document;
  if((p=n.indexOf("?"))>0 &&parent.frames.length){
    d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);
  }
  if(!x && d.getElementById){x=d.getElementById(n); return x;}
  if(!(x=d[n]) && d.all){ x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];}
  for(i=0;!x&&d.layers&&i<d.layers.length;i++){ x=MM_findObj(n,d.layers[i].document);}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,m,obj,args=MM_showHideLayers.arguments;  
    for (i=0; i<(args.length-2); i+=3)
      if ((obj=MM_findObj(args[i]))!=null) {
        v=args[i+2];
	if (v == "show") m = 'block';
	else m = 'none';
        if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	obj.visibility = v;
	obj.display = m;
	
      }  
}

function colorObj(obj,color){ 
  if (obj && obj.style){
   obj=obj.style;
   obj.backgroundColor=color;
  }
}


function color(id,color){
  obj=MM_findObj(id,document);
  if (obj && obj.style){
   obj=obj.style;
   obj.backgroundColor=color;
  }
}
 

function cambiaEnlace(id,clase){
  document.getElementById(id).className=clase;
}
function inici_esquerra() {
	var TheWindowWidth = (document.all) ? document.body.clientWidth : window.innerWidth;
	var esquerra=Math.max(parseInt((TheWindowWidth-776) / 2),0);	
        if(!document.all)esquerra=esquerra-9;
 return esquerra;
}

function posicio_capa(id,left_offset,top,width){
  obj=MM_findObj(id);
  if (obj && obj.style){
    obj=obj.style;
    obj.left=(inici_esquerra()+left_offset)+"px";
	if(top>0)obj.top=top+"px";
    obj.width=width+"px";
  }
}

function posicio_subcapa(idsubcapa,idcapa,left_offset,width){
	objP=MM_findObj(idcapa);
	obj=MM_findObj(idsubcapa);
	if (objP && objP.style && obj && obj.style){
	  objP=objP.style;
	  obj=obj.style;
	  obj.left=(left_offset+parseInt(objP.width))+"px";
      obj.width=width+"px";
    }
}


function mostra_contingut(nrecipient,idcontingut,nomMenu,nomImg,nomCont,maximo){
  idMenu=nomMenu+nrecipient;
  objMenu=MM_findObj(idMenu);
  idImg=nomImg+nrecipient;
  objImg=MM_findObj(idImg);
  idRecip=nomCont+nrecipient;
  objRecip=MM_findObj(idRecip);
  if(objRecip && objRecip.style && objMenu && objMenu.style && objImg && objImg.style)
  {   
    for(i=1;i<=maximo;i++)
    {
      idObjM=nomMenu+i;
      idObjI=nomImg+i;
      idObj=nomCont+i;
      if(idRecip!=idObj)
      {
        objM=MM_findObj(idObjM);
		objI=MM_findObj(idObjI);
        obj=MM_findObj(idObj);      
        if(obj && obj.style && objM && objM.style && objI && objI.style)
	{
	  objM=objM.style;
	  objI=objI.style;
          obj=obj.style;
//	  objM.color='#7d7b7a';
          objI.visibility='hidden';
	  obj.display='none';	  
        }
      }
    }    
    objMenu=objMenu.style;    
    objImg=objImg.style;
    objRecip=objRecip.style;
//    objMenu.color='#135b6e';
    objImg.visibility='visible';
    objRecip.display='block';

	var j = 1;
	for(j=1;j<=maximo;j++){
		var menu = nomMenu+j;
		if(j!=nrecipient)document.getElementById(menu).className="texto_normal";
                else document.getElementById(menu).className="texto_destacado";
	}
  }  
}

function resizeHandler(){
  //MODIFICAR EN CAS DE CANVIAR POSICIO LEFT O WIDTH DE LES CAPES
  //Predomina LEFT i WIDTH del javaScript sobre la fulla d'estils
  posicio_capa("Layer4",530,77,127);//capa Estudiants UAB
  posicio_capa("Layer5",637,77,127);//capa Personal UAB
}

function resizeMain(){
  //MODIFICAR EN CAS DE CANVIAR POSICIO LEFT O WIDTH DE LES CAPES
  //Predomina LEFT i WIDTH del javaScript sobre la fulla d'estils
  posicio_capa("Layer4",530,155,127);//capa Estudiants UAB
  posicio_capa("Layer5",640,155,127);//capa Personal UAB
}

function init(){
  resizeHandler();
  window.onresize= resizeHandler;
}

function initMain(){
  resizeMain();
  window.onresize=resizeMain; 
}
