// JavaScript Document



function conSinAlojamiento(valor){
	if(valor=="Con Alojamiento"){
	document.getElementById("tr_inicio_fin_acc").style.display="table-row";
	}else{
	document.getElementById("tr_inicio_fin_acc").style.display="none";		
	}
}


function mensaje(idioma)
{
  switch(idioma)
  {
	  case 'spanish':
	  	alert('Por favor, este campo es obligatorio');
		break;
	  case 'english':
	   alert('please, this information is required');
	   break;
	  case 'french':
	    alert('s\u2019il vous pla\u00EEt, cet champ est obligatoire');
	    break;
	  case 'german':
	    alert('wenden Sie sich bitte in diesem Bereich erforderlich ist');
		break;
	  default:
	   alert('please, this information is required');
      break;
  }
	
}


function validar(idioma){

	//select alojamiento
	if(document.form1.alojamiento.options[document.form1.alojamiento.selectedIndex].value=="")
	{
		document.form1.alojamiento.focus();	
		mensaje(idioma);
		return false;
	}


	//select CiudadSelect
	if(document.form1.CiudadSelect.options[document.form1.CiudadSelect.selectedIndex].value=="")
	{
	  document.form1.CiudadSelect.focus();
	  mensaje(idioma);
	  return false;
	}	
	
	
	//Nombre
	if (document.form1.Nombre.value=="")
	{ 
	   document.form1.Nombre.focus();
	    mensaje(idioma);
	   return false;
	}
	
	//Apellidos
	if (document.form1.Apellidos.value=="")
	{ 
	   document.form1.Apellidos.focus();
		mensaje(idioma);
	   return false;
	}
	
	//email
	if (document.form1.email.value=="")
	{ 
	 document.form1.email.focus();	
	 mensaje(idioma);
	 return false;
	}

/*	//Telefono
	if (document.form1.Telefono.value=="")
	{ 
	   document.form1.Telefono.focus();
		mensaje(idioma);
	   return false;
	}*/
	
/*	//Pasaporte
	if (document.form1.Pasaporte.value=="")
	{ 
	   document.form1.Pasaporte.focus();
		mensaje(idioma);
	   return false;
	}*/

	//Pais de preocedencia
	
		if(paisOri.getComboText()==""){
		mensaje(idioma);
		paisOri.DOMelem_input.focus();
		return false;
		}


/*	//Idiomas
	if (document.form1.Idiomas.value=="")
	{ 
	   document.form1.Idiomas.focus();
    	mensaje(idioma);
	   return false;
	}*/
	
	//select Sexo
	if(document.form1.Sexo.options[document.form1.Sexo.selectedIndex].value=="")
	{
	  document.form1.Sexo.focus();
	mensaje(idioma);
	  return false;
	}
	
	//Nacimiento
	if (document.form1.Nacimiento.value=="" || document.form1.Nacimiento.value=="dd/mm/yy")
	{ 
	   document.form1.Nacimiento.focus();
	    mensaje(idioma);
	   return false;
	}
	

//Si elige con alojamiento, comprobamos si ha metido fecha de alojamiento:
 if(document.getElementById("alojamiento").value=="Con Alojamiento"){
	var fecha_inicio = document.form1.fecha_inicio.value;
	var fecha_fin = document.form1.fecha_fin.value;	

	if(fecha_inicio==""){
	   cargaCalendario(document.getElementById("fecha_inicio"))
	    mensaje(idioma);
	   return false;		
	}

	
	if(fecha_fin==""){
	   cargaCalendario(document.getElementById("fecha_fin"))
	    mensaje(idioma);
	   return false;		
	}
	
	
	 	if(fechaJs(fecha_fin) <= fechaJs(fecha_inicio)){
		if(idioma=="french"){	
		alert("la date de début doit être antérieure à la fin")	;
		}else{
		alert("La fecha de Fin del alojamiento ha ser POSTERIOR a la fecha de Inicio del alojamiento");
		}
		cargaCalendario(document.getElementById("fecha_fin"))
		return false;
	}
	
 }


//inicio y fin del curso
	var fecha_inicio_curso= document.form1.fecha_inicio_curso.value;
	var fecha_fin_curso=document.form1.fecha_fin_curso.value;

	if(fecha_inicio_curso==""){
	   cargaCalendario(document.getElementById("fecha_inicio_curso"))
	    mensaje(idioma);
	   return false;		
	}

	
	if(fecha_fin_curso==""){
	   cargaCalendario(document.getElementById("fecha_fin_curso"))
	    mensaje(idioma);
	   return false;		
	}
	
	
	 	if(fechaJs(fecha_fin_curso) <= fechaJs(fecha_inicio_curso)){
		if(idioma=="french"){
		alert("La date d\'arriv\u00E9e doit avoir lieu avant la date de d\u00E9part")	
		}else{
		alert("La fecha de Fin del alojamiento ha ser POSTERIOR a la fecha de Inicio del alojamiento")
		}
		cargaCalendario(document.getElementById("fecha_fin_curso"))
		return false;
	}
	
	
	//seleccionar nivel
	var nivel=getCheckedValue(document.forms['form1'].elements['nivel']);	
	 if(nivel==""){
	 document.getElementById("tabla_niveles").style.backgroundColor="#CCCCCC";
	 alert("falta nivel");
	 return false;
	 }




	form1.submit();
	
}// fin de la funcion validar


