/***** COOKIES *****/

function setCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString() + "; path=/";
}

function readCookie(cookieName) {
	var theCookie=""+document.cookie;
	var ind=theCookie.indexOf(cookieName);
	if (ind==-1 || cookieName=="") return ""; 
	var ind1=theCookie.indexOf(';',ind);
	if (ind1==-1) ind1=theCookie.length; 
	return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}



function imagen_fondo() {

// Advanced Random Images Start
// Copyright 2001-2002 All rights reserved, by Paul Davis - www.kaosweaver.com
  var j,d="",l="",m="",p="",q="",z="",KW_ARI= new Array();
  KW_ARI[KW_ARI.length]='images/pagina1_03.jpg';
  KW_ARI[KW_ARI.length]='images/pagina1_04.jpg';
  KW_ARI[KW_ARI.length]='images/pagina1_05.jpg';
  KW_ARI[KW_ARI.length]='images/pagina1_06.jpg';
  KW_ARI[KW_ARI.length]='images/pagina1_07.jpg';
  KW_ARI[KW_ARI.length]='images/pagina1_08.jpg';
  KW_ARI[KW_ARI.length]='images/pagina1_09.jpg';
  KW_ARI[KW_ARI.length]='images/pagina1_10.jpg';
  KW_ARI[KW_ARI.length]='images/pagina1_11.jpg';
  KW_ARI[KW_ARI.length]='images/pagina1_12.jpg';
  j=parseInt(Math.random()*KW_ARI.length);
  j=(isNaN(j))?0:j;
 return ("<td width=355  height=96 bgcolor=#000000 > <img src="+KW_ARI[j]+" width=355 height=96 alt=Banner Centres de la Ramón Llull al banner></td>");
  // return( 	"<td width=355 style=background:url("+KW_ARI[j]+") no-repeat; valign=top></td>");
// 	<td width="442" style="background:url(images/pagina1_03.jpg) no-repeat;" valign="top">
// Advanced Random Images End


}


//get main style sheet
var pre = "<link rel=stylesheet href=\"css/estilos_"
var post = ".css\">"
if(readCookie("estilos")!=""){
	var estilos = readCookie("estilos");
}else{
	var estilos = "0";
}
document.write(pre+estilos+post);

//get menu js
var js;
switch (estilos){
	case "3":
		js = 'expanding-multiple_3.js';
		break;
	default:
		js = 'expanding-multiple.js';
		break;
}
pre = "<script type=\"text/javascript\" src=\"menuvert/udm-resources/";
post = "\"></script>"
document.write(pre+js+post);

function setCss(css){
	setCookie("estilos", css, 30);
	window.location.reload();
}

function openMap(_url){
	window.open(_url, 'mapaWin', 'width=400,height=400');
}

function openIntranet(_url){
	window.open(_url, 'mapaWin', 'width=800,height=600');
}
function adjustTarget(target){
	var links = document.getElementsByTagName('a');
	for (var i=0; i<links.length; i++){
		links[i].href = 'javascript:openMapLink(\''+links[i].href+'\');'
	}
}

function openMapLink(href){
	window.opener.location = href;
	window.close();
}

function createJsLinks(){
	var lnk = document.getElementById("lnkMapa");
	lnk.onclick = new Function("openMap('"+lnk.href+"');return false;");
//	lnk = document.getElementById("lnkIntranet");
//	lnk.onclick = new Function("openIntranet('"+lnk.href+"');return false;");
	lnk = document.getElementById("lnkCss_0");
	lnk.onclick = new Function("setCss('0');return false;");
	lnk = document.getElementById("lnkCss_1");
	lnk.onclick = new Function("setCss('1');return false;");
	lnk = document.getElementById("lnkCss_2");
	lnk.onclick = new Function("setCss('2');return false;");
	lnk = document.getElementById("lnkCss_3");
	lnk.onclick = new Function("setCss('3');return false;");
	lnk = document.getElementById("lnkCss_4");
	lnk.onclick = new Function("setCss('0');return false;");
}

function init(){	
	createJsLinks();
}