Event.observe(window,'load',init,false);var lang="en";function init(){lang=document.getElementsByTagName("body")[0].getAttribute("lang");var url=window.location.toString();if(url.indexOf('error=true')>=0){Element.show('error');}
if($('form-login')!=null){Event.observe('enter','click',function(){$('form-login').submit();return false;},false);Event.observe(document,'keypress',function(event){if(event.keyCode==13)$('form-login').submit();});}
if($('emailcontact')){Event.observe('enter','click',function(){if(ValidaContactForm($('emailcontact')))$('emailcontact').submit();return false;},false);}
if($('autorization')){Event.observe('enter','click',function(){if(agreement(lang))$('autorization').submit();return false;},false);}
if($('TPForm')){Event.observe('enter','click',function(){if(ValidaTPForm($('TPForm')))$('TPForm').submit();return false;},false);}
if($('wedd_register')){Event.observe('enter_wedd','click',function(){if(ValidaRegisterWeddingForm($('wedd_register')))$('wedd_register').submit();return false;},false);}
if($('ForgotPass')){Event.observe('enter_pass','click',function(){if(ValidaForgotForm($('ForgotPass')))$('ForgotPass').submit();return false;},false);}
if($('main-banner')){var sw=new SMC.SlideShow('main-banner',{animSpeed:3,speed:8000});}
if($('btn-specialist')){Event.observe('btn-specialist','click',function(){if(ValidaSpecialistForm($('ContactForm')))$('ContactForm').submit();return false;},false);}
if(($('TPEnter'))&&($('TPEnter')!=null)){Event.observe('enter','keypress',function(event){Element.update('search-results',$F(Event.element(event)));});}
if($('wedd_vacation')){Event.observe('enter2','click',function(){if(ValidaVacationWeddingForm($('wedd_vacation')))$('wedd_vacation').submit();return false;},false);}}
function Change_Id(Id){if(Id.value==5){document.getElementById('IATA').disabled=true;}else{document.getElementById('IATA').disabled=false;}
if(Id.value==7){document.getElementById('other').style.display='block';}else{document.getElementById('other').style.display='none';};}
function ShowMsgEmpty(fieldname)
{alert("Please fill the field <<"+fieldname+">> .");}
function isEmpty(e){if((e.value==null)||(e.value==""))
return true;}
function mailOk(text,msg){var str=text.value;result=((str.indexOf('@')!=-1)&&(str.indexOf('@')!=0)&&(str.indexOf('@')!=str.length-1)&&(str.indexOf('.')!=-1)&&(str.indexOf('.')!=0)&&(str.indexOf('.')!=str.length-1))
if(!result)
alert('The email address is not valid.');text.focus();text.select();return result}
function textOk(text,msg){if(isEmpty(text)){ShowMsgEmpty(msg);text.focus();text.select();return false;}
return true;}
function Marca_Selected(myForm)
{menuNum=myForm.hoteles.selectedIndex;if(menuNum==null)
return;var name=myForm.hoteles[myForm.hoteles.selectedIndex].value;var pos=name.indexOf('_');var marca=name.substr(pos+1);var codhot=name.substr(0,pos);switch(marca){case'1':myForm.participants.value=myForm.sol.value;break;case'5':if(codhot==14){myForm.participants.value=myForm.melia.value;}else{myForm.participants.value=myForm.tryp.value;}break;case'3':myForm.participants.value=myForm.melia.value;break;default:myForm.participants.value=myForm.paradisus.value;break;}
myForm.participants.readOnly=false;}
function ValidaTPForm(TPF){if(!textOk(TPF.aname,"Name"))return false;if(!textOk(TPF.email,"Email"))return false;if(!mailOk(TPF.email,"Email"))return false;if(!textOk(TPF.travelname,"Company name"))return false;if(isEmpty(TPF.tagencia)||TPF.tagencia.value==0){ShowMsgEmpty("Company identifier");TPF.tagencia.focus();return false;}
if(!textOk(TPF.address,"Address"))return false;if(hasHTMLTags(TPF.address.value)){TPF.address.focus();return false;}
if(!textOk(TPF.city,"City"))return false;if(!textOk(TPF.zip,"Zip"))return false;if(isEmpty(TPF.country)||TPF.country.value==0){ShowMsgEmpty("Country");TPF.country.focus();return false;}
if(!textOk(TPF.phone,"Phone"))return false;if(!textOk(TPF.user,"User Name"))return false;if(!textOk(TPF.pass,"Password"))return false;if(TPF.pass.value!=TPF.confirmpass.value){alert('Los campos Clave y Confirmar clave deben ser iguales');TPF.pass.focus();return false;}
return true;}
function Valida_TPForm_Template(){if(TPOptions.TPOpt.value=='N'||TPOptions.AddOpt.value=='N'){alert("Please, select an option");return false;}}
function GoSearchP(){if((document.TPOptions.TPOpt.value!='N'))
window.location=document.TPOptions.TPOpt.value;}
function GoSearchS(){if((document.TPOptions.TPOpt1.value!='N')){if(document.TPOptions.page1.value!=''){window.location=document.TPOptions.page1.value+'?tp_option='+document.TPOptions.TPOpt1.value;}else{window.location=document.TPOptions.TPOpt1.value;}}else{window.location=document.TPOptions.page1.value}}
function ShowAdd(thishotel){window.open("/virtual-tours/"+thishotel,"","");}
function agreement(lang){if(document.authorization.check.checked==false){if(lang=='en'||lang=='fr')
alert('You most accept the terms and conditions.');else
alert('Debe aceptar los términos y condiciones.');return false;}else{return true;}}
function ValidaContactForm(FContact){if(!textOk(FContact.email,"Email"))return false;if(!mailOk(FContact.email,"Email"))return false;if(!textOk(FContact.Asunto,"Comment"))return false;return true;}
function ValidaSpecialistForm(FContact){if(!textOk(FContact.Asunto,"Asunto"))return false;return true;}
function ValidaForgotForm(TPF)
{if(!textOk(TPF.email,"Email"))
return false;if(!textOk(TPF.user,"User Name"))
return false;if(!textOk(TPF.pass,"Password"))
return false;if(!textOk(TPF.confirmpass,"Confirm Password"))
return false;if(TPF.pass.value!=TPF.confirmpass.value)
{alert('Los campos Clave y Confirmar clave deben ser iguales');TPF.pass.focus();return false;}
return true;}
function ValidaRegisterWeddingForm(TPF){var name=TPF.hoteles[TPF.hoteles.selectedIndex].value;var pos=name.indexOf('_');var marca=name.substr(pos+1);var codhot=name.substr(0,pos);if(isEmpty(TPF.wedd_name)){ShowMsgEmpty("Wedding Party");TPF.wedd_name.focus();return false;}
var date_dat=new Array();date_dat=TPF.checkin.value.split('-');var current1=new Date(date_dat[0],date_dat[1]-1,date_dat[2]);date1=current1.getTime();date_dat=TPF.checkout.value.split('-');var current2=new Date(date_dat[0],date_dat[1]-1,date_dat[2]);date2=current2.getTime();var current3=new Date();var current4=new Date(current3.getFullYear(),current3.getMonth(),current3.getDate());var today=current4.getTime();var lang=document.getElementsByTagName("body")[0].getAttribute("lang");if(date1>=date2){alert(langText[lang]['wedding_club'][1]);TPF.checkout.focus();return false;}
var date_dat_g=new Array();date_dat_g=TPF.checkin_g.value.split('-');var current5=new Date(date_dat_g[0],date_dat_g[1]-1,date_dat_g[2]);date3=current5.getTime();date_dat_g=TPF.checkout_g.value.split('-');var current6=new Date(date_dat_g[0],date_dat_g[1]-1,date_dat_g[2]);date4=current6.getTime();var current7=new Date();var current8=new Date(current7.getFullYear(),current7.getMonth(),current7.getDate());var today1=current8.getTime();var lang1=document.getElementsByTagName("body")[0].getAttribute("lang");if(date3<date1){alert(langText[lang]['wedding_club'][6]);TPF.checkin_g.focus();return false;}
if(date3>date2){alert(langText[lang]['wedding_club'][5]);TPF.checkin_g.focus();return false;}
if(date3>=date4){alert(langText[lang]['wedding_club'][1]);TPF.checkout_g.focus();return false;}
if((isEmpty(TPF.participants))&&(TPF.hoteles.value!='')){ShowMsgEmpty("Paying Participants");TPF.participants.focus();return false;}else if((isEmpty(TPF.participants))&&(TPF.hoteles.value=='')){alert('You most Select a Hotel');TPF.hoteles.focus();return false;}
if(isEmpty(TPF.t_op)){ShowMsgEmpty("Tour Operator Name");TPF.t_op.focus();return false;}
if(isEmpty(TPF.t_code)){ShowMsgEmpty("Confirmation Number");TPF.t_code.focus();return false;}
if(TPF.hoteles.value==''){alert('You most Select a Hotel');TPF.hoteles.focus();return false;}
switch(marca){case'1':if(parseInt(TPF.participants.value)<parseInt(TPF.sol.value)){alert("Please, fill <<Paying Participants>> with more than "+TPF.sol.value+" participants.");TPF.participants.focus();return false;}break;case'5':if(codhot=='14'){if(parseInt(TPF.participants.value)<parseInt(TPF.melia.value)){alert("Please, fill <<Paying Participants>> with more than "+TPF.melia.value+" participants.");TPF.participants.focus();return false;}
break;}
if(parseInt(TPF.participants.value)<parseInt(TPF.tryp.value)){alert("Please, fill <<Paying Participants>> with more than "+TPF.tryp.value+" participants.");TPF.participants.focus();return false;}break;case'3':if(parseInt(TPF.participants.value)<parseInt(TPF.melia.value)){alert("Please, fill <<Paying Participants>> with more than "+TPF.melia.value+" participants.");TPF.participants.focus();return false;}break;case'4':if(parseInt(TPF.participants.value)<parseInt(TPF.paradisus.value)){alert("Please, fill <<Paying Participants>> with more than "+TPF.paradisus.value+" participants.");TPF.participants.focus();return false;}break;}
return true;}
function ValidaVacationWeddingForm(TPF){if(TPF.hoteles.value==''){alert('You most Select a Hotel');TPF.hoteles.focus();return false;}
var noches;var date_dat=new Array();date_dat=TPF.checkin.value.split('-');var current1=new Date(date_dat[0],date_dat[1]-1,date_dat[2]);date1=current1.getTime();date_dat=TPF.checkout.value.split('-');var current2=new Date(date_dat[0],date_dat[1]-1,date_dat[2]);date2=current2.getTime();noches=(date2-date1)/86400000;var current3=new Date();var current4=new Date(current3.getFullYear(),current3.getMonth(),current3.getDate());var today=current4.getTime();var lang=document.getElementsByTagName("body")[0].getAttribute("lang");if(date1>=date2){alert(langText[lang]['crs'][1]);TPF.checkout.focus();return false;}
if(noches>parseInt(TPF.points.value)){ShowTextLang(langText[lang],noches,parseInt(TPF.points.value));TPF.checkout.focus();return false;}
if(isEmpty(TPF.n_people)){ShowMsgEmpty("Number of People");TPF.n_people.focus();return false;}
return true;}
function ShowTextLang(lang,noches,puntos){switch(lang){case'es':alert('Usted no puede solicitar '+noches+' días de vacaciones ya que solo dispone de '+puntos+' puntos acumulados');break;case'fr':alert('Vous ne pouvez pas demander '+noches+' jours de vacances car vous ne disposez que de '+puntos+' points accumulés');break;default:alert("You can't request "+noches+" days of vacations because you have only "+puntos+" points acumulated");break;}}
