startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
  				}
  				node.onmouseout=function() {
  					this.className=this.className.replace(" over", "");
   				}
			}
		}
	}
	
	if(document.getElementById("tablabody")!=null){
	tableRoot = document.getElementById("tablabody");
	
		for (i=0; i<tableRoot.childNodes.length; i++) {
			
			nodetable = tableRoot.childNodes[i];
			tablaenlaces = tableRoot.getElementsByTagName('a');
		
			nodetable.onmouseover=function() {
				this.className+="sobre";
			}
			nodetable.onmouseout=function() {
				this.className=this.className.replace("sobre", "");
   			}  			
		
			nodetable.onclick=function(){
				enlace=this.getElementsByTagName('a')[0];
				location.href=enlace;
			}
		}
	}
	
	
	nuevosEnlaces=document.getElementsByTagName('a');
	for (i=0; i<nuevosEnlaces.length; i++) {
		nuevoEnlace=nuevosEnlaces[i];
		if(nuevoEnlace.className.substr(0, 3)=='pop'){
			
			nuevoEnlace.onclick=function(){
				dimensiones=this.className.substring(3, this.className.length);
				vectorDimensiones = dimensiones.split("-");
				x=vectorDimensiones[0]; y=vectorDimensiones[1];
				cadenaParametros="width="+x+",height="+y;
				window.open(this.href, '_blank', cadenaParametros);
				return false;
			}
		}
		
		if ( (nuevoEnlace.href.indexOf(document.location.host) === -1 ) && (nuevoEnlace.href.indexOf('mailto') === -1)) {
       		nuevoEnlace.target = '_blank';
    	}
	}
}

window.onload=startList;


function validar(form) {

    var err="Se produjeron los siguientes errores:";
 

 if(form.nombre.value=='') {
  err += "\n - Debe introducir un nombre.";
 }

if((form.email.value=='')&&(form.telefono.value=='')){
 err += "\n - Debe introducir una forma de contacto, email o telefono.";
}

if(form.email.value!=''){
	if(!validateEmail(form.email.value)){
	err += "\n - Debe introducir su email correctamente.";
	
	}

}



 if(form.mensaje.value=='') {
  err += "\n - Debe introducir un mensaje.";
 }
 

 
 if(err != "Se produjeron los siguientes errores:") {
  alert (err);
  return false;
 }
 else {
  return true;
 }
}

function validateEmail(email) {
 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email))
 {
  return (true)
 }
}

