/*
* Copyright 2002-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
 * This script, when included in a html file, can be used to make collapsible menus
 *
 * Typical usage:
 * <script type="text/javascript" language="JavaScript" src="menu.js"></script>
 */
<!--
if (document.getElementById){ 
  document.write('<style type="text/css">#leftColumn ul li ul li ul{display: none;} #cajaRefRapida{display: none; }#enviaMailId{display: none;}</style>')
}
function SwitchCapa(obj) {
	var re = new RegExp("menu_([0-9])*");
	var idUL = new String("");
	var hijos = new Array(obj.childNodes);
	for (var i =0;i<hijos.length;i++) {
		var shijos = hijos[i];
    	for (var j=0;j<shijos.length;j++) {
    		if (shijos[j].id !== undefined) {
    			if (shijos[j].id.match(re)) {
    				idUL = shijos[j].id;
    			}
    		}
    	}
	}
	if (idUL!="") {
    	//TIENE HIJOS, HAY QUE MOSTRARLOS
    	var muestraUL = document.getElementById(idUL);
    	if (muestraUL.style.display == 'block') muestraUL.style.display = 'none';	
    	else muestraUL.style.display = 'block';
    }
}
function muestraCapa() {
    if(document.getElementById)  {
    	if (opcActiva) {
    		var re = new RegExp("menu_([0-9])*");
    		//LI ACTIV0
    		var capaOpc = "menu_"+seccActiva+"_"+opcActiva+"_title";
    		var opcID = document.getElementById(capaOpc);
    		var padreId = opcID.parentNode.id;
    		var hijos = new Array(opcID.childNodes);
    		var idUL = new String("");
    		//SI EL PADRE ES UN UL, DEBE MOSTRARLO
    		if (padreId.match(re)) {
    			var muestraUL = document.getElementById(padreId);
    			muestraUL.style.display = 'block';
    		}
    		for (var i=0;i<hijos.length;i++) {
    			var shijos = hijos[i];
    			for (var j=0;j<shijos.length;j++) {
    				if (shijos[j].id !== undefined) {
    					if (shijos[j].id.match(re)) {
    						idUL = shijos[j].id;
    					}
    				}
    			}
    		}
    		if (idUL!="") {
    			//TIENE HIJOS, HAY QUE MOSTRARLOS
    			var muestraUL = document.getElementById(idUL);
    			muestraUL.style.display = 'block';	
    		}
    	}
    }
}
function SwitchMail(obj) {
	if(document.getElementById)  {
    	var el = document.getElementById(obj);
    	var title = document.getElementById(obj+'Title');	

    if(el.style.display != "block"){      
      el.style.display = "block";
    }else{     
      el.style.display = "none";
    }
  }
}


function clasificaFoto(obj, img)
{
img.style.display = "block";
var alto = img.height;
var ancho = img.width;
return alto;
}
function SwitchCajaRefRapida(obj, thePath)
{	
  	if(document.getElementById)  {
    	var el = document.getElementById(obj);
    	var title = document.getElementById(obj+'Title');	

    if(el.style.display != "block"){ 
     
      el.style.display = "block";
    }else{
      
      el.style.display = "none";
    }
  }
}
function despliegaCapa(objLayer) {
	this.contador = 0;
	this.objLayer= objLayer;
}
despliegaCapa.prototype.alternaCapa = function(objImg,srcOff,srcOn) {
	if (document.getElementById) {
		if (objImg!="") var eleImagen = document.getElementById(objImg);
		var eleLayer = document.getElementById(this.objLayer);
		if  (eleLayer != null) {
			if (eleLayer.style.display != "block") {
				eleLayer.style.display = "block";
				if (srcOn!="") eleImagen.src=srcOn;
			} else {
				eleLayer.style.display = "none";
				if (srcOff!="") eleImagen.src=srcOff;
			}			
		}			
	}
}
function SwitchLink(tipo,obj) {
	if (tipo) {
		obj.style.color = "#000000";
		obj.style.textDecoration = "underline";
	} else {
		obj.style.color = "#a70a0d";
		obj.style.textDecoration = "none";
	}
}

function checkEmail(correo) {
         if (!correo) return true;
         var a = correo.indexOf("@");
         var p = correo.lastIndexOf(".");
         var l = correo.length;
         if (a<1 || a>l-5 || a>p-2 || p<l-5 || p>l-3) return false;
         var especial = true;
         for (var i=a+1;i<l;i++) {
              var c=correo.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;
}
function campoObligatorio(campo) {
  if (!eval(campo+".value")) {
    alert("Este campo es obligatorio");
    eval(campo+".focus()");
    return false;
  }
  return true;
}
function enviaForm() {
  var campo = new Array();
  var objeto = "document.form1";
  campo[0] = objeto+".nombre";
  campo[1] = objeto+".email";
  campo[2] = objeto+".asunto";
  campo[3] = objeto+".mensaje";
  for (var i=0;i<campo.length-1;i++) {
    if (!campoObligatorio(campo[i])) return
  }
  if (!checkEmail(eval(campo[1]+".value"))) {
    alert("Escriba una direcci򬟤e correo v૩da");
    eval(campo[1]+".value=\"\"");
    eval(campo[1]+".focus()");
    return
  }
  eval(objeto+".submit()");
}
function enviaFormSocio() {
  var campo = new Array();
  var objeto = "document.form1";
  campo[0] = objeto+".nombre";
  campo[1] = objeto+".direccion";
  campo[2] = objeto+".poblacion";
  campo[3] = objeto+".telefono";
  campo[4] = objeto+".provincia";
  campo[5] = objeto+".fechanac";
  campo[6] = objeto+".dni";
  campo[7] = objeto+".profesion";
  campo[8] = objeto+".email";
  for (var i=0;i<campo.length-1;i++) {
    if (!campoObligatorio(campo[i])) return
  }
  if (!checkEmail(eval(campo[8]+".value"))) {
    alert("Escriba una direccion de correo valida");
    eval(campo[8]+".value=\"\"");
    eval(campo[8]+".focus()");
    return
  }
  eval(objeto+".submit()");
}
function MM_swapImgRestore() { 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
var imagen=0;
function MM_swapImage() { 
  
  var i,j=0,x,a=MM_swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){
	   document.MM_sr[j++]=x; 
	   if(!x.oSrc) x.oSrc=x.src; 
	   if (imagen) {
		   x.src="/img/ico_maximiza.gif";  
		   imagen=0;
	   } else {
		   x.src="/img/ico_maximiza_o.gif"; 
		   imagen=1;
	   }
  }
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//-->