// JavaScript Document

function escribeMail(){
	var nombre = 'info';
    var sitio = 'alicantenatura.es';
    document.write('<a href=\"mailto:' + nombre + '@' + sitio + '\" title=\"e-mail &Aacute;rea Medio Ambiente Diputaci&oacute;n Provincial Alicante\" alt=\"e-mail &Aacute;rea Medio Ambiente Diputaci&oacute;n Provincial Alicante\">');
    document.write(nombre + '@' + sitio + '</a>');	
}

function escribeMail2(){
	var nombre = 'mambient';
    var sitio = 'dip-alicante.es';
    document.write('<a href=\"mailto:' + nombre + '@' + sitio + '\" title=\"e-mail &Aacute;rea Medio Ambiente Diputaci&oacute;n Provincial Alicante\" alt=\"e-mail &Aacute;rea Medio Ambiente Diputaci&oacute;n Provincial Alicante\">');
    document.write(nombre + '@' + sitio + '</a>');	
}

function escribeMail3(){
	var nombre = 'salonmedioambiente';
    var sitio = 'alicantenatura.es';
    document.write('<a href=\"mailto:' + nombre + '@' + sitio + '\" title=\"e-mail &Aacute;rea Medio Ambiente Diputaci&oacute;n Provincial Alicante\" alt=\"e-mail &Aacute;rea Medio Ambiente Diputaci&oacute;n Provincial Alicante\">');
    document.write(nombre + '@' + sitio + '</a>');	
}

function borrarCampos(){
	var nombre = document.getElementById('nombre');
	var empresa = document.getElementById('empresa');
	var direccion = document.getElementById('direccion');
	var cp = document.getElementById('cp');
	var poblacion = document.getElementById('poblacion');
	var provincia = document.getElementById('provincia');
	var telefono = document.getElementById('telefono');
	var email = document.getElementById('email');
	var sectoractividad = document.getElementById('sectoractividad');
	var consulta = document.getElementById('consulta');
	nombre.value = "";
	empresa.value = "";
	direccion.value = "";
	cp.value = "";
	poblacion.value = "";
	provincia.selectedIndex = 0;
	telefono.value = "";
	email.value = "";
	sectoractividad.value = "";
	consulta.value = "";
}

function revisaformulario() {
	var formulario = document.getElementById('form1');
	if(formulario.nombre.value == ""){ 
		formulario.nombre.focus();
		formulario.nombre.select();
		alert('Contenido del campo Nombre no v\u00e1lido.');
		return false
	}   	

	if(formulario.empresa.value == ""){ 
		formulario.empresa.focus();
		formulario.empresa.select();
		alert('Contenido del campo Empresa no v\u00e1lido.');
		return false
	} 
	
	if(formulario.direccion.value == ""){ 
		formulario.direccion.focus();
		formulario.direccion.select();
		alert('Contenido del campo Dirección no v\u00e1lido.');
		return false
	} 

	if(formulario.cp.value == ""){ 
		formulario.cp.focus();
		formulario.cp.select();
		alert('Contenido del campo Cp no v\u00e1lido.');
		return false
	} 

	if(formulario.poblacion.value == ""){ 
		formulario.poblacion.focus();
		formulario.poblacion.select();
		alert('Contenido del campo Población no v\u00e1lido.');
		return false
	}

	if(formulario.telefono.value == ""){ 
		formulario.telefono.focus();
		formulario.telefono.select();
		alert('Contenido del campo Teléfono no v\u00e1lido.');
		return false
	}
	
	if(formulario.email.value == ""){
		formulario.email.focus();
		formulario.email.select();
		alert('Contenido del campo E-MAIL no v\u00e1lida.');
		return false
	}   	

var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
			if(!filter.test(formulario.email.value)){
				formulario.email.focus();
				formulario.email.select();
				alert("Direcci\u00f3n de E-MAIL no v\u00e1lida.");
				return;
			}	

	if(formulario.sectoractividad.value == ""){ 
		formulario.sectoractividad.focus();
		formulario.sectoractividad.select();
		alert('Contenido del campo Sector / Actividad no v\u00e1lido.');
		return false
	}
	
	if(formulario.consulta.value == ""){
		formulario.consulta.focus();
		formulario.consulta.select();
		alert('Contenido del campo CONSULTA no v\u00e1lido.');
		return false
	}
	formulario.submit();
}

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 RandomBanner(numero){
	n=0;
	switch(numero){
		case 1:
			previo = "bannerIndex";
			for (i=1;i<=12;i++) {
				if(i<10){
  					this[n++]= previo+"0"+i+".jpg";
				}else{
					this[n++]= previo+i+".jpg";
				}
				this.N=n;
			}
		break;
		case 2: 
			previo = "banner";
			for (i=1;i<=12;i++) {
				if(i<10){
  					this[n++]= previo+"0"+i+".jpg";
				}else{
					this[n++]= previo+i+".jpg";
				}
				this.N=n;
			}
		break;
	}
}

function banner(numero){
	var Imagenes=new RandomBanner(numero);
	src= Imagenes[ Math.floor(Math.random() * Imagenes.N) ] ;
	document.write("<style type='text/css'>#hero{background-image: url(images/"+src+")}</style>");
}

function RandomFooter(numero){
	n=0;
	switch(numero){
		case 1:
			previo = "footer";
			for (i=1;i<=9;i++) {
				if(i<10){
  					this[n++]= previo+"0"+i+".jpg";
				}else{
					this[n++]= previo+i+".jpg";
				}
				this.N=n;
			}
		break;
		case 2: 
			previo = "footer";
			for (i=1;i<=9;i++) {
				if(i<10){
  					this[n++]= previo+"0"+i+".jpg";
				}else{
					this[n++]= previo+i+".jpg";
				}
				this.N=n;
			}
		break;
	}
}

function footer(numero){
	var Imagenes=new RandomFooter(numero);
	src= Imagenes[ Math.floor(Math.random() * Imagenes.N) ] ;
	document.write("<style type='text/css'>#bannerFlash{background-image: url(images/"+src+")}</style>");
}

function toggleLayer(whichLayer){
	if (document.getElementById){
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}else{
		if (document.all){
			var style2 = document.all[whichLayer].style;
			style2.display = style2.display? "":"block";
		}else{
			if (document.layers){
				var style2 = document.layers[whichLayer].style;
				style2.display = style2.display? "":"block";
			}
		}
	}
}