function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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[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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,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 (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

// Funcions per mostrar/ocultar blocs
function showInline (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.display = "inline";
	}
}
function hideInline (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.display = "none";
	}
}
function showhideInline (elName) {
	var theElemenet = document.getElementById(elName);
	if(theElemenet.style.display=='none') {
		theElemenet.style.display='inline';
	} else {
		theElemenet.style.display='none';
	}
}

// 
MM_reloadPage(true);
Indx=0;
BGimgportada = new Array();

BGimgportada[0] = ['#9a3232','#6f7870','#e7edfa'];
BGimgportada[1] = ['#7c6494','#837a64','#f2e6e8'];
BGimgportada[2] = ['#e33c29','#634e65','#efe6f0'];
BGimgportada[3] = ['#9a2721','#df3930','#f5e6e6'];
BGimgportada[4] = ['#b59970','#6f7870','#f5f0e8'];
BGimgportada[5] = ['#e66007','#6f7870','#e7edfa'];
BGimgportada[6] = ['#74959b','#5b7184','#e6ebf2'];
BGimgportada[7] = ['#ff2d20','#473649','#e6ecf2'];

function newImage(esportada) {
// Genera un enter entre 0 i 10
// afegim ?01 a les imatges per forçar reload quan es canvien le imatges si modifiquem el número
// el navegador no l'agafa de la cache
Indx = Math.round(Math.random()*7);
document.getElementById("cap").style.backgroundImage = "url(/img/cstop_fons" + Indx + ".gif?01)";
if (esportada) {
	document.getElementById("contingut").style.backgroundImage = "url(/img/imgporta" + Indx + ".jpg?01)";
	var DivItems = document.getElementById("serveis").getElementsByTagName("li");
	for (var i=0;i<DivItems.length;i++){
		if (DivItems[i].className == "titolsecc") {
			DivItems[i].style.backgroundColor = BGimgportada[Indx][0];
		}
	}
	
	var DivItems = document.getElementById("recursos").getElementsByTagName("li");
	for (var i=0;i<DivItems.length;i++){
		if (DivItems[i].className == "titolsecc") {
			DivItems[i].style.backgroundColor = BGimgportada[Indx][1];
		}
	}	
}
else {
	document.getElementById("contingut").style.backgroundImage = "url(/img/imgporta_dins" + Indx + ".jpg?01)";
}
//document.getElementById("webbasics").style.backgroundColor = BGimgportada[Indx][1];
//document.imgporta.src = "img/imgporta" + Indx + ".jpg";
//document.getElementById("recursos_iula").style.backgroundColor = BGimgportada[Indx][1];
//document.getElementById("recursos_online").style.backgroundColor = BGimgportada[Indx][1];
//document.getElementById("serveis_dreta").style.backgroundColor = BGimgportada[Indx][2];
//document.getElementById("imgportada").style.backgroundColor = BGimgportada[Indx][0];
//document.getElementById("serveis_dreta").style.borderColor = BGimgportada[Indx][0];
//document.classes.all.titolsecc.backgroundColor = BGimgportada[Indx][2];

}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