function fechaJs(fecha){
	var array_fecha = fecha.split("/");	
	var dia = (array_fecha[0])-1;
	var mes = (array_fecha[1])-1;
	var anio = (array_fecha[2]);
	
	var nuevaFecha= new Date (anio, mes, dia);
	return nuevaFecha;

}



// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


//III.44 function validaEmail(email,objeto)
function validaEmail(email,objeto){
	var filter=/[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\.[A-Za-z0-9_-]+/;
	if (filter.test(email)==false){
	alert("Incorrect email");
	objeto.value="";
	objeto.focus();
	return false;
	}
}


function cargaTexto(idioma,desde){
	if(idioma=="english"){
		var cadena="";
		cadena+="<div id='texto_1_cabecera'>";
		 if(desde=="index"){
		 cadena+="<img border='0' src='im_comunes/texto_cabecera.jpg'>";
		 }else{
		 cadena+="<img border='0' src='../im_comunes/texto_cabecera.jpg'>";
		 }
		cadena+="</div>";
	
		cadena+="<div class='titulo_texto1'>";	
		cadena+="The best Spanish is learned in Madrid and Valencia (SPAIN)!";
		cadena+="</div>";
		
		cadena+="<div class='pal_texto1'>";
		cadena+="ALUNI.net, in colaboration with <a href='http://www.paraninfo.com/espanol.php?idioma=us' class='enlace' target='_blank'>Paraninfo</a> (<a href='http://centrosasociados.cervantes.es/Inicio2.htm' class='enlace'  target='_blank'>Accredited Center of the Instituto Cervantes</a>) in <strong>Madrid</strong>, and  <a href='http://www.albereda.es/inicio.html' class='enlace' target='_blank'>Albereda</a> in <strong>Valencia</strong>, offers, at great prices, 40 hour/<u><strong>2 weeks</strong></u> Spanish courses in Madrid with housing (optional):";	
		cadena+="</div>";
		if(desde=="index"){
		cadena+="<div style='text-align:center; margin-bottom:0px;'><img src='im_comunes/ing_precio.jpg'  border='0'  title='Spanish courses in Madrid, Sevilla and Valencia'></div>";
		}else{
		cadena+="<div style='text-align:center; margin-bottom:0px;'><img src='../im_comunes/ing_precio.jpg'  border='0'  title='Spanish courses in Madrid, Sevilla and Valencia'></div>";
		}
		
		cadena+="<div class='rojo_texto1' style='float:left'>";
			cadena+="* Enrollment fee is only required for the first course<br>";
			cadena+="* This Course-Housing price is valid if the course take place between <strong>March 1st - October 1st</strong> <br>";
			cadena+="* Enrollment fee is not required for ALUNI.net students (who stay 3 months or more, in the past or in the future)";		
		cadena+="</div>";
   }


	if(idioma=="french"){
		var cadena="";
		cadena+="<div id='texto_1_cabecera'>";
		 if(desde=="index"){
		 cadena+="<img border='0' src='im_comunes/texto_cabecera.jpg'>";
		 }else{
		 cadena+="<img border='0' src='../im_comunes/texto_cabecera.jpg'>";
		 }
		cadena+="</div>";
	
		cadena+="<div class='titulo_texto1'>";	
		cadena+="LE PLUS BEL ESPAGNOL S'APPREND À MADRID ET VALENCE!";
		cadena+="</div>";
		
		cadena+="<div class='pal_texto1'>";
		cadena+="ALUNI.net organise en partenariat avec  <a href='http://www.paraninfo.com/espanol.php?idioma=fr' class='enlace' target='_blank'>L\u00B4\u00E9cole Paraninfo</a> (<a href='http://centrosasociados.cervantes.es/Inicio2.htm' class='enlace'  target='_blank'>Centre agr\u00E9\u00E9 par l\'Institut Cervantes</a>) \u00E0 <strong>Madrid</strong>, et avec   <a href='http://www.albereda.es/inicio.html' class='enlace' target='_blank'>L\u00B4\u00E9cole Albereda</a> \u00E0 <strong>Valencia</strong>, et pendant toute l\u00B4ann\u00E9e, des cours intensifs de 40 heures de cours en 2 semaines avec logement en activit\u00E9s (en option)"
		//cadena+="ALUNI.net organise en partenariat avec <a href='http://www.paraninfo.com/espanol.php?idioma=fr' class='enlace' target='_blank'>l\'\u00C9cole Paraninfo</a>  (<a href='http://centrosasociados.cervantes.es/Inicio2.htm' class='enlace'  target='_blank'>Centre accr\u00e9dit\u00e9 de l\'Institut Cervantes</a>), \u00E0 des prix tr\u00E8s attractifs, 40 heures de cours d\u2019Espagnol pendant <strong><u>2 semaines</u></strong> sur Madrid et Valence, avec logement (en option) et activit\u00E9s";	
		cadena+="</div>";
		if(desde=="index"){
		cadena+="<div style='text-align:center; margin-bottom:0px;'><img src='im_comunes/fr_precio.jpg'  border='0'  title='Spanish courses in Madrid, Sevilla and Valencia'></div>";
		}else{
		cadena+="<div style='text-align:center; margin-bottom:0px;'><img src='../im_comunes/fr_precio.jpg'  border='0'  title='Spanish courses in Madrid, Sevilla and Valencia'></div>";
		}
		
		
		cadena+="<div class='rojo_texto1' style='float:left'>";
			cadena+="* L\u2019inscription seule se paye au premier cours<br>";
			cadena+="* l\u2019offre sp\u00E9ciale : prix du cours + logement  (390 \u20AC) est valable si les cours ont lieu entre le 1er mars et le 1er octobre <br>";
			cadena+="* L\u2019inscription est gratuite pour les \u00E9tudiants de Aluni (engagement de 3 mois minimum)";		
		cadena+="</div>";
   }
   
   
 	if(idioma=="spanish"){
		var cadena="";
		cadena+="<div id='texto_1_cabecera'>";
		 if(desde=="index"){
		 cadena+="<img border='0' src='im_comunes/texto_cabecera.jpg'>";
		 }else{
		 cadena+="<img border='0' src='../im_comunes/texto_cabecera.jpg'>";
		 }
		cadena+="</div>";
	
		cadena+="<div class='titulo_texto1'>";	
		cadena+="\u00A1El  buen castellano se aprende en Madrid y Valencia!";
		cadena+="</div>";
		
		cadena+="<div class='pal_texto1'>";
		cadena+="ALUNI.net, en colaboraci\u00F3n con  <a href='http://www.paraninfo.com/espanol.php?idioma=es' class='enlace' target='_blank'>Paraninfo</a> (<a href='http://centrosasociados.cervantes.es/Inicio.htm' class='enlace'  target='_blank'>Centro acreditado del Instituto Cervantes</a>) en <strong>Madrid</strong>, y con  <a href='http://www.albereda.es/inicio.html' class='enlace' target='_blank'>Albereda</a> en <strong>Valencia</strong>, ofrece aloajamiento y cursos de Espa\u00F1ol, de 40 horas de clases (2 semanas), en Madrid y Valencia"; 
		cadena+="</div>";
		if(desde=="index"){
		cadena+="<div style='text-align:center; margin-bottom:0px;'><img src='im_comunes/esp_precio.jpg'  border='0'  title='Spanish courses in Madrid, Sevilla and Valencia'></div>";
		}else{
		cadena+="<div style='text-align:center; margin-bottom:0px;'><img src='../im_comunes/esp_precio.jpg'  border='0'  title='Spanish courses in Madrid, Sevilla and Valencia'></div>";
		}
		
		
		cadena+="<div class='rojo_texto1' style='float:left'>";
			cadena+="* La matr\u00EDcula solamente se paga en el primer curso<br>";
			cadena+="* Oferta de alojamiento v\u00E1lida para todos los cursos realizados <strong>entre el 1 de marzo y el 1 de octubre</strong><br>";
			cadena+="* La matr\u00EDcula es gratuita para los estudiantes que se alojen en Aluni durante tres meses o m\u00E1s";		
		cadena+="</div>";
   }  
document.getElementById('texto1').innerHTML=cadena;	
ocultaCargandoTodo()
}// fin cargaTitulo_texto1(idioma){


function ocultaCargandoTodo(){	
	if(document.getElementById('cargandoTodo')){
	document.getElementById('cargandoTodo').style.display='none';
	}
}

