/*
.........................
:: Window Popper ::
.........................
*/

function pop(u,n,f, w, h, c) {
  if(window.screen)if(c)if(c=="1"){
    var l = (screen.width-w)/2;
    var t = (screen.height-h)/2;
    f+=(f!='')?',':'';
    f+='left='+l+',top='+t;
  }
  flop=window.open(u,n,f+((f!='')?',':'')+'width='+w+',height='+h);
  flop.focus();
}


/*
.........................
:: Switch Div ::
.........................
*/

function switchDiv(divNum){
	x=document.getElementById("s" + divNum);
	y=document.getElementById("i" + divNum);
	if(x.style.display != "block"){
		x.style.display="block";
		y.src="img/menuOpen.gif";
	}else{
		x.style.display="none";
		y.src="img/menuClosed.gif";
    }
}


/*
.........................
:: The xRollovers ::
.........................
*/

// OPCIÓ SELECCIONADA PER A CADA MENÚ
var AmbClick = new Array();
AmbClick[0] = 0; //MENU principal
AmbClick[1] = 0; //SUBMENU


// NUMERO D'OPCIONS DELS MENÚS
var NMenus = new Array();
NMenus[0] = 5;
NMenus[1] = 8;


function MsOver(qui,index,nom,marc) {
	for (var cont = 1; cont < NMenus[index]+1; cont++)
	{ if (qui==cont && AmbClick[index]!=cont) {
	    x=document.getElementById(nom+cont);
		if (marc == "submenu") {
			x.src = "../rcs/"+nom+"_on.gif";
		} else {
	    	x.src = "rcs/"+nom+cont+"_on.gif";
			}
	    }
	}
}

function MsOut(qui,index,nom,marc) {
	for (var cont = 1; cont < NMenus[index]+1; cont++)
	{ if (qui==cont && AmbClick[index]!=cont) {
	    x=document.getElementById(nom+cont);
		if (marc == "submenu") {
			x.src = "../rcs/"+nom+".gif";
		} else {
	    	x.src = "rcs/"+nom+cont+".gif";
			}
 	    }
	}
}

function MsOnclick(qui,index,nom,marc) {
	MsOver(qui,index,nom,marc);
	for (var cont = 1; cont < NMenus[index]+1; cont++)
	{ if (AmbClick[index]==cont) {
	    x=document.getElementById(nom+cont);
		if (marc == "submenu") {
			x.src = "../rcs/"+nom+".gif";
		} else {
	    	x.src = "rcs/"+nom+cont+".gif";
			}
	    }
	}
	AmbClick[index]=qui;
}


/*
.........................
:: Cookie Recipes ::
.........................
*/

function saveCookie(name,value,days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000))
                var expires = "; expires="+date.toGMTString()
        }
        else expires = ""
        document.cookie = name+"="+value+expires+"; path=/"
}

function readCookie(name) {
        var nameEQ = name + "="
        var ca = document.cookie.split(';')
        for(var i=0;i<ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length)
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length)
        }
        return null
}

function deleteCookie(name) {
        saveCookie(name,"",-1)
}


/*
.........................
:: Event Listener Interface ::
.........................
*/

function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    //alert("Handler could not be attached");
  }
}

function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    //alert("Handler could not be removed");
  }
}

/*
.........................
:: NAVIGATION FUNCTIONS ::
.........................
*/

function contenido(pagina) {
	// Ejecuta el link de los submenús
	top.contenido.document.location.href = pagina;
	}

function quienesomos() {
	top.submenus.document.location.href = "quienesomos/submenu.htm";
	top.contenido.document.location.href = "quienesomos/index.php";
	top.banners.document.getElementById('foto1').src = "rcs/fotosa5.jpg";
	top.banners.document.getElementById('foto2').src = "rcs/fotosb6.jpg";
	top.imagenes.document.getElementById('imagen').src = "rcs/imagenes3.jpg";
	}

function actividad() {
	top.submenus.document.location.href = "actividad/submenu.htm";
	top.contenido.document.location.href = "actividad/index.php";
	top.banners.document.getElementById('foto1').src = "rcs/fotosa6.jpg";
	top.banners.document.getElementById('foto2').src = "rcs/fotosb3.jpg";
	top.imagenes.document.getElementById('imagen').src = "rcs/imagenes2.jpg";
	}

function referencias() {
	top.submenus.document.location.href = "referencias/submenu.htm";
	top.contenido.document.location.href = "referencias/index.php";
	top.banners.document.getElementById('foto1').src = "rcs/fotosa7.jpg";
	top.banners.document.getElementById('foto2').src = "rcs/fotosb2.jpg";
	top.imagenes.document.getElementById('imagen').src = "rcs/imagenes7.jpg";
	}

function prensa() {
	top.submenus.document.location.href = "prensa/submenu.htm";
	top.contenido.document.location.href = "prensa/index.php";
	top.banners.document.getElementById('foto1').src = "rcs/fotosa4.jpg";
	top.banners.document.getElementById('foto2').src = "rcs/fotosb4.jpg";
	top.imagenes.document.getElementById('imagen').src = "rcs/imagenes4.jpg";
	}

function contacto() {
	top.submenus.document.location.href = "contacto/submenu.htm";
	top.contenido.document.location.href = "contacto/index.php";
	top.banners.document.getElementById('foto1').src = "rcs/fotosa3.jpg";
	top.banners.document.getElementById('foto2').src = "rcs/fotosb5.jpg";
	top.imagenes.document.getElementById('imagen').src = "rcs/imagenes6.jpg";
	}
	
function descargas() {
	top.submenus.document.location.href = "descargas/submenu.htm";
	top.contenido.document.location.href = "descargas/index.php";
	top.banners.document.getElementById('foto1').src = "rcs/fotosa8.jpg";
	top.banners.document.getElementById('foto2').src = "rcs/fotosb8.jpg";
	top.imagenes.document.getElementById('imagen').src = "rcs/imagenes8.jpg";
	}