
/* hack del puto IE para evitar el parpadeo en los rollovers */
if(document.uniqueID && !window.XMLHttpRequest ){
	document.execCommand("BackgroundImageCache",false,true)
}


/* 
	esta función es un hack para I5+/IE6
	"añade" la capacidad de hover a los elementos LI, claseándolos
*/
startList = function()
{
	// hack para IE6, evitando que quite una imagen del menu si tienes el ratón sobre el menú, al cargar la página 
	//document.getElementById("nav1").style.display = "block";
	/*
	maxFoto = new Window('winMaxFoto', {
		width:300, height:200, 
		resizable: false, minimizable: false, maximizable: false
	})
	*/
	//if (readCookie('SCVcookie')!='si') {
	//	createCookie('SCVcookie','si',30);
	//	obrirAvis();
	//}
	
	$(document).ready(function() {
		$("a.fancy_group").fancybox({
			'hideOnContentClick'	: false,
			'zoomOpacity'			: true,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500
		});
	});
	
}

window.onload=startList;

function Pagina(npagg) {
	form = document.forms["miForm"];
	form.npag.value = npagg;
	form.submit();
}

function Foto(idd,ancho,alto) {
	maxFoto.setZIndex(9);
	maxFoto.setSize(ancho,alto);
	maxFoto.setURL('foto.asp?id='+escape(idd));
	maxFoto.showCenter();
}

function FotoId(idd,ancho,alto) {
	idd = document.getElementById(idd).name;
	maxFoto.setZIndex(9);
	maxFoto.setSize(ancho,alto);
	maxFoto.setURL('foto.asp?id='+escape(idd));
	maxFoto.showCenter();
}

function ChangeDate() {
	form = document.forms["miForm"];
	if (form.search_date.value == 'dd/mm/aaaa') {
		form.search_date.value = '';
	}
	document.getElementById("search_date").className = 'campoDate';
}

function ChangeToDate() {
	form = document.forms["miForm"];
	if (form.search_todate.value == 'dd/mm/aaaa') {
		form.search_todate.value = '';
	}
	document.getElementById("search_todate").className = 'campoDate';
}

function ChangeKeyword(sValue) {
	form = document.forms["miForm"];
	if (form.search_keyword.value == sValue) {
		form.search_keyword.value = '';
	}
	document.getElementById("search_keyword").className = 'campoKeyword';
}

function getObject(objectId) { 
		// cross-browser function to get an object's style object given its id
		 if(document.getElementById && document.getElementById(objectId)) return document.getElementById(objectId); 
		 // W3C DOM
		 else if (document.all && document.all(objectId)) return document.all(objectId); 
		 // MSIE 4 DOM
		 else if (document.layers && document.layers[objectId]) return document.layers[objectId];
		 // NN 4 DOM.. note: this won't find nested layers
		 else return false; 
 }


/*********************************
Funcions Galeria Imatges - Plano
**********************************/
function bajaOpacidad(){
if(opa >= 0){
	setOpacity(document.visor, opa);
	opa -=10
	setTimeout('bajaOpacidad()',10)
	}
else{presImagen()}
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function presImagen(){
document.visor.src= srcImage;
subeOpacidad()
}
function subeOpacidad(){
if(opa <= 100){
	setOpacity(document.visor, opa);
	opa += 10
	setTimeout('subeOpacidad()',10)
	}
}

function imatgeJS(nom,src,descripcion,ancho,alto)
{
	this.nom=nom;
	this.source=src;
	this.descripcion=descripcion;
	this.ancho=ancho;
	this.alto=alto;	
}
/*********************************
Fi Funcions Galeria Imatges Plano
**********************************/

function jsHidden(id){
	  var obj = getObject(id);
	  obj.className = "hidden";
 }

/*********************************
Funcions Ocutar Div's
**********************************/
 function items(id,sNomLLista){
      var obj = getObject('item_' + id);
	  obj.className = "contenidoItem";
	  ocultaItems(id, sNomLLista);
	  
 }
 
 //Oculta tots menys id
 function ocultaItems(id, sNomLLista){
      listado = getObject(sNomLLista);
      contenedores = listado.getElementsByTagName('div')
      numContenedores = contenedores.length
      for(m=0; m < numContenedores; m++){
		 if (contenedores[m].id != "item_"+id) {
	         if(contenedores[m].id.indexOf('item_') == 0)
				 contenedores[m].className = "contenidoItemHidden";
    	     //contenedores[m].style.display = 'none';
		 }
      }
  }

/*********************************

**********************************/
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var 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 obrirAvis() {
	generateCoverDiv('cover','#000000',75)	
	document.getElementById("aviso").style.display = 'block';
}
function tancarAvis() {
	document.getElementById('cover').style.visibility='hidden';
	document.getElementById('aviso').style.visibility='hidden';
}

if(navigator.userAgent.indexOf("MSIE")>=0) navegador=0;
else navegador=1;

function generateCoverDiv(id, color, opacity)
{
	var layer=document.createElement('div');
	layer.id=id;
	layer.style.width=(document.body.offsetWidth+20)+'px';
	layer.style.height=(document.body.offsetHeight+70)+'px';
	layer.style.backgroundColor=color;
	layer.style.position='absolute';
	layer.style.top=0;
	layer.style.left=0;
	layer.style.zIndex=100;
	if(navegador==0) layer.style.filter='alpha(opacity='+opacity+')';
	else layer.style.opacity=opacity/100;
	document.body.appendChild(layer);
}

function amagar() {
	a = document.getElementById("amagar").style.display;
	if (a=='none' || a=='') {
		document.getElementById("amagar").style.display = 'block';
		document.getElementById("veure").style.display = 'none';
	} else {
		document.getElementById("amagar").style.display = 'none';
		document.getElementById("veure").style.display = 'block';
	}
}

function president() {
	a = document.getElementById("amagar_presi").style.display;
	if (a=='none' || a=='') {
		document.getElementById("amagar_presi").style.display = 'block';
		document.getElementById("veure_presi").style.display = 'none';
	} else {
		document.getElementById("amagar_presi").style.display = 'none';
		document.getElementById("veure_presi").style.display = 'block';
	}
}

function alcalde() {
	a = document.getElementById("amagar_alcalde").style.display;
	if (a=='none' || a=='') {
		document.getElementById("amagar_alcalde").style.display = 'block';
		document.getElementById("veure_alcalde").style.display = 'none';
	} else {
		document.getElementById("amagar_alcalde").style.display = 'none';
		document.getElementById("veure_alcalde").style.display = 'block';
	}
}

function resultats2009() {
	a = document.getElementById("resultats2009").style.display;
	if (a=='none' || a=='') {
		document.getElementById("resultats2009").style.display = 'block';
		document.getElementById("resultats2008").style.display = 'none';
	} else {
		document.getElementById("resultats2009").style.display = 'none';
	}
}

function resultats2008() {
	a = document.getElementById("resultats2008").style.display;
	if (a=='none' || a=='') {
		document.getElementById("resultats2008").style.display = 'block';
		document.getElementById("resultats2009").style.display = 'none';
	} else {
		document.getElementById("resultats2008").style.display = 'none';
	}
}
