
/* hack del puto IE para evitar el parpadeo en los rollovers */
if(document.uniqueID && !window.XMLHttpRequest ){
	document.execCommand("BackgroundImageCache",false,true)
}

//Hacemos una precarga de las imagenes de los menus (efecto optico)
image1=new Image(161, 15); 
image1.src="/images/menuarriba.gif"; 
image2=new Image(161,15); 
image2.src="/images/menuabajo.gif"; 
image3=new Image(5,407); 
image3.src="/images/fondomenu.gif"; 
image4=new Image(2,54); 
image4.src="/images/fondoindenaCap.gif"; 
image5=new Image(4,407); 
image5.src="/images/fondoindena.gif"; 

/* 
	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
	})
}

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 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 contacto_enviar() {
	form = document.forms["miForm"];
	if (form.nombre.value == '' || form.apellidos.value == '' || form.mail.value == '' || form.mensaje.value == '') {
		alert('Se deben cumplimentar todos los valores marcados como obligatorios');
	} else {
		if (!RetEsEmail(form.mail.value))	{
			alert('El formato del Email no es correto');
		} else {
			form.submit();
		}
	}
}

function RetEsEmail(email) {
  // @ entremedio: mínimo 1 char antes y 4 (e.g. @a.fr) después.
  // . después de la @, con almenos 2 chars entre ellos
  // . entre 4 (e.g. .firm) y 2 (e.g. .es) chars. antes del final

  var a= email.indexOf('@'), p=email.lastIndexOf('.'), l=email.length;
  if (a<1 || a>l-5 || a>p-2 || p<l-5 || p>l-3) return false;

  // nombre de dominio: solo a-z,0-9,- y .
  // además los especiales (. y -) no deben estar al principio
  // o al final ni debe haber dos especiales seguidos:

  var especial=true;
  for (var i=a+1; i<l; i++) {
    var c= email.charAt(i).toLowerCase();
        if ((c>='0' && c<='9') || (c>='a' && c<='z')) especial=false;
        else if (c=='-' || c=='.') {
          if (especial) return false;
          especial= true;
        }
        else return false;
  }
  
  if (especial) return false;

  return true;
}

  
  