/**************************************************************************
 *    VALIDAR FORMULARIO                                                  *
 **************************************************************************/
function validarContacto(){
        var pattern = /^[a-zA-Z0-9\-\._]+@[a-zA-Z0-9\-_]+(\.?[a-zA-Z0-9\-_]*){2,3}\.[a-zA-Z]{2,3}$/;
				var Str;
        with (document.forms['formContacto']){
			if (nombre.value=="" || nombre.value=="Enter your name"){
				alert("Enter your name");
				nombre.focus();
				return false;
           	} 
			if (apellidos.value=="" || apellidos.value=="Enter your surnames"){
				alert("Enter your surnames");
				apellidos.focus();
				return false;
           	}   
            if (correo.value=="" || correo.value=="Enter your e-mail"){
                alert("Enter your e-mail.");
				correo.focus();
                return false;
						}
			if (correo.value!="" && !pattern.test(correo.value) ){
                alert("Enter your e-mail.");
				correo.focus();
                return false;
            }
			if (telefono.value=="" || telefono.value=="Enter your phone"){
				alert("Enter your phone");
				telefono.focus();
				return false;
           	}   
				Str = mensaje.value;
				if (Str.length == 0 || mensaje.value=="Enter your comments")
				{
					alert ("Enter your comments.");
					mensaje.focus();
					return false;
				}
			if (!clausula.checked){
				alert("I have read and I agree to the Data Protection Policy");
				clausula.focus();
				return false;
           	}   
    		}
}



function validarpregunta_EN(){
var pattern = /^[a-zA-Z0-9\-\._]+@[a-zA-Z0-9\-_]+(\.?[a-zA-Z0-9\-_]*){2,3}\.[a-zA-Z]{2,3}$/;
        with (document.formPregunta){
			
		   
			if (nombre.value=="" || nombre.value=="Enter your name and your surnames"){
                alert("Enter your first name and your surnames.");
				document.formPregunta.nombre.focus();
                return false;
           }

		   
		   if (mail.value=="" || mail.value=="Enter your e-mail"){
                alert("Enter your e-mail.");
				document.formPregunta.mail.focus();
                return false;
			}
			if (mail.value!="" && !pattern.test(mail.value) ){
                alert("The e-mail address you have included is incorrect. Please check it.");
				document.formPregunta.mail.focus();
                return false;
            }
			
			
			var Str = pregunta.value;
			if (Str.length == 0 || pregunta.value=="Enter your question"){
				alert("Enter your question.");
				document.formPregunta.pregunta.focus();
				return false;
			}
			
			
			
		}
}

/*Formulario*/

function comprobarCuota(){
	var cuota=0;
	with (document.formInscripcion){
			if(asistencia_12.checked==true){
				cuota=cuota+50;
				asistencia.checked=false;				
			}
			if(asistencia_13.checked==true){
				cuota=cuota+50;
				asistencia.checked=false;				
			}
			if(asistencia_14.checked==true){
				cuota=cuota+50;
				asistencia.checked=false;
			}
			if(cuota==150){
				cuota=100;
				asistencia_12.checked=false;
				asistencia_13.checked=false;
				asistencia_14.checked=false;
				asistencia.checked=true;
			}
			if(asistencia.checked==true){
				cuota=100;
				asistencia_12.checked=false;
				asistencia_13.checked=false;
				asistencia_14.checked=false;
		}
		total.value = cuota;
	}
}


function comprobarCuotaTotal(){
	var cuota=0;
	with (document.formInscripcion){
		if(asistencia.checked==true){
				cuota=100;
				asistencia_12.checked=false;
				asistencia_13.checked=false;
				asistencia_14.checked=false;
		}
		total.value = cuota;
	}
}





function validarInscripcion_ES(){
var pattern = /^[a-zA-Z0-9\-\._]+@[a-zA-Z0-9\-_]+(\.?[a-zA-Z0-9\-_]*){2,3}\.[a-zA-Z]{2,3}$/;
        with (document.formInscripcion){
			
			if (apellidos.value=="" || apellidos.value=="Enter your surnames"){
                alert("Enter your surnames.");
				document.formInscripcion.apellidos.focus();
                return false;
           }
		   
			if (nombre.value=="" || nombre.value=="Enter your name"){
                alert("Enter your name.");
				document.formInscripcion.nombre.focus();
                return false;
           }
		   
		   /*if (empresa.value=="" || empresa.value=="Introduzca el nombre de su empresa"){
			alert("Por favor, debe indicar su empresa.");
			document.formInscripcion.empresa.focus();
			return false;
           }
		   */
		   if (telefono.value=="" || telefono.value=="Enter your phone"){
			alert("Enter your phone.");
			document.formInscripcion.telefono.focus();
			return false;
           }
		   
		   if (mail.value=="" || mail.value=="Enter your e-mail"){
                alert("Enter your e-mail.");
				document.formInscripcion.mail.focus();
                return false;
			}
			if (mail.value!="" && !pattern.test(mail.value) ){
                alert("Enter your e-mail.");
				document.formInscripcion.mail.focus();
                return false;
            }	
			if(asistencia.checked==false){
				if(asistencia_12.checked==true || asistencia_13.checked==true || asistencia_14.checked==true){//alguna opcion esta seleccionada
				}else{
					alert("Por favor, debe seleccionar una cuota de participación.");
                return false;
				}
			}
		}
		window.print();
}

/**************************************************************************************************
Función para indicar que se abre en ventana nueva los enlaces target=_blank rel=external
**************************************************************************************************/
function externalLinks() {
	var txt_ventana = ". New window";
	var txt_ventana_no_title = " New window.";
	
 if (!document.getElementsByTagName) return;

 var anchors = document.getElementsByTagName("a");
 var tit;
 for (var i=0; i<anchors.length; i++) {

   var anchor = anchors[i];
	
	//sino tiene title lo pone el javascript
	if(anchor.getAttribute("title")){
	}else{
		//anchor.title = anchor.innerHTML ;
		asignar_no_title(anchor,anchor.innerHTML);
	}
	
	//Comprobar si el enlace tiene target _blank
	if (anchor.getAttribute("target") == "_blank"){
		if(anchor.getAttribute("title")){
			tit = anchor.getAttribute("title");
			asignar_title(anchor,txt_ventana,txt_ventana_no_title,tit)
		}else{
			tit = anchor.innerHTML;
			asignar_title(anchor,txt_ventana,txt_ventana_no_title,tit)
		}
	}
	
		if(anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank";
			if(anchor.getAttribute("title")){
				tit = anchor.getAttribute("title");
				asignar_title(anchor,txt_ventana,txt_ventana_no_title,tit)
			}else{
				tit = anchor.innerHTML;
				asignar_title(anchor,txt_ventana,txt_ventana_no_title,tit)
			}
		}
 }
}

function asignar_title(anchor,txt_ventana,txt_ventana_no_title,tit){
	if(tit.slice(tit.length-1,tit.length)=='.'){
		anchor.title = tit + txt_ventana_no_title;
	}else{
		anchor.title = tit + txt_ventana;
	}
}


function asignar_no_title(anchor,tit){
	anchor.title = tit ;
	//Si es imágen
	if(tit.indexOf('<img')==0){
		var vble_img = anchor.getElementsByTagName('img');
		anchor.title = vble_img[0].getAttribute("alt");
	}else{
		if(tit.indexOf('<img')==0){
			anchor.title = "";
		}
		
	}
	
	
}

/**************************************************************************************************
**************************************************************************************************/

window.onload=function()
{
  externalLinks();
}
