function CambiarEtiquetas(personas,habitacion){
	var cantidad = valorPersona(personas,habitacion);
	var el = Ext.get('hijo');
	if(el)Ext.fly('hijo').remove();	
	el = Ext.get('elId');
	var dhConfig = {
		id:'hijo',
		tag: 'p',
		cls: 'myCls',
		html: cantidad+' &euro;'
	};
	el.createChild(dhConfig); 
 } 
function valorPersona(txt, habi){
	var pxpersona = 0;
	var extra =400;
	switch(txt)
		{
			case '1 Person': pxpersona = 0; 	  if(habi == 'Doppelzimmer')extra = 0;else pxpersona += extra; break;
			case '2 Personen':pxpersona = 0;   if(habi == 'Doppelzimmer')extra = 0;else pxpersona += (extra*2); break;
		}
	return pxpersona;
}
function validaError(){
	var band = false;
	if(document.getElementById('textfield').value =='')colocaEstiloError('paraErrorNombre','ErrorNombre');else {band = true;var el = Ext.get('ErrorNombre');if(el)Ext.fly('ErrorNombre').remove();}
	if(document.getElementById('textfield2').value =='')colocaEstiloError('paraErrorApellido','ErrorApellido');else {band = true;var el = Ext.get('ErrorApellido');if(el)Ext.fly('ErrorApellido').remove();}
	if(document.getElementById('textfield3').value =='')colocaEstiloError('paraErrorEmail','ErrorEmail');else {band = true;var el = Ext.get('ErrorEmail');if(el)Ext.fly('ErrorEmail').remove();}
	if(document.getElementById('textfield4').value =='')colocaEstiloError('paraErrorCalle','ErrorCalle');else {band = true;var el = Ext.get('ErrorCalle');if(el)Ext.fly('ErrorCalle').remove();}
	if(document.getElementById('textfield5').value =='')colocaEstiloError('paraErrorCp','ErrorCp');else {band = true;var el = Ext.get('ErrorCp');if(el)Ext.fly('ErrorCp').remove();}
	if(document.getElementById('textfield6').value =='')colocaEstiloError('paraErrorCiudad','ErrorCiudad');else {band = true;var el = Ext.get('ErrorCiudad');if(el)Ext.fly('ErrorCiudad').remove();}
	if(document.getElementById('textfield7').value =='')colocaEstiloError('paraErrorPais','ErrorPais');else {band = true;var el = Ext.get('ErrorPais');if(el)Ext.fly('ErrorPais').remove();}
	if(document.getElementById('textfield8').value =='')colocaEstiloError('paraErrorNacimiento','ErrorNacimiento');else {band = true;var el = Ext.get('ErrorNacimiento');if(el)Ext.fly('ErrorNacimiento').remove();}
	if(document.getElementById('textfield9').value =='')colocaEstiloError('paraErrorTelefono','ErrorTelefono');else {band = true;var el = Ext.get('ErrorTelefono');if(el)Ext.fly('ErrorTelefono').remove();}
	if(document.getElementById('checkbox4').checked ==false)colocaEstiloError('paraErrorAceptar','ErrorAceptar');else {band = true;var el = Ext.get('ErrorAceptar');if(el)Ext.fly('ErrorAceptar').remove();}
	if(document.getElementById('checkbox20').checked ==false && document.getElementById('checkbox30').checked ==false)colocaEstiloError('paraErrorCheckboxConfirm','ErrorCheckboxConfirm');else {band = true;var el = Ext.get('ErrorCheckboxConfirm');if(el)Ext.fly('ErrorCheckboxConfirm').remove();}
	if(band == true)enviarCorreo();
}
function validaLimpiar(){
	
	document.getElementById('textfield').value ='';  
	var el = Ext.get('ErrorNombre');if(el)Ext.fly('ErrorNombre').remove();
	document.getElementById('textfield2').value ='';
	var el = Ext.get('ErrorApellido');if(el)Ext.fly('ErrorApellido').remove();
	document.getElementById('textfield3').value ='';
	var el = Ext.get('ErrorEmail');if(el)Ext.fly('ErrorEmail').remove();
	document.getElementById('textfield4').value ='';
	var el = Ext.get('ErrorCalle');if(el)Ext.fly('ErrorCalle').remove();
	document.getElementById('textfield5').value ='';
	var el = Ext.get('ErrorCp');if(el)Ext.fly('ErrorCp').remove();
	document.getElementById('textfield6').value ='';
	var el = Ext.get('ErrorCiudad');if(el)Ext.fly('ErrorCiudad').remove();
	document.getElementById('textfield7').value ='';
	var el = Ext.get('ErrorPais');if(el)Ext.fly('ErrorPais').remove();
	document.getElementById('textfield8').value ='';
	var el = Ext.get('ErrorNacimiento');if(el)Ext.fly('ErrorNacimiento').remove();
	document.getElementById('textfield9').value ='';
	var el = Ext.get('ErrorTelefono');if(el)Ext.fly('ErrorTelefono').remove();
	document.getElementById('checkbox4').checked =false;
	var el = Ext.get('ErrorAceptar');if(el)Ext.fly('ErrorAceptar').remove();
	document.getElementById('checkbox20').checked =false;
	document.getElementById('checkbox30').checked =false;
	var el = Ext.get('ErrorCheckboxConfirm');if(el)Ext.fly('ErrorCheckboxConfirm').remove();
	document.getElementById('textarea').value ='';
}
function colocaEstiloError(padre,hijo){
	var el = Ext.get(hijo);
	if(el)Ext.fly(hijo).remove();
	el = Ext.get(padre);	
	var dhConfig = {
		id:hijo,
		tag: 'div',
		cls: 'error',
		html: 'This field is needed'
	};
	el.createChild(dhConfig);
}
function enviarCorreo(){
	var tour = document.getElementById('select').value;
	var person = document.getElementById('select2').value;
	var habi = document.getElementById('select3').value;
	var viaje = document.getElementById('select4').value;
	var total = valorPersona(person,habi);
	
	var nombre = document.getElementById('textfield').value;
	var apeido = document.getElementById('textfield2').value;
	var email = document.getElementById('textfield3').value;
	var calle = document.getElementById('textfield4').value;
	var postal = document.getElementById('textfield5').value;
	var ciudad = document.getElementById('textfield6').value;
	var pais = document.getElementById('textfield7').value;
	var fecha = document.getElementById('textfield8').value;
	var tel = document.getElementById('textfield9').value;
	var coment = document.getElementById('textarea').value;
	
	if(document.getElementById('checkbox30').checked == true) viaje = '';
	
	Ext.Ajax.request({
		url: 'mail.php',
		method: 'POST',
		params: {
			tour: tour,
			person: person,
			habi: 	habi,
			viaje: 	viaje,
			total: 	total,
			nombre: nombre,
			apeido: apeido,
			email: 	email,
			calle: 	calle,
			postal: postal,
			ciudad: ciudad,
			pais: 	pais,
			fecha: 	fecha,
			tel: 	tel,
			coment: coment
		},
		success: function(response){
			window.location =('http://www.faszinationmexiko.com/gracias.html');
			
		},
		failure: function(response){
			alert('no es posible hacer esto');
		}
	});
}
//////////////////////////////////////////////////////////////////////////////////////////////













