var	isNS4 = (document.layers) ? true : false;
var	isIE4 = (document.all && !document.getElementById) ? true : false;
var	isIE5 = (document.all && document.getElementById) ? true : false;
var	isNS6 = (!document.all && document.getElementById) ? true : false

function MM_swapImgRestore() { //v3.0
  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() { //v3.0
  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) { //v4.0
  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 && document.getElementByid) x=document.getElementByid(n); return x;
}
function MM_swapImage() { //v3.0
  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; x.src=a[i+2];}
}

//******************************************
//******************************************
function capas() {
	//DynLayer(??,x,y,w,h,bgColor,visibility,Z,bgImg,content)
	cultura = new DynLayer(null,360,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>historia y cultura</b></span>');
	municipios = new DynLayer(null,375,30,100,15,null,'hidden',100,null,'<span class="verde11"><b>municipios</b></span>');
	transporte = new DynLayer(null,380,30,100,15,null,'hidden',100,null,'<span class="verde11"><b>transporte</b></span>');
	ruta = new DynLayer(null,360,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>rutas de interés</b></span>');	
	foto = new DynLayer(null,360,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>&aacute;lbum de fotos</b></span>');		
	info = new DynLayer(null,355,30,140,15,null,'hidden',100,null,'<span class="verde11"><b>espacios protegidos</b></span>');
	monumento = new DynLayer(null,350,30,160,15,null,'hidden',100,null,'<span class="verde11"><b>museos y monumentos</b></span>');
	gastronomia = new DynLayer(null,370,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>gastronomía</b></span>');
	artesania = new DynLayer(null,370,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>artesanía</b></span>');
	playa = new DynLayer(null,380,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>playas</b></span>');	
	ocio = new DynLayer(null,370,30,140,15,null,'hidden',100,null,'<span class="verde11"><b>zonas de ocio</b></span>');	
	agenda = new DynLayer(null,380,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>agenda</b></span>');

	archipielago = new DynLayer(null,370,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>Islas Canarias</b></span>');
	hierro = new DynLayer(null,370,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>El Hierro</b></span>');
	lapalma = new DynLayer(null,370,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>La Palma</b></span>');
	gomera = new DynLayer(null,370,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>La Gomera</b></span>');
	tenerife = new DynLayer(null,370,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>Tenerife</b></span>');
	grancanaria = new DynLayer(null,370,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>Gran Canaria</b></span>');
	fuerteventura = new DynLayer(null,370,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>Fuerteventura</b></span>');
	lanzarote = new DynLayer(null,370,30,120,15,null,'hidden',100,null,'<span class="verde11"><b>Lanzarote</b></span>');	

	DynAPI.document.addChild(cultura);
	DynAPI.document.addChild(municipios);
	DynAPI.document.addChild(transporte);	
	DynAPI.document.addChild(ruta);	
	DynAPI.document.addChild(foto);	
	DynAPI.document.addChild(info);
	DynAPI.document.addChild(monumento);
	DynAPI.document.addChild(gastronomia);
	DynAPI.document.addChild(artesania);
	DynAPI.document.addChild(playa);
	DynAPI.document.addChild(ocio);	
	DynAPI.document.addChild(agenda);		

	DynAPI.document.addChild(archipielago);	
	DynAPI.document.addChild(hierro);
	DynAPI.document.addChild(lapalma);
	DynAPI.document.addChild(gomera);			
	DynAPI.document.addChild(tenerife);
	DynAPI.document.addChild(grancanaria);
	DynAPI.document.addChild(fuerteventura);
	DynAPI.document.addChild(lanzarote);			
}				

//*********************************
//*********************************

//scroll
var msg = "Esta pagina requiere Internet Explorer 6, Netscape 7 o superiores"
var dyn = (isNS6 || isIE5) ? true : alert(msg);
var lft = 5; 
var pos = 0;   // initial top position
var stp = 4;    // step increment size
var spd = 110;   // speed of increment
var upr = -550;  // upper limiter -550
var lwr = 0;   // lower limiter
var tim;         // timer variable
var hija;
function scroll_up(alto,capahija) {
	hija=capahija
	upr= alto
	if(pos > upr) pos -= stp;
	do_scroll(pos,hija); 
	tim = setTimeout("scroll_up(upr,hija)", spd);
}
function scroll_dn(capahija) {
	hija=capahija
	if(pos < lwr) pos += stp;
	do_scroll(pos,hija);
	tim = setTimeout("scroll_dn(hija)", spd);
}
function do_scroll(pos,capahija) {
	hija=capahija
	if (isIE5) {
		eval("document.all." + hija+ ".style.top = pos");}
	if (isNS6)
		eval("document.getElementById(\"" + hija+ "\").style.top=pos");
}
function no_scroll() { clearTimeout(tim);}


function elalto(capamadre,capahija) {
	if (isIE5) {
		eval("alto_madre=(parseInt(document.all." +capamadre+".style.height))")
		eval("alto_hija=(parseInt(" + capahija+ ".scrollHeight))")
	}
	if (isNS6) {
		eval("alto_madre= parseInt(document.getElementById(\"" + capamadre+ "\").style.height)")
		eval("alto_hija= parseInt(document.getElementById(\"" + capahija + "\").offsetHeight)")
	}
	limite = alto_madre -alto_hija
	return limite;
}

//*********************
//	abrir ventana
//*********************
function ventana(elurl,w,h) { 
	x=(screen.width-10)/2-w/2;
	y=(screen.height-30)/2-h/2;
	features='';
	features+='toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+','
	features+='left='+x+',';
	features+='top='+y+',';
	window.open(elurl,'',features); 
}
function ventana_scroll(elurl,w,h) { 
	x=(screen.width-10)/2-w/2;
	y=(screen.height-30)/2-h/2;
	features='';
	features+='toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+w+',height='+h+','
	features+='left='+x+',';
	features+='top='+y+',';
	window.open(elurl,'',features); 
}

function ventana_resizable(elurl,w,h) { 
	x=(screen.width-10)/2-w/2;
	y=(screen.height-30)/2-h/2;
	features='';
	features+='toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+w+',height='+h+','
	features+='left='+x+',';
	features+='top='+y+',';
	window.open(elurl,'',features); 
}
function rincon_atencion(url) {
	if (url=="popup")
		ventana_resizable('../canmundo/boletin/boletin.html',770,500)
	else
		window.location.href=url
}
//*********************
//	elecciones
//*********************
function elecciones_cabildo(idelecciones,isla,anyo) {
	doc= "elecciones_cabildo.asp?id=" + isla + "&idelecciones=" + idelecciones + "&anyo=" + anyo
	ventana_resizable(doc,770,500)
}
function elecciones_municipales(idelecciones,isla,anyo,idmunicipio,municipio) {
	doc= "elecciones_municipales.asp?id=" + isla + "&idelecciones=" + idelecciones + "&anyo=" + anyo + "&idmunicipio=" + idmunicipio + "&municipio=" + municipio
	ventana_resizable(doc,760,200)
}
function presupuestos_municipales(anyo,idmunicipio,municipio) {
	doc= "presupuestos_municipales.asp?anyo=" + anyo + "&idmunicipio=" + idmunicipio + "&municipio=" + municipio
	ventana_resizable(doc,760,200)
}
//*********************
//	validacion de formularios
//*********************
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una dirección de e-mail válida.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe ser numérico.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' debe contener un número entre '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' debe completarse.\n'; }
  } if (errors) alert('Se han producido los siguientes errores:\n'+errors);
  document.MM_returnValue = (errors == '');
}

