
function GenerateAirTicket(resId)
{frm=document.getElementById('FormGenerateAirTicket');frm.elements['ReservationId'].value=resId;frm.submit();}
var hiddenControls;function HideControls(aDiv){this.hiddenControls=new Array();var aboveElement=document.getElementById(aDiv);var arrElements=document.getElementsByTagName('SELECT');for(var myIndex=0;myIndex<arrElements.length;myIndex++){var myElement=arrElements[myIndex];var elementInside=isInside(aboveElement,myElement);if(elementInside){myElement.style.visibility="hidden";hiddenControls[hiddenControls.length]=myElement;}}}
var arrOnLoadFuncs=new Array();function AddOnLoadFunc(func)
{arrOnLoadFuncs[arrOnLoadFuncs.length]=func;}
function SetOnLoadFunc()
{window.onload=ExecuteOnLoadFuncs;}
function ExecuteOnLoadFuncs()
{for(var i=0;i<arrOnLoadFuncs.length;i++)
{eval(arrOnLoadFuncs[i]);}}
function MaximizeMinimize(siteId,idElement,action)
{if(action=='')
{if(document.getElementById(idElement).className=="info_scroll")
{action="max";}
else
{action="min";}}
if(action=="max")
{document.getElementById(idElement).className="info_scroll_open";document.getElementById(idElement+"_img").src="/images/"+siteId+"/arrow_up.gif";document.getElementById(idElement+"_img").alt="minimizar";}
else if(action=="min")
{document.getElementById(idElement).className="info_scroll";document.getElementById(idElement+"_img").src="/images/"+siteId+"/arrow_down.gif";document.getElementById(idElement+"_img").alt="maximizar";}}
function ShowHide(siteId,ID,img,url)
{if(document.getElementById(ID).style.display=="none")
{document.getElementById(ID).style.display="block";document.getElementById(ID+"_img").src=url+"/images/"+siteId+"/btn_link_down.gif";}
else
{document.getElementById(ID).style.display="none";document.getElementById(ID+"_img").src=url+"/images/"+siteId+"/btn_link.gif";}}
var xmlhttp
var ajaxPath="/AjaxPage/AjaxPage.aspx";function GetResult(url,fcStatus)
{if(window.XMLHttpRequest)
{xmlhttp=new XMLHttpRequest()
xmlhttp.onreadystatechange=xmlhttpChangeBarraSapo;xmlhttp.open("GET",url,true)
xmlhttp.send(null)}
else if(window.ActiveXObject)
{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
if(xmlhttp)
{xmlhttp.onreadystatechange=xmlhttpChangeBarraSapo;xmlhttp.open("GET",url,true)
xmlhttp.send()}}}
function xmlhttpChangeBarraSapo()
{alert('change1');if(xmlhttp.readyState==4)
{if(xmlhttp.status==200)
{alert('change2');document.getElementById("barra_sapo").innerHTML=xmlhttp.responseText;alert(xmlhttp.responseText);}
else
{alert("Ocorreu um erro barra sapo.");}}}
function __getData(url,div)
{url=String(url);if(url.indexOf('pubserver=1')==-1)
url=ajaxPath+"?path="+url;if(String(window.location).indexOf("refreshcache=1")!=-1)
url+="&refreshcache=1";if(String(window.location).indexOf("usecache=0")!=-1)
url+="&usecache=0";if(window.XMLHttpRequest)
{var request=new XMLHttpRequest();request.onreadystatechange=function(){XmlHttpChange(request,div)};request.open("GET",url,true);request.send(null);}
else if(window.ActiveXObject)
{var request=new ActiveXObject("Microsoft.XMLHTTP");if(request)
{request.onreadystatechange=function(){XmlHttpChange(request,div)};request.open("GET",url,true);request.send();}}}
function XmlHttpChange(request,div)
{if(request.readyState==4)
{if(request.status==200)
{var startScriptArr=request.responseText.split("<script");for(var i=0;i!=startScriptArr.length;++i)
{var endScriptArr=startScriptArr[i].split("<\/script>");if(endScriptArr.length>0&&endScriptArr.length==2)
{var script=document.createElement('script');script.type='text/javascript';script.text=endScriptArr[0].slice(endScriptArr[0].indexOf(">")+1,endScriptArr[0].length);var head;if(document.all)
head=document.all.tags("head");else
head=document.getElementsByTagName("head");head[0].appendChild(script);}}
var strResp=request.responseText;var targetElem=document.getElementById(div);if(targetElem!=null)
{targetElem.innerHTML=strResp;}}
else
{document.getElementById(div).innerHTML="<div><h1>Ajax Error</h1></div><div>"+request.responseText+"</div>";}}}
var javascriptSentences=new Array(54);javascriptSentences[0]="Dia de partida não pode ultrapassar o intervalo de datas disponível.";javascriptSentences[1]="Dia da semana inválido.";javascriptSentences[2]="O E-mail não corresponde a um formato válido.";javascriptSentences[3]="A password deve ter, no mínimo, ";javascriptSentences[4]=" caracteres.";javascriptSentences[5]="Nome do Beneficiário Inválido";javascriptSentences[6]="Por favor, preencha o NOME do passageiro.";javascriptSentences[7]="O NOME dos passageiros possui caracteres inválidos.\n\nPor favor reescreva o seu nome.";javascriptSentences[8]="Por favor, preencha o APELIDO do passageiro.";javascriptSentences[9]="O APELIDO dos passageiros  possui caracteres inválidos.\n\nPor favor reescreva o seu nome.";javascriptSentences[10]="Nome Constante no Cartão Inválido";javascriptSentences[11]="Número do Cartão Inválido";javascriptSentences[12]="Código de Segurança Inválido";javascriptSentences[13]="Data de Validade Incorrecta";javascriptSentences[14]="Número de Telefone Inválido";javascriptSentences[15]="Data Inválida.";javascriptSentences[16]="Email de Entrega";javascriptSentences[17]="Telefone de contacto";javascriptSentences[18]="Morada";javascriptSentences[19]="Código de Postal";javascriptSentences[20]="Localidade";javascriptSentences[21]="N. de Contribuinte";javascriptSentences[22]="Nome";javascriptSentences[23]="Morada da Facturação";javascriptSentences[24]="Código de Postal da Facturação";javascriptSentences[25]="Localidade da Facturação";javascriptSentences[26]="O seguintes campos não podem estar vazios:\n\n";javascriptSentences[27]="O seguinte campo não pode estar vazio:\n\n";javascriptSentences[28]="Email Inválido";javascriptSentences[29]="Código de Postal Inválido";javascriptSentences[30]="Código de Postal da Facturação Inválido";javascriptSentences[31]="N. Contribuinte Inválido";javascriptSentences[32]="Número de Telefone tem que ter entre 9 a 15 Dígitos";javascriptSentences[33]="Número de Telefone de Contacto tem entre 9 a 14 Dígitos";javascriptSentences[34]="No Número de Telefone use o prefixo 00 em vez de +";javascriptSentences[35]="No Número de Telefone não use espaços entre os dígitos";javascriptSentences[36]="Assinale que concorda que a sua documentação seja entregue electronicamente";javascriptSentences[37]="O Serviço ";javascriptSentences[38]=" possui menos de ";javascriptSentences[39]=" pessoa(s) associada(s).";javascriptSentences[40]="Tem que assinalar que autoriza o pagamento com cartão de crédito.";javascriptSentences[41]="Fechar";javascriptSentences[42]="Preencha os dados de emissão ou assinale que confirmará mais tarde o tipo de identificação";javascriptSentences[43]="Data de nascimento do passageiro ";javascriptSentences[44]=" incorrecta.";javascriptSentences[45]=" tem menos de 2 anos.";javascriptSentences[46]=" maior que a data de hoje";javascriptSentences[47]=" possui mais de 2 anos no dia de partida.";javascriptSentences[48]=" possui mais de 11 anos no dia de partida.";javascriptSentences[49]="O passageiro ";javascriptSentences[50]="A pessoa que escolheu não está registada como sendo uma criança.";javascriptSentences[51]="A pessoa que escolheu não está registada como sendo um bebe.";javascriptSentences[52]="Código de segurança possui é composto por 3 digitos.";javascriptSentences[53]="Por favor, seleccione o SEXO do passageiro.";function ShowBenef(valInsurancePrice)
{var valPrice=String(valInsurancePrice);if(valPrice=="-1")
{valPrice="0";}
valPrice=Number(valPrice.replace(",","."));var valTotalPrice=Number(document.getElementById("div_TotalPrice").innerHTML.replace(",","."));valTotalPrice-=Number(document.getElementById("fldInsuranceOldPrice").value)
valTotalPrice+=valPrice;document.getElementById("div_TotalPrice").innerHTML=String(valTotalPrice.toFixed(2)).replace(".",",");if(valInsurancePrice!="-1")
{document.getElementById("fldInsuranceOldPrice").value=valInsurancePrice.replace(",",".");if(document.getElementById("div_Benef")!=null)
{document.getElementById("div_Benef").style.display="";}}
else
{document.getElementById("fldInsuranceOldPrice").value="0";if(document.getElementById("div_Benef")!=null)
{document.getElementById('div_Benef').style.display="none";}}}
function TestIfRegularYear(year)
{return!(((year%4)==0&&(year%100)!=0)||(year%400)==0);}
function CancelSwitch(state,dataDIV_ID,cancelDIV_ID)
{if(state=="cancel")
{document.getElementById(cancelDIV_ID).zIndex=100;document.getElementById(cancelDIV_ID).style.position='absolute';document.getElementById(cancelDIV_ID).style.display='block';document.getElementById(cancelDIV_ID).style.left="121px";}
else
{document.getElementById(cancelDIV_ID).style.display='none';}}
function GetDaysInMonth(month)
{var minDaysInMonth=30;var maxDaysInMonth=31;if(month<8)
return(minDaysInMonth+(month%2));return(maxDaysInMonth-(month%2));}
function CheckDateAux(day,month,year)
{var control=(TestIfRegularYear(year)?28:29);if(month==2)
return(day<=control);return(day<=GetDaysInMonth(month));}
function CheckWeekDay(dayIndex)
{if(days_flags!="")
{if(days_flags[dayIndex]=="NO")
return false;}
return true;}
function CheckEndDate(clientID)
{var endDate_aux=String(document.getElementById('endDate_AUX'+clientID).value);var endDate=endDate_aux.split('/');var endDate_date=new Date();var choosenDate_date=new Date();endDate_date.setDate(endDate[0]);endDate_date.setMonth(endDate[1]);endDate_date.setFullYear(endDate[2]);choosenDate_date.setDate(document.getElementById('day'+clientID).value);choosenDate_date.setMonth(document.getElementById('month'+clientID).value);choosenDate_date.setFullYear(document.getElementById('year'+clientID).value);if(endDate_date>=choosenDate_date)
return true;else
return false;}
function CheckDateShortVacation(day,month,year,clientID)
{EndDate(clientID);var date=new Date();var now=new Date();date.setFullYear(year);date.setMonth(month-1);date.setDate(day);if(!CheckDateAux(day,month,year)||date-now<0)
{document.getElementById('validToGo').value="0";alert(javascriptSentences[15]);return false;}
else if(!CheckEndDate(clientID))
{document.getElementById('validToGo').value="0";alert(javascriptSentences[0]);return false;}
else if(!CheckWeekDay(date.getDay()))
{document.getElementById('validToGo').value="0";alert(javascriptSentences[1]);return false;}
document.getElementById('validToGo').value="1";return true;}
function ShowHideFF(id)
{var obj=document.getElementById(id);if(obj.style.display=='none')
obj.style.display=''
else
{obj.style.display='none';var index=id.split('_')[1];document.getElementById('myFFN_'+index).value='';}}
function GetNamesToPutAux(nome,apelido,index,div,passIndex,BDate)
{var result=false;var BIandPassPort="";if(document.getElementsByName('fldBI')!=null&&document.getElementsByName('fldBI').length>0)
{BIandPassPort+="document.getElementsByName(\"fldBI\")["+index+"].value=document.getElementById(\"IDNumber_Pass"+passIndex+"\").value;";BIandPassPort+="document.getElementsByName(\"fldPassPort\")["+index+"].value=document.getElementById(\"Passport_Pass"+passIndex+"\").value;";}
for(var i=0;i<document.getElementsByName('fldNome').length;i++)
{if(nome==document.getElementsByName('fldNome')[i].value&&apelido==document.getElementsByName('fldApelido')[i].value)
result=true}
if(!result)
return"<a href='javascript:void(0);' style='cursor:hand' onclick='SetTruePassenger("+(index+1)+");SetAge("+index+",\""+BDate+"\");document.getElementsByName(\"fldNome\")["+index+"].value=\""+nome+"\";document.getElementsByName(\"fldApelido\")["+index+"].value=\""+apelido+"\";document.getElementById(\""+div+"\").style.display=\"none\";"+BIandPassPort+";GetNamesToPut("+index+",\""+div+"\");' class='normal_text'>&#160;"+nome+" "+apelido+"&#160;</a><br>";else
return"";}
function SetAge(index,bdate)
{var nIndex;var nDay,nMonth,nYear;var insertedYear=false;nIndex=Number(index);nDay=Number(bdate.split('/')[0]);nMonth=Number(bdate.split('/')[1]);nYear=Number(bdate.split('/')[2]);if(document.getElementsByName('fldNascimentoDia')[index].options!=null)
{document.getElementsByName('fldNascimentoDia')[index].options.selectedIndex=(nDay-1);document.getElementsByName('fldNascimentoMes')[index].options.selectedIndex=(nMonth-1);for(var i=0;i<document.getElementsByName('fldNascimentoAno')[index].options.length;i++)
{if(Number(document.getElementsByName('fldNascimentoAno')[index].options[i].value)==nYear)
{insertedYear=true;document.getElementsByName('fldNascimentoAno')[index].options.selectedIndex=i;break;}}
if(!insertedYear&&document.getElementsByName('fldTipo')[index].value=="CH")
{alert(javascriptSentences[50]);}
if(!insertedYear&&document.getElementsByName('fldTipo')[index].value=="IN")
{alert(javascriptSentences[51]);}}}
function GetNamesToPut(index,div)
{var result="";var resultAux="";var nome1=document.getElementById('FName_Pass1').value;var nome2=document.getElementById('FName_Pass2').value;var nome3=document.getElementById('FName_Pass3').value;var apelido1=document.getElementById('LName_Pass1').value;var apelido2=document.getElementById('LName_Pass2').value;var apelido3=document.getElementById('LName_Pass3').value;var BDate1=document.getElementById('BDate_Pass_1').value;var BDate2=document.getElementById('BDate_Pass_2').value;var BDate3=document.getElementById('BDate_Pass_3').value;resultAux=result;result+=GetNamesToPutAux(nome1,apelido1,index,div,1,BDate1);if(result==resultAux)
SetTruePassenger(1);else
SetFalsePassenger(1);resultAux=result;result+=GetNamesToPutAux(nome2,apelido2,index,div,2,BDate2);if(result==resultAux)
SetTruePassenger(2);else
SetFalsePassenger(2);resultAux=result;result+=GetNamesToPutAux(nome3,apelido3,index,div,3,BDate3);if(result==resultAux)
SetTruePassenger(3);else
SetFalsePassenger(3);return result;}
function PassengerIsTheSameThatRegistry(index)
{var nome="";var apelido="";if(index!=0)
{if(document.getElementById('FName_Pass'+index)!=null)
{nome=document.getElementById('FName_Pass'+index).value;apelido=document.getElementById('LName_Pass'+index).value}}
else
{nome=document.getElementById('clientName').value;apelido=document.getElementById('clientLastName').value;}
for(var i=0;i<document.getElementsByName('fldNome').length;i++)
{if(RetiraAcentos(nome)==RetiraAcentos(document.getElementsByName('fldNome')[i].value)&&RetiraAcentos(apelido)==RetiraAcentos(document.getElementsByName('fldApelido')[i].value))
return true;}
return false;}
function CheckPassengersAndRegistry()
{var passengerRegistry=document.getElementById('RegistryPassengers').value.split(',');var result="";for(i=0;i<passengerRegistry.length;i++)
if(passengerRegistry[i]=="true")
{if(!PassengerIsTheSameThatRegistry(i))
passengerRegistry[i]="false";}
for(i=0;i<passengerRegistry.length;i++)
{if(result!="")
result+=",";result+=passengerRegistry[i];}
document.getElementById('RegistryPassengers').value=result;}
function SetTruePassenger(index)
{var passengerRegistry=document.getElementById('RegistryPassengers').value.split(',');SetPassengerRegistry(passengerRegistry,"true",index);}
function SetFalsePassenger(index)
{var passengerRegistry=document.getElementById('RegistryPassengers').value.split(',');SetPassengerRegistry(passengerRegistry,"false",index);}
function SetPassengerRegistry(passengerRegistry,value,index)
{var result="";passengerRegistry[index]=value;for(i=0;i<passengerRegistry.length;i++)
{if(result!="")
result+=",";result+=passengerRegistry[i];}
document.getElementById('RegistryPassengers').value=result;}
function CheckUncheckUseRegData(sIndex)
{if(document.getElementById("fldUseRegData_"+sIndex).value=="1")
{document.getElementById("fldUseRegData_"+sIndex).value="0";}
else
{document.getElementById("fldUseRegData_"+sIndex).value="1";}
GetRegisterData(sIndex)}
function CheckUncheckFF(sIndex)
{if(document.getElementById("fldFF_"+sIndex).value=="1")
{document.getElementById("fldCheckboxFF_"+sIndex).checked=false;document.getElementById("divFFData_"+sIndex).style.display="none";document.getElementById("fldFF_"+sIndex).value="0";}
else
{document.getElementById("fldCheckboxFF_"+sIndex).checked=true;document.getElementById("divFFData_"+sIndex).style.display="";document.getElementById("fldFF_"+sIndex).value="1";}}
function CheckUncheckSuplements(sIndex,sValue)
{if(document.getElementById("fldSuplements_"+sIndex).value=="")
{document.getElementById("fldSupCheckbox_"+sIndex).src="CheckoutImages/checkbox_on.gif";document.getElementById("fldSuplements_"+sIndex).value=sValue;}
else
{document.getElementById("fldSupCheckbox_"+sIndex).src="CheckoutImages/checkbox_off.gif";document.getElementById("fldSuplements_"+sIndex).value="";}}
function ResetInsuranceOption(pk_agreement)
{if(document.getElementById('NoInsuranceOption_Agreement_'+pk_agreement)!=null)
{document.getElementById('NoInsuranceOption_Agreement_'+pk_agreement).checked=true;}}
function SelectInsurance(sValue,sIndex)
{document.getElementById("fldInsurance").value=sValue;}
function ShowInsuranceOptionsDiv(insuranceDivPos)
{if(document.getElementById('InsuranceCounter')!=null)
{for(var i=0;i<document.getElementById('InsuranceCounter').value+1;i++)
{if(document.getElementById('insuranceAgreementDiv_'+i)!=null){if(i==insuranceDivPos)
{document.getElementById('insuranceAgreementDiv_'+i).style.display='';}else
{document.getElementById('insuranceAgreementDiv_'+i).style.display='none';}}}}}
function GetRegisterData(sIndex)
{if(document.getElementById("fldUseRegData_"+sIndex).value=="1")
{SetTruePassenger(0);SetComboBoxOption(document.getElementById("fldTreatment_"+sIndex),document.getElementById("ClientRegDataTreatment").value);document.getElementById("fldFirstName_"+sIndex).value=document.getElementById("ClientRegDataFirstName").value;document.getElementById("fldLastName_"+sIndex).value=document.getElementById("ClientRegDataLastName").value;document.getElementById("fldAge_"+sIndex).value=document.getElementById("ClientRegDataAge").value;if(document.getElementById("fldComboBirthdateDay_"+sIndex)!=null)
{var birthDate=document.getElementById("ClientRegDataBirthDate").value;var birthDateDay=birthDate.split('/')[2];var birthDateMonth=birthDate.split('/')[1];var birthDateYear=birthDate.split('/')[0];if(isNaN(birthDateDay))
birthDateDay="";else
birthDateDay=Number(birthDateDay);if(isNaN(birthDateMonth))
birthDateMonth="";else
birthDateMonth=Number(birthDateMonth);if(isNaN(birthDateYear))
birthDateYear="";else
birthDateYear=Number(birthDateYear);document.getElementById("fldComboBirthdateDay_"+sIndex).value=birthDateDay;document.getElementById("fldComboBirthdateMonth_"+sIndex).value=birthDateMonth;document.getElementById("fldComboBirthdateYear_"+sIndex).value=birthDateYear;}
SetGender(document.getElementById("ClientRegDataGender").value,"Gender",sIndex);if(document.getElementById("fldDocType_"+sIndex)!=null)
{SetComboBoxOption(document.getElementById("fldDocType_"+sIndex),document.getElementById("ClientRegDataDocType").value);document.getElementById("fldDocNumber_"+sIndex).value=document.getElementById("ClientRegDataDocNumber").value;document.getElementById("fldDocExpDate_"+sIndex).value=document.getElementById("ClientRegDataDocExpDate").value;}
if(document.getElementById('clientFFNComp')!=null)
{if(document.getElementById('fldCompanhia0')!=null)
{var codes=document.getElementById('clientFFNComp').value.split(',');var has=false;var myCode=document.getElementById('fldCompanhia0').value;var index;for(var a=0;a<codes.length;a++)
{if(myCode==codes[a])
{index=a;has=true;break;}}
if(has)
{if(document.getElementById('checkFFN_0').checked!=true)
{document.getElementById('checkFFN_0').checked=true;ShowHideFF('FF_0');}
document.getElementById('myFFN_0').value=document.getElementById('clientFFN').value.split(',')[index];}}}}
else
{SetFalsePassenger(0);document.getElementById("fldTreatment_"+sIndex).value="";document.getElementById("fldFirstName_"+sIndex).value="";document.getElementById("fldLastName_"+sIndex).value="";document.getElementById("fldAge_"+sIndex).value="";if(document.getElementById("fldComboBirthdateDay_"+sIndex)!=null)
{document.getElementById("fldComboBirthdateDay_"+sIndex).value="";document.getElementById("fldComboBirthdateMonth_"+sIndex).value="";document.getElementById("fldComboBirthdateYear_"+sIndex).value="";}
SetGender("","Gender",sIndex);if(document.getElementById("fldDocType_"+sIndex)!=null)
{document.getElementById("fldDocType_"+sIndex).value="";document.getElementById("fldDocNumber_"+sIndex).value="";document.getElementById("fldDocExpDate_"+sIndex).value="";}
if(document.getElementById("fldFFAirVendor_"+sIndex)!=null)
{document.getElementById("fldFFNumber_"+sIndex).value="";if(document.getElementById("fldFF_"+sIndex).value=="1")
{CheckUncheckFF(sIndex);}}}}
function SetComboBoxOption(objComboBox,strOptionValue)
{for(var i=0;i<objComboBox.options.length;i++)
if(objComboBox.options[i].value==strOptionValue)
objComboBox.options.selectedIndex=i;}
function SetPassengerType(sFldValue,sFldName,sFldCount)
{document.getElementById("fld"+sFldName+"_"+sFldCount).value=sFldValue;if(sFldValue=="CH")
{document.getElementById("fldChk"+sFldName+"_CH_"+sFldCount).checked=true;document.getElementById("fldChk"+sFldName+"_IN_"+sFldCount).checked=false;}
else if(sFldValue=="IN")
{document.getElementById("fldChk"+sFldName+"_CH_"+sFldCount).checked=false;document.getElementById("fldChk"+sFldName+"_IN_"+sFldCount).checked=true;}
else
{document.getElementById("fldChk"+sFldName+"_CH_"+sFldCount).checked=false;document.getElementById("fldChk"+sFldName+"_IN_"+sFldCount).checked=false;}
GetAgeBox(sFldValue,sFldCount)}
function GetAgeBox(val,id)
{if(val=="AD")
{document.getElementById("div_SupAge_"+id).style.display="none";document.getElementById("fldSupAgeCH_"+id).style.display="none";document.getElementById("fldSupAgeIN_"+id).style.display="none";}
if(val=="CH")
{document.getElementById("div_SupAge_"+id).style.display="block";document.getElementById("fldSupAgeCH_"+id).style.display="block";document.getElementById("fldSupAgeIN_"+id).style.display="none";}
if(val=="IN")
{document.getElementById("div_SupAge_"+id).style.display="block";document.getElementById("fldSupAgeCH_"+id).style.display="none";document.getElementById("fldSupAgeIN_"+id).style.display="block";}}
function CheckUncheckSuplement(idxSup)
{ShowHideDivSuplement(idxSup);UpdateAllPricesAndTaxes();}
function SelectSuplement(idxSup)
{document.getElementById("fldSuplements_"+idxSup).checked=true;ShowHideDivSuplement(idxSup);}
function ShowHideDivSuplement(idxSup)
{var divSupData="div_SupData_"+idxSup;if(document.getElementById("fldSuplements_"+idxSup).checked)
{if(document.getElementById(divSupData)!=null)
{document.getElementById(divSupData).style.display="block";document.getElementById("fldSupTreatment_"+idxSup).setAttribute("name","fldSupTreatment_sel");document.getElementById("fldSupFirstName_"+idxSup).setAttribute("name","fldSupFirstName_sel");document.getElementById("fldSupLastName_"+idxSup).setAttribute("name","fldSupLastName_sel");document.getElementById("fldSupGender_"+idxSup).setAttribute("name","fldSupGender_sel");document.getElementById("fldSupPassengerType_"+idxSup).setAttribute("name","fldSupPassengerType_sel");document.getElementById("fldSupAgeCH_"+idxSup).setAttribute("name","fldSupAgeCH_sel");document.getElementById("fldSupAgeIN_"+idxSup).setAttribute("name","fldSupAgeIN_sel");}}
else
{if(document.getElementById(divSupData)!=null)
{document.getElementById(divSupData).style.display="none";document.getElementById("fldSupTreatment_"+idxSup).setAttribute("name","fldSupTreatment");document.getElementById("fldSupFirstName_"+idxSup).setAttribute("name","fldSupFirstName");document.getElementById("fldSupLastName_"+idxSup).setAttribute("name","fldSupLastName");document.getElementById("fldSupGender_"+idxSup).setAttribute("name","fldSupGender");document.getElementById("fldSupPassengerType_"+idxSup).setAttribute("name","fldSupPassengerType");document.getElementById("fldSupAgeCH_"+idxSup).setAttribute("name","fldSupAgeCH");document.getElementById("fldSupAgeIN_"+idxSup).setAttribute("name","fldSupAgeIN");}}}
function UpdateAllPricesAndTaxes()
{var idx;var valNumPersons=0;var valSupRoom,valSupBasePrice,valSupPassengerIndicator,valSupPricePerPersonIndicator;var valBasePrice,valExtrasPrice,valTaxesPrice,valTotalUnitPrice,valTotalPrice;valBasePrice=0;valExtrasPrice=Number(String(document.getElementById("div_ExtrasPrice").innerHTML).replace(",","."));idx=0;while(document.getElementById("hidRoomCapacity"+idx)!=null)
{valNumPersons+=Number(document.getElementById("hidRoomCapacity"+idx).value);valBasePrice+=Number(document.getElementById("hidRoomBasePrice"+idx).value);idx++;}
idx=0;while(document.getElementById("fldSuplements_"+idx)!=null)
{if(document.getElementById("fldSuplements_"+idx).checked)
{if(document.getElementById("hidSupPassengerIndicator"+idx).value=="YES")
{valNumPersons++;}}
idx++;}
idx=0;while(document.getElementById("fldSuplements_"+idx)!=null)
{if(document.getElementById("fldSuplements_"+idx).checked)
{valSupRoom=document.getElementById("hidSupRoom"+idx).value;valSupBasePrice=document.getElementById("hidSupBasePrice"+idx).value;valSupPassengerIndicator=document.getElementById("hidSupPassengerIndicator"+idx).value;valSupPricePerPersonIndicator=document.getElementById("hidSupPricePerPersonIndicator"+idx).value;if(valSupPassengerIndicator=="NO")
{if(valSupPricePerPersonIndicator=="YES")
{valBasePrice+=Number(valSupBasePrice)*Number(GetNumberPassengersByRoom(valSupRoom));}
else
{valBasePrice+=Number(valSupBasePrice);}}
else
{valBasePrice+=Number(valSupBasePrice);}}
idx++;}
valTaxesPrice=Number(valNumPersons)*Number(document.getElementById("hidTotalTaxPerPerson").value);valTotalPrice=Number(valBasePrice)+Number(valExtrasPrice)+Number(valTaxesPrice);if(Number(valNumPersons)>0)
valTotalUnitPrice=Number(valTotalPrice)/Number(valNumPersons);else
valTotalUnitPrice=Number(valTotalPrice);document.getElementById("div_BasePrice").innerHTML=String(valBasePrice.toFixed(2)).replace(".",",");document.getElementById("div_TaxesPrice").innerHTML=String(valTaxesPrice.toFixed(2)).replace(".",",");document.getElementById('div_TotalUnitPrice').innerHTML=String(valTotalUnitPrice.toFixed(2)).replace(".",",");document.getElementById('div_TotalPrice').innerHTML=String(valTotalPrice.toFixed(2)).replace(".",",");UpdateCreditValue();}
function UpdateCreditValue()
{var divCreditValue=document.getElementById('div_CreditValue');if(divCreditValue!=null)
{var valCreditValue=Number(String(divCreditValue.innerHTML).replace(",","."));var divTotalPrice=document.getElementById("div_TotalPrice");var valTotalPrice=Number(String(divTotalPrice.innerHTML).replace(",","."));var valCreditDuration=Number(document.getElementById("hidCreditDuration").value);var valCreditInterestRate=Number(document.getElementById("hidCreditInterestRate").value);valCreditValue=valTotalPrice*(1+(valCreditInterestRate/100))/valCreditDuration;divCreditValue.innerHTML=String(valCreditValue.toFixed(2)).replace(".",",");}}
function GetNumberPassengersByRoom(idxRoom)
{var idSupPass;var valNumPassengers=0;valNumPassengers+=Number(document.getElementById("hidRoomCapacity"+idxRoom).value);var i=0;while(document.getElementById("hidSupRoom"+i)!=null)
{if(document.getElementById("hidSupRoom"+i).value==idxRoom)
{if(document.getElementById("fldSuplements_"+i).checked)
{if(document.getElementById("hidSupPassengerIndicator"+i).value=="YES")
{valNumPassengers++;}}}
i++;}
return valNumPassengers;}
function ValidValue(value)
{return value!=null&&value!=""&&value!="undefined";}
function Error(id,desc)
{this.id=id;this.desc=desc;return this;}
function Trim(str)
{return str.replace(/^\s+|\s+$/,'');}
function ValidateEmail(email)
{var reg=/^(\w+(?:(\.|\-)\w+)*)@((?:\w+(?:(\.|\-)\w+)*\.)+)([a-z\d]{2,})$/i;return reg.test(email);}
function ValidatePassword(pass,minLength)
{return String(pass).length>=minLength;}
function Validation_Login(flag_login)
{if(flag_login=="login")
{document.getElementById("State").value="Login";document.getElementById("Event").value="Login";}
return ValidationSimpleLogin();}
function ValidationSimpleLogin()
{var minPassLength=4;var objEmail=document.getElementById("fldEmail");var objPassword=document.getElementById("fldPassword");if(!ValidateEmail(objEmail.value))
{alert("O E-mail não corresponde a um formato válido.");objEmail.focus();return false;}
if(!ValidatePassword(objPassword.value,minPassLength))
{alert("A password deve ter, no mínimo, "+minPassLength+" caracteres.");objPassword.focus();return false;}
return true;}
function Validation_RecoverPassword()
{var objEmail=document.getElementById("fldEmail");if(objEmail.value=="")
{alert("Por favor, insira o e-mail");objEmail.focus();return false;}
if(!ValidateEmail(objEmail.value))
{alert("Por favor, insira um e-mail válido");objEmail.focus();return false;}
return true;}
function RetiraAcentos(Campo)
{var Acentos="%E1%E0%E3%E2%E2%C1%C0%C3%C2%E9%EA%C9%CA%ED%CD%F3%F5%F4%D3%D4%D5%FA%DA%DC%E7%C7"
var Traducao="aaaaaAAAAeeEEiIoooOOOuUUcC";var Posic,Carac;var TempLog="";for(var i=0;i<Campo.length;i++)
{Carac=Campo.charAt(i);Posic=Acentos.indexOf(escape(Carac));if(Posic>-1&&escape(Carac).length>1)
{TempLog+=Traducao.charAt(Posic/3);}
else
{TempLog+=Campo.charAt(i);}}
return(TempLog);}
function VerifyChar(str)
{str=RetiraAcentos(Trim(str));str=String(str);str=str.replace(" ","");str=str.toUpperCase();var ch;if(str=="")
return false;for(var i=0;i<str.length;i++)
{ch=str.charAt(i);if((ch<"A"||"Z"<ch))
return false;}
return true;}
function VerifyNumber(str)
{var control=true;var ch;for(var i=0;i<str.length;i++)
{ch=str.charAt(i);if(ch<"0"||"9"<ch)
control=false;}
return control;}
function GetDaysInMonth(month)
{var minDaysInMonth=30;var maxDaysInMonth=31;if(month<8)
return(minDaysInMonth+(month%2));return(maxDaysInMonth-(month%2));}
function CheckDateAux(day,month,year)
{var control=(TestIfRegularYear(year)?28:29);if(day==0||month==0||year==0)
return false;if(month==2)
return(day<=control);return(day<=GetDaysInMonth(month));}
function VerifyDate(year,month,day)
{if(year!=-1&&month!=-1&&day!=-1)
return CheckDateAux(day,month,year);return true;}
function ValidatePassengersAux()
{for(var i=0;i<document.getElementsByName("fldFirstName").length;i++)
{var currentNameObj=document.getElementsByName("fldFirstName")[i];var currentSurnameObj=document.getElementsByName("fldLastName")[i];var currentDayObj=document.getElementsByName("fldNascimentoDia")[i];var currentMonthObj=document.getElementsByName("fldNascimentoMes")[i];var currentYearObj=document.getElementsByName("fldNascimentoAno")[i];currentNameObj.value=RetiraAcentos(currentNameObj.value);currentSurnameObj.value=RetiraAcentos(currentSurnameObj.value);if(!ValidValue(Trim(String(currentNameObj.value))))
{currentNameObj.focus();throw new Error("Passengers","Por favor, preencha o NOME do passageiro.");}
if(!VerifyChar(String(currentNameObj.value)))
{currentNameObj.focus();throw new Error("Passengers","O NOME dos passageiros apenas aceita letras (exclui acentua%C3%A7%C3%B5es, cedilhas e espa%C3%A7os).\n\nPor favor reescreva o seu nome.");}
if(!ValidValue(Trim(String(currentSurnameObj.value))))
{currentSurnameObj.focus();throw new Error("Passengers","Por favor, preencha o APELIDO do passageiro.");}
if(!VerifyChar(String(currentSurnameObj.value)))
{currentSurnameObj.focus();throw new Error("Passengers","O APELIDO dos passageiros apenas aceita letras (exclui acentua%C3%A7%C3%B5es, cedilhas e espa%C3%A7os).\n\nPor favor reescreva o seu nome.");}
if(!VerifyDate(currentYearObj.value,currentMonthObj.value,currentDayObj.value))
{currentDayObj.focus();throw new Error("Passengers","DATA de NASCIMENTO invv%C3%A1lida.");}}}
function CorrectTrim(str_var)
{var str=String(str_var);var result="";for(var i=0;i<str.length;i++)
{if(str.charAt(i)!=' ')
result+=str.charAt(i);}
return result;}
function ValidateBenef()
{document.getElementById("State").value="MoreServices";document.getElementById("Event").value="Book";if(document.getElementById("div_Benef")!=null)
{if(document.getElementById("div_Benef").style.display!="none")
{var sBenefName="";var oBenefName=document.getElementsByName("fldBenefName");for(var i=0;i<oBenefName.length;i++)
{sBenefName=CorrectTrim(String(oBenefName[i].value));if(!VerifyChar(sBenefName))
{alert(javascriptSentences[5]);oBenefName[i].focus()
return false;}}}}
if(document.getElementById("totalSpecial")!=null&&document.getElementById("totalSpecial").value!="0")
{return ValidateAllSpecial();}
return true;}
function ValidateAges()
{var types=document.getElementsByName('fldTipo');var days=document.getElementsByName('fldNascimentoDia');var months=document.getElementsByName('fldNascimentoMes');var years=document.getElementsByName('fldNascimentoAno');var dep=document.getElementById('departuredate').value;var date=new Date();var dateAux;var today;var depart=new Date();var isleap;var feb;for(var i=0;i<types.length;i++)
{if(types[i].value=="IN")
{isleap=(years[i].value%4==0&&(years[i].value%100!=0||years[i].value%400==0));feb=(Number(months[i].value)==2&&(Number(days[i].value)>29||(Number(days[i].value)==29&&!isleap)));date.setFullYear(Number(years[i].value),Number(months[i].value)-1,Number(days[i].value));depart.setFullYear(Number(dep.split('/')[0]),Number(dep.split('/')[1])-1,Number(dep.split('/')[2]));today=new Date();depart.setYear(depart.getFullYear()-3);if(feb||((Number(months[i].value)==4||Number(months[i].value)==6||Number(months[i].value)==9||Number(months[i].value)==11)&&Number(days[i].value)==31))
{alert(javascriptSentences[43]+(i+1)+javascriptSentences[44]);return false;}
else if(date.getTime()<=depart.getTime())
{alert(javascriptSentences[49]+(i+1)+javascriptSentences[47]);return false;}
else if(date.getTime()>today.getTime())
{alert(javascriptSentences[43]+(i+1)+javascriptSentences[46]);return false;}}
if(types[i].value=="CH")
{dateAux=new Date();isleap=(years[i].value%4==0&&(years[i].value%100!=0||years[i].value%400==0));feb=(Number(months[i].value)==2&&(Number(days[i].value)>29||(Number(days[i].value)==29&&!isleap)));date.setFullYear(Number(years[i].value),Number(months[i].value)-1,Number(days[i].value));depart.setFullYear(Number(dep.split('/')[0]),Number(dep.split('/')[1])-1,Number(dep.split('/')[2]));depart.setYear(depart.getFullYear()-12);dateAux.setFullYear(Number(dep.split('/')[0]),Number(dep.split('/')[1])-1,Number(dep.split('/')[2]));dateAux.setYear((Number(dateAux.getFullYear())-3));if(feb||((Number(months[i].value)==4||Number(months[i].value)==6||Number(months[i].value)==9||Number(months[i].value)==11)&&Number(days[i].value)==31))
{alert(javascriptSentences[43]+(i+1)+javascriptSentences[44]);return false;}
else if(date.getTime()<=depart.getTime())
{alert(javascriptSentences[49]+(i+1)+javascriptSentences[48]);return false;}
else if(date.getTime()>dateAux.getTime())
{alert(javascriptSentences[49]+(i+1)+javascriptSentences[45]);return false;}}}
return true;}
function ValidateGuestAux()
{var objTreatment,objFirstName,objLastName,objAge,objGender;var objDocType,objDocNumber,objDocExpDate;for(var i=0;i<document.getElementsByName("fldFirstName").length;i++)
{if(!document.getElementsByName("fldFirstName")[i].disabled==true)
{objFirstName=document.getElementsByName("fldFirstName")[i];objLastName=document.getElementsByName("fldLastName")[i];objGender=document.getElementById("fldGender_"+i);objFirstName.value=CorrectTrim(objFirstName.value);objLastName.value=CorrectTrim(objLastName.value);if(document.getElementById('fldNascimentoDia')!=null)
{if(!ValidateAges())
return false;}
if(document.getElementsByName("fldDocType")!=null)
{objDocType=document.getElementsByName("fldDocType")[i];objDocNumber=document.getElementsByName("fldDocNumber")[i];objDocExpdate=document.getElementsByName("fldDocExpDate")[i];}
objFirstName.value=RetiraAcentos(objFirstName.value);objLastName.value=RetiraAcentos(objLastName.value);if(!ValidValue(Trim(String(objFirstName.value))))
{objFirstName.focus();alert(javascriptSentences[6]);return false;}
if(!VerifyChar(String(objFirstName.value)))
{objFirstName.focus();alert(javascriptSentences[7]);return false;}
if(!ValidValue(Trim(String(objLastName.value))))
{objLastName.focus();alert(javascriptSentences[8]);return false;}
if(!VerifyChar(String(objLastName.value)))
{objLastName.focus();alert(javascriptSentences[9]);return false;}
if(document.getElementById("fldFFAirVendor_0")!=null)
{if(objFirstName.value.length>12)
{objFirstName.focus();alert("O NOME do Passageiro não pode ter mais que 12 caracteres.");return false;}
if(objLastName.value.length>12)
{objLastName.focus();alert("O APELIDO do Passageiro não pode ter mais que 12 caracteres.");return false;}}
if(!ValidValue(Trim(String(objGender.value))))
{alert(javascriptSentences[53]);return false;}
if(document.getElementById("fldComboBirthdateDay_"+i)!=null)
{if(document.getElementById("fldComboBirthdateDay_"+i).value=="")
{document.getElementById("fldComboBirthdateDay_"+i).focus();alert("A Data de Nascimento é obrigatória.\nPor favor escolha o dia da Data de Nascimento.");return false;}
if(document.getElementById("fldComboBirthdateMonth_"+i).value=="")
{document.getElementById("fldComboBirthdateMonth_"+i).focus();alert("A Data de Nascimento é obrigatória.\nPor favor escolha o mês da Data de Nascimento.");return false;}
if(document.getElementById("fldComboBirthdateYear_"+i).value=="")
{document.getElementById("fldComboBirthdateYear_"+i).focus();alert("A Data de Nascimento é obrigatória.\nPor favor escolha o ano da Data de Nascimento.");return false;}}}}
for(var i=0;i<document.getElementsByName("fldSupFirstName").length;i++)
{if(SuplementPerson(i))
{objFirstName=document.getElementsByName("fldSupFirstName")[i];objLastName=document.getElementsByName("fldSupLastName")[i];objGender=document.getElementById("fldSupGender_"+i);objFirstName.value=RetiraAcentos(objFirstName.value);objLastName.value=RetiraAcentos(objLastName.value);if(!ValidValue(Trim(String(objFirstName.value))))
{objFirstName.focus();alert(javascriptSentences[6]);return false;}
if(!VerifyChar(String(objFirstName.value)))
{objFirstName.focus();alert(javascriptSentences[7]);return false;}
if(!ValidValue(Trim(String(objLastName.value))))
{objLastName.focus();alert(javascriptSentences[8]);return false;}
if(!VerifyChar(String(objLastName.value)))
{objLastName.focus();alert(javascriptSentences[9]);return false;}
if(!ValidValue(Trim(String(objGender.value))))
{alert(javascriptSentences[53]);return false;}}}
if(document.getElementById('totalSpecial')!=null&&document.getElementById('totalSpecial').value!="0")
{return ValidateAllSpecial();}
CheckPassengersAndRegistry();return true;}
function SuplementPerson(i)
{var div_sup_data=document.getElementById(String(document.getElementsByName("fldSuplements")[i].id).replace("fldSuplements_","div_SupData_"));if(div_sup_data!=null)
return div_sup_data.style.display=="block";else
return false;}
function ValidatePaymentsAux()
{var strPaymentMethod=document.getElementById('fldPaymentMethod').value;var strCCType=document.getElementById('fldCCType').value;var objCCNumber=document.getElementById('fldCCNumber');var objCCName=document.getElementById('fldCCName');var objCCExpDateMonth=document.getElementById('fldCCExpDateMonth');var objCCExpDateYear=document.getElementById('fldCCExpDateYear');var objCCSecurityCode=document.getElementById('fldCCSecurityCode');var objPaymentAuthorization=document.getElementById('fldPaymentAuthorization');if(strPaymentMethod=="CCRED")
{if(objPaymentAuthorization.value=="NO")
{alert(javascriptSentences[40]);return false;}
objCCName.value=RetiraAcentos(objCCName.value);if(Trim(objCCName.value)==""||!VerifyChar(removeSpace(String(objCCName.value))))
{objCCName.focus();alert(javascriptSentences[10]);return false;}
if(!isCreditCardValid(objCCNumber.value,strCCType))
{objCCNumber.select();alert(javascriptSentences[11]);return false;}
if(strCCType!="AMEX")
{if(objCCSecurityCode.value==''||!VerifyNumber(objCCSecurityCode.value)||objCCSecurityCode.value.length!=3)
{objCCSecurityCode.focus();alert(javascriptSentences[12]);return false;}}
else
{if(objCCSecurityCode.value!='000')
{objCCSecurityCode.focus();alert(javascriptSentences[12]+"\nEste tipo de cartão não tem código de segurança");return false;}}
if(!VerifyDate(objCCExpDateYear.value,objCCExpDateMonth.value,1))
{objCCExpDateYear.focus();alert(javascriptSentences[13]);return false;}
var currDate=new Date();var currYear=currDate.getFullYear();var currMonth=currDate.getMonth()+1;var strCurrYear=String(currYear);var strCurrMonth=String(currMonth);if(strCurrMonth.length==1)strCurrMonth="0"+strCurrMonth;if((String(objCCExpDateYear.value)+String(objCCExpDateMonth.value))<(strCurrYear+strCurrMonth))
{objCCExpDateYear.focus();alert(javascriptSentences[13]);return false;}}
return true;}
function ValidateInvoiceData()
{var strInvoiceData=document.getElementById("fldInvoiceData").value;var objAddress=document.getElementById("fldInvoice"+strInvoiceData+"Address");var objPostalCode1=document.getElementById("fldInvoice"+strInvoiceData+"PostalCode1");var objPostalCode2=document.getElementById("fldInvoice"+strInvoiceData+"PostalCode2");var objPostalPlace=document.getElementById("fldInvoice"+strInvoiceData+"PostalPlace");var objCountry=document.getElementById("fldInvoice"+strInvoiceData+"Country");if(strInvoiceData=="LowFare")
{if(Trim(document.getElementById("fldInvoiceNIF").value)=="")
{document.getElementById("fldInvoiceNIF").focus();alert("O Nº de Contribuinte é obrigatório.");return false;}
if(Trim(document.getElementById("fldInvoiceFirstName").value)=="")
{document.getElementById("fldInvoiceFirstName").focus();alert("O Nome é obrigatório.");return false;}
if(Trim(document.getElementById("fldInvoiceLastName").value)=="")
{document.getElementById("fldInvoiceLastName").focus();alert("O Apelido é obrigatório.");return false;}
if(Trim(document.getElementById("fldInvoiceAddress").value)=="")
{document.getElementById("fldInvoiceAddress").focus();alert("A Morada é obrigatória.");return false;}
if(Trim(document.getElementById("fldInvoicePostalCode1").value)=="")
{document.getElementById("fldInvoicePostalCode1").focus();alert("O Código Postal é obrigatório.");return false;}
if(Trim(document.getElementById("fldInvoicePostalPlace").value)=="")
{document.getElementById("fldInvoicePostalPlace").focus();alert("A Localidade é obrigatória.");return false;}
if(document.getElementById("fldInvoiceCountry").value=="")
{document.getElementById("fldInvoiceCountry").focus();alert("O País é obrigatório.");return false;}
if(Trim(document.getElementById("fldInvoiceEmail").value)=="")
{document.getElementById("fldInvoiceEmail").focus();alert("O E-mail é obrigatório.");return false;}
if(!ValidateEmail(Trim(document.getElementById("fldInvoiceEmail").value)))
{document.getElementById("fldInvoiceEmail").focus();alert("O E-mail tem um formato inválido.\nPor favor insira um E-mail válido.");return false;}
if(Trim(document.getElementById("fldInvoicePhone").value)=="")
{document.getElementById("fldInvoicePhone").focus();alert("O Telefone é obrigatório.");return false;}}
else if(strInvoiceData=="Comp")
{var objCompany=document.getElementById("fldInvoiceCompany");var objCompNIF=document.getElementById("fldInvoiceCompNIF");if(Trim(objCompany.value)=="")
{objCompany.focus();alert("O campo da Companhia é obrigatório.");return false;}
if(Trim(objCompNIF.value)=="")
{objCompNIF.focus();alert("O campo do Nº Contribuinte é obrigatório.");return false;}}
else
{var objFirstName=document.getElementById("fldInvoice"+strInvoiceData+"FirstName");var objLastName=document.getElementById("fldInvoice"+strInvoiceData+"LastName");if(Trim(objFirstName.value)=="")
{objFirstName.focus();alert("O campo do Nome é obrigatório.");return false;}
if(Trim(objLastName.value)=="")
{objLastName.focus();alert("O campo do Apelido é obrigatório.");return false;}}
if(Trim(objAddress.value)=="")
{objAddress.focus();alert("O campo da Morada é obrigatório.");return false;}
if(Trim(objPostalCode1.value)=="")
{objPostalCode1.focus();alert("O campo do Código Postal é obrigatório.");return false;}
if(Trim(objPostalPlace.value)=="")
{objPostalPlace.focus();alert("O campo da Localidade é obrigatório.");return false;}
return true;}
function SetGender(sFldValue,sFldName,sFldCount)
{document.getElementById("fld"+sFldName+"_"+sFldCount).value=sFldValue;if(sFldValue=="M")
{document.getElementById("fldChk"+sFldName+"_M_"+sFldCount).checked=true;document.getElementById("fldChk"+sFldName+"_F_"+sFldCount).checked=false;}
else if(sFldValue=="F")
{document.getElementById("fldChk"+sFldName+"_M_"+sFldCount).checked=false;document.getElementById("fldChk"+sFldName+"_F_"+sFldCount).checked=true;}
else
{document.getElementById("fldChk"+sFldName+"_M_"+sFldCount).checked=false;document.getElementById("fldChk"+sFldName+"_F_"+sFldCount).checked=false;}}
function BirthDate(total,type)
{var today;var id;var minus;var obj;var value=0;var day;var month;var year;day=document.getElementById('departuredate').value.split('/')[2];month=document.getElementById('departuredate').value.split('/')[1];year=document.getElementById('departuredate').value.split('/')[0];for(i=0;i<total;i++)
{if(type=="")
{document.getElementById('fldNascimentoMes').value+=",";document.getElementById('fldNascimentoDia').value+=",";document.getElementById('fldNascimentoAno').value+=",";}
else
{today=new Date();today.setFullYear(year,month,day);id="idade_"+type+i;obj=document.getElementById(id);minus=obj.options[obj.selectedIndex].value;if(type=="bebe_")
{today.setMonth(today.getMonth()-minus);}
else
{today.setFullYear(today.getFullYear()-minus);}
value=today.getMonth()+1;document.getElementById('fldNascimentoMes').value+=","+value;document.getElementById('fldNascimentoDia').value+=","+today.getDate();document.getElementById('fldNascimentoAno').value+=","+today.getFullYear();}
today=null;}}
function Vaildate_Driver()
{document.getElementById("State").value="Passengers";document.getElementById("Event").value="Book";if(Trim(document.getElementById("fldFirstName_0").value)=="")
{alert("Tem de introduzir o nome do condutor");document.getElementById("fldFirstName_0").focus();return false;}
if(Trim(document.getElementById("fldFirstName_0").value)!=""&&!VerifyChar(removeSpace(String(document.getElementById("fldFirstName_0").value))))
{alert("O nome do condutor contém caracteres inválidos");document.getElementById("fldFirstName_0").focus();return false;}
if(Trim(document.getElementById("fldLastName_0").value)=="")
{alert("Tem de introduzir o apelido do condutor");document.getElementById("fldLastName_0").focus();return false;}
if(Trim(document.getElementById("fldLastName_0").value)!=""&&!VerifyChar(removeSpace(String(document.getElementById("fldLastName_0").value))))
{alert("O apelido do condutor contém caracteres inválidos");document.getElementById("fldLastName_0").focus();return false;}
if(Trim(document.getElementById("fldGender_0").value)=="")
{alert("Tem de seleccionar o sexo do condutor");return false;}
if(Trim(document.getElementById("fldAge_0").value)=="")
{alert("Tem de introduzir a idade do condutor");document.getElementById("fldAge_0").focus();return false;}
if(String(Number(document.getElementById("fldAge_0").value))=="NaN")
{alert("A idade do condutor não é válida");document.getElementById("fldAge_0").focus();return false;}
if(!CheckDateAux(document.getElementById("DrivingLicenceIssuedDate_1").options[document.getElementById("DrivingLicenceIssuedDate_1").selectedIndex].value,document.getElementById("DrivingLicenceIssuedDate_2").options[document.getElementById("DrivingLicenceIssuedDate_2").selectedIndex].value,document.getElementById("DrivingLicenceIssuedDate_3").options[document.getElementById("DrivingLicenceIssuedDate_3").selectedIndex].value))
{alert("A data de obtenção da carta de condução não é válida");return false;}
var today=new Date();today=new Date(today.getFullYear(),today.getMonth(),today.getDate());var issueDate=new Date(document.getElementById("DrivingLicenceIssuedDate_3").options[document.getElementById("DrivingLicenceIssuedDate_3").selectedIndex].value,document.getElementById("DrivingLicenceIssuedDate_2").options[document.getElementById("DrivingLicenceIssuedDate_2").selectedIndex].value-1,document.getElementById("DrivingLicenceIssuedDate_1").options[document.getElementById("DrivingLicenceIssuedDate_1").selectedIndex].value);if(today.getTime()<issueDate.getTime())
{alert("A data de obtenção da carta de condução não pode ser superior ao dia actual");return false;}
if(!CheckDateAux(document.getElementById("DrivingLicenceValidDate_1").options[document.getElementById("DrivingLicenceValidDate_1").selectedIndex].value,document.getElementById("DrivingLicenceValidDate_2").options[document.getElementById("DrivingLicenceValidDate_2").selectedIndex].value,document.getElementById("DrivingLicenceValidDate_3").options[document.getElementById("DrivingLicenceValidDate_3").selectedIndex].value))
{alert("A data de validade da carta de condução não é válida");return false;}
var validateDate=new Date(document.getElementById("DrivingLicenceValidDate_3").options[document.getElementById("DrivingLicenceValidDate_3").selectedIndex].value,document.getElementById("DrivingLicenceValidDate_2").options[document.getElementById("DrivingLicenceValidDate_2").selectedIndex].value-1,document.getElementById("DrivingLicenceValidDate_1").options[document.getElementById("DrivingLicenceValidDate_1").selectedIndex].value);if(today.getTime()>validateDate.getTime())
{alert("A data de validade da carta de condução não pode ser inferior ao dia actual");return false;}
if(Trim(document.getElementById("DrivingLicenceNumber").value)=="")
{alert("Tem de introduzir o número da carta de condução");document.getElementById("DrivingLicenceNumber").focus();return false;}
return true;}
function Validate_Guests()
{var result;if(document.getElementsByName('fldEmailCheque').length==0)
{if(document.getElementById('validToGo')!=null&&document.getElementById('validToGo').value=='0')
{alert(javascriptSentences[15]);return false;}
document.getElementById("State").value="Passengers";document.getElementById("Event").value="Book";var pass=ValidateGuestAux();if(!pass)
return false;var control=true;var str;if(document.getElementsByName('fldMyContactPhone')[0]!=null&&pass==true)
{str=String(document.getElementsByName('fldMyContactPhone')[0].value);if(String(document.getElementsByName('fldMyContactPhone')[0].value).indexOf(' ')!=-1)
{alert(javascriptSentences[35]);return false;}
if(String(document.getElementsByName('fldMyContactPhone')[0].value).indexOf('+')!=-1)
{alert(javascriptSentences[34]);return false;}
if(Trim(str)==""||str.length<9||str.length>15)
{document.getElementsByName('fldMyContactPhone')[0].focus()
alert(javascriptSentences[32]);return false;}
for(var i=0;i<str.length;i++)
{ch=str.charAt(i);if(ch<"0"||"9"<ch)
{document.getElementsByName('fldMyContactPhone')[0].focus()
alert(javascriptSentences[14]);return false;}}
if(Trim(document.getElementsByName('fldContactPhone')[0].value)!="")
{str=String(document.getElementsByName('fldContactPhone')[0].value);if(String(document.getElementsByName('fldContactPhone')[0].value).indexOf(' ')!=-1)
{alert(javascriptSentences[35]);return false;}
if(String(document.getElementsByName('fldContactPhone')[0].value).indexOf('+')!=-1)
{alert(javascriptSentences[34]);return false;}
if(Trim(str)==""||str.length<9||str.length>15)
{document.getElementsByName('fldContactPhone')[0].focus()
alert(javascriptSentences[33]);return false;}
NumberAux(str);}}
if(document.getElementsByName('fldContactName').length>0)
{document.getElementsByName('fldContactName')[0].value=RetiraAcentos(document.getElementsByName('fldContactName')[0].value);if(Trim(document.getElementsByName('fldContactName')[0].value)!=""&&!VerifyChar(removeSpace(String(document.getElementsByName('fldNomeCont')[0].value))))
{document.getElementsByName('fldContactName')[0].focus();alert(javascriptSentences[7]);return false;}}
if(control==false)
alert(javascriptSentences[14]);if(document.getElementById("fldChkCheckoutDisclaimer")!=null)
{if(document.getElementById("fldChkCheckoutDisclaimer").checked!=true)
{alert("Tem que aceitar as condições.");document.getElementById("fldChkCheckoutDisclaimer").focus();return false;}}
return pass&&control;}
else
{if(Trim(document.getElementsByName('fldEmailCheque')[0].value)==0||!ValidateEmail(Trim(document.getElementsByName('fldEmailCheque')[0].value)))
{alert(javascriptSentences[2]);return false;}
if(Trim(document.getElementsByName('fldPhone')[0].value)==0||!NumberAux(Trim(document.getElementsByName('fldPhone')[0].value)))
{alert(javascriptSentences[14]);return false;}
if(Trim(document.getElementsByName('fldFirstName')[0].value)==0||!VerifyChar(Trim(document.getElementsByName('fldFirstName')[0].value)))
{alert(javascriptSentences[7]);return false;}
if(Trim(document.getElementsByName('fldLastName')[0].value)==0||!VerifyChar(Trim(document.getElementsByName('fldLastName')[0].value)))
{alert(javascriptSentences[9]);return false;}
document.getElementById("State").value="Passengers";document.getElementById("Event").value="Book";}}
function NumberAux(str)
{str=String(str);for(var i=0;i<str.length;i++)
{ch=str.charAt(i);if(ch<"0"||"9"<ch)
{return false;}}
return true;}
function removeSpace(s)
{var temp="";for(var i=0;i<s.length;i++)
{if(s.charAt(i)!=' ')
temp+=s.charAt(i);}
return temp}
function Validation_Payments()
{document.getElementById("State").value="Payment";document.getElementById("Event").value="AditionalData";return(ValidatePaymentsAux()&&ValidateInvoiceData());}
function Validation_Payment_Ok()
{document.getElementById("State").value="Payment";document.getElementById("Event").value="AditionalData";return true;}
function Validation_Payment_NotOk()
{document.getElementById("State").value="MoreServices";document.getElementById("Event").value="Book";return true;}
function Validation_PaymentMinhas_Ok()
{document.getElementById("State").value="Payment";document.getElementById("Event").value="FromMinhasOk";return true;}
function Validation_PaymentMinhas_NotOk()
{document.getElementById("State").value="Payment";document.getElementById("Event").value="FromMinhasNotOk";return true;}
function Validation_Payments_Other()
{document.getElementById("State").value="Payment";document.getElementById("State").value="Thanks";return ValidatePaymentsAux();}
function MoreServices_Back()
{try
{document.getElementById("State").value="MoreServices";document.getElementById("Event").value="Back";}
catch(e)
{alert(decodeURIComponent(e.desc));return false;}}
function Payments_Back()
{try
{document.getElementById("State").value="MoreServices";document.getElementById("Event").value="Back";}
catch(e)
{alert(decodeURIComponent(e.desc));return false;}}
function Validation_Conclusion()
{document.getElementById("State").value="Reservation";return true;}
function Validation_OK()
{try
{document.getElementById("State").value="PrintReservation";}
catch(e)
{alert(decodeURIComponent(e.desc));return false;}}
function Confirmation_OK()
{try
{document.getElementById("State").value="Thanks";}
catch(e)
{alert(decodeURIComponent(e.desc));return false;}}
function isCreditCardValid(strCC_Number,strCC_Type)
{var CCTypeValidation;var strCC_Number_len=strCC_Number.length;var strCC_Type_Upper=String(removeSpace(strCC_Type.toUpperCase()));if(strCC_Number_len<4)
return false;var firstDigit=parseInt(strCC_Number.substr(0,1),10);var secondDigit=parseInt(strCC_Number.substr(1,1),10);var first4Digits=strCC_Number.substr(0,4);switch(strCC_Type_Upper)
{case"VISA":if(((strCC_Number_len==16)||(strCC_Number_len==13))&&(firstDigit==4))
CCTypeValidation=true;else
CCTypeValidation=false;break;case"MASTERCARD":case"EUROCARD":if((strCC_Number_len==16)&&(firstDigit==5)&&((secondDigit>=1)&&(secondDigit<=5)))
CCTypeValidation=true;else
CCTypeValidation=false;break;case"AMEX":case"AMERICANEXPRESS":if((strCC_Number_len==15)&&(firstDigit==3)&&((secondDigit==4)||(secondDigit==7)))
CCTypeValidation=true;else
CCTypeValidation=false;break;case"DINERSCLUB":case"CARTEBLANCHE":case"EBLANCHE":if((strCC_Number_len==14)&&(firstDigit==3)&&((secondDigit==0)||(secondDigit==6)||(secondDigit==8)))
CCTypeValidation=true;else
CCTypeValidation=false;break;case"DISCOVER":if((strCC_Number_len==16)&&(first4Digits=="6011"))
CCTypeValidation=true;else
CCTypeValidation=false;break;case"ENROUTE":if((strCC_Number_len==15)&&((first4Digits=="2014")||(first4Digits=="2149")))
CCTypeValidation=true;else
CCTypeValidation=false;break;case"JCB":if((strCC_Number_len==16)&&((first4Digits=="3088")||(first4Digits=="3096")||(first4Digits=="3112")||(first4Digits=="3158")||(first4Digits=="3337")||(first4Digits=="3528")))
CCTypeValidation=true;else
CCTypeValidation=false;break;default:CCTypeValidation=true;break;}
if(CCTypeValidation)
return isCreditCardNumberValid(strCC_Number);else
return false;}
function isCreditCardNumberValid(strCC_Number)
{var auxDigit,i,tproduct,sum,mul,strCC_Number_len;sum=0;mul=1;strCC_Number_len=strCC_Number.length;if(strCC_Number_len>19)
return false;for(i=0;i<strCC_Number_len;i++)
{auxDigit=strCC_Number.substr(strCC_Number_len-i-1,1);tproduct=parseInt(auxDigit,10)*mul;if(tproduct>=10)
sum+=(tproduct%10)+1;else
sum+=tproduct;if(mul==1)
mul++;else
mul--;}
if(sum%10==0)
return true;else
return false;}
function GetPageCoords(element)
{var coords={x:0,y:0};while(element)
{coords.x+=element.offsetLeft;coords.y+=element.offsetTop;element=element.offsetParent;}
return coords;}
function GetPageCoordsById(elementId)
{if(document.all)
{return GetPageCoords(document.all[elementId]);}
else if(document.getElementById)
{return GetPageCoords(document.getElementById(elementId));}}
var sIdEngineContainer="divEngineContainer";var defaultDayDiff=4;function DrawEnginesLinks(sHighlightLink,sIdContainer,sMenuText,sEngineType)
{var returnVal="";var objEngineContainer=document.getElementById(sIdEngineContainer);if(objEngineContainer==null)
return;var str="<div class=\"motorLayer_"+sHighlightLink+"\" id=\"motorLayer\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"lftLayer_motor\"/><td class=\"bgLayer_motor\"><div class=\"motor_itemOver\">"+sMenuText+"</div></td><td class=\"rgtLayer_motor\"/></tr></tbody></table></div>";document.getElementById("divSelectedMenuItem").innerHTML=str;if(sEngineType!="advanced")
objEngineContainer.innerHTML="<table cellspacing=\"0\" cellpadding=\"0\" class=\"motor\"><tbody><tr><td valign=\"top\" align=\"center\"><table cellspacing=\"0\" cellpadding=\"0\" class=\"motorAviao\"><tbody><tr><td height=\"65\"></td></tr><tr><td colspan=\"2\" class=\"line3D_horz_motor\"/></tr><tr><td align=\"center\" style=\"padding-top:15px; padding-bottom:15px;\">Aguarde por favor...</td></tr><tr><td colspan=\"2\" class=\"line3D_horz_motor\"/></tr><tr><td height=\"65\"></td></tr></tbody></table></td></tr></tbody></table>";else
objEngineContainer.innerHTML="<table cellspacing=\"0\" cellpadding=\"0\" class=\"motor_2\"><tbody><tr><td valign=\"top\" align=\"center\"><table cellspacing=\"0\" cellpadding=\"0\" class=\"motorAviao_2\"><tbody><tr><td height=\"65\"></td></tr><tr><td colspan=\"2\" class=\"line3D_horz_motor\"/></tr><tr><td align=\"center\" style=\"padding-top:15px; padding-bottom:15px;\">Aguarde por favor...</td></tr><tr><td colspan=\"2\" class=\"line3D_horz_motor\"/></tr><tr><td height=\"65\"></td></tr></tbody></table></td></tr></tbody></table>";switch(sHighlightLink)
{case"aviao":__getData("$_Engines_AirEngine",sIdEngineContainer);break;case"aviaoHotel":__getData("$_Engines_AirHotelEngine",sIdEngineContainer);break;case"hotel":if(sEngineType!="advanced")
__getData("$_Engines_HotelEngine",sIdEngineContainer);else
__getData("$_Engines_HotelEngineAdvanced",sIdEngineContainer);break;case"caro":__getData("$_Engines_CarEngine",sIdEngineContainer);break;case"ferias":__getData("$_Engines_VacationsEngine",sIdEngineContainer);break;case"evasoes":__getData("$_Engines_EvasionsEngine",sIdEngineContainer);break;default:break;}
var objContainer=document.getElementById(sIdContainer);if(objContainer!=null)
objContainer.innerHTML=returnVal;}
function ShowDivFrequentDestinations(divId,divIdclose,fldInput,refID,x,y)
{var sElement;document.getElementById(divId).style.display="block";if(divIdclose!="")
document.getElementById(divIdclose).style.display="none";document.getElementById("fldTextDestination_"+divId).value=fldInput;document.getElementById(divId).style.display="block";document.getElementById(divId).style.top=String(GetPageCoordsById(refID).y-y)+"px";document.getElementById(divId).style.left=String(GetPageCoordsById(refID).x+x)+"px";document.getElementById(divId).style.backgroundColor="white";var browserType=String(navigator.appVersion);if(browserType.toLowerCase().indexOf("msie")>-1&&browserType.toLowerCase().indexOf("7.0")==-1)
HideControls(divId);}
function CloseDivFrequentDestinations(divId,displayElements)
{var sElement;document.getElementById(divId).style.display="none";if(displayElements!=null&&displayElements!="")
{displayElements=String(displayElements);displayElements=displayElements.split(",");if(displayElements[0]!=null&&displayElements[0]!=""&&displayElements[0]!="undefined")
{for(var i=0;i<displayElements.length;i++)
{sElement=displayElements[i];sElement=sElement.replace(/^\s+|\s+$/g,'');if(document.getElementById(sElement)!=null)
{document.getElementById(sElement).style.visibility="visible";}
else
{try
{document.getElementsByName(sElement)[0].style.display="visible";}
catch(e)
{}}}}}}
function ChooseFrequentDestination(fldInput,value)
{var sInputField;var arrInputFields=document.getElementById(fldInput).value.split(",");for(var i=0;i<arrInputFields.length;i++)
{sInputField=arrInputFields[i];sInputField=sInputField.replace(/^\s+|\s+$/g,'');if(document.getElementById(sInputField)!=null)
{document.getElementById(sInputField).value=value;}}}
function GetNewDate(day,month,year)
{month--;return new Date(year,month,day);}
function RegularReservationDate(day,month,year)
{var dayTime=Number(86400000);var currentDate=new Date();currentDate.setHours(0);currentDate.setMinutes(0);currentDate.setSeconds(0);currentDate.setMilliseconds(0);var inDate=new Date(year,Number(month)-1,day);var diffDays=Number((inDate.valueOf()-currentDate.valueOf())/dayTime);return(Math.ceil(diffDays)>=defaultDayDiff);}
function CheckDate(day,month,year)
{if(!CheckDateAux(day,month,year)||!RegularReservationDate(day,month,year))
return false;return true;}
function GetTestNights(dateOut,dateIn)
{var dayTime=86400000;var nights=GetNightsValue(dateOut,dateIn);if(nights>=0)
return true;return false;}
function GetNightsValue(dateOut,dateIn)
{var dayTime=86400000;return((dateOut.valueOf()-dateIn.valueOf())/dayTime);}
function CheckDateAux(day,month,year)
{if(year<1000)
return false;if(month<1||month>12)
return false;if(day<1||day>31)
return false;return(day<=GetDaysInMonth(month,year));}
function GetDaysInMonth(month,year)
{var minDaysInMonth=30;var maxDaysInMonth=31;if(month<8)
{if(month==2)
return(TestIfRegularYear(year)?28:29);else
return(minDaysInMonth+(month%2));}
else
{return(maxDaysInMonth-(month%2));}}
function GetNights()
{var day1=document.getElementById('BegDay').options[document.getElementById('BegDay').options.selectedIndex].value;var month1=document.getElementById('BegMonth').options[document.getElementById('BegMonth').options.selectedIndex].value;var year1=document.getElementById('BegYear').options[document.getElementById('BegYear').options.selectedIndex].value;var day2=document.getElementById('EndDay').options[document.getElementById('EndDay').options.selectedIndex].value;var month2=document.getElementById('EndMonth').options[document.getElementById('EndMonth').options.selectedIndex].value;var year2=document.getElementById('EndYear').options[document.getElementById('EndYear').options.selectedIndex].value;var date1=new Date();var date2=new Date();var one_day=1000*60*60*24;date1.setFullYear(year1,month1-1,day1);date2.setFullYear(year2,month2-1,day2);var days=Math.ceil((date2.getTime()-date1.getTime())/(one_day));if(days<0)
document.getElementById('Nights').options.selectedIndex=0;else if(document.getElementById('Nights').options.length>=days)
document.getElementById('Nights').options.selectedIndex=days;else
document.getElementById('Nights').options.selectedIndex=45;}
function ReturnDateByNights(nights)
{var day1=document.getElementById('BegDay').options[document.getElementById('BegDay').options.selectedIndex].value;var month1=document.getElementById('BegMonth').options[document.getElementById('BegMonth').options.selectedIndex].value;var year1=document.getElementById('BegYear').options[document.getElementById('BegYear').options.selectedIndex].value;var date1=new Date();date1.setFullYear(year1,month1,day1);date1.setMonth(date1.getMonth()-1);var milliseg=date1.getTime()+(1000*60*60*24*nights);date1.setTime(milliseg);document.getElementById('EndDay').options.selectedIndex=date1.getDate()-1;document.getElementById('EndMonth').options.selectedIndex=date1.getMonth();document.getElementById('YanoMes2').options.selectedIndex=date1.getMonth()+1;SetDateFieldsCalendar(calendarDepartDIV_Hotel,calendarReturnDIV_Hotel,1);document.getElementById('EndDay').options.selectedIndex=date1.getDate()-1;SetDateFieldsCalendar(calendarDepartDIV_Hotel,calendarReturnDIV_Hotel,1);}
function ChangeAirEngineTripType()
{if(document.getElementById("engine_air_trip_type").checked)
{document.getElementById("td_engine_air_arrival_date").style.visibility="hidden";document.getElementById("td_engine_air_arrival_hours").style.visibility="hidden";document.getElementById("engine_air_arrival_hours").style.visibility="hidden";}
else
{document.getElementById("td_engine_air_arrival_date").style.visibility="visible";document.getElementById("td_engine_air_arrival_hours").style.visibility="visible";document.getElementById("engine_air_arrival_hours").style.visibility="visible";}}
function IsDateValid(strInput)
{var str=Trim(strInput);var day=str.split('/')[0];var month=str.split('/')[1];var year=str.split('/')[2];if(!IsNumberValid(day)||!IsNumberValid(month)||!IsNumberValid(year))
{return false;}
else
{if(String(year).length!=4)
{return false;}
else
{return ValidateDate(day,month,year);}}}
function IsDateValidAux(strInput)
{var str=Trim(strInput);var day=str.split('/')[0];var month=str.split('/')[1];var year=str.split('/')[2];var dias_semana=new Array("Domingo","Segunda-feira","Terça-feira","Quarta-feira","Quinta-feira","Sexta-feira","Sábado");var currentDate="";currentDate=document.getElementById("currentDate").value;var data=Trim(currentDate);var dataAux=data.split(' ')[0];var hora=data.split(' ')[1];var diaDoMes=dataAux.split('/')[0];var mes=dataAux.split('/')[1];var ano=dataAux.split('/')[2];var dataCorrente=new Date(ano,mes-1,diaDoMes,0,0,0);var diaDaSemana=dataCorrente.getDay();if(!IsNumberValid(day)||!IsNumberValid(month)||!IsNumberValid(year))
{return false;}
else
{if(String(year).length!=4)
{return false;}
else
{if(!ValidaDiaSemanaHora(diaDaSemana,hora,diaDoMes,mes,ano,day,month,year))
{return false;}
else
{return ValidateDate(day,month,year);}}}}
function ValidaDiaSemanaHora(diaDaSemana,hora,diaDoMes,mes,ano,day,month,year)
{var delta=0;delta.value=delta+document.getElementById("delta").value;if(diaDaSemana==0)
{var data=new Date(ano,mes-1,diaDoMes,0,0,0);var dataAux=new Date(year,month-1,day,0,0,0);data.setDate(data.getDate()+2+delta);if(dataAux<data)
{alert("Pesquise uma data com pelo menos "+(2+delta)+" dia(s) a partir da data de hoje.");return false;}
else
{return true;}}
if(diaDaSemana==1||diaDaSemana==2||diaDaSemana==3||diaDaSemana==4)
{if(hora<18)
{var data=new Date(ano,mes-1,diaDoMes,0,0,0);var dataAux=new Date(year,month-1,day,0,0,0);data.setDate(data.getDate()+1+delta);if(dataAux<data)
{alert("Pesquise uma data com pelo menos "+(1+delta)+" dia(s) a partir da data de hoje.");return false;}
else
{return true;}}
else
{var data=new Date(ano,mes-1,diaDoMes,0,0,0);var dataAux=new Date(year,month-1,day,0,0,0);data.setDate(data.getDate()+2+delta);if(dataAux<data)
{alert("Pesquise uma data com pelo menos "+(2+delta)+" dia(s) a partir da data de hoje.");return false;}
else
{return true;}}}
if(diaDaSemana==5)
{if(hora<18)
{var data=new Date(ano,mes-1,diaDoMes,0,0,0);var dataAux=new Date(year,month-1,day,0,0,0);data.setDate(data.getDate()+1+delta);if(dataAux<data)
{alert("Pesquise uma data com pelo menos "+(1+delta)+" dia(s) a partir da data de hoje.");return false;}
else
{return true;}}
else
{var data=new Date(ano,mes-1,diaDoMes,0,0,0);var dataAux=new Date(year,month-1,day,0,0,0);data.setDate(data.getDate()+4+delta);if(dataAux<data)
{alert("Pesquise uma data com pelo menos "+(4+delta)+" dia(s) a partir da data de hoje.");return false;}
else
{return true;}}}
if(diaDaSemana==6)
{var data=new Date(ano,mes-1,diaDoMes,0,0,0);var dataAux=new Date(year,month-1,day,0,0,0);data.setDate(data.getDate()+3+delta);if(dataAux<data)
{alert("Pesquise uma data com pelo menos "+(3+delta)+" dia(s) a partir da data de hoje.");return false;}
else
{return true;}}}
function ValidateDate(day,month,year)
{var totalDaysInFeb=(IsRegularYear(year)?28:29);if(month<1||month>12)
return false;if(month==2)
return(day<=totalDaysInFeb);else
return(day<=GetDaysInMonth(month));}
function IsRegularYear(year)
{return!(((year%4)==0&&(year%100)!=0)||(year%400)==0);}
function IsDateBetween(inputDate,minDateValid,maxDateValid)
{var inputDateObj=GetDateObject(inputDate);var minDateObj=GetDateObject(minDateValid);var maxDateObj=GetDateObject(maxDateValid);if(inputDateObj==null)
{return false;}
else
{if((minDateObj==null)&&(maxDateObj==null))
{return false;}
else
{if(minDateObj!=null)
{if(inputDateObj<minDateObj)
{return false;}}
if(maxDateObj!=null)
{if(inputDateObj>maxDateObj)
{return false;}}
return true;}}}
function GetDateObject(strInput)
{try
{var str=Trim(strInput);var day=str.split('/')[0];var month=str.split('/')[1];var year=str.split('/')[2];var dateObj=new Date();dateObj.setFullYear(Number(year));dateObj.setMonth(Number(month)-1);dateObj.setDate(Number(day));return dateObj;}
catch(ex)
{return null;}}
function IsNumberValid(strInput)
{var str=Trim(strInput);var currChar;for(var i=0;i<str.length;i++)
{currChar=str.charAt(i);if(currChar<"0"||"9"<currChar)
return false;}
return true;}
function ValidateAirEngine()
{var objDepartureDate=document.getElementsByName("engine_air_departure_date")[0];var objArrivalDate=document.getElementsByName("engine_air_arrival_date")[0];var objDepartureCity=document.getElementsByName("engine_air_departure_city")[0];var objArrivalCity=document.getElementsByName("engine_air_arrival_city")[0];if(objDepartureCity.value=="")
{alert("Introduza a cidade de partida");objDepartureCity.focus();return false;}
if(objArrivalCity.value=="")
{alert("Introduza a cidade de destino");objArrivalCity.focus();return false;}
if(!IsDateValidAux(objDepartureDate.value))
{alert("A data de partida não é válida");objDepartureDate.focus();return false;}
if(!IsDateBetween(objDepartureDate.value,document.getElementById("hidTomorrowDate").value,null))
{alert("A data de partida tem que ser posterior a data actual");objDepartureDate.focus();return false;}
if(!document.getElementById("engine_air_trip_type").checked)
{if(!IsDateValidAux(objArrivalDate.value))
{alert("A data de regresso não é válida");objArrivalDate.focus();return false;}
if(!IsDateBetween(objArrivalDate.value,document.getElementById("hidTomorrowDate").value,null))
{alert("A data de regresso tem que ser posterior a data actual");objArrivalDate.focus();return false;}
if(!GetTestNights(GetDateObject(objArrivalDate.value),GetDateObject(objDepartureDate.value)))
{alert("A data de partida é posterior à data de regresso");objDepartureDate.focus();return false;}}
return true;}
function ValidateAirHotelEngine()
{var dateIn=GetNewDate(document.getElementsByName('dias_Aviao_AH').item(0).value,document.getElementsByName('mes_Aviao_AH').item(0).value,document.getElementsByName('Yano_AH').item(0).value);var dateOut=GetNewDate(document.getElementsByName('dias_Aviao2_AH').item(0).value,document.getElementsByName('mes_Aviao2_AH').item(0).value,document.getElementsByName('Yano2_AH').item(0).value);if(!CheckDate(document.getElementsByName('dias_Aviao_AH').item(0).value,document.getElementsByName('mes_Aviao_AH').item(0).value,document.getElementsByName('Yano_AH').item(0).value))
{alert("A data de partida não é válida");document.getElementsByName('dias_Aviao_AH_mes_Aviao_AH_Yano_AH')[0].focus();return false;}
if(!CheckDate(document.getElementsByName('dias_Aviao2_AH').item(0).value,document.getElementsByName('mes_Aviao2_AH').item(0).value,document.getElementsByName('Yano2_AH').item(0).value))
{alert("A data de regresso não é válida");document.getElementsByName('dias_Aviao2_AH_mes_Aviao2_AH_Yano2_AH')[0].focus();return false;}
if(!GetTestNights(dateOut,dateIn))
{alert("A data de partida é posterior à data de regresso");document.getElementsByName('dias_Aviao_AH_mes_Aviao_AH_Yano_AH')[0].focus();return false;}
if(dateOut-dateIn<=0)
{alert("A data de regresso tem que ser posterior à data de partida");document.getElementsByName('dias_Aviao_AH_mes_Aviao_AH_Yano_AH')[0].focus();return false;}
if(document.getElementsByName('engine_airhotel_departure_city')[0].value!="")
{if(document.getElementsByName('engine_airhotel_arrival_city')[0].value=="")
{alert("Introduza a cidade de destino");document.getElementsByName('engine_airhotel_arrival_city')[0].focus();return false;}}
else
{alert("Introduza a cidade de partida");document.getElementsByName('engine_airhotel_departure_city')[0].focus();return false;}
var singles=document.getElementById("engine_airhotel_singles").value;var doubles=document.getElementById("engine_airhotel_doubles").value;var triples=document.getElementById("engine_airhotel_triples").value;var adults=document.getElementById("engine_airhotel_adults").value;var children=document.getElementById("engine_airhotel_children").value;var infants=document.getElementById("engine_airhotel_infants").value;if(Number(singles)+Number(doubles)*2+Number(triples)*3!=Number(adults)+Number(children)+Number(infants))
{alert("Pesquisa impossivel. Verifique a coerência entre o tipo de alojamento e o número de pessoas");return false;}
return true;}
function CheckEngineHotelLocation()
{if(document.getElementById("EngineHotelLocation")!=null)
{if(document.getElementById("EngineHotelLocation").value=="")
{document.getElementById("divEngineHotelBlock2").innerHTML=document.getElementById("divEngineHotelCheckinCheckout").innerHTML;document.getElementById("divEngineHotelCheckinCheckout").innerHTML="";document.getElementById("divEngineHotelName").innerHTML="";}
else
{document.getElementById("divEngineHotelBlock1").innerHTML=document.getElementById("divEngineHotelCheckinCheckout").innerHTML;document.getElementById("divEngineHotelCheckinCheckout").innerHTML="";document.getElementById("divEngineHotelBlock2").innerHTML=document.getElementById("divEngineHotelName").innerHTML;document.getElementById("divEngineHotelName").innerHTML="";}}}
function DisplayRooms(val)
{for(var i=1;i<=3;i++)
{obj=document.getElementById("div_engine_hotel_room"+i);if(obj!=null)
{if(i<=val)
obj.style.display="";else
obj.style.display="none";}}}
function ValidateHotelEngine()
{var dateIn=GetNewDate(document.getElementsByName('BegDay').item(0).value,document.getElementsByName('BegMonth').item(0).value,document.getElementsByName('BegYear').item(0).value);var dateOut=GetNewDate(document.getElementsByName('EndDay').item(0).value,document.getElementsByName('EndMonth').item(0).value,document.getElementsByName('EndYear').item(0).value);if(!CheckDate(document.getElementsByName('BegDay').item(0).value,document.getElementsByName('BegMonth').item(0).value,document.getElementsByName('BegYear').item(0).value))
{alert("A data de Check-In não é válida.");document.getElementsByName('BegDay_BegMonth_BegYear').item(0).focus();return false;}
if(!CheckDate(document.getElementsByName('EndDay').item(0).value,document.getElementsByName('EndMonth').item(0).value,document.getElementsByName('EndYear').item(0).value))
{alert("A data de Check-Out não é válida.");document.getElementsByName('EndDay_EndMonth_EndYear').item(0).focus();return false;}
if(dateOut-dateIn<=0)
{alert("A data de Check-Out tem que ser posterior à data de Check-In.");document.getElementsByName('BegDay_BegMonth_BegYear').item(0).focus();return false;}
if(document.getElementsByName('City')[0].value=="")
{alert("Tem de preencher o destino.");document.getElementsByName('City')[0].focus();return false;}
return true;}
function UpdateArrivalPlace()
{document.getElementById("engine_car_arrival_city").value=document.getElementById("engine_car_departure_city").value;}
function UpdateDeparturePlace()
{document.getElementById("engine_car_departure_city").value=document.getElementById("engine_car_arrival_city").value;}
function ValidateCarEngine()
{var dateIn=GetNewDate(document.getElementsByName('selCalDays_Car').item(0).value,document.getElementsByName('selCalMonths_Car').item(0).value,document.getElementsByName('selCalYears_Car').item(0).value);var dateOut=GetNewDate(document.getElementsByName('selCal2Days_Car').item(0).value,document.getElementsByName('selCal2Months_Car').item(0).value,document.getElementsByName('selCal2Years_Car').item(0).value);if(!CheckDate(document.getElementsByName('selCalDays_Car').item(0).value,document.getElementsByName('selCalMonths_Car').item(0).value,document.getElementsByName('selCalYears_Car').item(0).value))
{alert("A data de Levantamento não é válida");document.getElementsByName('selCalDays_Car_selCalMonths_Car_selCalYears_Car').item(0).focus();return false;}
if(!CheckDate(document.getElementsByName('selCal2Days_Car').item(0).value,document.getElementsByName('selCal2Months_Car').item(0).value,document.getElementsByName('selCal2Years_Car').item(0).value))
{alert("A data de devolução não é válida");document.getElementsByName('selCal2Days_Car_selCal2Months_Car_selCal2Years_Car').item(0).focus();return false;}
if(!GetTestNights(dateOut,dateIn))
{alert("A data de levantamento é posterior à data de devolução");document.getElementsByName('dias_Carro_mes_Carro_Yano').item(0).focus();return false;}
if(document.getElementsByName('engine_car_departure_city')[0].value!="")
{if(document.getElementsByName('engine_car_arrival_city')[0].value=="")
{alert("Introduza o local de devolução");document.getElementsByName('engine_car_arrival_city')[0].focus();return false;}}
else
{alert("Introduza o local de levantamento");document.getElementsByName('engine_car_departure_city')[0].focus();return false;}
return true;}
function BindVacationsEngine(sIdEngineForm,sIdEngineContainer,sEngineType)
{var objEngineForm=document.getElementById(sIdEngineForm);var objEngineContainer=document.getElementById(sIdEngineContainer);objEngineForm.action="/AjaxPage/searchbox.aspx?mtr=vacations";objEngineForm.target="ifrMotor";objEngineForm.submit();if(sEngineType!="advanced")
objEngineContainer.innerHTML="<table cellspacing=\"0\" cellpadding=\"0\" class=\"motor\"><tbody><tr><td valign=\"top\" align=\"center\"><table cellspacing=\"0\" cellpadding=\"0\" class=\"motorAviao\"><tbody><tr><td height=\"65\"></td></tr><tr><td colspan=\"2\" class=\"line3D_horz_motor\"/></tr><tr><td align=\"center\" style=\"padding-top:15px; padding-bottom:15px;\">Aguarde por favor...</td></tr><tr><td colspan=\"2\" class=\"line3D_horz_motor\"/></tr><tr><td height=\"65\"></td></tr></tbody></table></td></tr></tbody></table>";else
objEngineContainer.innerHTML="<table cellspacing=\"0\" cellpadding=\"0\" class=\"motor_2\"><tbody><tr><td valign=\"top\" align=\"center\"><table cellspacing=\"0\" cellpadding=\"0\" class=\"motorAviao_2\"><tbody><tr><td height=\"65\"></td></tr><tr><td colspan=\"2\" class=\"line3D_horz_motor\"/></tr><tr><td align=\"center\" style=\"padding-top:15px; padding-bottom:15px;\">Aguarde por favor...</td></tr><tr><td colspan=\"2\" class=\"line3D_horz_motor\"/></tr><tr><td height=\"65\"></td></tr></tbody></table></td></tr></tbody></table>";}
function BindEvasionsEngine(sIdEngineForm,sIdEngineContainer,sEngineType)
{var objEngineForm=document.getElementById(sIdEngineForm);var objEngineContainer=document.getElementById(sIdEngineContainer);objEngineForm.action="/AjaxPage/searchbox.aspx?mtr=evasions";objEngineForm.target="ifrMotor";objEngineForm.submit();if(sEngineType!="advanced")
objEngineContainer.innerHTML="<table cellspacing=\"0\" cellpadding=\"0\" class=\"motor\"><tbody><tr><td valign=\"top\" align=\"center\"><table cellspacing=\"0\" cellpadding=\"0\" class=\"motorAviao\"><tbody><tr><td height=\"65\"></td></tr><tr><td colspan=\"2\" class=\"line3D_horz_motor\"/></tr><tr><td align=\"center\" style=\"padding-top:15px; padding-bottom:15px;\">Aguarde por favor...</td></tr><tr><td colspan=\"2\" class=\"line3D_horz_motor\"/></tr><tr><td height=\"65\"></td></tr></tbody></table></td></tr></tbody></table>";else
objEngineContainer.innerHTML="<table cellspacing=\"0\" cellpadding=\"0\" class=\"motor_2\"><tbody><tr><td valign=\"top\" align=\"center\"><table cellspacing=\"0\" cellpadding=\"0\" class=\"motorAviao_2\"><tbody><tr><td height=\"65\"></td></tr><tr><td colspan=\"2\" class=\"line3D_horz_motor\"/></tr><tr><td align=\"center\" style=\"padding-top:15px; padding-bottom:15px;\">Aguarde por favor...</td></tr><tr><td colspan=\"2\" class=\"line3D_horz_motor\"/></tr><tr><td height=\"65\"></td></tr></tbody></table></td></tr></tbody></table>";}
var theObjects=document.getElementsByTagName("object");for(var i=0;i<theObjects.length;i++)
{theObjects[i].outerHTML=theObjects[i].outerHTML;}
function OpenPopupWindow(winURL,winName,winFeatures)
{var objWin=window.open(winURL,winName,winFeatures);objWin.focus();}
function info(flight_position)
{var form=window.open("AirFlightInfo.aspx","flight_info","left=30,screenX=30,top=50,screenY=50,width=850,height=700,scrollbars=yes,resizable=yes");form.focus();}
function isValidEmail(strEmail)
{var reg=/^(\w+(?:(\.|\-)\w+)*)@((?:\w+(?:(\.|\-)\w+)*\.)+)([a-z\d]{2,})$/i;return reg.test(strEmail);}
function oc(a)
{var o={};for(var i=0;i<a.length;i++)
{o[a[i]]='';}
return o;}
function upEngineContainer(){var sIdEngineContainer="divEngineContainer";var objEngineContainer=document.getElementById(sIdEngineContainer);if(objEngineContainer!=null)
{var strOpen="<table cellspacing='0' cellpadding='0'><tbody><tr><td width='336' style='width: 336px;'><table class='conteudo_left' cellspacing='0' cellpadding='0'><tbody><tr><td class='boxMotor'>";var strClose="</td></tr></tbody></table></td></tr></tbody></table>";var elementInnerHTML=objEngineContainer.innerHTML;if(elementInnerHTML.match("conteudo_left")==null)objEngineContainer.innerHTML=strOpen+objEngineContainer.innerHTML+strClose;}}
var myCalendar=new k4tCalendar();var myMonths=new Array();myMonths[1]="Janeiro";myMonths[2]="Fevereiro";myMonths[3]="Mar&ccedil;o";myMonths[4]="Abril";myMonths[5]="Maio";myMonths[6]="Junho";myMonths[7]="Julho";myMonths[8]="Agosto";myMonths[9]="Setembro";myMonths[10]="Outubro";myMonths[11]="Novembro";myMonths[12]="Dezembro";var myWeek=new Array();myWeek[0]="Dom";myWeek[1]="&nbsp;Seg&nbsp;";myWeek[2]="&nbsp;Ter&nbsp;";myWeek[3]="Qua&nbsp;";myWeek[4]="Qui&nbsp;";myWeek[5]="&nbsp;Sex&nbsp;";myWeek[6]="&nbsp;S&aacute;b&nbsp;";function CalendarConfig(){myCalendar.Id='myCalendar';myCalendar.containerId='CalSpan';myCalendar.onSelectDate=EventSelectDate;myCalendar.UseTooltipHeader=true;myCalendar.UseTooltipDays=true;myCalendar.UseTooltipFooter=true;myCalendar.minDate=new Date();myCalendar.maxDate=null;myCalendar.width="150px";myCalendar.height="150px";myCalendar.monthDesc=myMonths;myCalendar.weekDesc=myWeek;myCalendar.Draw();myCalendar.Hide();}
function myOnLoad(){CalendarConfig();chkCalendarVisibility(myCalendar);}
function showCalendar(obj){showCalendarInPosition(obj,10,-5);}
function showCalendarInPosition(obj,distX,distY){myCalendar.Show(obj,distX,distY);obj.select();return false;}
function updateCalendar(obj){myCalendar.Show(obj);}
var typeDays=new Array();typeDays[0]=1;typeDays[1]=0;typeDays[2]=1;function DateToString(myDate)
{var myDay=myDate.getDate();var myMonth=myDate.getMonth()+1;var myYear=myDate.getFullYear();myDay=addBeginZero(myDay);myMonth=addBeginZero(myMonth);return myDay+myCalendar.dateSpliter+myMonth+myCalendar.dateSpliter+myYear;}
function EventSelectDate(){var myDate=this.SelectedDate();this.caller.value=DateToString(myDate);this.caller.onchange();this.Hide();}
function hideCalendar(){myCalendar.Hide();}
function setMinDate(dateStr,typeIdx)
{if(dateStr=='now')
{myCalendar.minDate=new Date();myCalendar.maxDate=null;}
else
{var arrDate=dateStr.split('/');var date=new Date(arrDate[2],arrDate[1]-1,arrDate[0]);date.setDate(date.getDate()+typeDays[typeIdx]);myCalendar.minDate=date;myCalendar.maxDate=null;}}
function Update2ndDate(objVal1,objVal2,typeIdx)
{var tmpStr=objVal1.value.split('/');var date1=new Date(new Number(tmpStr[2]),new Number(tmpStr[1]-1),new Number(tmpStr[0]));tmpStr=objVal2.value.split('/');var date2=new Date(new Number(tmpStr[2]),new Number(tmpStr[1]-1),new Number(tmpStr[0]));if(date1>=date2)
{var myDate=date1;myDate.setDate(myDate.getDate()+typeDays[typeIdx]);objVal2.value=DateToString(myDate);}}
function SetNumNightsDate(objSelect,objVal1,objVal2)
{if(objSelect.selectedIndex!=0)
{var tmpStr=objVal1.value.split('/');var date1=new Date(new Number(tmpStr[2]),new Number(tmpStr[1]-1),new Number(tmpStr[0]));date1.setDate(date1.getDate()+objSelect.selectedIndex);objVal2.value=DateToString(date1)}
else
{objSelect.selectedIndex=1;SetNumNightsDate(objSelect,objVal1,objVal2);}}
function SetNumNights(objSelect,objVal1,objVal2)
{var one_day=1000*60*60*24
var tmpStr=objVal1.value.split('/');var date1=new Date(new Number(tmpStr[2]),new Number(tmpStr[1]-1),new Number(tmpStr[0]));tmpStr=objVal2.value.split('/');var date2=new Date(new Number(tmpStr[2]),new Number(tmpStr[1]-1),new Number(tmpStr[0]));objSelect.selectedIndex=Math.ceil((date2.getTime()-date1.getTime())/(one_day));}
function ExtractDateValues(dayId,monthId,yearId,value)
{var tmpStr=value.split('/');document.getElementById(dayId).value=new Number(tmpStr[0]);document.getElementById(monthId).value=new Number(tmpStr[1]);document.getElementById(yearId).value=new Number(tmpStr[2]);}
var calendarIdPrefix="k4tCalendar";function k4tCalendar(){this.ctor=function(){document.onclick=function(evt){if(document.onclick!=null)
eval(document.onclick);chkCalendarVisibility(evt,myCalendar);}}
this.ctor();this.Id='';this.containerId='';this.caller='';this.callerId='';this.dateSpliter='/';this.iDay=new Date().getDate();this.iMonth=new Date().getMonth()+1;this.iYear=new Date().getFullYear();this.minDate=null;this.maxDate=null;this.width=null;this.height=null;this.CloseText='x Fechar';this.ToolTipPreviousYearText='Ano anterior';this.ToolTipPreviousMonthText='M&ecirc;s anterior';this.ToolTipNextYearText='Ano seguinte';this.ToolTipNextMonthText='M&ecirc;s seguinte';this.ToolTipCloseText='Fechar calend&aacute;rio';this.CSSCalendarBackground='CSSCalendarBackground';this.CSSCellSpacer='CSSCellSpacer';this.CSSRowStart='CSSRowStart';this.CSSYearPrevious='CSSYearPrevious';this.CSSMonthPrevious='CSSMonthPrevious';this.CSSMonthNext='CSSMonthNext';this.CSSYearNext='CSSYearNext';this.CSSRowEnd='CSSRowEnd';this.CSSHeader='CSSHeader';this.CSSWeekDaysHeader='CSSWeekDaysHeader';this.CSSWeekEndsHeader='CSSWeekEndsHeader';this.CSSWeekDays='CSSWeekDays';this.CSSWeekEnds='CSSWeekEnds';this.CSSCurrentDay='CSSCurrentDay';this.CSSSelectDay='CSSSelectDay';this.CSSClose='CSSClose';this.CSSCloseText='CSSCloseText';this.Visible=false;this.MouseIsOver=false;this.UseTooltipHeader=false;this.UseTooltipDays=false;this.UseTooltipFooter=false;this.hiddenControls=null;this.onSelectDate=null;this.onYearPrevious=null;this.onMonthPrevious=null;this.onMonthNext=null;this.onYearNext=null;this.onShow=null;this.onHide=null;this.monthDesc=new Array();this.monthDesc[1]="Jan";this.monthDesc[2]="Fev";this.monthDesc[3]="Mar";this.monthDesc[4]="Abr";this.monthDesc[5]="Mai";this.monthDesc[6]="Jun";this.monthDesc[7]="Jul";this.monthDesc[8]="Ago";this.monthDesc[9]="Set";this.monthDesc[10]="Out";this.monthDesc[11]="Nov";this.monthDesc[12]="Dez";this.getMonth=function(monthIndex){var returnValue="";if(monthIndex>0&&monthIndex<13){returnValue=this.monthDesc[monthIndex];}
return returnValue;}
this.weekDesc=new Array();this.weekDesc[0]="D";this.weekDesc[1]="S";this.weekDesc[2]="T";this.weekDesc[3]="Q";this.weekDesc[4]="Q";this.weekDesc[5]="S";this.weekDesc[6]="S";this.getWeekDays=function(){return this.weekDesc;}
function fGetDaysInMonth(iMonth,iYear){var dPrevDate=new Date(iYear,iMonth+1,0);return dPrevDate.getDate();}
function isLeap(yyyy){var returnValue=false;returnValue=(yyyy%400==0)||((yyyy%4==0)&&(yyyy%100!=0));return returnValue;}
function isLeapYear(myYear){var returnValue=isLeap(myYear);return returnValue;}
function checkDate(myDayStr,myMonthStr,myYearStr){var myDate=new Date(myYearStr,(myMonthStr-1),myDayStr);return!(myDate.getMonth()!=(myMonthStr-1));}
this.selectElement=function(dayElementId){var dayElement=document.getElementById(dayElementId);if(dayElement!=null){dayElement.className=this.CSSSelectDay;}}
this.NextYear=function(){if(this.onYearNext!=null){this.onYearNext();}
this.iDay=this.getMaxMonthDay();var dDataInc=new Date(this.iYear+1,this.iMonth-1,this.iDay);this.iYear=dDataInc.getFullYear();this.iDay=this.getMaxMonthDay(this.iMonth);this.Draw();}
this.NextMonth=function(){if(this.onMonthNext!=null){this.onMonthNext();}
var dDataInc=new Date(this.iYear,this.iMonth-1,1);if(dDataInc.getMonth()==11){dDataInc.setFullYear(dDataInc.getFullYear()+1);dDataInc.setMonth(0);}
else{dDataInc.setMonth(dDataInc.getMonth()+1);}
this.iMonth=dDataInc.getMonth()+1;this.iYear=dDataInc.getFullYear();this.iDay=this.getMaxMonthDay(this.iMonth);this.Draw();}
this.PrevMonth=function(){if(this.onMonthPrevious!=null){this.onMonthPrevious();}
var dDataDec=new Date(this.iYear,this.iMonth-1,1);if(dDataDec.getMonth()==0){dDataDec.setFullYear(dDataDec.getFullYear()-1);dDataDec.setMonth(11);}
else{dDataDec.setMonth(dDataDec.getMonth()-1);}
this.iMonth=dDataDec.getMonth()+1;this.iYear=dDataDec.getFullYear();this.iDay=this.getMaxMonthDay(this.iMonth);this.Draw();}
this.PrevYear=function(){if(this.onYearPrevious!=null){this.onYearPrevious();}
this.iDay=this.getMaxMonthDay();var dDataDec=new Date(this.iYear-1,this.iMonth-1,this.iDay);this.iYear=dDataDec.getFullYear();this.iDay=this.getMaxMonthDay(this.iMonth);this.Draw();}
this.getMaxMonthDay=function(checkMonth){var myDate=new Date(this.iYear,checkMonth,0);var maxDate=myDate.getDate();var returnDay=this.iDay;if(maxDate<returnDay){returnDay=maxDate;}
return returnDay;}
this.SelectDay=function(iNewDay){if(checkDate(iNewDay,this.iMonth,this.iYear)){var dayElementId=calendarIdPrefix+"-Day-"+this.iDay+"-"+this.Id;var dayElement=document.getElementById(dayElementId);if(dayElement!=null){dayElement.className=this.CSSWeekDays;}
this.iDay=iNewDay;dayElementId=calendarIdPrefix+"-Day-"+this.iDay+"-"+this.Id;dayElement=document.getElementById(dayElementId);this.selectElement(dayElementId);this.Hide();if(this.onSelectDate!=null){this.onSelectDate();}}}
this.SelectDate=function(newDate){var myDay=newDate.getDate();var myMonth=newDate.getMonth();var myYear=newDate.getFullYear();this.iDay=myDay;this.iMonth=myMonth+1;this.iYear=myYear;this.Draw();}
this.SelectedDate=function(){return new Date(this.iYear,(this.iMonth-1),this.iDay);}
this.Show=function(caller,distX,distY){this.caller=caller;this.callerId=caller.id;if(this.onShow!=null){this.onShow();}
var containerElement=document.getElementById(this.containerId);containerElement.style.display='block';if(caller.value.length>0){this.SelectDate(getDateFromString(caller.value,this.dateSpliter));}
else{this.Draw();}
if(typeof distX!="undefined"){var posX=findPosX(caller)+caller.offsetWidth+distX;var posY=findPosY(caller)+distY;}
else{posX=findPosX(caller)+caller.offsetWidth+10;posY=findPosY(caller)-80;}
containerElement.style.left=posX+"px";containerElement.style.top=posY+"px";var foraEmX=((posX+containerElement.offsetWidth)>document.body.clientWidth);var foraEmY=((posY+containerElement.offsetHeight)>document.body.clientHeight);if(foraEmX){posX-=(document.body.clientWidth-(posX+containerElement.offsetWidth));containerElement.style.left=posX+"px";}
if(foraEmY){posY+=(document.body.clientHeight-(posY+containerElement.offsetHeight));containerElement.style.top=posY+"px";}
this.Visible=true;this.hideControls();if(this.UseTooltipHeader||this.UseTooltipDays||this.UseTooltipFooter)
startTooltip();}
this.Hide=function(){if(this.onHide!=null){this.onHide();}
this.showControls();var containerElement=document.getElementById(this.containerId);containerElement.style.display='none';this.Visible=false;document.onmousemove=null;}
this.Draw=function(){var outputHtml="";var CSSWidth="";var CSSHeight="";if(this.width!=null){CSSWidth="width: "+this.width+";";}
if(this.height!=null){CSSHeight="height: "+this.height+";";}
outputHtml+="<table class=\""+this.CSSCalendarBackground+"\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\" style=\""+CSSWidth+CSSHeight+" \" onmouseover=\""+this.Id+".MouseIsOver = true;\" onmouseout=\""+this.Id+".MouseIsOver = false;\">";outputHtml+="<tr>";outputHtml+="<td align=\"center\">";outputHtml+=this.DrawHeader();outputHtml+="</td>";outputHtml+="</tr>";outputHtml+="<tr>";outputHtml+="<td align=\"center\">";outputHtml+="<table width=\"100%\" cellspacing=\"2\" cellpadding=\"0\" style=\"border-top:1px solid #CCCCCC; border-bottom:1px solid #CCCCCC; background-color: #ffffff;\">";outputHtml+=this.DrawWheekDays();outputHtml+=this.DrawDays();outputHtml+="</table>";outputHtml+="</td>";outputHtml+="</tr>";outputHtml+="<tr>";outputHtml+="<td align=\"center\">";outputHtml+=this.DrawFooter();outputHtml+="</td>";outputHtml+="</tr>";outputHtml+="</table>";var containerElement=document.getElementById(this.containerId);containerElement.innerHTML=outputHtml;this.Visible=true;}
this.DrawHeader=function(){var outputHtml="";outputHtml+="<table width=\"100%\"id=\""+calendarIdPrefix+"Header-"+this.Id+"\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">";outputHtml+="<tr>";outputHtml+="<td class=\""+this.CSSRowStart+"\">&nbsp;</td>";outputHtml+="<td";if(this.UseTooltipHeader){outputHtml+=" onMouseover=\"hilite(this);ddrivetip('"+this.ToolTipPreviousYearText+"');\" onMouseout=\"restore(this);hideddrivetip();\"";}
else{outputHtml+=" onMouseover=\"hilite(this);\" onMouseout=\"restore(this);\"";}
outputHtml+=" onclick=\""+this.Id+".PrevYear();\" class=\""+this.CSSYearPrevious+"\" id=\""+calendarIdPrefix+"-PrevYear-"+this.Id+"\">&lt;&lt;</td>";outputHtml+="<td class=\""+this.CSSCellSpacer+"\">&nbsp;</td>";outputHtml+="<td";if(this.UseTooltipHeader){outputHtml+=" onMouseover=\"hilite(this);ddrivetip('"+this.ToolTipPreviousMonthText+"');\" onMouseout=\"restore(this);hideddrivetip();\"";}
else{outputHtml+=" onMouseover=\"hilite(this);\" onMouseout=\"restore(this);\"";}
outputHtml+=" onclick=\""+this.Id+".PrevMonth();\" class=\""+this.CSSMonthPrevious+"\" id=\""+calendarIdPrefix+"-PrevMonth-"+this.Id+"\">&lt;</td>";outputHtml+="<td class=\""+this.CSSCellSpacer+"\">&nbsp;</td>";outputHtml+="<td class=\""+this.CSSHeader+"\" nowrap>"+this.getMonth(this.iMonth)+" "+this.iYear+"</td>";outputHtml+="<td class=\""+this.CSSCellSpacer+"\">&nbsp;</td>";outputHtml+="<td";if(this.UseTooltipHeader){outputHtml+=" onMouseover=\"hilite(this);ddrivetip('"+this.ToolTipNextMonthText+"');\"; onMouseout=\"restore(this);hideddrivetip();\"";}
else{outputHtml+=" onMouseover=\"hilite(this);\" onMouseout=\"restore(this);\"";}
outputHtml+=" onclick=\""+this.Id+".NextMonth();\" class=\""+this.CSSMonthNext+"\" id=\""+calendarIdPrefix+"-NextMonth-"+this.Id+"\">&gt;</td>";outputHtml+="<td class=\""+this.CSSCellSpacer+"\">&nbsp;</td>";outputHtml+="<td";if(this.UseTooltipHeader){outputHtml+=" onMouseover=\"hilite(this);ddrivetip('"+this.ToolTipNextYearText+"');\"; onMouseout=\"restore(this);hideddrivetip();\"";}
else{outputHtml+=" onMouseover=\"hilite(this);\" onMouseout=\"restore(this);\"";}
outputHtml+=" onclick=\""+this.Id+".NextYear();\" class=\""+this.CSSYearNext+"\" id=\""+calendarIdPrefix+"-NextYear-"+this.Id+"\">&gt;&gt;</td>";outputHtml+="<td class=\""+this.CSSRowEnd+"\">&nbsp;</td>";outputHtml+="</tr>";outputHtml+="</table>";return outputHtml;}
this.DrawWheekDays=function(){var aWeekd=this.getWeekDays();var outputHtml="";outputHtml+="<tr>";for(var iWeek=0;iWeek<aWeekd.length;iWeek++){var className=this.CSSWeekDaysHeader;if(iWeek==0||iWeek==6){className=this.CSSWeekEndsHeader;}
outputHtml+="<td  class=\""+className+"\">"+aWeekd[iWeek]+"</td>";}
outputHtml+="</tr>";return outputHtml;}
this.DrawDays=function(){var myMonth=new Array();myMonth[0]=new Array(7);myMonth[1]=new Array(7);myMonth[2]=new Array(7);myMonth[3]=new Array(7);myMonth[4]=new Array(7);myMonth[5]=new Array(7);var dCalDate=new Date(this.iYear,this.iMonth-1,1);var iDayOfFirst=dCalDate.getDay();var iDaysInMonth=fGetDaysInMonth(dCalDate.getMonth(),dCalDate.getFullYear());var iVarDate=1;var i,d,w;for(d=iDayOfFirst;d<7;d++){myMonth[0][d]=iVarDate;iVarDate++;}
for(w=1;w<myMonth.length;w++){for(d=0;d<7;d++){if(iVarDate<=iDaysInMonth){myMonth[w][d]=iVarDate;iVarDate++;}
else{myMonth[w][d]=0;}}}
var outputHtml="";var DayCount=0;for(w=0;w<myMonth.length;w++){var newRow="<tr height=\"20\">";var gotDays=false;for(d=0;d<7;d++){if(myMonth[w][d]>0){DayCount++;gotDays=true;var className=this.CSSWeekDays;if(d==0||d==6)
className=this.CSSWeekEnds;if((new Date().getDate()==myMonth[w][d])&&(new Date().getMonth()+1==this.iMonth)&&(new Date().getFullYear()==this.iYear)){className=this.CSSCurrentDay;}
if(myMonth[w][d]==this.iDay){className=this.CSSSelectDay;}
var diaValido=false;var validoMin=false;if(this.minDate!=null){if(new Date(this.iYear,this.iMonth-1,myMonth[w][d])>=this.minDate)
validoMin=true;else
validoMin=false;}
else{validoMin=true;}
var validoMax=false;if(this.maxDate!=null){if(new Date(this.iYear,this.iMonth-1,myMonth[w][d])<=this.maxDate)
validoMax=true;else
validoMax=false;}
else{validoMax=true;}
diaValido=validoMin&&validoMax;var visibleDayText=addBeginZero(DayCount);var visibleMonthText=this.getMonth(this.iMonth);newRow+="<td id='"+calendarIdPrefix+"-Day-"+DayCount+"-"+this.Id+"' class='"+className+"'";if(this.UseTooltipDays){newRow+=" onMouseover=\"hilite(this);ddrivetip('"+visibleDayText+" de "+visibleMonthText+" de "+this.iYear+"');\"; onMouseout=\"restore(this);hideddrivetip();\"";}
else{newRow+=" onMouseover=\"hilite(this);\" onMouseout=\"restore(this);\"";}
if(diaValido){newRow+=" onclick=\""+this.Id+".SelectDay("+DayCount+");\" style='cursor: pointer;'>";}
else{newRow+=" style='filter: alpha(opacity=30);-moz-opacity:.30;opacity:.30;cursor: no-drop;'>";}
newRow+=myMonth[w][d];}else{newRow+="<td>";newRow+="&nbsp;";}
newRow+="</td>";}
newRow+="</tr>";if(gotDays){outputHtml+=newRow;}}
return outputHtml;}
this.DrawFooter=function(){var outputHtml="";outputHtml+="<table id=\"CalHeader-"+this.Id+"\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">";outputHtml+="<tr>";outputHtml+="<td class=\""+this.CSSRowStart+"\" width=\"30%\">&nbsp;</td>";outputHtml+="<td class=\""+this.CSSClose+"\"  width=\"40%\" id=\""+calendarIdPrefix+"-CloseButton-"+this.Id+"\" onclick=\""+this.Id+".Hide(); return false;\" nowrap";if(this.UseTooltipFooter){outputHtml+=" onMouseover=\"hilite(this);ddrivetip('"+this.ToolTipCloseText+"');\"; onMouseout=\"restore(this);hideddrivetip();\"";}
else{outputHtml+=" onMouseover=\"hilite(this);\" onMouseout=\"restore(this);\"";}
outputHtml+=">"+this.CloseText+"</td>";outputHtml+="<td class=\""+this.CSSRowEnd+"\" width=\"30%\">&nbsp;</td>";outputHtml+="</tr>";outputHtml+="</table>";return outputHtml;}
this.setElementUnder=function(){if(this.CSSCalendarBackground.length>0){var thisCalendar=document.getElementById(this.containerId);var posX=thisCalendar.offsetLeft;var posY=thisCalendar.offsetTop;var width=thisCalendar.offsetWidth;var height=thisCalendar.offsetHeight;var backgroundElementId=calendarIdPrefix+"-Background-"+this.Id;var targetElement=document.getElementById(backgroundElementId);if(targetElement==null){var myElement=document.createElement("<span id=\""+backgroundElementId+"\" class=\""+this.CSSCalendarBackground+"\"></span>");document.getElementById("body").appendChild(myElement);targetElement=document.getElementById(backgroundElementId);}
targetElement.style.left=posX;targetElement.style.top=posY;targetElement.style.width=width;targetElement.style.height=height;thisCalendar.style.zIndex=10000;targetElement.style.zIndex=thisCalendar.style.zIndex-1;}}
this.hideControls=function(){this.hiddenControls=new Array();var aboveElement=document.getElementById(this.containerId);var arrElements=document.getElementsByTagName('SELECT');for(var myIndex=0;myIndex<arrElements.length;myIndex++){var myElement=arrElements[myIndex];var elementInside=isInside(aboveElement,myElement);if(elementInside){myElement.style.visibility='hidden';this.hiddenControls[this.hiddenControls.length]=myElement;}}}
this.showControls=function(){if(this.hiddenControls!=null){for(var myIndex=0;myIndex<this.hiddenControls.length;myIndex++){var myElement=this.hiddenControls[myIndex];myElement.style.visibility='visible';}
this.hiddenControls=null;}}}
function addBeginZero(valor){var returnValue=valor;if(valor<10){returnValue="0"+valor;}
return returnValue;}
function isDate(value){return!isNaN(new Date(value));}
function chkDate(obj){var returnValue=isDate(obj.value);if(!returnValue){alert('Data inválida');obj.focus();}
return returnValue;}
function getDateFromString(myValue,splitter){var returnDate=new Date();if(isDate(myValue,0)){var dateArr=myValue.split(splitter);if(dateArr.length==3){var myYear=Number(dateArr[2]);var myMonth=Number(dateArr[1]);var myDay=Number(dateArr[0]);returnDate=new Date(myYear,myMonth-1,myDay);}}
return returnDate;}
function findPosX(obj){var curleft=0;if(obj.offsetParent)
{while(obj.offsetParent)
{curleft+=obj.offsetLeft
obj=obj.offsetParent;}}
else if(obj.x)
curleft+=obj.x;return curleft;}
function findPosY(obj){var curtop=0;if(obj.offsetParent)
{while(obj.offsetParent)
{curtop+=obj.offsetTop
obj=obj.offsetParent;}}
else if(obj.y)
curtop+=obj.y;return curtop;}
function isInside(containerElement,element){var returnValue=false;var width=element.offsetWidth;var height=element.offsetHeight;var elementX1=findPosX(element);var elementY1=findPosY(element);var elementX2=elementX1+width;var elementY2=elementY1;var elementX3=elementX1;var elementY3=elementY1+height;var elementX4=elementX1+width;var elementY4=elementY1+height;if(!returnValue)
returnValue=returnValue||isInsideArea(containerElement,elementX1,elementY1);if(!returnValue)
returnValue=returnValue||isInsideArea(containerElement,elementX2,elementY2);if(!returnValue)
returnValue=returnValue||isInsideArea(containerElement,elementX3,elementY3);if(!returnValue)
returnValue=returnValue||isInsideArea(containerElement,elementX4,elementY4);if(!returnValue)
returnValue=returnValue||intersectLines(containerElement,elementX1,elementY1,elementX2,elementY2);if(!returnValue)
returnValue=returnValue||intersectLines(containerElement,elementX2,elementY2,elementX4,elementY4);if(!returnValue)
returnValue=returnValue||intersectLines(containerElement,elementX4,elementY4,elementX3,elementY3);if(!returnValue)
returnValue=returnValue||intersectLines(containerElement,elementX3,elementY3,elementX1,elementY1);return returnValue;}
function isInsideArea(containerElement,myX,myY){var returnValue=false;var width=containerElement.offsetWidth;var height=containerElement.offsetHeight;var containerX1=findPosX(containerElement);var containerY1=findPosY(containerElement);var containerX2=containerX1+width;var containerY2=containerY1;var containerX3=containerX1;var containerY3=containerY1+height;var containerX4=containerX1+width;var containerY4=containerY1+height;if((containerX1<=myX)&&(containerX2>=myX)){if((containerY1<=myY)&&(containerY3>=myY)){returnValue=true;}}
return returnValue;return true;}
function intersectLines(containerElement,lineX1,lineY1,LineX2,LineY2){var returnValue=false;var containerWidth=containerElement.offsetWidth;var containerHeight=containerElement.offsetHeight;var containerX1=findPosX(containerElement);var containerY1=findPosY(containerElement);var containerX2=containerX1+containerWidth;var containerY2=containerY1;var containerX3=containerX1;var containerY3=containerY1+containerHeight;var containerX4=containerX1+containerWidth;var containerY4=containerY1+containerHeight;if(!returnValue)
returnValue=returnValue||intersect(containerX1,containerY1,containerX2,containerY2,lineX1,lineY1,LineX2,LineY2);if(!returnValue)
returnValue=returnValue||intersect(containerX2,containerY2,containerX4,containerY4,lineX1,lineY1,LineX2,LineY2);if(!returnValue)
returnValue=returnValue||intersect(containerX4,containerY4,containerX3,containerY3,lineX1,lineY1,LineX2,LineY2);if(!returnValue)
returnValue=returnValue||intersect(containerX3,containerY3,containerX1,containerY1,lineX1,lineY1,LineX2,LineY2);return returnValue;}
function intersect(line1X1,line1Y1,line1X2,line1Y2,line2X1,line2Y1,line2X2,line2Y2){var returnValue=false;if((line1X1<=line2X1)&&(line2X1<=line1X2)){if((line2Y1<=line1Y1)&&(line1Y1<=line2Y2)){returnValue=true;}}
return returnValue;}
function getElementHeight(Elem){if(ns4){var elem=getObjNN4(document,Elem);return elem.clip.height;}
else
{if(document.getElementById){var elem=document.getElementById(Elem);}
else if(document.all){var elem=document.all[Elem];}
if(op5){xPos=elem.style.pixelHeight;}else{xPos=elem.offsetHeight;}
return xPos;}}
function getElementWidth(Elem){if(ns4){var elem=getObjNN4(document,Elem);return elem.clip.width;}else{if(document.getElementById){var elem=document.getElementById(Elem);}else if(document.all){var elem=document.all[Elem];}
if(op5){xPos=elem.style.pixelWidth;}else{xPos=elem.offsetWidth;}
return xPos;}}
function getObjNN4(obj,name)
{var x=obj.layers;var foundLayer;for(var i=0;i<x.length;i++)
{if(x[i].id==name)
foundLayer=x[i];else if(x[i].layers.length)
var tmp=getObjNN4(x[i],name);if(tmp)foundLayer=tmp;}
return foundLayer;}
function chkDate(obj){var returnValue=true;if(!isDate(obj.value,0)){alert('Data inválida');obj.select();obj.focus();returnValue=false;}
return returnValue;}
function isDigit(theDigit){var digitArray=new Array('0','1','2','3','4','5','6','7','8','9'),j;for(j=0;j<digitArray.length;j++){if(theDigit==digitArray[j]){return true;}}
return false;}
function isPositiveInteger(theString){var theData=new String(theString)
if(!isDigit(theData.charAt(0))){if(!(theData.charAt(0)=='+')){return false;}}
for(var i=1;i<theData.length;i++){if(!isDigit(theData.charAt(i))){return false;}}
return true;}
function isDate2(s,f){var a1=s.split("/");var a2=s.split("-");var e=true;if((a1.length!=3)&&(a2.length!=3)){e=false;}
else{if(a1.length==3)
var na=a1;if(a2.length==3)
var na=a2;if(isPositiveInteger(na[0])&&isPositiveInteger(na[1])&&isPositiveInteger(na[2])){if(f==1){var d=na[1],m=na[0];}
else{var d=na[0],m=na[1];}
var y=na[2];if(((e)&&(y<1000)||y.length>4)){e=false}
if(e){v=new Date(m+"/"+d+"/"+y);if(v.getMonth()!=m-1){e=false;}}}
else{e=false;}}
return e;}
function chkCalendarVisibility(evt,objCalendar){if(window.event)
evt=window.event;if(objCalendar!=null&&evt!=null){var node;if(window.event){node=evt.srcElement;}else{node=evt.target;while(node.nodeType!=node.ELEMENT_NODE)
node=node.parentNode;}
if(node!=null){if(node.id!=objCalendar.callerId){if(objCalendar.Visible&&!objCalendar.MouseIsOver){objCalendar.Hide();}}}}}
var cssHilitePrefix="_hilite";function hilite(item){var sClass=item.className;if(checkSubstring(sClass))
return;item.className=sClass+cssHilitePrefix;}
function restore(item){var sClass=item.className;if(!checkSubstring(sClass))
return;item.className=sClass.substring(0,(sClass.length-cssHilitePrefix.length));}
function checkSubstring(sClass){if(sClass.substring((sClass.length-cssHilitePrefix.length),sClass.length)==cssHilitePrefix){return true;}
return false;}
var tipobj=null;var pointerobj=null;var offsetfromcursorX=12;var offsetfromcursorY=10;var offsetdivfrompointerX=10;var offsetdivfrompointerY=14;var ie=document.all;var ns6=document.getElementById&&!document.all;var enabletip=false;function startTooltip(){if(ie||ns6)
tipobj=document.all?document.all["dhtmltooltip"]:document.getElementById?document.getElementById("dhtmltooltip"):"";pointerobj=document.all?document.all["dhtmlpointer"]:document.getElementById?document.getElementById("dhtmlpointer"):"";document.onmousemove=positiontip;}
function ietruebody(){return(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body;}
function ddrivetip(thetext,thewidth,thecolor){if(ns6||ie){if(typeof thewidth!="undefined")
tipobj.style.width=thewidth+"px";if(typeof thecolor!="undefined"&&thecolor!="")
tipobj.style.backgroundColor=thecolor;tipobj.innerHTML=thetext;enabletip=true;return false;}}
function positiontip(e){if(enabletip){var nondefaultpos=false;var curX=(ns6)?e.pageX:event.clientX+ietruebody().scrollLeft;var curY=(ns6)?e.pageY:event.clientY+ietruebody().scrollTop;var winwidth=ie&&!window.opera?ietruebody().clientWidth:window.innerWidth-20;var winheight=ie&&!window.opera?ietruebody().clientHeight:window.innerHeight-20;var rightedge=ie&&!window.opera?winwidth-event.clientX-offsetfromcursorX:winwidth-e.clientX-offsetfromcursorX;var bottomedge=ie&&!window.opera?winheight-event.clientY-offsetfromcursorY:winheight-e.clientY-offsetfromcursorY;var leftedge=(offsetfromcursorX<0)?offsetfromcursorX*(-1):-1000;if(rightedge<tipobj.offsetWidth){tipobj.style.left=curX-tipobj.offsetWidth+"px";nondefaultpos=true;}
else if(curX<leftedge)
tipobj.style.left="5px";else{tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px";pointerobj.style.left=curX+offsetfromcursorX+"px";}
if(bottomedge<tipobj.offsetHeight){tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px";nondefaultpos=true;}
else{tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px";pointerobj.style.top=curY+offsetfromcursorY+"px";}
tipobj.style.visibility="visible";if(!nondefaultpos)
pointerobj.style.visibility="visible";else
pointerobj.style.visibility="hidden";}}
function hideddrivetip(){if(ns6||ie){enabletip=false;tipobj.style.visibility="hidden";pointerobj.style.visibility="hidden";tipobj.style.left="-1000px";tipobj.style.backgroundColor='';tipobj.style.width='';}}