
var ranPageLoad=false;
var numOfRegions="";
var lcId = new Date().getTime();
function ngToggleJourney(id,openStateId,calendarSelection)
{
if(calendarSelection == 0)
{
visible = $("#"+id+"-body").css("display");
if(visible == "block")
$("#"+id+"-body").slideUp(250,function(){
$("#"+id+"-body").hide();
document.getElementById(openStateId).value = "false";
$("#"+id+"-arrow").attr("src","/cms/global/assets/images/site/icon/arrowBlackRight.gif");
});
else
$("#"+id+"-body").slideDown(250,function(){
$("#"+id+"-body").show();
document.getElementById(openStateId).value = "true";
$("#"+id+"-arrow").attr("src","/cms/global/assets/images/site/icon/arrowBlackDown.gif");
});
setToggleArrow(id);
}
}
function setToggleArrow(id)
{
var state = document.getElementById(id+"-body").style.display;
if(state == "block" || state == "")
$("#"+id+"-arrow").attr("src","/cms/global/assets/images/site/icon/arrowBlackDown.gif");
else
$("#"+id+"-arrow").attr("src","/cms/global/assets/images/site/icon/arrowBlackRight.gif");
}
function setToggleArrowState(id,state)
{
visible = $("#"+id+"-body").css("display");
if(state==1)
{
if(visible == "none")
{
$("#"+id+"-arrow").attr("src","/cms/global/assets/images/icons/arrowBlackDown.gif");
$("#"+id+"-body").show();
if(document.getElementById(id+"-open"))
document.getElementById(id+"-open").value = "true";
}
}
else
{
if(visible == "block")
{
$("#"+id+"-arrow").attr("src","/cms/global/assets/images/icons/arrowBlackRight.gif");
$("#"+id+"-body").hide();
if(document.getElementById(id+"-open"))
document.getElementById(id+"-open").value = "false";
}
}
}
function addParams(mileage)
{
if(typeof mileage=="undefined")
return "?eId=199003&TabSelected=selTabCountries";
else
return "?eId=199003&TabSelected=selTabCountries&MileageAmount="+mileage;
}
function countRegions(miles){
var i=1;
while (getIdElement('region'+i))
{
numOfRegions=i;
i++;
}
if(miles)
{
getIdElement('floatPodHead').innerHTML=getIdElement('execMileage').innerHTML;
}
updateFloatPod();
}
function clickTab(id, eId){
if (((id=='selTabCountries' || id=='selTabCities') && (getIdElement("tabs").className=='selTabCountries' || getIdElement("tabs").className=='selTabCities')) || !flashOkay)
{
removeWCErrors()
selectTab(id);
}
else
{
getIdElement('tabSelected').value=id;
getIdElement('eId').value=eId;
document.mainForm.submit();
}
}
function selectTab(id){
getIdElement("tabs").className.replace(getIdElement("tabs").className, id).trim();
tabId=getIdElement("tabs").firstChild;
while(tabId)
{
if (tabId.className)
tabId.className="";
tabId=tabId.nextSibling;
}
getIdElement("tabs").className=id;
getIdElement(id).className="selected";
hideShowData(id);
}
function hideShowData(id)
{
var city='city';
var country='country';
if (id=='selTabCountries')
{
for (i=1; i<=numOfRegions; i++) {
city='city'+i;
country='country'+i;
getIdElement(city).style.display='none';
getIdElement(country).style.display='block';
}
if(document.getElementById("t-tracking-fragment") != undefined)
{
trackingInfo["interaction"] = "Countries";
document.getElementById("t-tracking-fragment").innerHTML = vsDoTracking();
}
}
else if(id=='selTabCities')
{
for (i=1; i<=numOfRegions; i++) {
city='city'+i;
country='country'+i;
getIdElement(city).style.display='block';
getIdElement(country).style.display='none';
}
if(document.getElementById("t-tracking-fragment") != undefined)
{
trackingInfo["interaction"] = "Cities";
document.getElementById("t-tracking-fragment").innerHTML = vsDoTracking();
}
}
}
String.prototype.trim = function() {
return this.replace( /^\s+|\s+$/, "" );
}
function processForm(id){
var formatMiles=getIdElement('MileageAmount').value.replace(/,/g, "");
formatMiles=formatMiles.replace(/\./g, "");
formatMiles=removeLeadZeros(formatMiles);
if (id=='mainForm')
{
trackingInfo["interaction"] = "SubmitButton";
document.getElementById("t-tracking-fragment").innerHTML = vsDoTracking();
}
if(id=='mainForm')
{
if ((getIdElement('CofD').value != getIdElement('loadCofD').value) || (getIdElement('Currency').value != getIdElement('loadCurrency').value))
{
getIdElement('tabSelected').value=getIdElement("tabs").className;
getIdElement('eId').value='199003';
getIdElement('MileageAmount').value=formatMiles;
return true;
}
else
{
removeWCErrors()
if (getIdElement('MileageAmount').value!="")
{
if(formatMiles!=parseInt(formatMiles))
{
getIdElement('mfErrors').style.display='block';
return false;
}
else
getIdElement('MileageAmount').value=formatMiles;
}
else
formatMiles=0;
if (getIdElement('CabinCode').value != getIdElement('loadClass').value)
{
getIdElement('to').value='';
getIdElement('pointsInfo').style.display='none';
getIdElement('loadClass').value=getIdElement('CabinCode').value;
}
updateData(id, parseInt(formatMiles));
updateFloatPod();
return false;
}
}
else
{
getIdElement('MilesCofD').value=getIdElement('CofD').value;
getIdElement('MilesCabin').value=getIdElement('CabinCode').value;
getIdElement('MilesCurrency').value=getIdElement('Currency').value;
getIdElement('MilesMileage').value=formatMiles;
getIdElement('tabSelected2').value=getIdElement("tabs").className;
getIdElement('eId2').value='199003';
trackingInfo["interaction"] = "CalculateMiles";
document.getElementById("t-tracking-fragment").innerHTML = vsDoTracking();
return true;
}
}
function updateData(id, processFormValue)
{
getIdElement('mfErrors').style.display='none';
var classArray=new Array('M','W','J','F');
var myClass=getIdElement('CabinCode').value;
var requiredPoints="";
var actualPoints="";
if (getIdElement('MileageAmount').value!="")
{
if(processFormValue)
actualPoints=processFormValue;
else
{
actualPoints=getIdElement('MileageAmount').value.replace(/,/g, "");
actualPoints=parseInt(actualPoints.replace(/\./, ""));
}
getIdElement('MileageAmount').value=actualPoints;
}
for (i=1; i<=numOfRegions; i++)
{
for(j=0; j<classArray.length; j++)
{
if (classArray[j]==myClass)
{
if (getIdElement('region'+i+classArray[j]))
{
getIdElement('region'+i).style.display='block';
getIdElement('region'+i+classArray[j]).style.display='block';
requiredPoints=parseInt(getIdElement('miles'+i+classArray[j]).innerHTML.replace(/,/g, ""));
if(requiredPoints<=actualPoints)
{
getIdElement('milesTick'+i+classArray[j]).style.visibility='visible';
}
else
{
getIdElement('milesTick'+i+classArray[j]).style.visibility='hidden';
}
if(getIdElement('partMiles'+i+classArray[j]))
{
requiredPoints=getIdElement('partMiles'+i+classArray[j]).innerHTML.replace(/,/g, "");
if(requiredPoints<=actualPoints)
{
getIdElement('pcpmTick'+i+classArray[j]).style.visibility='visible';
}
else
{
getIdElement('pcpmTick'+i+classArray[j]).style.visibility='hidden';
}
}
}
else
getIdElement('region'+i).style.display='none';
}
else if(getIdElement('region'+i+classArray[j]))
getIdElement('region'+i+classArray[j]).style.display='none';
}
}
}
function updateFloatPod()
{
getIdElement('hiddenDivCabin').innerHTML=document.mainForm.CabinCode.options[document.mainForm.CabinCode.selectedIndex].text;
if (getIdElement('MileageAmount').value!="")
getIdElement('hiddenDivMileage').innerHTML=getIdElement('MileageAmount').value;
else
getIdElement('hiddenDivMileage').innerHTML=0;
var currentPointsString=getIdElement('hiddenDivText').innerHTML;
currentPointsString=currentPointsString.replace("hiddenDivCabin", "floatPodCabin");
currentPointsString=currentPointsString.replace("hiddenDivMileage", "floatPodMileage");
getIdElement('currentPoints').innerHTML=currentPointsString;
}
function getPoints(ajaxInfo)
{
if(ajaxInfo)
getIdElement('pointsInfo').style.display='block';
else
getIdElement('pointsInfo').style.display='none';
return false;
}
function removeWCErrors()
{
if(getIdElement("appErrors"))
{
if (getIdElement("appErrors").style.display='block')
{
getIdElement("appErrors").style.display='none';
getIdElement("to").value='';
}
}
}
function removeLeadZeros(str)
{
while(str.length > 1 && str.substring(0,1) == '0')
{
str=str.substring(1,str.length);
}
return str;
}
function redGetDestinations(e,thisSearch){
if(!useAJAX)
return;
var keyCode=e.keyCode?e.keyCode:e.which?e.which:e.charCode;
if(thisSearch.length<3 || keyCode==27){
toggleDestinations(false);
return;
}
if((keyCode==40) && document.getElementById(goFld).options.length>0 && document.getElementById(goFld).options	[0].value!=''){
toggleDestinations(true);
document.getElementById(goFld).focus();
document.getElementById(goFld).selectedIndex=0;
return false;
}
if(prevSearch!='' && thisSearch.indexOf(prevSearch)==0)
populateDestinations();
else{
prevSearch=thisSearch.substring(0,3);
try{locationHelper.getMatchedRedemptionLocations(saveDestinations,prevSearch);}
catch(err){};
}
}
function redDisplayCities(to){
if(!useAJAX)
return;
var thisSearch='';
if(typeof(to)=='string'){
to=document.getElementById(to);
}
toFld=to;
thisSearch=to.value;
if(searchFld!=to.id)
toggleDestinations(false);
searchFld=to.id;
document.getElementById(goFld).selectedIndex=-1;
if(thisSearch.length<3){
return;
}
else if(prevSearch==''){
prevSearch=thisSearch.substring(0,3);
locationHelper.getMatchedRedemptionLocations(saveDestinations,prevSearch);
}
else if(thisSearch.indexOf(prevSearch)==0 && document.getElementById(goFld).options.length>0 && document.getElementById(goFld).options[0].value!=0){
toggleDestinations(true);
}
else{
prevSearch=thisSearch.substring(0,3);
locationHelper.getMatchedRedemptionLocations(saveDestinations,prevSearch);
}
}
function redSelectDestination(){
if(!useAJAX)
return;
var destName='';
destName=DWRUtil.getText(goFld);
if(destName=='')
return;
DWRUtil.setValue(toFld,destName);
toggleDestinations(false);
DWRUtil.removeAllOptions(goFld);
document.getElementById(goFld).blur();
toFld.focus();
}
function redUpdateDestination(event){
var keyCode=event.keyCode?event.keyCode:event.which?event.which:event.charCode;
switch(keyCode){
case 13:
redSelectDestination()
break;
case 27:
document.getElementById(searchFld).focus();
break;
case 38:
if(goIndex==-1){
document.getElementById(goFld).selectedIndex=-1;
document.getElementById(searchFld).focus();
}
break;
}
}
var YOffset=0;
var staticYOffset=0;
var lastY=-0;
function makeStatic() {
getElm('floatPod').style.marginTop=findPos(getElm('t-additional-page-info-fragment'))+'px';
bssm=getElm("floatPod").style;
if (window.pageYOffset)
winY=window.pageYOffset;
else
winY=truebody().scrollTop;
if (winY!=lastY&&winY>YOffset-staticYOffset)
smooth=.2 * (winY-lastY-YOffset+staticYOffset);
else if (YOffset-staticYOffset+lastY>YOffset-staticYOffset) {
smooth=.2 * (winY-lastY-(YOffset-(YOffset-winY)));
}
else {smooth=0}
if(smooth>0)
smooth=Math.ceil(smooth);
else
smooth=Math.floor(smooth);
if (bssm.top)
{
bssm.top=parseInt(bssm.top)+smooth+"px";
}
else
{
bssm.pixelTop+=smooth;
}
lastY=lastY+smooth;
setTimeout('makeStatic()', 1)
}
function truebody(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}
function findPos(obj) {
var divTop=0;
if (obj.offsetParent) {
divTop=obj.offsetTop
while (obj=obj.offsetParent) {
divTop+=obj.offsetTop
}
}
return [divTop+10];
}

