/********* FUNCIÓ DE POPUP  ***************/
/* html/js*/
function open_fotohi(titulo,foto,altura,anchura)
		{
			var anchura_ventana
			if(anchura>=500) {anchura=500;anchura_ventana=550}
			if(anchura<500) {anchura_ventana=anchura+50;}
			msgwindow=open("pop_fotohigh.htm?titulo=" + titulo + "&foto=" + foto + "&anchura=" + anchura,"FotoamP","width=" + anchura_ventana + ",height=" + altura + ",scrollbars=yes,resizable=yes");
		}
		
//DESCRIPTION:  Obre una finestra, tipo Pop-up General
function obrePopupGeneral(sURL, iWidth, iHeight){
	//comprovació navegador
	var sNav = navigator.userAgent;
	var nInd_gk = sNav.indexOf("Gecko");
	if (nInd_gk != -1){
		iWidth += 4;
		iHeight += 4;
	}
	var anPos_final = new Array();
    var iWidthAux = (screen.availWidth - iWidth) / 2;
    var iHeightAux = (screen.availHeight - iHeight) / 2;
	var sParam = 'toolbar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no,menubar=no,width='+iWidth+',height='+iHeight+',left='+iWidthAux+',top='+iHeightAux;
    var wPopup = window.open(sURL,"finestra",sParam);
}

function muestraoculta(idObj) {
	obj = document.getElementById(idObj);
	if (obj.style.display == "block") obj.style.display = "none";
	else obj.style.display = "block";
}

function ocultatodo(numcapas) {
	for(i=1; i<=numcapas; i++) {
		ncapa = "capa" + i;
		obj	= document.getElementById(ncapa);
		obj.style.display = "none";
	}	
}

function ocultarueda(numruedas) { //Las rueda se empieza a contar desde 0
	for(i=0; i<=numruedas; i++) {
		nrueda = "rueda" + i;
		obj	= document.getElementById(nrueda);
		obj.style.display = "none";
	}	
}

function muestrarueda(idObj) {
	obj = document.getElementById(idObj);
	obj.style.display = "block";
}

var aleatorio = Math.floor(Math.random()*15); //Rueda: empieza por una imagen aleatoria
function countMyself() {
    if ( typeof countMyself.counter == 'undefined' ) {  // Check to see if the counter has been initialized
        countMyself.counter = aleatorio;
    }
	countMyself.counter++;
	j=countMyself.counter%16; //Hay 16 imagenes en la rueda
	ocultarueda(15);  //pero empiezan por 0
	muestrarueda('rueda'+j);
}

var challenge = new Date();
var myChallenge = challenge.getTime();

//Para cargar la capa catalogo catalan
var urlCatalogoCa="http://www.astrosabadell.org/html/capas/catalogo_ca.txt";
function catalogoCa() {
	_ajax.cargarUrl(new AjaxPeticion(urlCatalogoCa+"?challenge=" + myChallenge, "contenidocapa", null, true), 1);
}

//Para cargar la capa catalogo castellano
var urlCatalogoEs="http://www.astrosabadell.org/html/capas/catalogo_es.txt";
function catalogoEs() {
	_ajax.cargarUrl(new AjaxPeticion(urlCatalogoEs+"?challenge=" + myChallenge, "contenidocapa", null, true), 1);
}

//Para cargar la capa mitologia catalan
var urlMitologiaCa="http://www.astrosabadell.org/html/capas/mitologia_ca.txt";
function mitologiaCa() {
	_ajax.cargarUrl(new AjaxPeticion(urlMitologiaCa+"?challenge=" + myChallenge, "contenidocapa", null, true), 1);
}

//Para cargar la capa mitologia castellano
var urlMitologiaEs="http://www.astrosabadell.org/html/capas/mitologia_es.txt";
function mitologiaEs() {
	_ajax.cargarUrl(new AjaxPeticion(urlMitologiaEs+"?challenge=" + myChallenge, "contenidocapa", null, true), 1);
}

videos = new Array();
videos[0] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/ha4AMohZFzI&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ha4AMohZFzI&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[1] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/yHMAQKSJFhI&hl=es_ES&fs=1&rel=0&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/yHMAQKSJFhI&hl=es_ES&fs=1&rel=0&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[2] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/KGzKymc1pGE&hl=es_ES&fs=1&rel=0&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/KGzKymc1pGE&hl=es_ES&fs=1&rel=0&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[3] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/82CxyDX2yns&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/82CxyDX2yns&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[4] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/baaGOqIJaFM&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/baaGOqIJaFM&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[5] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/HnhCBejIsM4&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/HnhCBejIsM4&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[6] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/7HXjopsobPg&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/7HXjopsobPg&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[7] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/OZH28se9Na4&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/OZH28se9Na4&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[8] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/ZvQWjlxMs4A&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ZvQWjlxMs4A&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[9] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/nis2t9EubBs&amp;hl=es_ES&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/nis2t9EubBs&amp;hl=es_ES&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[10] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/EeXEcsZZLPQ&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/EeXEcsZZLPQ&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[11] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/D0F2TK_Tj6Y&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/D0F2TK_Tj6Y&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[12] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/ww-qwI2w6r8&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ww-qwI2w6r8&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[13] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/o4YUXpB-3mE&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/o4YUXpB-3mE&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[14] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/xt9Bvc8s_d0&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/xt9Bvc8s_d0&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[15] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/0welGFpThTA&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/0welGFpThTA&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[16] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/17jymDn0W6U&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/17jymDn0W6U&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[17] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/CEe8vzJjj3M&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/CEe8vzJjj3M&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[18] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/E8K4m0bpm_Q&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/E8K4m0bpm_Q&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[19] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/kK4n5l7bHSw&amp;hl=es_ES&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/kK4n5l7bHSw&amp;hl=es_ES&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>'
videos[20] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/V2uGq0BNZbI&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/V2uGq0BNZbI&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[21] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/v7HDfkngv7o&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/v7HDfkngv7o&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[21] = '<object width="250" height="160"><param name="movie" value="http://www.youtube.com/v/uagcjOIXuX8&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/uagcjOIXuX8&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[22] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/5w-GC0Q78zU&hl=es_ES&fs=1&rel=0&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/5w-GC0Q78zU&hl=es_ES&fs=1&rel=0&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[23] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/4a_lDbvFc4E&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/4a_lDbvFc4E&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[24] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/oAVjF_7ensg&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/oAVjF_7ensg&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[25] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/NW7WGMteGis&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/NW7WGMteGis&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[26] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/jqxSAaqXA-c&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/jqxSAaqXA-c&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[27] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/0J8srN24pSQ&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/0J8srN24pSQ&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[28] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/R3-OcZF8-Fc&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/R3-OcZF8-Fc&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[29] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/CPv_Y3e3R_w&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/CPv_Y3e3R_w&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[30] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/q6m5Ughaukc&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/q6m5Ughaukc&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[31] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/c2UOFqK-elQ&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/c2UOFqK-elQ&hl=es_ES&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';
videos[32] = '<object width="250" height="165"><param name="movie" value="http://www.youtube.com/v/EaKbQ5xNi_0&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/EaKbQ5xNi_0&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="250" height="165"></embed></object>';


function ponVideo() {
	stamp = new Date();
	dia = stamp.getDate();
	long=videos.length;
	//k=myChallenge%long;
	k=dia%long;
	//alert("La hora es " + stamp);
	//alert("El dia es " + dia);
	//alert("El valor del video es " +k);
	document.getElementById("tercericono").innerHTML = videos[k]; //videos[k];
}