	function Browser(){
	  this.dom = document.getElementById?1:0;
	  this.ie4 = (document.all && !this.dom)?1:0;
	  this.ns4 = (document.layers && !this.dom)?1:0;
	  this.ns6 = (this.dom && !document.all)?1:0;
	  this.ie5 = (this.dom && document.all)?1:0;
	  this.ok = this.dom || this.ie4 || this.ie5;
	  this.platform = navigator.platform;
	}
	var browser = new Browser();	

	function popup(pag, nombre, parametros){		
    var ventana = window.open(pag,nombre,parametros)
    ventana.focus();
	}

	function LTrim(str){
	   var whitespace = new String(" \t\n\r");

	   var s = new String(str);

	   if (whitespace.indexOf(s.charAt(0)) != -1) {
	      var j=0, i = s.length;
	      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
	         j++;
	      s = s.substring(j, i);
	   }
	   return s;
	}


	function RTrim(str){
	   var whitespace = new String(" \t\n\r");

	   var s = new String(str);

	   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
	      var i = s.length - 1;
	      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
	         i--;
	      s = s.substring(0, i+1);
	   }

	   return s;
	}

	function Trim(str){
	   return RTrim(LTrim(str));
	}

	function txtBlanco(elemento, msg){
	   valor = Trim(elemento.value);
	   if(valor==""){
	      if(elemento.type!="hidden")
	      	elemento.focus();
	      alert(msg);
	      return false;
	   }
	   elemento = valor;
	   return true;
	}

	function validacbo (elemento, msg){
		valor = elemento.selectedIndex;
		if(valor==-1){
			alert(msg);
	    elemento.focus();
	    return false;
		}
	   return true;
	}
	
	function validacboBlanco (elemento, msg){
		valor = elemento.options[elemento.selectedIndex].value;
		if(valor==""){
			alert(msg);
	    elemento.focus();
	    return false;
		}
	   return true;
	}

	function replaceStr(str, strBuscar, strSustituir){
		var strLon = str.length;
		var strIni = "", strFin = "";

		for(var i=0;i<=strLon;i++){
			pos = str.indexOf(strBuscar)
			if(pos != -1){
				strIni = str.substring(0, pos)
				strFin = str.substring(pos + strBuscar.length)
				str = strIni + strSustituir + strFin
			}
		}

		return str
	}

	function validaMoneda(elemento, msg){
		elemento.value = replaceStr(elemento.value, ",", ".")
		valor = Trim(elemento.value);
		if(valor != "" && isNaN(valor)){
			alert(msg);
		    elemento.focus();
		    return false;
		}
	   return true;
	}

	function validaNumero(elemento, msg){
		valor = Trim(elemento.value);		
		if(valor != "" && isNaN(valor)){
			alert(msg);
	    elemento.focus();
	    return false;
		}
	   	return true;
	}

	function posimgY(obj){
		if(browser.ie4 || browser.ie5 || browser.dom) return wipeGetOffset(obj,"Top");		
	 	if(browser.ns4) return obj.y;
	}

	function posimgX(obj){
		if(browser.ie4 || browser.ie5 || browser.dom) return wipeGetOffset(obj,"Left");		
	  if(browser.ns4) return obj.x;
	}

	function wipeGetOffset(obj, coord) {
		var val = obj["offset"+coord] ;
		while ((obj = obj.offsetParent )!=null) {
			val += obj["offset"+coord];
			if (obj.border && obj.border != 0) val++;
		}
		return val;
	}

	function div(nombre, imgRef){
		if (browser.ns4){
	    	var tmpLayer = new Layer(127);
	  	}
	 	if (browser.dom || browser.ie4){
			var tmpLayer = browser.dom?document.getElementById(nombre):document.all(nombre);
	  }
	  if(imgRef != ""){
			objRef = document.getElementById(imgRef);
			this.xRef = posimgX(objRef);
			this.yRef = posimgY(objRef);
		}

  	this.containerLayer = tmpLayer;
  	this.desplazaX = desplazaX;
  	this.desplazaY = desplazaY;
  	this.escribeDiv = escribeDiv;
  	this.visible = visible;
  	this.display = display;
  	this.muestraContenido = contenido;
	}

	function contenido(){
		if (browser.ie || browser.dom)
			return this.containerLayer.innerHTML
	}

	function visible(valor){
		if (browser.ie || browser.dom){
			divmenu = this.containerLayer.style
			switch(valor){
		 		case 0:
		 			nuevo_estado = "hidden";
		 			break;
		 		case 1:
		 			nuevo_estado = "visible";
			}
		}else{
			if (browser.ns4){
			 	divmenu = this.containerLayer;
			 	switch(valor){
			 		case 0:
			 			nuevo_estado = "hide";
			 			break;
			 		case 1:
			 			nuevo_estado = "show";
				}
			}
		}

		divmenu.visibility = nuevo_estado
	}

	function display(valor){
		if (browser.ie || browser.dom){
			divmenu = this.containerLayer.style
			switch(valor){
		 		case 0:
		 			nuevo_estado = "none";
		 			break;
		 		case 1:
		 			nuevo_estado = "block";
			}
			divmenu.display = nuevo_estado
		}
	}

	function escribeDiv(str){
		if (browser.ie4)
			this.containerLayer.innerHTML = str;
		else
			if (browser.dom)
				this.containerLayer.innerHTML = str;
			else
				if(browser.ns4){
					this.containerLayer.document.open();
					this.containerLayer.document.write(str);
					this.containerLayer.document.close();
				}
	}

	function desplazaX(x){
		if (browser.dom || browser.ie4)
			this.containerLayer.style.left = x;
		if(browser.ns4)
			this.containerLayer.left = x;
	}

	function desplazaY(y){
		if (browser.dom || browser.ie4)
			this.containerLayer.style.top = y;
		if(browser.ns4)
			this.containerLayer.top = y;
	}		
	
	function validaBuscador(){
		var formu = document.forms["frmBuscador"]
		if(formu["txtBus"].value == 'Buscar'){
			alert('Es necesario introducir un texto de busqueda')			
		}else{
			if(txtBlanco(formu["txtBus"], 'Es necesario introducir un texto de busqueda')){
				if(formu["txtBus"].value.length < 3){
					alert("No se puede hacer una consulta inferior a tres caracteres")
					return false
				}else{
					return true
				}
			}
		}
		return false
	}			
	
	function redirecciona(id){
		top.window.opener.document.location='default.asp?x=' + id			
	}				
	
	function cargaUrl(){
		var formu = document.forms["frmWebs"]
		if (formu["webAcciona"].options[formu["webAcciona"].options.selectedIndex].value!="")
			window.open(formu["webAcciona"].options[formu["webAcciona"].options.selectedIndex].value,'WebAcciona','')
	}
	
	function irSeccion(){
		var formu = document.forms["frmBusAct"]
		sector = formu["x"].options[formu["x"].options.selectedIndex].value		
		if(sector!=""){			
			formu.submit();
		}
	}				
	
	idZonaOld = 0
	
	function despliega(idZona){				
		var pais = new div(idZona, '')
		pais.display(1)
		if(idZonaOld != 0 && idZonaOld != idZona){
			var pais = new div(idZonaOld, '')
			pais.display(0)
		}
		idZonaOld = idZona
	}
	
	function validaEnviarAmigo(){
		var formu = document.forms["frmEnviarAmigo"]
		if(txtBlanco(formu["txtNomDest"], 'El nombre del destinatario es un dato requerido'))	
			if(txtBlanco(formu["txtEmailDest"], 'El email del destinatario es un dato requerido'))		
				if(txtBlanco(formu["txtNom"], 'Su nombre es un dato requerido'))	
					if(txtBlanco(formu["txtEmail"], 'Su Email es un dato requerido'))				
						return true
		return false
	}
	
	function cambiaCategoria(){
		var formu = document.forms["frmCategorias"]
		sector = formu["cboCategorias"].options[formu["cboCategorias"].options.selectedIndex].value		
		if(sector!=""){			
			formu.submit();
		}
	}
	
	function validaContacto(){
		var formu = document.forms["frmContacto"]
		if(txtBlanco(formu["txtNom"], 'El nombre es un dato requerido'))	
			if(txtBlanco(formu["txtApellidos"], 'Los apellidos son un dato requerido'))		
				if(txtBlanco(formu["txtTlf"], 'El teléfono es un dato requerido'))	
					if(txtBlanco(formu["txtEmail"], 'El Email es un dato requerido'))				
						//if(txtBlanco(formu["txtMedio"], 'El medio al que representa es un dato requerido'))				
							if(txtBlanco(formu["txtTexto"], 'El motivo de la consulta es un dato requerido'))				
								return true
		return false
	}