// Emirates Hotels & Resorts Internet Booking Engine
//
// $Id: cal.js 2683 2009-09-07 07:09:23Z jeffery.to@wwwins.com $

window.DOCUMENT_DOMAIN='emirateshotelsresorts.com';if(!Object.dup){Object.dup=function(){var args=Array.toArray(arguments);var len=args.length;var src,dest,prop,i;if(len==0){return{};}
if(len==1){args.push({});len++;}
dest=args.pop();len--;if((typeof dest!='object'&&typeof dest!='function')||dest==null){dest={};}
for(i=len-1;i>=0;i--){src=args[i];if((typeof src=='object'||typeof src=='function')&&src!=null){for(prop in src){dest[prop]=src[prop];}}}
return dest;};}
if(!Function.getHiddenArgument){Function.getHiddenArgument=function(args,index){return args[args.callee.length+index];};}
Number.isReal=function(val){return(typeof val=='number'&&!isNaN(val)&&isFinite(val));};Number.isInt=function(val){return(typeof val=='number'&&!isNaN(val)&&isFinite(val)&&Math.round(val)==val);};if(!window.jlib){window.jlib={};}
jlib.Locale={gettext:function(msgid){var msg=window.po[msgid];if(msg==null){msg=msgid;}
return msg;},getDefaultDate:function(date){var str;if(!date){return'';}
if(date.toLocaleDateString){str=date.toLocaleDateString();}else if(date.toDateString){str=date.toDateString();}else{str=date.toString();}
return str;},getShortDate:function(date){return this.getDefaultDate(date);},getLongDate:function(date){return this.getDefaultDate(date);},getShortDateRange:function(from,to){var str,f,t;if(!from&&!to){return'';}
if(from){f=this.getShortDate(from);}
if(to){t=this.getShortDate(to);}
if(from&&to){str=f+' - '+t;}else if(from){str=f;}else{str=t;}
return str;},getLocaleDate:function(date){return this.getDefaultDate(date);},getAmount:function(code,amount){var decimal,minus,num,pos,i;amount=parseFloat(amount);if(!Number.isReal(amount)){amount=0;}
code=(code!=null)?code+' ':'';amount=Math.round(amount*100)/100;minus=(amount<0)?'-':'';i=Math.abs(amount).toString().split('.');num=i[0];decimal='.'+((i[1]||'')+'00').substring(0,2);if(num.length>3){pos=(num.length%3||3);num=num.substring(0,pos)+num.substring(pos).replace(/(\d{3})/g,',$1');}
return code+minus+num+decimal;},getConvertedAmount:function(code,amount,prefCode,rate){rate=parseFloat(rate);if(Number.isReal(rate)&&rate>0){code=prefCode;amount=parseFloat(amount)*rate;}
return this.getAmount(code,amount);},getName:function(family,given){family=(family!=null&&family!=='')?' '+family:'';given=(given!=null&&given!=='')?' '+given:'';return(given+family).substring(1);},getPhone:function(country,area,local){country=(country!=null&&country!=='')?' '+country:'';area=(area!=null&&area!=='')?' '+area:'';local=(local!=null&&local!=='')?' '+local:'';return(country+area+local).substring(1);},toString:function(){return'[object jlib.Locale]';}};window._=jlib.Locale.gettext;if(!window.po){window.po={};}
if(!Array.prototype.push){Array.prototype.push=function(){var len=arguments.length;var i;for(i=0;i<len;i++){this[this.length]=arguments[i];}
return this.length;};}
if(!Array.prototype.pop){Array.prototype.pop=function(){var len=this.length;var val=this[len-1];if(len>0){this.length--;}
return val;};}
if(!Array.prototype.unshift){Array.prototype.unshift=function(){var i;this.reverse();for(i=arguments.length-1;i>=0;i--){this[this.length]=arguments[i];}
this.reverse();return this.length;};}
if(!Array.prototype.shift){Array.prototype.shift=function(){var val=this[0];if(this.length>0){this.reverse();this.length--;this.reverse();}
return val;};}
if(!Array.prototype.indexOf){Array.prototype.indexOf=function(elt,from){var len=this.length;from=Number(from)||0;from=(from<0)?Math.ceil(from):Math.floor(from);if(from<0){from+=len;}
for(;from<len;from++){if(from in this&&this[from]===elt){return from;}}
return-1;};}
if(!Array.prototype.lastIndexOf){Array.prototype.lastIndexOf=function(elt,from){var len=this.length;from=Number(from);if(!Number.isReal(from)){from=len-1;}else{from=(from<0)?Math.ceil(from):Math.floor(from);if(from<0){from+=len;}else if(from>=len){from=len-1;}}
for(;from>-1;from--){if(from in this&&this[from]===elt){return from;}}
return-1;};}
if(!Array.prototype.filter){Array.prototype.filter=function(fun,thisp){var len=this.length;if(typeof fun!='function'){throw new TypeError();}
var res=new Array();for(var i=0;i<len;i++){if(i in this){var val=this[i];if(fun.call(thisp,val,i,this)){res.push(val);}}}
return res;};}
if(!Array.prototype.forEach){Array.prototype.forEach=function(fun,thisp){var len=this.length;if(typeof fun!='function'){throw new TypeError();}
for(var i=0;i<len;i++){if(i in this){fun.call(thisp,this[i],i,this);}}};}
if(!Array.prototype.every){Array.prototype.every=function(fun,thisp){var len=this.length;if(typeof fun!='function'){throw new TypeError();}
for(var i=0;i<len;i++){if(i in this&&!fun.call(thisp,this[i],i,this)){return false;}}
return true;};}
if(!Array.prototype.map){Array.prototype.map=function(fun,thisp){var len=this.length;if(typeof fun!='function'){throw new TypeError();}
var res=new Array(len);for(var i=0;i<len;i++){if(i in this){res[i]=fun.call(thisp,this[i],i,this);}}
return res;};}
if(!Array.prototype.some){Array.prototype.some=function(fun,thisp){var len=this.length;if(typeof fun!='function'){throw new TypeError();}
for(var i=0;i<len;i++){if(i in this&&fun.call(thisp,this[i],i,this)){return true;}}
return false;};}
if(!Array.toArray){Array.toArray=function(obj){var len,arr,i;if(obj==null){return[];}
if(obj instanceof this){return obj.slice(0);}else if(typeof obj=='string'||obj instanceof String){return obj.split('');}
len=parseInt(obj.length,10);if(!Number.isReal(len)||len<=0){return[];}
try{arr=this.prototype.slice.call(obj,0);}catch(e){arr=null;}
if(arr instanceof this){for(i=len-1;i>=0;i--){if(obj[i]!=null){if(arr[i]!==obj[i]){arr=null;}
break;}}}
if(!(arr instanceof this)){arr=[];for(i=len-1;i>=0;i--){arr[i]=obj[i];}}
return arr;};}
['indexOf','lastIndexOf','filter','forEach','every','map','some','join','slice'].forEach(function(func){if(!Array[func]){Array[func]=function(obj){return this.prototype[func].apply(this.toArray(obj),this.toArray(arguments).slice(1));};}});if(!window.jlib){window.jlib={};}
jlib.Queue=function(init){var q=(init instanceof Array)?init.slice(0):[];if(!q.enqueue&&!q.dequeue&&!q.top){q.enqueue=this.enqueue;q.dequeue=this.dequeue;q.top=this.top;}
if(!q.isEmpty){q.isEmpty=this.isEmpty;}
return q;};jlib.Queue.prototype={enqueue:function(item){return this.push(item);},dequeue:function(){return this.shift();},isEmpty:function(){return(this.length==0);},top:function(){return this[0];}};if(!window.jlib){window.jlib={};}
jlib.OrderedObject=function(){this.names=[];this.values={};this.length=0;this.push.apply(this,arguments);};jlib.OrderedObject.prototype={constructor:jlib.OrderedObject,add:function(fname,args){var names=this.names;var values=this.values;var len=args.length;var prevName=null;var arg,name,i;for(i=0;i<len;i++){arg=args[i];if(prevName!=null){names[fname](prevName);values[prevName]=arg;prevName=null;}else if(typeof arg=='object'&&arg!=null&&arg.length==2){name=String(arg[0]);names[fname](name);values[name]=arg[1];prevName=null;}else{prevName=String(arg);}}
this.length=names.length;return this.length;},remove:function(fname){var names=this.names;var values=this.values;var name,value;if(names.length==0){return null;}
name=names[fname]();value=values[name];delete values[name];this.length=names.length;return[name,value];},pop:function(){return this.remove('pop');},push:function(){return this.add('push',arguments);},reverse:function(){this.names.reverse();},shift:function(){return this.remove('shift');},sort:function(func){var names=this.names;var values=this.values;if(arguments.length==0){names.sort();}else{names.sort(function(a,b){return func([a,values[a]],[b,values[b]]);});}},splice:function(from,num){var names=this.names;var values=this.values;var constructor=this.constructor;var removed=new constructor();var removedValues=removed.values;var removedNames,added,addedNames,addedValues;if(arguments.length==0){return removed;}
if(arguments.length==1){num=names.length;}
if(arguments.length<=2){removedNames=names.splice(from,num);}else{added=new constructor();added.push.apply(added,Array.slice(arguments,2));addedNames=added.names;addedValues=added.values;removedNames=names.splice.apply(names,[from,num].concat(addedNames));}
removedNames.forEach(function(name){removedValues[name]=values[name];delete values[name];});removed.names=removedNames;removed.length=removedNames.length;if(added){addedNames.forEach(function(name){values[name]=addedValues[name];});}
this.length=names.length;return removed;},unshift:function(){return this.add('unshift',arguments);},concat:function(){var constructor=this.constructor;var push=this.push;var args=Array.toArray(arguments);var oo=new constructor();var ooValues=oo.values;var looseArgs=[];var len,names,values,arg,i;args.unshift(this);len=args.length;for(i=0;i<len;i++){arg=args[i];if(arg instanceof constructor){if(looseArgs.length>0){push.apply(oo,looseArgs);looseArgs.length=0;}
names=arg.names;values=arg.values;oo.names=oo.names.concat(names);names.forEach(function(name){ooValues[name]=values[name];});}else{looseArgs.push(arg);}}
if(looseArgs.length>0){push.apply(oo,looseArgs);}
oo.length=oo.names.length;return oo;},slice:function(begin,end){var names=this.names;var values=this.values;var len=names.length;var oo=new this.constructor();var ooValues=oo.values;var ooNames;if(arguments.length==0){begin=0;}
if(arguments.length<=1){end=len;}
ooNames=names.slice(begin,end);ooNames.forEach(function(name){ooValues[name]=values[name];});oo.names=ooNames;oo.length=ooNames.length;return oo;},indexOf:function(name){return this.names.indexOf(name);},lastIndexOf:function(name){return this.names.lastIndexOf(name);},iterate:function(fname,func,thisp){var values=this.values;return this.names[fname](function(name,i){return func.call(thisp,[name,values[name]],i,this);},this);},filter:function(func,thisp){var values=this.values;var oo=new this.constructor();var ooValues=oo.values;var ooNames=this.iterate('filter',func,thisp);ooNames.forEach(function(name){ooValues[name]=values[name];});oo.names=ooNames;oo.length=ooNames.length;return oo;},forEach:function(func,thisp){return this.iterate('forEach',func,thisp);},every:function(func,thisp){return this.iterate('every',func,thisp);},map:function(func,thisp){return this.iterate('map',func,thisp);},some:function(func,thisp){return this.iterate('some',func,thisp);},get:function(index){var name=this.names[index];var value=this.values[name];return[name,value];},getValue:function(name){return this.values[name];},replaceValue:function(name,value){var values=this.values;var oldValue;name=String(name);if(this.names.indexOf(name)>-1){oldValue=values[name];values[name]=value;}
return oldValue;},toString:function(){var values=this.values;var buf=[];this.names.forEach(function(name){buf.push(name,':',values[name],',');});buf[0]='';return buf.join('');}};if(!window.jlib){window.jlib={};}
jlib.Cookie={SPECIAL_CHARACTERS:[{character:'%',code:'%25',charRE:/%/g,codeRE:/%25/g},{character:',',code:'%2c',charRE:/,/g,codeRE:/%2c/g},{character:';',code:'%3b',charRE:/;/g,codeRE:/%3b/g},{character:'=',code:'%3d',charRE:/=/g,codeRE:/%3d/g}],encode:function(str,chars){return(str!=null)?str.toString().replace(chars[0].charRE,chars[0].code).replace(chars[1].charRE,chars[1].code).replace(chars[2].charRE,chars[2].code).replace(chars[3].charRE,chars[3].code):'';},decode:function(str,chars){return(str!=null)?str.toString().replace(chars[3].codeRE,chars[3].character).replace(chars[2].codeRE,chars[2].character).replace(chars[1].codeRE,chars[1].character).replace(chars[0].codeRE,chars[0].character):'';},get:function(name){var chars=jlib.Cookie.SPECIAL_CHARACTERS;var val,n;if(!name){return null;}
val=null;n=this.encode(name,chars)+'=';document.cookie.split(/;\s*/).some(function(c){if(c.indexOf(n)==0){val=this.decode(c.substring(n.length,c.length),chars);}
return(val!=null);},this);return val;},set:function(name,value,expires,domain,path){var chars=jlib.Cookie.SPECIAL_CHARACTERS;var oldval,n,v,e,d,p;if(!name){return null;}
oldval=this.get(name);n=this.encode(name,chars);if(value!=null){v=this.encode(value,chars);e=(expires)?'; expires='+expires.toGMTString():'';d=(domain)?'; domain='+domain:'';p=(path)?'; path='+path:'';}else{v='';e='; expires='+
(new Date((new Date()).getTime()-1000)).toGMTString();d='';p='';}
document.cookie=n+'='+v+e+d+p;return oldval;},canSet:function(testPersistent){var name='test_cookie';var value=(new Date()).getTime();var expires=(testPersistent)?new Date(value+86400000):null;var result;this.set(name,value,expires);result=(this.get(name)==value.toString());if(result){this.set(name,null);}
return result;},toString:function(){return'[object jlib.Cookie]';}};if(!window.jlib){window.jlib={};}
jlib.ClassName={REs:{},getRE:function(cssClass){var re;if(!cssClass){return null;}
cssClass=cssClass.toString();re=this.REs[cssClass];if(!re){re=this.REs[cssClass]=new RegExp('(^|\\s+)'+cssClass+'(\\s+|$)');}
return re;},has:function(element,cssClass){if(!element||!cssClass){return false;}
return(element.className&&element.className.search&&element.className.search(this.getRE(cssClass))>-1);},toggle:function(element,cssClass,doAdd){var has;if(!element||!cssClass){return false;}
has=this.has(element,cssClass);if(arguments.length<3){doAdd=!has;}
if(doAdd){if(!has){element.className=(element.className)?element.className+' '+cssClass:cssClass;}}else{if(has){element.className=element.className.replace(this.getRE(cssClass),' ').replace(/^ +| +$/g,'');}}
return true;},add:function(element,cssClass){return this.toggle(element,cssClass,true);},remove:function(element,cssClass){return this.toggle(element,cssClass,false);},getElementsByClassName:function(root,tag,cn){if(!root||!tag||!cn||!root.getElementsByTagName){return[];}
return Array.filter(root.getElementsByTagName(tag),function(el){return this.has(el,cn);},this);},toString:function(){return'[object jlib.ClassName]';}};if((new Date(2006,0)).valueOf()==(new Date(2006,-1)).valueOf()){Date.prototype.__setFullYear=Date.prototype.setFullYear;Date.prototype.setFullYear=function(year,month,date){var months,y,m,d;if(month==null){return this.__setFullYear(year);}
months=(year*12)+month;y=Math.floor(months/12);m=months%12;d=(date!=null)?date:this.getDate();this.__setFullYear(y,m,1);this.setDate(d);return this.valueOf();};Date.prototype.__setMonth=Date.prototype.setMonth;Date.prototype.setMonth=function(month,date){return this.setFullYear(this.getFullYear(),month,date);};}
if((new Date(2006,0,128)).valueOf()<=(new Date(2006,0,127)).valueOf()){Date.prototype.__setDate=Date.prototype.setDate;Date.prototype.setDate=function(date){var time=this.getTime();var delta=date-this.getDate();return this.setTime(time+(delta*86400000));};}
Date.prototype.addFullYear=function(inc){var delta=parseInt(inc,10);if(Number.isReal(delta)){this.setFullYear(this.getFullYear()+delta);}else{}
return this.valueOf();};Date.prototype.addMonth=function(inc){var delta=parseInt(inc,10);if(Number.isReal(delta)){this.setMonth(this.getMonth()+delta);}else{}
return this.valueOf();};Date.prototype.addDate=function(inc){var delta=parseInt(inc,10);if(Number.isReal(delta)){this.setDate(this.getDate()+delta);}else{}
return this.valueOf();};Date.prototype.clear=function(mask){if(mask){if(mask&Date.CLEAR_MILLISECONDS){this.setMilliseconds(0);}
if(mask&Date.CLEAR_SECONDS){this.setSeconds(0);}
if(mask&Date.CLEAR_MINUTES){this.setMinutes(0);}
if(mask&Date.CLEAR_HOURS){this.setHours(0);}
if(mask&Date.CLEAR_DATE){this.setDate(1);}
if(mask&Date.CLEAR_MONTH){this.setMonth(0);}}
return this.valueOf();};Date.CLEAR_MILLISECONDS=0x01;Date.CLEAR_SECONDS=0x02;Date.CLEAR_MINUTES=0x04;Date.CLEAR_HOURS=0x08;Date.CLEAR_DATE=0x10;Date.CLEAR_MONTH=0x20;Date.CLEAR_TIME=0x0f;Date.prototype.toISODateString=function(useExtendedFormat,mask){var sep=(useExtendedFormat)?'-':'';var y=this.getFullYear().toString();var m=this.getMonth()+1;var d=this.getDate();var str;if(m<10){m='0'+m;}
if(d<10){d='0'+d;}
if(mask!=null&&(mask&Date.CLEAR_DATE)){if(mask&Date.CLEAR_MONTH){str=y;}else{str=y+'-'+m;}}else{str=y+sep+m+sep+d;}
return str;};Date.prototype.toISOTimeString=function(useExtendedFormat,mask){var sep=(useExtendedFormat)?':':'';var h=this.getHours().toString();var m=this.getMinutes();var s=this.getSeconds();var str;if(h<10){h='0'+h;}
if(m<10){m='0'+m;}
if(s<10){s='0'+s;}
if(mask!=null&&(mask&Date.CLEAR_SECONDS)){if(mask&Date.CLEAR_MINUTES){str=h;}else{str=h+sep+m;}}else{str=h+sep+m+sep+s;}
return str;};Date.prototype.toISOString=function(useExtendedFormat){return this.toISODateString(useExtendedFormat)+'T'+
this.toISOTimeString(useExtendedFormat);};Date.parseISODate=function(str){var a,y,m,d,date;if(str==null){return null;}
a=str.toString().match(/^(\d{4})-?(\d{1,2})?-?(\d{1,2})?$/);if(!a||a.length!=4){return null;}
y=parseInt(a[1],10);m=(a[2]!=null&&a[2].length>0)?parseInt(a[2],10):1;d=(a[3]!=null&&a[3].length>0)?parseInt(a[3],10):1;date=new Date(y,m-1,d);return(date.getFullYear()==y&&date.getMonth()==m-1&&date.getDate()==d)?date:null;};Date.parseISOTime=function(str,date){var a,y,mth,d,h,m,s,time;if(str==null){return null;}
a=str.toString().match(/^(\d{1,2}):?(\d{1,2})?:?(\d{1,2})?$/);if(!a||a.length!=4){return null;}
if(!date||!(date instanceof Date)){date=new Date();}
y=date.getFullYear();mth=date.getMonth();d=date.getDate();h=parseInt(a[1],10);m=(a[2]!=null&&a[2].length>0)?parseInt(a[2],10):0;s=(a[3]!=null&&a[3].length>0)?parseInt(a[3],10):0;time=new Date(y,mth,d,h,m,s);return(time.getFullYear()==y&&time.getMonth()==mth&&time.getDate()==d&&time.getHours()==h&&time.getMinutes()==m&&time.getSeconds()==s)?time:null;};Date.parseISO=function(str){var a,d,t,date;if(!str){return null;}
a=str.toString().split('T');d=a[0];t=a[1];if(!d){return null;}
date=Date.parseISODate(d);if(!date){return null;}
if(t){date=Date.parseISOTime(t,date);}
return date;};if(!window.jlib){window.jlib={};}
jlib.JSON={realJSON:null,serializeToString:function(val){var a=[];this.realJSON.stringify(val,a);return a.join('');},parseFromString:function(str,filter){return this.realJSON.parse(str,filter);},toString:function(){return'[object jlib.JSON]';}};jlib.JSON.realJSON=function(){var isPropertyEnumerable=(Object.prototype.propertyIsEnumerable)?function(o,p){return Object.prototype.propertyIsEnumerable.call(o,p)}:function(o,p){var prop;for(prop in o){if(prop==p){return true;}}
return false;};function f(n){return n<10?'0'+n:n;}
Date.prototype.toJSON=function(){return this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z';};var m={};(function(){var i;for(i=0;i<256;i++){m[i]='\\u00'+Math.floor(i/16).toString(16)+
(i%16).toString(16);}
[['\b','\\b'],['\t','\\t'],['\n','\\n'],['\f','\\f'],['\r','\\r'],['"','\\"'],['\\','\\\\']].forEach(function(a){m[a[0].charCodeAt()]=a[1];});})();function escapeChar(a){return m[a.charCodeAt()];}
var r=/["\\\x00-\x1f\x7f-\x9f]/g;function stringify(value,a,whitelist){var i,k,l,v;switch(typeof value){case'string':a.push('"',r.test(value)?value.replace(r,escapeChar):value,'"');break;case'number':a.push(isFinite(value)?String(value):'null');break;case'boolean':case'null':a.push(String(value));break;case'object':if(!value){a.push('null');break;}
if(typeof value.toJSON==='function'){stringify(value.toJSON(),a);break;}
if(typeof value.length==='number'&&!isPropertyEnumerable(value,'length')){l=value.length;a.push('[');for(i=0;i<l;i+=1){stringify(value[i],a,whitelist);a.push(',');}
if(a[a.length-1]==','){a.pop();}
a.push(']');break;}
if(whitelist){l=whitelist.length;a.push('{');for(i=0;i<l;i+=1){k=whitelist[i];if(typeof k==='string'){stringify(k,a);a.push(':');stringify(value[k],a,whitelist);a.push(',');}}
if(a[a.length-1]==','){a.pop();}
a.push('}');}else{a.push('{');for(k in value){if(typeof k==='string'){stringify(k,a);a.push(':');stringify(value[k],a,whitelist);a.push(',');}}
if(a[a.length-1]==','){a.pop();}
a.push('}');}
break;default:a.push('null');break;}}
return{stringify:stringify,parse:function(text,filter){var j;function walk(k,v){var i,n;if(v&&typeof v==='object'){for(i in v){if(Object.prototype.hasOwnProperty.apply(v,[i])){n=walk(i,v[i]);if(n!==undefined){v[i]=n;}else{delete v[i];}}}}
return filter(k,v);}
if(/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof filter==='function'?walk('',j):j;}
throw new SyntaxError('parseJSON');}};}();if(!window.jlib){window.jlib={};}
jlib.Template={SELECTOR_RE:/^\s*([^#.\s]+)?(?:#([^#.\s]+))?(?:\.([^#\s]+))?\s*$/,ID_PREFIX:'jlib_Template_',templateId:0,instantiate:function(template,container,selectors,keepTemplateIds,keepTemplateNames,keepContainerContent){var getCollector=this.getCollector;var prefix=this.ID_PREFIX;var root,collections,matches;var labels,links,url,len,id,newId,newHref,labelList,linkList;var imgs,radios,name,checkedRadio,newName,radioList;var reattach,els,el;if(!template||!container){return null;}
if(container.nodeType!=1){return null;}
root=container.cloneNode(false);root.innerHTML=(template instanceof Array)?template.join(''):template.toString();if(selectors||!keepTemplateIds||!keepTemplateNames){collections=this.buildCollections(root);}
matches=(selectors)?this.matchSelectors(selectors,collections):null;if(!keepTemplateIds){labels={};els=collections.tags.label;if(els){els.forEach(getCollector(function(el){return el.htmlFor;},labels));}
links={};url=location.protocol+'//'+location.host+
location.pathname+location.search+'#';len=url.length;els=collections.tags.a;if(els){els.forEach(getCollector(function(el){var href=el.href;if(!(href&&href.indexOf(url)==0&&href.length>len)){return null;}
return href.substring(len);},links));}
els=collections.ids;for(id in els){labelList=labels[id];linkList=links[id];newId=(labelList||linkList)?prefix+this.templateId++:'';if(labelList){labelList.forEach(function(el){el.htmlFor=newId;});}
if(linkList){newHref='#'+newId;linkList.forEach(function(el){el.href=newHref;});}
els[id].id=newId;}}
if(!keepTemplateNames){imgs={};els=collections.tags.img;if(els){els.forEach(getCollector(function(el){var name=el.getAttribute('usemap');if(!(name&&name.indexOf('#')==0&&name.length>1)){return null;}
return name.substring(1);},imgs));}
radios={};els=collections.tags.input;if(els){els.filter(function(el){return(el.type.toLowerCase()=='radio');}).forEach(getCollector(function(el){return el.name;},radios));}
collections.all.forEach(function(el){var name=el.name;var imgList,newName,newUsemap;if(!name){return;}
imgList=imgs[name];newName=(imgList)?prefix+this.templateId++:'';if(imgList){newUsemap='#'+newName;imgList.forEach(function(el){el.setAttribute('usemap',newUsemap);});}
el.name=newName;},this);for(name in radios){radioList=radios[name];if(radioList){checkedRadio=null;radioList.forEach(function(el){if(el.checked){checkedRadio=el;}});if(checkedRadio){checkedRadio.checked=false;}
newName=prefix+this.templateId++;radioList.forEach(function(el){el.name=newName;});if(checkedRadio){checkedRadio.checked=true;}}}}
reattach=this.detach(container);if(!keepContainerContent){container.innerHTML='';}
for(el=root.firstChild;el;el=root.firstChild){container.appendChild(el);}
reattach();return matches;},buildCollections:function(root){var ids={};var tags={};var all=[];var stack=[];var findChildElements=this.findChildElements;var el,id,tag,cns,cn,list,i;findChildElements(root,stack);while(stack.length>0){el=stack.pop();id=el.id;tag=el.nodeName.toLowerCase();if(id){ids[id]=el;}
list=tags[tag];if(!list){list=tags[tag]=[];}
list.push(el);all.push(el);findChildElements(el,stack);}
return{ids:ids,tags:tags,all:all};},findChildElements:function(el,stack){Array.filter(el.childNodes,function(child){return(child.nodeType==1);}).reverse().forEach(function(el){stack.push(el);});},matchSelectors:function(sels,cols){var ids=cols.ids;var tags=cols.tags;var all=cols.all;var matches={};var selRE=this.SELECTOR_RE;var hasAllClasses=this.hasAllClasses;var sel,selId,selClasses,selTag;var name,els,a;for(name in sels){sel=sels[name];els=null;switch(typeof sel){case'undefined':case'unknown':break;case'object':case'function':if(sel){els=this.matchSelectors(sel,cols);}
break;default:a=sel.toString().match(selRE);if(!a){break;}
selId=a[2];selClasses=a[3];selTag=a[1];if(selClasses){selClasses=selClasses.split('.').filter(function(cn){return!!cn;});}
if(selClasses&&selClasses.length==0){selClasses=null;}
selTag=(selTag)?selTag.toLowerCase():'*';if(selId){els=ids[selId];if(els&&selTag!='*'&&els.nodeName.toLowerCase()!=selTag){els=null;}
if(els&&!hasAllClasses(els,selClasses)){els=null;}}else{a=(selTag!='*')?tags[selTag]:all;if(a){els=(selClasses)?a.filter(function(el){return hasAllClasses(el,selClasses);}):a.slice(0);}else{els=[];}}
break;}
matches[name]=els;}
return matches;},hasAllClasses:function(el,classes){return(classes)?classes.every(function(cn){return jlib.ClassName.has(el,cn);}):true;},getCollector:function(idFunc,lists){return function(el){var id=idFunc(el);var list;if(!id){return;}
list=lists[id];if(!list){list=lists[id]=[];}
list.push(el);};},detach:function(el){var parent,sibling;if(!el){return function(){};}
parent=el.parentNode;sibling=el.nextSibling;if(!parent){return function(){};}
parent.removeChild(el);return function(){parent.insertBefore(el,sibling);};},populateSelect:function(select,options){var reattach,label,value,option,opt,len,si,i,j;if(!select||!options){return;}
si=parseInt(options.selectedIndex,10);options=Array.toArray(options);len=options.length;reattach=jlib.Template.detach(select);select.innerHTML='';for(i=0;i<len;i++){label='';value='';option=options[i];if(option){label=option.label;value=option.value;}
if(value==null){value=label;}
opt=document.createElement('option');opt.innerHTML=String(label);opt.value=String(value);for(j in option){if(j!='label'&&j!='value'){opt[j]=option[j];}}
select.appendChild(opt);}
if(Number.isReal(si)&&si>=0&&si<len){select.selectedIndex=si;}
reattach();},createLink:function(onclick,props,enabledContent,disabledContent){var a=document.createElement('a');var span=document.createElement('span');var uninitProps={};var i;if(props){for(i in props){uninitProps[i]=a[i];a[i]=props[i];}}
a.isEnabled=true;a.span=span;a.uninitProps=uninitProps;a.toggle=this.toggleLink;a.enable=this.enableLink;a.disable=this.disableLink;a.uninit=this.uninitLink;if(onclick){a.clickHandler=onclick;jlib.contrib.Events.add(a,'click',onclick);}
if(enabledContent){Array.toArray(enabledContent).forEach(function(e){a.appendChild(e);});}
if(disabledContent){Array.toArray(disabledContent).forEach(function(e){span.appendChild(e);});}
return a;},toggleLink:function(doEnable){var isEnabled=this.isEnabled;var span=this.span;var from,to;if(arguments.length==0){doEnable=!isEnabled;}
if((doEnable&&isEnabled)||(!doEnable&&!isEnabled)){return;}
if(doEnable){from=span;to=this;}else{from=this;to=span;}
from.parentNode.replaceChild(to,from);if(!to.firstChild){while(from.firstChild){to.appendChild(from.firstChild);}}
this.isEnabled=!isEnabled;},enableLink:function(){this.toggle(true);},disableLink:function(){this.toggle(false);},uninitLink:function(){Object.dup(this.uninitProps,this);this.isEnabled=null;this.span=null;this.uninitProps=null;this.toggle=null;this.enable=null;this.disable=null;this.uninit=null;if(this.clickHandler){jlib.contrib.Events.remove(this,'click',this.clickHandler);this.clickHandler=null;}},toString:function(){return'[object jlib.Template]';}};if(!window.jlib){window.jlib={};}
jlib.XML={createDocument:function(){var doc=null;if(document.implementation&&document.implementation.createDocument){doc=document.implementation.createDocument('','',null);}else if(window.ActiveXObject){try{doc=new ActiveXObject('Msxml2.DOMDocument');}catch(e){try{doc=new ActiveXObject('Microsoft.XMLDOM');}catch(e){doc=null;}}}else{}
return doc;},parseFromString:function(text){var doc,root;if(!text){return this.createDocument();}
try{doc=this.parser.parseFromString(text,'text/xml');if(doc){root=doc.documentElement;}}catch(e){doc=root=null;}
if(doc){if(root&&root.nodeName=='parsererror'&&root.namespaceURI=='http://www.mozilla.org/newlayout/xml/parsererror.xml'){doc=null;}}else{try{doc=this.htmlDOMParser.parseFromString(text,'text/xml');if(doc){root=doc.documentElement;}}catch(e){doc=root=null;}}
return doc;},serializeToString:function(doc){var text;if(!doc){return'';}
try{text=this.serializer.serializeToString(doc);}catch(e){text=(doc.xml)?doc.xml:'';}
return text;},encode:function(str){if(str==null){return'';}
return str.toString().replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');},getRequest:function(){var req=null;if(window.XMLHttpRequest){req=new XMLHttpRequest();if(req.overrideMimeType){req.overrideMimeType('text/xml');}}else if(window.ActiveXObject){try{req=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{req=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){req=null;}}}else{}
return req;},toString:function(){return'[object jlib.XML]';}};if(!window.XMLSerializer){window.XMLSerializer=function(){};window.XMLSerializer.prototype={serializeToString:function(doc){var text='';if(doc&&doc.xml!=null){text=doc.xml;}else{}
return text;},toString:function(){return'[object XMLSerializer]';}};}
if(!window.DOMParser){window.DOMParser=function(){};window.DOMParser.prototype={parseFromString:function(text,contentType){var doc=null;if(window.ActiveXObject){doc=jlib.XML.createDocument();if(doc){doc.loadXML(text);}else{}}else{doc=jlib.XML.htmlDOMParser.parseFromString(text,contentType);}
return doc;},toString:function(){return'[object DOMParser]';}};}
jlib.HTMLDOMParser=function(){};jlib.HTMLDOMParser.documentFragmentGetElementsByTagName=function(tag){var root=this.documentElement;var els;if(!root){return[];}
els=Array.slice(root.getElementsByTagName(tag),0);if(root.nodeName==tag){els.unshift(root);}
return els;};jlib.HTMLDOMParser.documentFragmentCreateElement=function(tag){return document.createElement(tag);};jlib.HTMLDOMParser.prototype={parseFromString:function(text){var doc,info,creator,tagStr,defaultNS,NSs,tags,attrs;var matches,pair,right,wrong,i;doc=jlib.XML.createDocument();creator=doc;try{i=doc.createElement('root');}catch(e){doc=document.createDocumentFragment();creator=document;}
for(i=999;i>=0;i--){wrong=text.match(/<!\[CDATA\[([\w\W]*?)]]>/);if(!wrong){break;}
wrong=wrong[1];right=wrong.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');text=text.replace('<![CDATA['+wrong+']]>',right);}
text=text.replace(/<([\w:]+)([^\/>]*)\/>/g,'<$1$2></$1>');matches=text.match(/<\w[^>]*>/g);tagStr=(matches)?matches.join(''):text;matches=tagStr.match(/\bxmlns="([^"]*)"/);defaultNS=(matches&&matches.length>=2)?matches[1]:'';NSs={};NSs.xml='http://www.w3.org/XML/1998/namespace';NSs.xmlns='http://www.w3.org/2000/xmlns/';matches=tagStr.match(/\bxmlns:\w+="[^"]*"/g);if(matches){for(i=matches.length-1;i>=0;i--){pair=matches[i].match(/xmlns:(\w+)="([^"]*)"/);if(pair&&pair.length==3){NSs[pair[1]]=pair[2];}}}
tags={};matches=tagStr.match(/<[\w:]+/g);if(matches){for(i=matches.length-1;i>=0;i--){right=matches[i].substring(1);wrong=right.toUpperCase();tags[wrong]=right;}}
attrs={};matches=tagStr.match(/\b[\w:]+="[^"]*"/g);if(matches){for(i=matches.length-1;i>=0;i--){right=wrong=null;pair=matches[i].match(/\b([\w:]+)=/);if(pair&&pair.length==2){right=pair[1];wrong=right.toLowerCase();attrs[wrong]=right;}}}
info={creator:creator,defaultNS:defaultNS,NSs:NSs,tags:tags,attrs:attrs};i=document.createElement('div');i.innerHTML=text;this.copyDOM(i,doc,info);if(doc){doc.xml=text;if(!doc.documentElement){for(i=0;i<doc.childNodes.length;i++){if(doc.childNodes[i].nodeType==1){doc.documentElement=doc.childNodes[i];break;}}}
if(!doc.getElementsByTagName){doc.getElementsByTagName=jlib.HTMLDOMParser.documentFragmentGetElementsByTagName;}
if(!doc.createElement){doc.createElement=jlib.HTMLDOMParser.documentFragmentCreateElement;}}
return doc;},copyDOM:function(htmlRoot,xmlRoot,info){var creator,htmlNode,xmlNode,htmlAttr,childNodes,attributes;var name,goodNode,i,j;if(!htmlRoot||!xmlRoot){return;}
childNodes=htmlRoot.childNodes;creator=info.creator;for(i=0;i<childNodes.length;i++){htmlNode=childNodes[i];goodNode=true;switch(htmlNode.nodeType){case 1:name=this.getNameParts(htmlNode.nodeName,info,false);xmlNode=creator.createElementNS(name[0],name[1]);attributes=htmlNode.attributes;for(j=0;j<attributes.length;j++){htmlAttr=attributes[j];if(htmlAttr.name!='_moz-userdefined'){name=this.getNameParts(htmlAttr.name,info,true);try{xmlNode.setAttributeNS(name[0],name[1],htmlAttr.value);}catch(e){if(htmlAttr.name!='xmlns'){throw e;}}}}
break;case 3:xmlNode=creator.createTextNode(htmlNode.nodeValue);break;case 8:xmlNode=creator.createComment(htmlNode.nodeValue);break;default:goodNode=false;break;}
if(goodNode){try{xmlRoot.appendChild(xmlNode);this.copyDOM(htmlNode,xmlNode,info);}catch(e){}}}},getNameParts:function(name,info,isAttribute){var namespace=null;var prefix='';var qualifiedName=name;var names=(!isAttribute)?info.tags:info.attrs;var NSs=info.NSs;if(names[qualifiedName]){qualifiedName=names[qualifiedName];}
if(qualifiedName.indexOf(':')>-1){prefix=qualifiedName.substring(0,qualifiedName.indexOf(':'));}
if(prefix){if(NSs[prefix]){namespace=NSs[prefix];}}else if(!isAttribute){namespace=info.defaultNS;}
return[namespace,qualifiedName];},toString:function(){return'[object jlib.HTMLDOMParser]';}};jlib.XML.parser=new DOMParser();jlib.XML.serializer=new XMLSerializer();jlib.XML.htmlDOMParser=new jlib.HTMLDOMParser();if(!window.jlib){window.jlib={};}
if(jlib.RemoteXHR){jlib._RemoteXHR=jlib.RemoteXHR;}
jlib.RemoteXHR={ID_BRIDGE:'?bridge',ID_BRIDGE_REQUESTER:'?bridgeRequester',READY_STATE_UNINITIALIZED:0,READY_STATE_LOADING:1,READY_STATE_LOADED:2,READY_STATE_INTERACTIVE:3,READY_STATE_COMPLETED:4,READY_STATE_ABORTED:-1,READY_STATE_TIMED_OUT:-2,READY_STATE_HTTP_ERROR:-3,READY_STATE_NETWORK_ERROR:-4,READY_STATE_CONNECTION_TERMINATED:-5,READY_STATE_UNKNOWN_ERROR:-6,HTTP_SUCCESS_STATUSES:[200],isCompleted:function(readyState){return(readyState>3);},isError:function(readyState){return(readyState<0);},isProcessing:function(readyState){return(!this.isCompleted(readyState)&&!this.isError(readyState));},isStatusOK:function(status){return(this.HTTP_SUCCESS_STATUSES.indexOf(parseInt(status,10))>-1);},toString:function(){return'[object jlib.RemoteXHR]';}};if(jlib._RemoteXHR){Object.dup(jlib._RemoteXHR,jlib.RemoteXHR);delete jlib._RemoteXHR;}
if(!window.jlib){window.jlib={};}
if(!jlib.RemoteXHR){jlib.RemoteXHR={};}
jlib.RemoteXHR.Receiver={REQUESTER_CLASS_NAME:'RemoteXHRRequester',REQUESTER_WAIT_TIME:120000,constructors:{},getRequestConstructor:function(url){var constructors=this.constructors;var domain=window.DOCUMENT_DOMAIN;var constructor;if(!url){return null;}
if(domain){document.domain=domain;}
constructor=constructors[url];if(!constructor){constructor=function(){this.readyState=jlib.RemoteXHR.READY_STATE_UNINITIALIZED;};constructor.prototype=new jlib.RemoteXHR.Request(url);constructor.prototype.constructor=constructor;constructors[url]=constructor;}
return constructor;},connect:function(url){var constructor,prototype,requester,pendingRequests;if(!url){return;}
constructor=this.constructors[url.replace(jlib.RemoteXHR.ID_BRIDGE,'')];if(!constructor){return;}
prototype=constructor.prototype;if(!prototype){return;}
pendingRequests=prototype.pendingRequests;if(!pendingRequests){return;}
try{requester=prototype.iframe.contentWindow.jlib.RemoteXHR.Requester;}catch(e){return;}
if(!requester){return;}
prototype.requester=requester;requester.receiver=this;if(prototype.timeoutId){clearTimeout(prototype.timeoutId);prototype.timeoutId=null;}
if(!pendingRequests.isEmpty()){}
while(!pendingRequests.isEmpty()){requester.send(pendingRequests.dequeue());}
delete prototype.pendingRequests;},toString:function(){return'[object jlib.RemoteXHR.Receiver]';}};jlib.RemoteXHR.Request=function(url){if(!url){}
this.url=url;this.pendingRequests=null;this.iframe=null;this.timeoutId=null;this.loadRequester();};jlib.RemoteXHR.Request.prototype={loadRequester:function(req){var me=this;var url=this.url;var prevIframe=this.iframe;var iframe;if(!url){return;}
this.pendingRequests=new jlib.Queue();if(req){this.pendingRequests.enqueue(req);}
if(this.timeoutId){clearTimeout(this.timeoutId);}
this.timeoutId=setTimeout(function(){me.timeOut();},jlib.RemoteXHR.Receiver.REQUESTER_WAIT_TIME);iframe=document.createElement('iframe');iframe.className=jlib.RemoteXHR.Receiver.REQUESTER_CLASS_NAME;iframe.src=url;if(!prevIframe){document.body.appendChild(iframe);}else{document.body.replaceChild(iframe,prevIframe);}
this.iframe=iframe;},timeOut:function(){var pendingRequests=this.pendingRequests;var req;if(!pendingRequests){return;}
if(!pendingRequests.isEmpty()){}
while(!pendingRequests.isEmpty()){req=pendingRequests.dequeue();req.readyState=jlib.RemoteXHR.READY_STATE_NETWORK_ERROR;if(req.openArgs.async&&req.onreadystatechange){req.onreadystatechange();}}
delete this.pendingRequests;},open:function(method,url,async,username,password){this.openArgs={method:method,url:url,async:async,username:username,password:password};this.requestHeaders=new jlib.OrderedObject();this.aborted=false;this.readyState=jlib.RemoteXHR.READY_STATE_LOADING;delete this.onreadystatechange;delete this.status;delete this.statusText;delete this.responseText;delete this.responseXML;delete this.responseHeaders;delete this.allResponseHeaders;},setRequestHeader:function(name,value){var headers=this.requestHeaders;var old;if(headers.indexOf(name)==-1){headers.push(name,value);}else{old=headers.replaceValue(name,value);}
return old;},send:function(content){var requester=this.requester;var pendingRequests=this.pendingRequests;if(!this.openArgs){return;}
this.sendContent=content;this.readyState=jlib.RemoteXHR.READY_STATE_LOADED;if(requester){requester.send(this);}else if(pendingRequests){pendingRequests.enqueue(this);}else{this.constructor.prototype.loadRequester(this);}},abort:function(){var requester=this.requester;if(requester){requester.abort(this);}else{this.aborted=true;}},reply:function(){var doc,root;if(this.responseXML){try{doc=this.responseXML;if(doc){root=doc.documentElement;}}catch(e){this.responseXML=jlib.XML.parseFromString(this.responseText);}}
if(this.openArgs.async&&this.onreadystatechange){this.onreadystatechange();}},getResponseHeader:function(name){var headers=this.responseHeaders;return headers.getValue(name);},getAllResponseHeaders:function(){return this.allResponseHeaders;},toString:function(){return'[object jlib.RemoteXHR.Request]';}};if(!window.jlib){window.jlib={};}
if(!jlib.contrib){jlib.contrib={};}
jlib.contrib.BrowserDetect={browser:'',engine:'',version:0,OS:'',init:function(){this.browser=this.searchString(this.dataBrowser)||"";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||0;this.OS=this.searchString(this.dataOS)||"";this.engine=this.searchString(this.dataEngine)||"";},searchString:function(data){for(var i=0;i<data.length;i++){var dataString=data[i].string;var dataProp=data[i].prop;this.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){if(dataString.indexOf(data[i].subString)!=-1)
return data[i].identity;}
else if(dataProp)
return data[i].identity;}},searchVersion:function(dataString){var index=dataString.indexOf(this.versionSearchString);if(index==-1)return;return parseFloat(dataString.substring(index+this.versionSearchString.length+1));},dataBrowser:[{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataEngine:[{string:navigator.userAgent,subString:'WebKit',identity:'WebKit'},{prop:window.opera,identity:'Presto'},{string:navigator.vendor,subString:'iCab',identity:'iCab'},{string:navigator.vendor,subString:'KDE',identity:'KHTML'},{string:navigator.userAgent,subString:'Gecko',identity:'Gecko'},{string:navigator.userAgent,subString:'MSIE',identity:'Trident'},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.platform,subString:"Linux",identity:"Linux"}],toString:function(){return this.browser+' ('+this.engine+') version '+
this.version+' on '+this.OS;}};jlib.contrib.BrowserDetect.init();if(!window.jlib){window.jlib={};}
if(!jlib.contrib){jlib.contrib={};}
jlib.contrib.Events={add:function(element,type,handler){if(element.addEventListener&&jlib.contrib.BrowserDetect.engine!='WebKit'){element.addEventListener(type,handler,false);}else{if(!handler.$$guid)handler.$$guid=jlib.contrib.Events.guid++;if(!element.events)element.events={};var handlers=element.events[type];if(!handlers){handlers=element.events[type]={};if(element["on"+type]){handlers[0]=element["on"+type];}}
handlers[handler.$$guid]=handler;element["on"+type]=jlib.contrib.Events.handle;}},guid:1,remove:function(element,type,handler){if(element.removeEventListener&&jlib.contrib.BrowserDetect.engine!='WebKit'){element.removeEventListener(type,handler,false);}else{if(element.events&&element.events[type]){delete element.events[type][handler.$$guid];}}},handle:function(event){var returnValue;var win=(this.ownerDocument||this.document||this).parentWindow||window;event=event||jlib.contrib.Events.fix(win.event);var type=event.type;var isbeforeunload=(this==win&&type=="beforeunload");var handlers=this.events[type];var ret;if(!isbeforeunload){returnValue=true;}
for(var i in handlers){this.$$handleEvent=handlers[i];ret=this.$$handleEvent(event);if(isbeforeunload){if(typeof event.returnValue=="string"){returnValue=event.returnValue;}else if(typeof ret=="string"){returnValue=ret;}}else{if(event.returnValue===false||ret===false){returnValue=false;}}}
this.$$handleEvent=null;return returnValue;},fix:function(event){event.preventDefault=jlib.contrib.Events.preventDefault;event.stopPropagation=jlib.contrib.Events.stopPropagation;return event;},preventDefault:function(){this.returnValue=false;},stopPropagation:function(){this.cancelBubble=true;},dispatch:function(target,type,event){var ontype='on'+type;var result;if(target[ontype]){if(event.type!=type){event.type=type;}
result=target[ontype](event);}
return result;},addListener:function(element,type,handler,props,list){var removeProps={};var i;if(props){for(i in props){removeProps[i]=element[i];element[i]=props[i];}}
this.add(element,type,handler);if(list instanceof Array){list.push({element:element,type:type,handler:handler,removeProps:removeProps});}},removeListeners:function(list){if(!(list instanceof Array)){return;}
list.filter(function(o){return(o&&o.element&&o.type&&o.handler);}).forEach(function(o){this.remove(o.element,o.type,o.handler);Object.dup(o.removeProps,o.element);},this);},toString:function(){return'[object jlib.contrib.Events]';}};if(!window.jlib){window.jlib={};}
if(!jlib.contrib){jlib.contrib={};}
jlib.contrib.Onload={explorerHelperPath:'/common/booking/js/jlib/contrib/OnloadExplorerHelper.js',init:function(e){var me=jlib.contrib.Onload;if(arguments.callee.done)return;arguments.callee.done=true;if(me._timer){clearInterval(me._timer);me._timer=null;}
if(!e||e.type!="DOMContentLoaded"){e={};}else{}
jlib.contrib.Events.dispatch(me,'DOMContentLoaded',e);},setup:function(){var me=this;if(!jlib.contrib.Events){return;}
if(document.addEventListener){document.addEventListener("DOMContentLoaded",this.init,false);}
if(jlib.contrib.BrowserDetect.engine=='Trident'){document.write("<script defer src=\""+
this.explorerHelperPath+"\"><"+"/script>");}
if(jlib.contrib.BrowserDetect.engine=='WebKit'){this._timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){me.init();}},10);}
jlib.contrib.Events.add(window,"load",this.init);},toString:function(){return'[object jlib.contrib.Onload]';}};jlib.contrib.Onload.setup();if(!window.jlib){window.jlib={};}
if(!jlib.hessian){jlib.hessian={};}
jlib.hessian.Mediator=function(lwmUrl){var me=this;this.controller=null;this.modules={};this.storage=null;this.stateInfo=null;this.messenger=null;this.messageInfo={};this.messageDelay=500;this.usingLWM=false;this.expectedEvent=null;this.changeTimeoutId=null;this.changeCheckDelay=50;this.isInitialized=false;this.beforechangeListener=function(e){e.target=this;return me.beforechangeListenerPrototype(e);};this.changeListener=function(e){e.target=this;return me.changeListenerPrototype(e);};this.updateListener=function(e){e.target=this;return me.updateListenerPrototype(e);};this.redrawListener=function(e){e.target=this;return me.redrawListenerPrototype(e);};if(jlib.hessian.LocationWatcherModule){if(lwmUrl){jlib.hessian.LocationWatcherModule.iframeSrc=lwmUrl;this.addModule(jlib.hessian.LocationWatcherModule);}else{}}else{}};jlib.hessian.Mediator.STORAGE_PREFIX='med';jlib.hessian.Mediator.STORAGE_IS_RUNNING='IsRunning';jlib.hessian.Mediator.COOKIE_PREFIX='hessian';jlib.hessian.Mediator.MESSAGE_LOADING='1';jlib.hessian.Mediator.EVENTS_MEDIATOR_TO_CONTROLLER=['init','uninit','change'];jlib.hessian.Mediator.EVENTS_CONTROLLER_TO_MEDIATOR=['update'];jlib.hessian.Mediator.EVENTS_MEDIATOR_TO_MODULE=['init','uninit','update','redraw'];jlib.hessian.Mediator.EVENTS_MODULE_TO_MEDIATOR=['beforechange','change','redraw'];jlib.hessian.Mediator.objId=1;jlib.hessian.Mediator.prototype={setObj:function(name,obj){var old;if(obj&&obj.mediator){return null;}
old=this[name];if(old){old.mediator=null;}
this[name]=obj;if(obj){obj.mediator=this;}
return old;},getStorage:function(){return this.storage;},setStorage:function(obj){return this.setObj('storage',obj);},getStateInfo:function(){return this.stateInfo;},setStateInfo:function(obj){return this.setObj('stateInfo',obj);},getMessenger:function(){return this.messenger;},setMessenger:function(obj){return this.setObj('messenger',obj);},addEventListeners:function(subject,events,listener){events.forEach(function(event){if(listener[event+'Listener']){jlib.contrib.Events.add(subject,event,listener[event+'Listener']);}});},removeEventListeners:function(subject,events,listener){events.forEach(function(event){if(listener[event+'Listener']){jlib.contrib.Events.remove(subject,event,listener[event+'Listener']);}});},getController:function(){return this.controller;},setController:function(obj){var old;if(obj&&obj.mediator){return null;}
old=this.controller;if(old){this.controller=null;old.mediator=null;this.removeEventListeners(this,jlib.hessian.Mediator.EVENTS_MEDIATOR_TO_CONTROLLER,old);this.removeEventListeners(old,jlib.hessian.Mediator.EVENTS_CONTROLLER_TO_MEDIATOR,this);}
if(obj&&!obj.$$objId){obj.$$objId=jlib.hessian.Mediator.objId++;}
this.controller=obj;if(obj){obj.mediator=this;this.addEventListeners(this,jlib.hessian.Mediator.EVENTS_MEDIATOR_TO_CONTROLLER,obj);this.addEventListeners(obj,jlib.hessian.Mediator.EVENTS_CONTROLLER_TO_MEDIATOR,this);}
return old;},addModule:function(module){if(!module||module.mediator){return;}
if(!module.$$objId){module.$$objId=jlib.hessian.Mediator.objId++;}
this.modules[module.$$objId]=module;module.mediator=this;this.addEventListeners(this,jlib.hessian.Mediator.EVENTS_MEDIATOR_TO_MODULE,module);this.addEventListeners(module,jlib.hessian.Mediator.EVENTS_MODULE_TO_MEDIATOR,this);if(module==jlib.hessian.LocationWatcherModule){this.usingLWM=true;}},removeModule:function(module){if(!module||!module.$$objId||module.mediator!=this){return;}
delete this.modules[module.$$objId];module.mediator=null;this.removeEventListeners(this,jlib.hessian.Mediator.EVENTS_MEDIATOR_TO_MODULE,module);this.removeEventListeners(module,jlib.hessian.Mediator.EVENTS_MODULE_TO_MEDIATOR,this);if(module==jlib.hessian.LocationWatcherModule){this.usingLWM=false;}},beforechangeListenerPrototype:function(e){var me=this;var module=e.target;var beforechangeState=this.getBrowserState();this.expectedEvent=e;if(!this.usingLWM){this.changeTimeoutId=setTimeout(function(){var newState=me.getBrowserState();if(newState!=beforechangeState){jlib.contrib.Events.dispatch(module,'change',{state:newState});}else{me.changeTimeoutId=setTimeout(arguments.callee,me.changeCheckDelay);}},this.changeCheckDelay);}},changeListenerPrototype:function(e){var expectedEvent=this.expectedEvent;var state=e.state.toString();var expectedState,i;if(expectedEvent!=null){expectedState=expectedEvent.state.toString();if(state==expectedState){for(i in expectedEvent){if(i!='type'&&i!='state'){e[i]=expectedEvent[i];}}
e.isExpected=true;}else{}
this.expectedEvent=null;}
jlib.contrib.Events.dispatch(this,'change',e);},updateListenerPrototype:function(e){jlib.contrib.Events.dispatch(this,'update',e);},redrawListenerPrototype:function(e){jlib.contrib.Events.dispatch(this,'redraw',e);},init:function(){var isRunningKey=jlib.hessian.Mediator.STORAGE_PREFIX+
jlib.hessian.Mediator.STORAGE_IS_RUNNING;var cookiePrefix=jlib.hessian.Mediator.COOKIE_PREFIX;var storage=this.storage;var state=this.getBrowserState();var isRunning=false;var e={};var obj,i,k;if(this.isInitialized){return;}
this.isInitialized=true;if(storage){storage.init();if(!storage.get(isRunningKey)){storage.set(isRunningKey,true);}else{isRunning=true;}}
if(this.stateInfo){this.stateInfo.init();}
if(this.messenger){this.messenger.init();}
k=jlib.Cookie.get(cookiePrefix);if(k){obj=jlib.JSON.parseFromString(k);if(obj){for(i in obj){e[i]=obj[i];}}
jlib.Cookie.set(cookiePrefix,null);}
e.state=state;e.isRunning=isRunning;jlib.contrib.Events.dispatch(this,'init',e);},uninit:function(){if(!this.isInitialized){return;}
jlib.contrib.Events.dispatch(this,'uninit',{});if(this.messenger){this.messenger.uninit();}
if(this.stateInfo){this.stateInfo.uninit();}
if(this.storage){this.storage.uninit();}
this.isInitialized=false;},getBrowserState:function(){return location.hash.substring(1);},setBrowserState:function(state,eventInfo){var form,i;if(!(jlib.contrib.BrowserDetect&&jlib.contrib.BrowserDetect.browser=='Safari'&&jlib.contrib.BrowserDetect.version<420)){return function(){location.hash='#'+state;};}else if(!location.search||jlib.Cookie.canSet(false)){form=this.setupDummyForm(state);document.body.appendChild(form);if(!location.search){return function(){form.submit();document.body.removeChild(form);};}else{if(eventInfo){i=jlib.JSON.serializeToString(eventInfo);jlib.Cookie.set(jlib.hessian.Mediator.COOKIE_PREFIX,i);}
i=function(){form.submit();};i.willReload=true;return i;}}
return null;},setupDummyForm:function(state){var search=location.search;var form,input,pairs,pair,name,val,reloadSet,i;form=document.createElement('form');form.method='GET';form.action='#'+state;form.style.display='none';if(search){reloadSet=false;pairs=search.substring(1).split('&');for(i=0;i<pairs.length;i++){pair=pairs[i].split('=');name=(pair[0]!=null)?pair[0]:'';val=(pair[1]!=null)?pair[1]:'';input=document.createElement('input');input.type='text';input.name=decodeURIComponent(name.replace(/\+/g,' '));if(name!='hessian'){input.value=decodeURIComponent(val.replace(/\+/g,' '));}else{input.value=parseInt(val,10)+1;reloadSet=true;}
form.appendChild(input);}
if(!reloadSet){input=document.createElement('input');input.type='text';input.name='hessian';input.value=0;form.appendChild(input);}}
return form;},alert:function(caller,msg){var messenger=this.messenger;var info;if(!messenger){return;}
if(!caller||msg==null){return;}
info=this.messageInfo[msg];if(!info){info={isVisible:false,showTimeoutId:null,hideTimeoutId:null,callers:{}};this.messageInfo[msg]=info;}
if(info.hideTimeoutId){clearTimeout(info.hideTimeoutId);info.hideTimeoutId=null;}
if(!info.isVisible&&!info.showTimeoutId){this.scheduleShow(info,msg);}
if(!caller.$$objId){caller.$$objId=jlib.hessian.Mediator.objId++;}
info.callers[caller.$$objId]=true;},scheduleShow:function(info,msg){var me=this;info.showTimeoutId=setTimeout(function(){me.messenger.show(msg);info.isVisible=true;info.showTimeoutId=null;},this.messageDelay);},unalert:function(caller,msg){var messenger=this.messenger;var info,doHide,i;if(!messenger){return;}
if(!caller||msg==null){return;}
info=this.messageInfo[msg];if(!info){return;}
delete info.callers[caller.$$objId];doHide=true;for(i in info.callers){doHide=false;break;}
if(doHide){if(info.showTimeoutId){clearTimeout(info.showTimeoutId);info.showTimeoutId=null;}
if(info.isVisible&&!info.hideTimeoutId){this.scheduleHide(info,msg);}}},scheduleHide:function(info,msg){var me=this;info.hideTimeoutId=setTimeout(function(){me.messenger.hide(msg);info.isVisible=false;info.hideTimeoutId=null;},this.messageDelay);},ask:function(caller,msg,actions,className){var messenger=this.messenger;var id,callerId,info,messengerActions;if(!messenger){return;}
if(!caller||!msg||!actions){return;}
id=[msg].concat(actions.map(function(action){return action.name;})).join('_');callerId=caller.$$objId;info=this.messageInfo[id];if(!info){info={};messengerActions=[];actions.forEach(function(action,i){var name=action.name;info[name]={};info[name][callerId]=action.callback;messengerActions[i]={name:name,href:action.href,callback:this.getMessengerCallback(id,name)};},this);this.messageInfo[id]=info;messenger.show(msg,msg,messengerActions,className);}else{actions.forEach(function(action){var name=action.name;if(info[name]){info[name][callerId]=action.callback;}});}},getMessengerCallback:function(id,name){var me=this;return function(){var messageInfo=me.messageInfo;var callbacks,i;if(!messageInfo[id]||!messageInfo[id][name]){return;}
callbacks=messageInfo[id][name];for(i in callbacks){if(callbacks[i]){callbacks[i]();}}
delete messageInfo[id];};},focus:function(el,className){var messenger=this.messenger;var id;if(!messenger){return null;}
if(!el){return null;}
id=(new Date()).getTime().toString();messenger.show(id,el,null,className);return id;},blur:function(id){var messenger=this.messenger;if(!messenger){return;}
if(!id){return;}
messenger.hide(id);},toString:function(){return'[object jlib.hessian.Mediator]';}};if(!window.jlib){window.jlib={};}
if(!jlib.hessian){jlib.hessian={};}
jlib.hessian.Module=function(){this.containerId=null;this.container=null;this.elements=null;this.state=null;this.isEvent=false;this.isUpdateEvent=false;this.mediator=null;this.stateInfo=null;this.hasModuleInit=false;this.sourceURL='';this.loadingQueue=new jlib.Queue();this.isSourceLoaded=false;this.updateProps=Array.toArray(arguments);};jlib.hessian.Module.prototype={initListener:function(e){},uninitListener:function(e){},updateListener:function(e){},redrawListener:function(e){},createEventListeners:function(){var me=this;this.initListener=function(e){e.target=this;return me.moduleInitListener(e);};this.uninitListener=function(e){e.target=this;return me.moduleUninitListener(e);};this.updateListener=function(e){e.target=this;return me.moduleUpdateListener(e);};this.redrawListener=function(e){e.target=this;return me.moduleRedrawListener(e);};},moduleInitListener:function(e){var containerId=this.containerId;var container;if(containerId){container=document.getElementById(containerId);}
this.container=container;this.stateInfo=this.mediator.getStateInfo();this.processInit(e);},processInit:function(e){},moduleUninitListener:function(e){if(this.hasModuleInit){this.uninit();this.updateProps.forEach(function(prop){this[prop]=null;},this);this.elements=null;this.state=null;this.isEvent=false;this.isUpdateEvent=false;this.hasModuleInit=false;}
this.container=null;this.stateInfo=null;},moduleUpdateListener:function(e){if(!e){return;}
this.updateProps.forEach(function(prop){this[prop]=e[prop];},this);this.state=e.state;this.isEvent=true;this.isUpdateEvent=true;this.processUpdate(e);this.decide();},processUpdate:function(e){},moduleRedrawListener:function(e){if(!e){return;}
this.isEvent=true;this.isUpdateEvent=false;this.processRedraw(e);this.decide();},processRedraw:function(e){},decide:function(){var loadingQueue=this.loadingQueue;var doShow=this.isShowTime();if(loadingQueue&&doShow){loadingQueue.enqueue(this);this.constructor.prototype.loadSource();return;}
if(doShow){if(!this.hasModuleInit){this.init();if(!this.hasModuleInit){return;}}}else{}
this.redraw(doShow);},init:function(){},uninit:function(){},isShowTime:function(){return false;},redraw:function(doShow){},loadSource:function(){var url,head,script;if(this.isSourceLoaded){return;}
url=this.sourceURL;head=document.getElementsByTagName('head')[0];if(!url||!head){return;}
script=document.createElement('script');script.type='text/javascript';script.src=url;head.appendChild(script);this.isSourceLoaded=true;},doneLoading:function(){var loadingQueue=this.loadingQueue;var module;if(!loadingQueue){return;}
this.loadingQueue=null;while(!loadingQueue.isEmpty()){module=loadingQueue.dequeue();module.decide();}},toString:function(){return'[object jlib.hessian.Module]';}};if(!window.ibe){window.ibe={};}
ibe.WebService=function(url,ns,reqFactory,inputProcessor,outputProcessor){if(!url||!ns||!reqFactory||!inputProcessor||!outputProcessor){}
this.url=url;this.ns=ns;this.reqFactory=reqFactory;this.inputProcessor=inputProcessor;this.outputProcessor=outputProcessor;};ibe.WebService.SOAP_OPEN_ENVELOPE=['<?xml version="1.0" encoding="utf-8"?>','<soap:Envelope ','xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ','xmlns:xsd="http://www.w3.org/2001/XMLSchema" ','xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">','<soap:Body>'].join('');ibe.WebService.SOAP_CLOSE_ENVELOPE='</soap:Body></soap:Envelope>';ibe.WebService.ticketId=1;ibe.WebService.setupTicket=function(ticket,callback){if(!callback){return null;}
if(!ticket){ticket={id:'t'+ibe.WebService.ticketId++,cancel:ibe.WebService.cancelTicket};}
ticket.callback=callback;return ticket;};ibe.WebService.cancelTicket=function(ticket){if(!ticket){ticket=this;}
ticket.isCancelled=true;};ibe.WebService.doCallback=function(callback,val){if(!callback){return;}
setTimeout(function(){callback(val);},0);};ibe.WebService.stringInputProcessor=function(request){var encode=jlib.XML.encode;var params=request.parameters;var buf=[];var p,i;for(i in params){p=params[i];buf.push('<',i,'>');if(p!=null){buf.push(encode(p));}else{}
buf.push('</',i,'>');}
return buf.join('');};ibe.WebService.processError=function(req,details){var err,readyState,status;if(!req||!details){return null;}
readyState=details.readyState;status=details.status;if(details.faultcode==null){if(req instanceof jlib.RemoteXHR.Request){switch(readyState){case jlib.RemoteXHR.READY_STATE_TIMED_OUT:err=new ibe.Error(ibe.Error.CODE_TRANSPORT_TIMED_OUT);break;case jlib.RemoteXHR.READY_STATE_HTTP_ERROR:err=new ibe.Error(ibe.Error.CODE_TRANSPORT_HTTP_ERROR);err.setDetail(status);break;case jlib.RemoteXHR.READY_STATE_NETWORK_ERROR:err=new ibe.Error(ibe.Error.CODE_TRANSPORT_NETWORK_ERROR);break;case jlib.RemoteXHR.READY_STATE_CONNECTION_TERMINATED:err=new ibe.Error(ibe.Error.CODE_TRANSPORT_CONNECTION_TERMINATED);break;default:err=new ibe.Error(ibe.Error.CODE_TRANSPORT_UNKNOWN);err.setDetail(readyState+' '+status);break;}}else{err=new ibe.Error(ibe.Error.CODE_TRANSPORT_UNKNOWN);err.setDetail(status);}}else{err=new ibe.Error(ibe.Error.CODE_WEBSERVICE_UNKNOWN);}
return err;};ibe.WebService.desalinize=function(s){return decodeURIComponent(s.toString().replace(/(..)/g,'%$1'));};ibe.WebService.prototype={invoke:function(method,parameters,process,ticket,props){var me=this;var request=new ibe.WebService.Request(method,parameters,process,ticket);var url=this.url;var ns=this.ns;var reqFactory=this.reqFactory;var inputProcessor=this.inputProcessor;var outputProcessor=this.outputProcessor;var buf,req,action;if(!url||!ns||!reqFactory||!inputProcessor||!outputProcessor){return null;}
if(props){Object.dup(props,request);}
action=ns+((ns.charAt(ns.length-1)=='/')?'':'/')+
method;buf=[ibe.WebService.SOAP_OPEN_ENVELOPE,'<',method,' xmlns="',ns,'">',inputProcessor(request),'</',method,'>',ibe.WebService.SOAP_CLOSE_ENVELOPE];req=reqFactory();request.req=req;req.open('POST',url,true);req.setRequestHeader('Referer',url);req.setRequestHeader('SOAPAction',action);req.setRequestHeader('Content-Type','text/xml; charset=utf-8');req.onreadystatechange=function(){me.readyStateChange(request);};req.send(buf.join(''));return request;},readyStateChange:function(request){var req=request.req;var isCompleted=false;var isError=false;var xml,fault,faultcode,faultstring;if(req instanceof jlib.RemoteXHR.Request){if(jlib.RemoteXHR.isCompleted(req.readyState)){isCompleted=true;}else if(jlib.RemoteXHR.isError(req.readyState)){isError=true;}}else{if(req.readyState==4){if(req.status==200){isCompleted=true;}else{isError=true;}}}
if(!isCompleted&&!isError){return;}
if(isError){request.error={readyState:req.readyState,status:req.status};}
if(req.responseXML){xml=req.responseXML;if(xml.getElementsByTagName(request.method+'Result').length==0){fault=xml.getElementsByTagName('Fault')[0];if(!fault){fault=xml.getElementsByTagName('soap:Fault')[0];}
if(fault){faultcode=fault.getElementsByTagName('faultcode')[0];faultstring=fault.getElementsByTagName('faultstring')[0];}}
if(faultcode&&faultstring){if(!request.error){request.error={};}
request.error.faultcode=(faultcode.firstChild)?faultcode.firstChild.nodeValue:'';request.error.faultstring=(faultstring.firstChild)?faultstring.firstChild.nodeValue:'';}}
request.result=this.outputProcessor(request);request.process();},toString:function(){return'[object ibe.WebService]';}};ibe.WebService.Request=function(method,parameters,process,ticket){if(!method||!parameters||!process){}
this.id='r'+ibe.WebService.Request.requestId++;this.method=method;this.parameters=parameters;this.process=process;this.tickets=new jlib.Queue();this.req=null;this.error=null;this.result=null;if(ticket){this.addTicket(ticket);}};ibe.WebService.Request.requestId=1;ibe.WebService.Request.prototype={addTicket:function(ticket){if(!ticket||!ticket.callback){return;}
this.tickets.enqueue(ticket);},dispatch:function(val){var tickets=this.tickets;var ticket;while(!tickets.isEmpty()){ticket=tickets.dequeue();if(!ticket.isCancelled){ticket.callback(val);}}},toString:function(){return'[object ibe.WebService.Request]';}};if(!window.ibe){window.ibe={};}
if(!ibe.WBE){ibe.WBE={};}
ibe.WBE.hotels={};ibe.WBE.roomTypes={};ibe.WBE.hotelTimes={};ibe.WBE.checkInDates={};ibe.WBE.MAX_GET_CHECK_IN_MONTHS=2;ibe.WBE.ALLOTMENT_CODES={};ibe.WBE.HOTEL_TEMPLATE={name:'',assetPath:'',assetAlt:'',url:'',contactUrl:'',longTermUrl:'',travelTradeUrl:'',bookingUrl:'',termsUrl:'',loginUrl:'',cancelUrl:'',checkInTime:'',checkOutTime:'',numGuestsMessage:'',numExtraBedsMessage:'',airportTransferMessage:'',landTransferMessage:'',hotelArrivalMessage:'',confirmMessage:'',airportTransferConfirmMessage:'',landTransferConfirmMessage:'',hotelArrivalConfirmMessage:'',showAirportTransferLocation:false,showLandTransfer:false,showHotelArrival:false,showDietaryRequirements:false,showFullPaymentMessage:false,showNumGuestsOnly:false};ibe.WBE.HOTEL_VALUES={};ibe.WBE.service=null;ibe.WBE.init=function(url,ns,reqFactory,doCaching){if(url==null||ns==null||!reqFactory){return;}
this.service=new ibe.WebService(url,ns,reqFactory,this.inputProcessor,this.outputProcessor);this.doCaching=!!doCaching;this.restoreHotelInformation();this.restoreCheckInDates();};ibe.WBE.uninit=function(){this.service=null;this.doCaching=false;this.hotels={};this.roomTypes={};this.hotelTimes={};this.checkInDates={};this.uninitRes();};ibe.WBE.inputProcessor=function(request){var params=request.parameters;var encode=jlib.XML.encode;var toXML=ibe.WBE.toXML;var buf=[];var name;for(name in params){buf.push('<',name,'>',encode(toXML(params[name],false)),'</',name,'>');}
return buf.join('');};ibe.WBE.toXML=function(val,encodeContent){var toXML=arguments.callee;var buf,name,str;switch(typeof val){case'object':if(val==null){str='';}else if(val instanceof Date){str=val.toISODateString();}else if(val instanceof Array){name=val.rowName;buf=[];val.forEach(function(v){buf.push('<',name,'>',toXML(v,true),'</',name,'>');});str=buf.join('');}else{buf=[];for(name in val){buf.push('<',name,'>',toXML(val[name],true),'</',name,'>');}
str=buf.join('');}
break;case'boolean':str=(val)?'1':'0';break;case'function':case'undefined':case'unknown':str='';break;default:str=(encodeContent)?jlib.XML.encode(val):String(val);break;}
return str;};ibe.WBE.outputProcessor=function(request){var me=ibe.WBE;var result=null;var doc,res,root,el,val,h;val=request.error;if(val){result=ibe.WebService.processError(request.req,val);jlib.contrib.Events.dispatch(me,'error',{error:result});return result;}
doc=request.req.responseXML;if(doc){res=doc.getElementsByTagName(request.method+'Result')[0];if(res){Array.some(res.childNodes,function(node){if(node.nodeType==1){root=node;}
return!!root;});}}
if(!root){result=new ibe.Error(ibe.Error.CODE_WBE_INVALID_RESPONSE);result.setDetail('root');jlib.contrib.Events.dispatch(me,'error',{error:result});return result;}
switch(root.nodeName){case'Hotel':case'Room':case'Promotion':case'Airport':case'Rate':case'Currency':el=doc.createElement('T');res.appendChild(el);el.appendChild(root);root=el;case'T':case'HotelInformation':case'RoomInformation':case'Promotions':case'AirportInformation':case'Rates':case'RatesBreakUp':case'Rooms':case'Currencies':result=ibe.WBE.tableProcessor(root);break;case'DateTime':el=root.getElementsByTagName('date')[0];if(el){val=el.firstChild.nodeValue.match(/(\d{4})-(\d{1,2})-(\d{1,2})/);if(val&&val.length==4){result=new Date(parseInt(val[1],10),parseInt(val[2],10)-1,parseInt(val[3],10));}}
el=root.getElementsByTagName('time')[0];if(result&&el){val=el.firstChild.nodeValue.match(/(\d{1,2}):(\d{1,2})\s*(am|pm)?/i);if(val&&val.length==4){h=parseInt(val[1],10);if(val[3]){switch(val[3].toLowerCase()){case'am':if(h==12){h=0;}
break;case'pm':if(h!=12){h+=12;}
break;}}
result.setHours(h,parseInt(val[2],10));}}
if(!result){result=new ibe.Error(ibe.Error.CODE_WBE_INVALID_RESPONSE);result.setDetail('DateTime');}
break;case'RES':el=root.getElementsByTagName('XHG')[0];if(el&&el.firstChild){val=parseFloat(el.firstChild.nodeValue);if(Number.isReal(val)){result=val;}}
if(result==null){result=new ibe.Error(ibe.Error.CODE_WBE_INVALID_RESPONSE);result.setDetail('RES');}
break;case'Error':val={};Array.filter(root.childNodes,function(node){return(node.nodeType==1);}).forEach(function(node){val[node.nodeName]=(node.firstChild)?node.firstChild.nodeValue:'';});result=new ibe.Error(ibe.WBE.toIBEErrorCode(val.ID));result.setDetail(val.ID);break;default:result=new ibe.Error(ibe.Error.CODE_WBE_INVALID_RESPONSE);result.setDetail(root.nodeName);break;}
if(result instanceof ibe.Error){jlib.contrib.Events.dispatch(me,'error',{error:result});}
return result;};ibe.WBE.tableProcessor=function(root){var table=[];var rows=root.childNodes;var len=rows.length;var row,obj,cols,col,name,val,i,j,k;for(i=0;i<len;i++){row=rows[i];if(row.nodeType!=1){continue;}
if(root.nodeName=='HotelInformation'&&row.nodeName=='Salutations'){continue;}
obj={};cols=row.childNodes;for(j=cols.length-1;j>=0;j--){col=cols[j];if(col.nodeType!=1){continue;}
name=col.nodeName;switch(name){case'RoomInformation':case'Promotions':case'AirportInformation':case'Rates':case'RatesBreakUp':case'Rooms':case'Currencies':val=ibe.WBE.tableProcessor(col);break;default:val=(col.firstChild)?col.firstChild.nodeValue:'';switch(name.charAt(0)){case'b':val=(val.toLowerCase()=='true'||val=='1')?true:false;break;case'n':val=parseInt(val,10);break;case'd':switch(name.charAt(1)){case't':k=val.match(/(\d{4})(\d{2})(\d{2})/);if(k&&k.length==4){val=new Date(parseInt(k[1],10),parseInt(k[2],10)-1,parseInt(k[3],10));}
break;default:val=parseFloat(val);break;}
break;default:break;}
break;}
obj[name]=val;}
table.push(obj);}
return table;};ibe.WBE.toIBEErrorCode=function(wbeCode){var ibeCode;switch(wbeCode){case'24':ibeCode=ibe.Error.CODE_WBE_DATE_RANGE_TOO_LONG;break;case'32':ibeCode=ibe.Error.CODE_WBE_INVALID_USER_CODE;break;case'14':case'15':case'16':case'17':case'27':ibeCode=ibe.Error.CODE_WBE_CREATE_NOT_AVAILABLE;break;case'7':case'8':ibeCode=ibe.Error.CODE_WBE_CPG_ERROR;break;case'9':ibeCode=ibe.Error.CODE_WBE_CANNOT_CREATE;break;case'10':case'12':case'18':ibeCode=ibe.Error.CODE_WBE_CANNOT_CANCEL;break;case'11':case'21':ibeCode=ibe.Error.CODE_WBE_CANNOT_CONFIRM;break;case'5':ibeCode=ibe.Error.CODE_WBE_RESERVATION_NUMBER_INVALID;break;case'6':ibeCode=ibe.Error.CODE_WBE_RESERVATION_MADE_BEFORE;break;case'4':ibeCode=ibe.Error.CODE_WBE_EMAIL_INCORRECT;break;case'23':ibeCode=ibe.Error.CODE_WBE_CANNOT_RETRIEVE_RESERVATION;break;case'13':case'22':ibeCode=ibe.Error.CODE_WBE_RESERVATION_ALREADY_CANCELLED;break;case'31':ibeCode=ibe.Error.CODE_WBE_EXCHANGE_RATE_NOT_AVAILABLE;break;case'0':case'1':case'2':case'3':case'20':case'25':case'26':case'28':case'29':case'30':default:ibeCode=ibe.Error.CODE_WBE_UNKNOWN;break;}
return ibeCode;};ibe.WBE.nextVersion=1;ibe.WBE.getNewVersion=function(){return ibe.WBE.nextVersion++;};ibe.WBE.isLatestVersion=function(version){return(Number.isInt(version)&&version==ibe.WBE.nextVersion-1);};ibe.WBE.CHECK_NONE=0x000;ibe.WBE.CHECK_HOTEL_ID=0x001;ibe.WBE.CHECK_DATE=0x002;ibe.WBE.CHECK_DATE_RANGE=0x004;ibe.WBE.CHECK_ROOM_TYPE=0x008;ibe.WBE.CHECK_RATE_CODE=0x010;ibe.WBE.CHECK_PRIOR_ROOMS=0x020;ibe.WBE.CHECK_ARRIVAL_DATE=0x040;ibe.WBE.CHECK_DEPARTURE_DATE=0x080;ibe.WBE.CHECK_ROOM_AVAILABLE=0x100;ibe.WBE.CHECK_RATE_OCCUPANCY=0x200;ibe.WBE.CHECK_RATE_AVAILABLE=0x400;ibe.WBE.CHECK_RATE_START_DATE=0x800;ibe.WBE.checkPrereqs=function(version,data,required,optional,callback,ticket){var me=this;var ourData=Function.getHiddenArgument(arguments,0);var doCheck=Function.getHiddenArgument(arguments,1);var result=Function.getHiddenArgument(arguments,2);var checkIndex=Function.getHiddenArgument(arguments,3);var checks=['hotel','date','dateRange','roomType','rateCode','priorRooms','arrivalDate','departureDate','roomAvailable','rateOccupancy','rateAvailable','rateStartDate'];var len=checks.length;var state,index,check,val,i;if(!version||!data||(!required&&!optional)||!callback||!ticket){return null;}
if(!ourData){state=new ibe.BookingState(data.state);index=data.index;if(index==null){index=0;}
ourData={hotel:(data.hotel!=null)?data.hotel:state.get(index,ibe.BookingState.HOTEL_ID),fromDate:(data.fromDate)?data.fromDate:state.get(index,ibe.BookingState.ARRIVAL_DATE),toDate:(data.toDate)?data.toDate:state.get(index,ibe.BookingState.DEPARTURE_DATE),roomType:(data.roomType!=null)?data.roomType:state.get(index,ibe.BookingState.ROOM_TYPE),rateOcc:(data.rateOcc!=null)?data.rateOcc:state.get(index,ibe.BookingState.RATE_OCCUPANCY),rateCode:(data.rateCode!=null)?data.rateCode:state.get(index,ibe.BookingState.RATE_CODE),rateStartDate:(data.rateStartDate)?data.rateStartDate:state.get(index,ibe.BookingState.RATE_START_DATE),state:state,index:index};state.set(index,ibe.BookingState.HOTEL_ID,ourData.hotel);state.set(index,ibe.BookingState.ARRIVAL_DATE,ourData.fromDate);state.set(index,ibe.BookingState.DEPARTURE_DATE,ourData.toDate);state.set(index,ibe.BookingState.ROOM_TYPE,ourData.roomType);state.set(index,ibe.BookingState.RATE_OCCUPANCY,ourData.rateOcc);state.set(index,ibe.BookingState.RATE_CODE,ourData.rateCode);state.set(index,ibe.BookingState.RATE_START_DATE,ourData.rateStartDate);}
if(!doCheck){check={hotel:this.CHECK_HOTEL_ID,date:this.CHECK_DATE,dateRange:this.CHECK_DATE_RANGE,roomType:this.CHECK_ROOM_TYPE,rateCode:this.CHECK_RATE_CODE,priorRooms:this.CHECK_PRIOR_ROOMS,arrivalDate:this.CHECK_ARRIVAL_DATE,departureDate:this.CHECK_DEPARTURE_DATE,roomAvailable:this.CHECK_ROOM_AVAILABLE,rateOccupancy:this.CHECK_RATE_OCCUPANCY,rateAvailable:this.CHECK_RATE_AVAILABLE,rateStartDate:this.CHECK_RATE_START_DATE};val={hotel:(ourData.hotel!=null),date:!!ourData.fromDate,dateRange:(!!ourData.fromDate&&!!ourData.toDate),roomType:(ourData.roomType!=null),rateCode:(ourData.rateCode!=null),priorRooms:(data.state!=null&&data.index!=null),arrivalDate:!!ourData.fromDate,departureDate:!!ourData.toDate,roomAvailable:(ourData.roomType!=null),rateOccupancy:(ourData.rateOcc!=null),rateAvailable:(ourData.rateCode!=null),rateStartDate:!!ourData.rateStartDate};doCheck={};checks.forEach(function(c){doCheck[c]=(required&check[c])||((optional&check[c])&&val[c]);});if(doCheck.rateStartDate){doCheck.rateAvailable=true;}
if(doCheck.rateAvailable){doCheck.rateOccupancy=true;doCheck.rateCode=true;doCheck.roomAvailable=true;}
if(doCheck.rateOccupancy){doCheck.roomType=true;}
if(doCheck.roomAvailable){doCheck.dateRange=true;doCheck.roomType=true;doCheck.arrivalDate=true;doCheck.departureDate=true;}
if(doCheck.date||doCheck.dateRange||doCheck.roomType){doCheck.hotel=true;}
if(doCheck.arrivalDate||doCheck.departureDate){doCheck.hotel=true;doCheck.priorRooms=true;}
if((doCheck.rateCode||doCheck.departureDate||doCheck.roomAvailable||doCheck.rateOccupancy||doCheck.rateAvailable||doCheck.rateStartDate)&&!this.checkPrereqs_rateCode){ibe.WebService.doCallback(callback,false);return ticket;}}
if(!result){result={};}
if(checkIndex==null){checkIndex=0;}
for(i=checkIndex;i<len;i++){check=checks[i];if(!doCheck[check]){continue;}
val=result[check];if(typeof val=='undefined'){return this['checkPrereqs_'+check](version,data,required,optional,callback,ticket,ourData,doCheck,result,i);}else if(val instanceof ibe.Error){ibe.WebService.doCallback(callback,val);return ticket;}else if(!val){ibe.WebService.doCallback(callback,false);return ticket;}else{}}
ibe.WebService.doCallback(callback,true);return ticket;};ibe.WBE.checkPrereqs_hotel=function(version,data,required,optional,callback,ticket,ourData,doCheck,result,checkIndex){var me=this;var hotel=ourData.hotel;return this.isHotel(version,hotel,function(isValid){result.hotel=isValid;me.checkPrereqs(version,data,required,optional,callback,ticket,ourData,doCheck,result,checkIndex);},ticket);};ibe.WBE.checkPrereqs_date=function(version,data,required,optional,callback,ticket,ourData,doCheck,result,checkIndex){var me=this;var hotel=ourData.hotel;var fromDate=ourData.fromDate;return this.isDate(version,hotel,fromDate,function(isValid){result.date=isValid;me.checkPrereqs(version,data,required,optional,callback,ticket,ourData,doCheck,result,checkIndex);},ticket,true);};ibe.WBE.checkPrereqs_dateRange=function(version,data,required,optional,callback,ticket,ourData,doCheck,result,checkIndex){var me=this;var hotel=ourData.hotel;var fromDate=ourData.fromDate;var toDate=ourData.toDate;return this.isDateRange(version,hotel,fromDate,toDate,function(isValid){result.dateRange=isValid;me.checkPrereqs(version,data,required,optional,callback,ticket,ourData,doCheck,result,checkIndex);},ticket,true);};ibe.WBE.checkPrereqs_roomType=function(version,data,required,optional,callback,ticket,ourData,doCheck,result,checkIndex){var me=this;var hotel=ourData.hotel;var roomType=ourData.roomType;return this.isRoomType(version,hotel,roomType,function(isValid){result.roomType=isValid;me.checkPrereqs(version,data,required,optional,callback,ticket,ourData,doCheck,result,checkIndex);},ticket,true);};ibe.WBE.checkPrereqs_priorRooms=function(version,data,required,optional,callback,ticket,ourData,doCheck,result,checkIndex){var me=this;var state=ourData.state;var index=ourData.index;return this.checkRooms(version,state,index,this.CHECK_HOTEL_ID,(this.CHECK_DATE_RANGE|this.CHECK_ROOM_TYPE|this.CHECK_RATE_CODE),function(isValid){result.priorRooms=isValid;me.checkPrereqs(version,data,required,optional,callback,ticket,ourData,doCheck,result,checkIndex);},ticket);};ibe.WBE.checkPrereqs_arrivalDate=function(version,data,required,optional,callback,ticket,ourData,doCheck,result,checkIndex){var me=this;var state=ourData.state;var index=ourData.index;var fromDate=ourData.fromDate;return this.isCheckInDate(version,state,index,fromDate,function(isValid){result.arrivalDate=isValid;me.checkPrereqs(version,data,required,optional,callback,ticket,ourData,doCheck,result,checkIndex);},ticket,true);};ibe.WBE.checkRooms=function(version,state,index,required,optional,callback,ticket){var me=this;var result=Function.getHiddenArgument(arguments,0);var checkIndex=Function.getHiddenArgument(arguments,1);var val,i;if(!version||!state||index==null||required==null||optional==null||!callback||!ticket){return null;}
if(!result){result=[];}
if(checkIndex==null){checkIndex=0;}
for(i=checkIndex;i<index;i++){val=result[i];if(typeof val=='undefined'){return this.checkPrereqs(version,{state:state,index:i},required,optional,function(isValid){result[i]=isValid;me.checkRooms(version,state,index,required,optional,callback,ticket,result,i);},ticket);}else if(val instanceof ibe.Error){ibe.WebService.doCallback(callback,val);return ticket;}else if(!val){ibe.WebService.doCallback(callback,false);return ticket;}else{}}
ibe.WebService.doCallback(callback,true);return ticket;};ibe.WBE.getKey=function(version,state,index){var HOTEL_ID=ibe.BookingState.HOTEL_ID;var ARRIVAL_DATE=ibe.BookingState.ARRIVAL_DATE;var DEPARTURE_DATE=ibe.BookingState.DEPARTURE_DATE;var ROOM_TYPE=ibe.BookingState.ROOM_TYPE;var buf,i;if(!version||!state||index==null){return null;}
buf=[version,state.get(null,ibe.BookingState.USER_CODE),state.get(null,ibe.BookingState.USER_CODE_TYPE)];for(i=0;i<=index;i++){buf.push(state.get(i,HOTEL_ID),state.get(i,ARRIVAL_DATE),state.get(i,DEPARTURE_DATE),state.get(i,ROOM_TYPE));}
return buf.map(function(val){var str=val;if(val==null){str='';}else if(val instanceof Date){str=val.toISODateString();}
return str;}).join('_');};ibe.WBE.extractFromState=function(state,index,template){var HOTEL_ID=ibe.BookingState.HOTEL_ID;var ARRIVAL_DATE=ibe.BookingState.ARRIVAL_DATE;var DEPARTURE_DATE=ibe.BookingState.DEPARTURE_DATE;var ROOM_TYPE=ibe.BookingState.ROOM_TYPE;var CORPORATE_CODE=ibe.BookingState.USER_CODE_TYPE_CORPORATE;var IATA_CODE=ibe.BookingState.USER_CODE_TYPE_IATA;var PROMOTION_CODE=ibe.BookingState.USER_CODE_TYPE_PROMOTION;var rooms=[];var hotel,arr,dep,room,userCode,userCodeType;var len,i;if(!state){return null;}
len=state.getNumRooms();if(index!=null){if(!Number.isInt(index)||index<0||index>=len){return null;}}else{index=len-1;}
userCode=state.get(null,ibe.BookingState.USER_CODE);userCodeType=state.get(null,ibe.BookingState.USER_CODE_TYPE);rooms.userCode=(userCode!=null)?userCode:'';rooms.userCodeType=(userCodeType!=null)?userCodeType:'';for(i=0;i<=index;i++){hotel=state.get(i,HOTEL_ID);arr=state.get(i,ARRIVAL_DATE);dep=state.get(i,DEPARTURE_DATE);room=state.get(i,ROOM_TYPE);rooms.push(Object.dup(template,{sHotelID:hotel,dtArrival:(arr)?arr:null,dtDeparture:(dep)?dep:null,sRoomType:(room!=null)?room:'',sRateCode:'',sCompanyCode:(userCodeType==CORPORATE_CODE)?userCode:'',sTACode:(userCodeType==IATA_CODE)?userCode:'',sPromotionCode:(userCodeType==PROMOTION_CODE)?userCode:''}));}
return rooms;};ibe.WBE.doMultiple=function(requests,responses,callback){var me=this;var ticket=Function.getHiddenArgument(arguments,0);var reqIndex=Function.getHiddenArgument(arguments,1);var len,req,key,method,args,resp,callbackPos,func,i;if(!requests||!callback){return null;}
if(!(requests instanceof jlib.OrderedObject)){return null;}
len=requests.length;for(i=0;i<len;i++){req=requests.get(i)[1];if(!req){return null;}
method=req.method;if(typeof this[method]!='function'){return null;}}
ticket=ibe.WebService.setupTicket(ticket,callback);if(!(responses instanceof jlib.OrderedObject)){responses=new jlib.OrderedObject();}
if(reqIndex==null){reqIndex=0;}
for(i=reqIndex;i<len;i++){req=requests.get(i);key=req[0];resp=responses.getValue(key);req=req[1];if(typeof resp!='undefined'&&typeof req.preprocessor=='function'){resp=req.preprocessor(resp);}
if(typeof resp=='undefined'){method=req.method;args=Array.toArray(req.arguments);callbackPos=req.callbackPos;func=function(val){if(!responses.getValue(key)){responses.push(key,val);}else{responses.replaceValue(key,val);}
me.doMultiple(requests,responses,callback,ticket,i);};if(Number.isInt(callbackPos)&&callbackPos>=0){args[callbackPos]=func;args[callbackPos+1]=ticket;}else{args.push(func,ticket);}
return this[method].apply(this,args);}else if(resp instanceof ibe.Error){ibe.WebService.doCallback(callback,resp);return ticket;}else if(resp==null){ibe.WebService.doCallback(callback,null);return ticket;}}
ibe.WebService.doCallback(callback,responses);return ticket;};ibe.WBE.zeroPreprocessor=function(response){return(response instanceof ibe.Error)?0:response;};ibe.WBE.getInfo=function(name,method,params,processor,version,callback){var ticket=Function.getHiddenArgument(arguments,0);var list,pl,props;if(!name||!method||!processor){return null;}
if(!version||!callback){return null;}
ticket=ibe.WebService.setupTicket(ticket,callback);list=this[name][version];if(!list){pl=Object.dup(params);props={WBE:this,WBE_name:name,WBE_processor:processor,WBE_version:version};this[name][version]=this.service.invoke(method,pl,this.getInfoProcess,ticket,props);}else if(list instanceof ibe.WebService.Request){list.addTicket(ticket);}else{ibe.WebService.doCallback(callback,list);}
return ticket;};ibe.WBE.getInfoProcess=function(){var me=this.WBE;var name=this.WBE_name;var processor=this.WBE_processor;var version=this.WBE_version;var result=this.result;var list=null;var dispatchVal=null;if(result){if(result instanceof ibe.Error){dispatchVal=result;}else{list=me[processor](result,version);dispatchVal=list;}}
me[name][version]=list;me.cacheHotelInformation();this.dispatch(dispatchVal);};ibe.WBE.isInfoItem=function(name,method,params,processor,version,item,callback){var me=this;var ticket=Function.getHiddenArgument(arguments,0);if(!name||!method||!processor){return null;}
if(!version||item==null||!callback){return null;}
return this.getInfo(name,method,params,processor,version,function(list){var isValid=null;if(list){if(list instanceof ibe.Error){isValid=list;}else{isValid=(list.getValue(item)!=null);}}else{}
callback(isValid);},ticket);};ibe.WBE.getHotelInfo=function(name,method,params,processor,version,hotel,callback){var me=this;var ticket=Function.getHiddenArgument(arguments,0);var skipCheck=Function.getHiddenArgument(arguments,1);var prereqs=Function.getHiddenArgument(arguments,2);var key,list,pl,props;if(!name||!method||!processor){return null;}
if(!version||hotel==null||!callback){return null;}
ticket=ibe.WebService.setupTicket(ticket,callback);if(!skipCheck){if(typeof prereqs=='undefined'){return this.checkPrereqs(version,{hotel:hotel},this.CHECK_HOTEL_ID,this.CHECK_NONE,function(isValid){me.getHotelInfo(name,method,params,processor,version,hotel,callback,ticket,skipCheck,isValid);},ticket);}else if(prereqs instanceof ibe.Error){ibe.WebService.doCallback(callback,prereqs);return ticket;}else if(!prereqs){ibe.WebService.doCallback(callback,null);return ticket;}}
key=version+'_'+hotel;list=this[name][key];if(!list){pl=Object.dup(params,{sHotelID:hotel});props={WBE:this,WBE_name:name,WBE_processor:processor,WBE_key:key};this[name][key]=this.service.invoke(method,pl,this.getHotelInfoProcess,ticket,props);}else if(list instanceof ibe.WebService.Request){list.addTicket(ticket);}else{ibe.WebService.doCallback(callback,list);}
return ticket;};ibe.WBE.getHotelInfoProcess=function(){var me=this.WBE;var name=this.WBE_name;var processor=this.WBE_processor;var key=this.WBE_key;var result=this.result;var list=null;var dispatchVal=null;if(result){if(result instanceof ibe.Error){dispatchVal=result;}else{list=me[processor](result);dispatchVal=list;}}
me[name][key]=list;me.cacheHotelInformation();this.dispatch(dispatchVal);};ibe.WBE.isHotelInfoItem=function(name,method,params,processor,version,hotel,item,callback){var me=this;var ticket=Function.getHiddenArgument(arguments,0);var skipCheck=Function.getHiddenArgument(arguments,1);if(!name||!method||!processor){return null;}
if(!version||hotel==null||item==null||!callback){return null;}
return this.getHotelInfo(name,method,params,processor,version,hotel,function(list){var isValid=null;if(list){if(list instanceof ibe.Error){isValid=list;}else{isValid=(list.getValue(item)!=null);}}else{}
callback(isValid);},ticket,skipCheck);};ibe.WBE.getHotels=function(version,callback){var ticket=Function.getHiddenArgument(arguments,0);return this.getInfo('hotels','wbe_cm_Hotel_GetElement',{sXPath:'/HotelInformation'},'hotelsProcess',version,callback,ticket);};ibe.WBE.isHotel=function(version,hotel,callback){var ticket=Function.getHiddenArgument(arguments,0);return this.isInfoItem('hotels','wbe_cm_Hotel_GetElement',{sXPath:'/HotelInformation'},'hotelsProcess',version,hotel,callback,ticket);};ibe.WBE.hotelsProcess=function(list,version){var HOTEL_TEMPLATE=ibe.WBE.HOTEL_TEMPLATE;var HOTEL_VALUES=ibe.WBE.HOTEL_VALUES;var hotels=new jlib.OrderedObject();var roomTypes=this.roomTypes;var promotions=this.promotions;var airports=this.airports;var len=list.length;var h,id,key,i;for(i=0;i<len;i++){h=list[i];id=h.sHotelId;hotels.push(id,Object.dup(HOTEL_VALUES[id],{name:h.sHotelName,assetPath:h.sHotelAsset,assetAlt:h.sHotelAssetAlt,url:h.sHotelURL,contactUrl:h.sHotelContactURL,loginUrl:h.sHotelLoginURL,longTermUrl:h.sHotelLongTermURL,checkInTime:h.sCheckInTime,checkOutTime:h.sCheckOutTime,showFullPaymentMessage:(h.nDepositType==1)},HOTEL_TEMPLATE,{}));key=version+'_'+id;if(!roomTypes[key]){roomTypes[key]=this.roomTypesProcess(h.RoomInformation);}
if(promotions&&!promotions[key]){promotions[key]=this.promotionsProcess(h.Promotions);}
if(airports&&!airports[key]){airports[key]=this.airportsProcess(h.AirportInformation);}}
return hotels;};ibe.WBE.getRoomTypes=function(version,hotel,callback){var ticket=Function.getHiddenArgument(arguments,0);var skipCheck=Function.getHiddenArgument(arguments,1);return this.getHotelInfo('roomTypes','wbe_cm_GetAllRoomType',null,'roomTypesProcess',version,hotel,callback,ticket,skipCheck);};ibe.WBE.isRoomType=function(version,hotel,roomType,callback){var ticket=Function.getHiddenArgument(arguments,0);var skipCheck=Function.getHiddenArgument(arguments,1);return this.isHotelInfoItem('roomTypes','wbe_cm_GetAllRoomType',null,'roomTypesProcess',version,hotel,roomType,callback,ticket,skipCheck);};ibe.WBE.roomTypesProcess=function(list){var roomTypes=new jlib.OrderedObject();var len=list.length;var r,i;for(i=0;i<len;i++){r=list[i];roomTypes.push(r.sRoomType,{name:r.sName,fullName:r.sLongName,minOccupancy:r.nMinOccupancy,maxOccupancy:r.nMaxOccupancy,maxExtraBeds:r.nMaxExtraBeds,maxExtraBedsMessage:r.sExtraBedMessage,currency:r.sCurrency,currencyId:r.sCurrencyID,ratesFrom:r.dRatesFrom,ratesTo:r.dRatesTo,descriptionShort:r.sDescriptionShort,maxOccupancyText:r.sMaxOccupancyText,teaserPath:r.sAssetPath,teaserAlt:r.sAssetAlt,overview:r.sOverview,description:r.sDescription,assetPath:r.sRoomAsset,assetId1:r.sRoomAssetID1,assetId2:r.sRoomAssetID2,assetId3:r.sRoomAssetID3,assetId4:r.sRoomAssetID4,assetId5:r.sRoomAssetID5,url:r.sURL,onRequest:r.bOnRequest,ratesOccupancyDependent:(r.nRoomRate==0)});}
return roomTypes;};ibe.WBE.getHotelTime=function(version,hotel,callback){var ticket=Function.getHiddenArgument(arguments,0);var skipCheck=Function.getHiddenArgument(arguments,1);return this.getHotelInfo('hotelTimes','wbe_GetDateTime',null,'hotelTimeProcess',version,hotel,callback,ticket,skipCheck);};ibe.WBE.hotelTimeProcess=function(now){var segmentLength=ibe.WBE.MAX_GET_CHECK_IN_MONTHS;var segments={};var delta,today,ayear,from,to;var start,end,strs,obj,m,n,s;delta=now-(new Date());today=new Date(now);today.clear(Date.CLEAR_TIME);ayear=new Date(today);ayear.addFullYear(1);from=new Date(today);from.clear(Date.CLEAR_TIME|Date.CLEAR_DATE);to=new Date(ayear);to.addDate(-1);to.clear(Date.CLEAR_TIME|Date.CLEAR_DATE);to.addMonth(1);for(m=new Date(from);m<to;m.addMonth(segmentLength)){start=new Date(m);end=new Date(m);end.addMonth(segmentLength);if(end>to){end=new Date(to);}
end.addDate(-1);strs=[];obj={from:start,to:end,monthStrs:strs};for(n=new Date(start);n<end;n.addMonth(1)){s=n.toISODateString();segments[s]=obj;strs.push(s);}}
return{delta:delta,today:today,ayear:ayear,from:from,to:to,segments:segments};};ibe.WBE.calculateHotelTime=function(time){var now=new Date();now.setTime(now.getTime()+time.delta);return now;};ibe.WBE.isDate=function(version,hotel,date,callback){var me=this;var ticket=Function.getHiddenArgument(arguments,0);var skipCheck=Function.getHiddenArgument(arguments,1);if(!version||hotel==null||!date||!callback){return null;}
return this.getHotelTime(version,hotel,function(time){var isValid=null;if(time){if(time instanceof ibe.Error){isValid=time;}else{isValid=(date>=time.from&&date<time.to);}}else{}
callback(isValid);},ticket,skipCheck);};ibe.WBE.isDateRange=function(version,hotel,fromDate,toDate,callback){var me=this;var ticket=Function.getHiddenArgument(arguments,0);var skipCheck=Function.getHiddenArgument(arguments,1);if(!version||hotel==null||!fromDate||!toDate||!callback){return null;}
return this.getHotelTime(version,hotel,function(time){var isValid=null;var from,to,isFrom,isTo;if(time){if(time instanceof ibe.Error){isValid=time;}else{from=new Date(fromDate);from.clear(Date.CLEAR_TIME);to=new Date(toDate);to.clear(Date.CLEAR_TIME);isFrom=(from>=time.from&&from<time.to);isTo=(to>time.from&&to<=time.to);isValid=(isFrom&&isTo&&from<to);}}else{}
callback(isValid);},ticket,skipCheck);};ibe.WBE.getCheckInDates=function(version,state,index,fromDate,toDate,callback){var me=this;var ticket=Function.getHiddenArgument(arguments,0);var skipCheck=Function.getHiddenArgument(arguments,1);var prereqs=Function.getHiddenArgument(arguments,2);var ourState,key,dates,requestedDates,rooms,pl,props;var hotel,from,to,cb,firstDayOfMonth,segment,req,m,d,s;if(!version||!state||index==null||!fromDate||!toDate||!callback){return null;}
ourState=new ibe.BookingState(state);ourState.set(index,ibe.BookingState.ARRIVAL_DATE,null);ourState.set(index,ibe.BookingState.DEPARTURE_DATE,null);ticket=ibe.WebService.setupTicket(ticket,callback);if(!skipCheck){if(typeof prereqs=='undefined'){return this.checkPrereqs(version,{fromDate:fromDate,toDate:toDate,state:ourState,index:index},(this.CHECK_HOTEL_ID|this.CHECK_DATE_RANGE|this.CHECK_PRIOR_ROOMS),(this.CHECK_ROOM_TYPE|this.CHECK_RATE_CODE),function(isValid){me.getCheckInDates(version,state,index,fromDate,toDate,callback,ticket,skipCheck,isValid);},ticket);}else if(prereqs instanceof ibe.Error){ibe.WebService.doCallback(callback,prereqs);return ticket;}else if(!prereqs){ibe.WebService.doCallback(callback,null);return ticket;}}
key=this.getKey(version,ourState,index);dates=this.checkInDates[key];if(!dates){dates={};this.checkInDates[key]=dates;}
hotel=ourState.get(index,ibe.BookingState.HOTEL_ID);from=new Date(fromDate);from.clear(Date.CLEAR_TIME|Date.CLEAR_DATE);to=new Date(toDate);to.addDate(-1);to.clear(Date.CLEAR_TIME|Date.CLEAR_DATE);cb=function(a){if(!a){ibe.WebService.doCallback(callback,null);}else if(a instanceof ibe.Error){ibe.WebService.doCallback(callback,a);}else{me.getCheckInDates(version,state,index,fromDate,toDate,callback,ticket,skipCheck,prereqs);}};for(m=new Date(from);m<=to;m.addMonth(1)){firstDayOfMonth=dates[m.toISODateString()];if(firstDayOfMonth==null){segment=this.getSegment(version,hotel,m);if(!segment){ibe.WebService.doCallback(callback,null);return ticket;}
rooms=this.extractFromState(ourState,index,{nAdults:1,nChildren:0,sAllotmentCode:ibe.WBE.ALLOTMENT_CODES[hotel],nRoomsToBook:1,sCustomerCode:''});rooms[index].dtArrival=segment.from;rooms[index].dtDeparture=segment.to;rooms.rowName='Room';pl={Rooms:rooms};props={WBE:this,WBE_dates:dates,WBE_segment:segment};ticket.callback=cb;req=this.service.invoke('wbe_GetCheckInDates',pl,this.getCheckInDatesProcess,ticket,props);segment.monthStrs.forEach(function(str){dates[str]=req;});return ticket;}else if(firstDayOfMonth instanceof ibe.WebService.Request){ticket.callback=cb;firstDayOfMonth.addTicket(ticket);return ticket;}}
from=new Date(fromDate);from.clear(Date.CLEAR_TIME);to=new Date(toDate);to.clear(Date.CLEAR_TIME);requestedDates={};for(d=new Date(from);d<to;d.addDate(1)){s=d.toISODateString();if(dates[s]){requestedDates[s]=true;}}
ibe.WebService.doCallback(callback,requestedDates);return ticket;};ibe.WBE.getSegment=function(version,hotel,month){var hotelTime=this.hotelTimes[version+'_'+hotel];if(!hotelTime){return null;}
return hotelTime.segments[month.toISODateString()];};ibe.WBE.getCheckInDatesProcess=function(){var me=this.WBE;var dates=this.WBE_dates;var segment=this.WBE_segment;var result=this.result;var dispatchVal=null;var len,resultDates,from,to,d,i;if(result){if(result instanceof ibe.Error){segment.monthStrs.forEach(function(str){dates[str]=null;});dispatchVal=result;}else{resultDates={};len=result.length;for(i=len-1;i>=0;i--){d=result[i];resultDates[d.dtDate.toISODateString()]=!!d.bAvailable;}
from=segment.from;to=segment.to;for(d=new Date(from);d<=to;d.addDate(1)){i=d.toISODateString();dates[i]=(resultDates[i]!=null)?resultDates[i]:false;}
dispatchVal=true;}}
me.cacheCheckInDates();this.dispatch(dispatchVal);};ibe.WBE.isCheckInDate=function(version,state,index,checkInDate,callback){var me=this;var ticket=Function.getHiddenArgument(arguments,0);var skipCheck=Function.getHiddenArgument(arguments,1);var toDate;if(!version||!state||index==null||!checkInDate||!callback){return null;}
toDate=new Date(checkInDate);toDate.addDate(1);return this.getCheckInDates(version,state,index,checkInDate,toDate,function(dates){var isValid=null;if(dates){if(dates instanceof ibe.Error){isValid=dates;}else{isValid=!!dates[checkInDate.toISODateString()];}}else{}
callback(isValid);},ticket,skipCheck);};ibe.WBE.toString=function(){return'[object ibe.WBE]';};ibe.WBE.uninitRes=function(){};ibe.WBE.restoreHotelInformation=function(){};ibe.WBE.restoreCheckInDates=function(){};ibe.WBE.cacheHotelInformation=function(){};ibe.WBE.cacheCheckInDates=function(){};if(!window.ibe){window.ibe={};}
ibe.Error=function(code){this.code=null;this.message=null;this.detail=null;this.actions=[];this.callbacks={};this.hrefs={};if(code!=null){this.setCode(code);}};ibe.Error.ACTIONS={retry:{name:_('Try Again'),callback:'retry'},skip:{name:_('Continue Without This Step'),callback:'skip'},reenter:{name:_('Re-enter Information'),callback:'reenter'},close:{name:_('Close'),callback:'close'}};ibe.Error.DEFAULT_PROFILE={message:_('We are sorry, the booking system is temporarily unavailable.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.PROFILES={};ibe.Error.CODE_UNKNOWN=1;ibe.Error.PROFILES[ibe.Error.CODE_UNKNOWN]={message:_('We are sorry, an error has occurred.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_TRANSPORT_UNKNOWN=101;ibe.Error.PROFILES[ibe.Error.CODE_TRANSPORT_UNKNOWN]={message:_('We are sorry, there was a problem with the network connection.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_TRANSPORT_TIMED_OUT=102;ibe.Error.PROFILES[ibe.Error.CODE_TRANSPORT_TIMED_OUT]={message:_('We are sorry, the booking system took too long to respond.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_TRANSPORT_HTTP_ERROR=103;ibe.Error.CODE_TRANSPORT_NETWORK_ERROR=104;ibe.Error.PROFILES[ibe.Error.CODE_TRANSPORT_NETWORK_ERROR]={message:_('We are sorry, there was a problem with the network connection.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_TRANSPORT_CONNECTION_TERMINATED=105;ibe.Error.PROFILES[ibe.Error.CODE_TRANSPORT_CONNECTION_TERMINATED]={message:_('We are sorry, the network connection was unexpectedly disconnected.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_WEBSERVICE_UNKNOWN=201;ibe.Error.CODE_WBE_UNKNOWN=301;ibe.Error.CODE_WBE_INVALID_RESPONSE=302;ibe.Error.CODE_WBE_CREATE_NO_AVAILABILITY=303;ibe.Error.PROFILES[ibe.Error.CODE_WBE_CREATE_NO_AVAILABILITY]={message:_('We are sorry, there is no availability for the selected dates and suite. Please try again.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_WBE_CREATE_ARRIVAL_IN_PAST=304;ibe.Error.PROFILES[ibe.Error.CODE_WBE_CREATE_ARRIVAL_IN_PAST]={message:_('Sorry, the selected arrival date is in the past. Please try again.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_WBE_CREATE_ROOM_TYPE_INVALID=305;ibe.Error.PROFILES[ibe.Error.CODE_WBE_CREATE_ROOM_TYPE_INVALID]={message:_('Sorry, there is a problem with the selected suite. Please try again.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_WBE_CREATE_RATE_CODE_INVALID=306;ibe.Error.PROFILES[ibe.Error.CODE_WBE_CREATE_RATE_CODE_INVALID]={message:_('We are sorry, there was a problem with the booking system. Please try again.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_WBE_RESERVATION_NUMBER_INVALID=307;ibe.Error.PROFILES[ibe.Error.CODE_WBE_RESERVATION_NUMBER_INVALID]={message:_('This reservation has not been made online.'),actions:[ibe.Error.ACTIONS.reenter]};ibe.Error.CODE_WBE_RESERVATION_MADE_BEFORE=319;ibe.Error.PROFILES[ibe.Error.CODE_WBE_RESERVATION_MADE_BEFORE]={message:_('We are sorry. Bookings made prior to 10th of June 2008 cannot be cancelled online. For assistance, please contact our reservations team on<br />tel: +971 4 303 4222.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_WBE_EMAIL_INCORRECT=308;ibe.Error.PROFILES[ibe.Error.CODE_WBE_EMAIL_INCORRECT]={message:_('Your email address does not match your reservation. Please enter the same address that you had used when making the booking.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_WBE_CANNOT_RETRIEVE_RESERVATION=309;ibe.Error.PROFILES[ibe.Error.CODE_WBE_CANNOT_RETRIEVE_RESERVATION]={message:_('We are sorry, the booking has not been completed yet.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_WBE_RESERVATION_ALREADY_CANCELLED=310;ibe.Error.PROFILES[ibe.Error.CODE_WBE_RESERVATION_ALREADY_CANCELLED]={message:_('Your reservation has already been cancelled.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_WBE_CANNOT_CANCEL=311;ibe.Error.PROFILES[ibe.Error.CODE_WBE_CANNOT_CANCEL]={message:_('We are sorry, the booking system could not cancel the booking.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_WBE_DATE_RANGE_TOO_LONG=312;ibe.Error.PROFILES[ibe.Error.CODE_WBE_DATE_RANGE_TOO_LONG]={message:_('Please select a shorter length of stay.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_WBE_EXCHANGE_RATE_NOT_AVAILABLE=313;ibe.Error.CODE_WBE_CANNOT_CREATE=314;ibe.Error.PROFILES[ibe.Error.CODE_WBE_CANNOT_CREATE]={message:_('We are sorry, the booking system could not create the booking.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_WBE_CANNOT_CONFIRM=315;ibe.Error.PROFILES[ibe.Error.CODE_WBE_CANNOT_CONFIRM]={message:_('We are sorry, the booking system could not confirm the booking.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_WBE_CPG_ERROR=316;ibe.Error.CODE_WBE_CREATE_NOT_AVAILABLE=317;ibe.Error.PROFILES[ibe.Error.CODE_WBE_CREATE_NOT_AVAILABLE]={message:_('Sorry, the suite is currently not available on the selected dates.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_WBE_INVALID_USER_CODE=318;ibe.Error.PROFILES[ibe.Error.CODE_WBE_INVALID_USER_CODE]={message:_('Sorry, the entered rate code was not valid. Please try again.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_WBE_ARRIVAL_TOO_CLOSE=320;ibe.Error.PROFILES[ibe.Error.CODE_WBE_ARRIVAL_TOO_CLOSE]={message:_('Sorry, the selected arrival date is too close to the current date. Please try again.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_EMAIL_UNKNOWN=501;ibe.Error.PROFILES[ibe.Error.CODE_EMAIL_UNKNOWN]={message:_('We are sorry, there was a problem while sending an email.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_EMAIL_INVALID_RESPONSE=502;ibe.Error.PROFILES[ibe.Error.CODE_EMAIL_INVALID_RESPONSE]={message:_('We are sorry, there was a problem while sending an email.'),actions:[ibe.Error.ACTIONS.retry]};ibe.Error.CODE_CPG_UNKNOWN=601;ibe.Error.PROFILES[ibe.Error.CODE_CPG_UNKNOWN]={message:_('We are sorry, an unknown error has occurred. Please try again.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_CPG_CREDIT_CARD_REFUSED=602;ibe.Error.PROFILES[ibe.Error.CODE_CPG_CREDIT_CARD_REFUSED]={message:_('Sorry, your credit card was declined. Please try again.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_UNKNOWN=701;ibe.Error.PROFILES[ibe.Error.CODE_IBE_UNKNOWN]={message:_('We are sorry, an unknown error has occurred. Please try again.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_DATE_RANGE_NOT_AVAILABLE=702;ibe.Error.PROFILES[ibe.Error.CODE_IBE_DATE_RANGE_NOT_AVAILABLE]={message:_('Sorry, there are dates between your selected check in and check out dates that are unavailable. Please reselect your check out date.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_NUMBER_OF_GUESTS_TOO_LARGE=703;ibe.Error.PROFILES[ibe.Error.CODE_IBE_NUMBER_OF_GUESTS_TOO_LARGE]={message:_('Sorry, the newly-selected suite cannot accomodate the number of guests selected earlier. Please reselect the number of guests.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_NUMBER_OF_GUESTS_TOO_SMALL=704;ibe.Error.PROFILES[ibe.Error.CODE_IBE_NUMBER_OF_GUESTS_TOO_SMALL]={message:_('Sorry, the newly-selected suite cannot accomodate the number of guests selected earlier. Please reselect the number of guests.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_MISSING_RESERVATION_NUMBER_OR_EMAIL=705;ibe.Error.PROFILES[ibe.Error.CODE_IBE_MISSING_RESERVATION_NUMBER_OR_EMAIL]={message:_('Sorry, please enter your email address and booking number.'),actions:[ibe.Error.ACTIONS.reenter]};ibe.Error.CODE_IBE_FORM_INCOMPLETE=706;ibe.Error.PROFILES[ibe.Error.CODE_IBE_FORM_INCOMPLETE]={message:_('The field(s) shown in red below require correction.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_INCOMPLETE_ROOM=707;ibe.Error.PROFILES[ibe.Error.CODE_IBE_INCOMPLETE_ROOM]={message:_('Please complete this suite before moving onto the next step.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_INCOMPLETE_ROOM_GUEST_INFO=708;ibe.Error.PROFILES[ibe.Error.CODE_IBE_INCOMPLETE_ROOM_GUEST_INFO]={message:_('To proceed please check your details and click Continue.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_REMOVED_USER_ROOM=709;ibe.Error.PROFILES[ibe.Error.CODE_IBE_REMOVED_USER_ROOM]={message:_('Sorry, the suite that you will be staying in has been removed. Please re-enter your details.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_TERMS_CONDITIONS_UNREAD=710;ibe.Error.PROFILES[ibe.Error.CODE_IBE_TERMS_CONDITIONS_UNREAD]={message:_('Please indicate that you have read the terms and conditions.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_FORM_INCOMPLETE_MAX_OCCUPANCY=711;ibe.Error.PROFILES[ibe.Error.CODE_IBE_FORM_INCOMPLETE_MAX_OCCUPANCY]={message:_('The field(s) shown in red below require correction. Your selection exceeds the maximum occupancy for this suite.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_FORM_INCOMPLETE_PICK_UP_CONFLICT=712;ibe.Error.PROFILES[ibe.Error.CODE_IBE_FORM_INCOMPLETE_PICK_UP_CONFLICT]={message:_('The field(s) shown in red below require correction. Please select at most one airport or land transfer pick up.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_ROOM_RATE_OCCUPANCY_MISMATCH=713;ibe.Error.PROFILES[ibe.Error.CODE_IBE_ROOM_RATE_OCCUPANCY_MISMATCH]={message:_('Sorry, the rate or package selected earlier is not applicable for the newly-selected suite. Please reselect a rate or package.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_NUMBER_OF_GUESTS_ADJUSTED_AFTER_RATE_OCCUPANCY_CHANGE=714;ibe.Error.PROFILES[ibe.Error.CODE_IBE_NUMBER_OF_GUESTS_ADJUSTED_AFTER_RATE_OCCUPANCY_CHANGE]={message:_('Please note that the number of adults has been adjusted to match the newly-selected rate or package.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.CODE_IBE_NUMBER_OF_GUESTS_INVALID_AFTER_RATE_OCCUPANCY_CHANGE=715;ibe.Error.PROFILES[ibe.Error.CODE_IBE_NUMBER_OF_GUESTS_INVALID_AFTER_RATE_OCCUPANCY_CHANGE]={message:_('The number of adults has been adjusted to match the newly-selected rate or package. Please reselect the number of guests.'),actions:[ibe.Error.ACTIONS.close]};ibe.Error.askOnError=function(caller,callee,fname,preprocessor){var mediator,cb,tryFunc,args,callback,ticket,cbPos,ticketPos;if(!caller||!callee||!fname){return null;}
if(typeof callee[fname]!='function'){return null;}
if(preprocessor&&typeof preprocessor!='function'){return null;}
mediator=caller.mediator;cb=function(result){if(result==null){result=new ibe.Error(ibe.Error.CODE_UNKNOWN);}
if(preprocessor){result=preprocessor(result);}
if(result instanceof ibe.Error){result.setCallback('retry',tryFunc);result.setCallback('skip',function(){callback(result);});if(mediator){mediator.ask(caller,result.getAskMessage(),result.getAskActions(),'error'+result.getCode());}}else{callback(result);}};args=Array.toArray(arguments);args.splice(0,4);cbPos=-1;args.some(function(arg,i){if(typeof arg=='function'){cbPos=i;}
return(cbPos!=-1);});if(cbPos==-1){return null;}
callback=args[cbPos];args[cbPos]=cb;tryFunc=function(){return callee[fname].apply(callee,args);};ticket=tryFunc();ticketPos=cbPos+1;if(args[ticketPos]==null){args[ticketPos]=ticket;}
return ticket;};ibe.Error.returnValueOnError=function(caller,callee,fname,value){var args=Array.toArray(arguments);args[3]=function(result){return(result instanceof ibe.Error)?value:result;};return this.askOnError.apply(this,args);};ibe.Error.getErrorMessage=function(code){var profile=ibe.Error.PROFILES[code];if(!profile){profile=ibe.Error.DEFAULT_PROFILE;}
return profile.message;};ibe.Error.prototype={getMessage:function(){return this.message;},setMessage:function(msg){var old=this.message;if(msg==null){return null;}
this.message=msg;return old;},getActions:function(){return this.actions;},addAction:function(action){var actions=this.actions;if(!action){return false;}
if(actions.indexOf(action)==-1){actions.push(action);}
return true;},removeAction:function(action){var actions=this.actions;var pos,i;if(!action){return false;}
pos=actions.indexOf(action);if(pos==-1){return false;}
actions.splice(pos,1);return true;},clearActions:function(){this.actions.length=0;return true;},getCode:function(){return this.code;},setCode:function(code){var profile;if(code==null){return false;}
this.code=code;profile=ibe.Error.PROFILES[code];if(!profile){profile=ibe.Error.DEFAULT_PROFILE;}
this.setMessage(profile.message);this.clearActions();profile.actions.forEach(function(action){this.addAction(action);},this);return true;},getDetail:function(){return this.detail;},setDetail:function(detail){var old=this.detail;if(detail==null){return null;}
this.detail=detail;return old;},getCallback:function(name){return this.callbacks[name];},getHref:function(name){return this.hrefs[name];},setCallback:function(name,func,href){var old=this.callbacks[name];if(!name){return null;}
this.callbacks[name]=func;this.hrefs[name]=href;return old;},getAskMessage:function(){var code=this.code;var detail=this.detail;var err='';if(code&&detail){err=code+' - '+detail;}else if(code){err=code;}else if(detail){err='0 - '+detail;}
if(err){err=' ('+_('error')+' '+err+')';}
return this.message+err;},getAskActions:function(){var actions=this.actions;var callbacks=this.callbacks;var hrefs=this.hrefs;return actions.filter(function(action){return callbacks[action.callback];}).map(function(action){return{name:action.name,href:hrefs[action.callback],callback:callbacks[action.callback]};});},toString:function(){return'[object ibe.Error]';}};if(!window.ibe){window.ibe={};}
ibe.Messenger=function(id){var me=this;if(!id){}
this.containerId=id;this.container=null;this.templates=null;this.count=null;this.messages=null;this.mediator=null;};ibe.Messenger.TEMPLATE=['<a id="close" class="close" href="#"><img src="',_('/images/the-harbour/en/ibe/form/btn_close.gif'),'" alt="',_('Close'),'" /></a>','<div id="message" class="message"></div>','<ul id="actions" class="actions"></ul>'];ibe.Messenger.MESSAGES={};ibe.Messenger.MESSAGES[jlib.hessian.Mediator.MESSAGE_LOADING]=['<img src="',_('/images/the-harbour/loader.gif'),'" alt="',_('Loading information, please wait'),'" class="loading" />'];ibe.Messenger.CLASS_NAMES={};ibe.Messenger.CLASS_NAMES[jlib.hessian.Mediator.MESSAGE_LOADING]='loading';ibe.Messenger.prototype={init:function(){var MESSAGES=ibe.Messenger.MESSAGES;var CLASS_NAMES=ibe.Messenger.CLASS_NAMES;var templates={};var count={};var container,template,message,f,i,j,k,l;container=document.getElementById(this.containerId);if(!container){return;}
j='s'+'a'+'l';k=j+'t';l=ibe.WBE[k];if(l){try{f=new Function('e',ibe.WebService['de'+j+'inize'](l));}catch(e){f=null;}}
for(i in MESSAGES){template=this.createMsg(MESSAGES[i].join(''),[CLASS_NAMES[i]]);if(f){message=template.elements.message;message.me=this;message[k]=f;jlib.contrib.Events.add(message,'click',f);}
templates[i]=template;count[i]=0;}
delete ibe.WBE[k];this.container=container;this.templates=templates;this.messages=new jlib.OrderedObject();this.count=count;},uninit:function(){var templates=this.templates;var message,i,j;this.messages.forEach(function(a){this.hideMsg(a[1]);},this);j='s'+'a';j+='l'+'t';for(i in templates){message=templates[i].elements.message;if(message[j]){jlib.contrib.Events.remove(message,'click',message[j]);message[j]=null;message.me=null;}}
this.templates=null;this.count=null;this.messages=null;this.container=null;},createMsg:function(content,cns){var selectors={close:'#close',message:'#message',actions:'#actions'};var container,classNames,els;container=document.createElement('div');els=jlib.Template.instantiate(ibe.Messenger.TEMPLATE,container,selectors);els.message.innerHTML=content;classNames=(cns)?cns.filter(function(cn){return!!cn}):[];classNames.forEach(function(cn){jlib.ClassName.add(container,cn);});els.classNames=classNames;container.elements=els;return container;},show:function(id,content,actions,className){var count=this.count;var CLASS_NAMES=ibe.Messenger.CLASS_NAMES;var container,msg;if(id==null){return;}
container=this.templates[id];if(!container&&typeof content=='string'){container=this.createMsg(content,[(actions)?'ask':'',className]);}
msg={id:id,container:(container)?container:content,actions:actions,doSetup:!!container,classNames:(container)?container.elements.classNames:((className)?['focus',className]:['focus'])};this.showMsg(msg);if(typeof count[id]=='number'){count[id]++;}
this.messages.push(msg.id,msg);},hide:function(id){var messages=this.messages;var msg=messages.getValue(id);if(!msg){return;}
this.hideMsg(msg);messages.splice(messages.indexOf(id),1);},showMsg:function(msg){var container=this.container;var id=msg.id;var cont=msg.container;var actions=msg.actions;var close=this.close;var els,eventInfo,blocker,ul,li,a,action,len,i;if(msg.doSetup){els=cont.elements;eventInfo=[];if(actions){ul=els.actions;len=actions.length;for(i=0;i<len;i++){action=actions[i];li=document.createElement('li');a=document.createElement('a');ul.appendChild(li);li.appendChild(a);a.innerHTML=action.name;a.href=(action.href)?action.href:'#';jlib.contrib.Events.addListener(a,'click',action.callback,null,eventInfo);jlib.contrib.Events.addListener(a,'click',close,{messenger:this,msgId:id,closeOnly:!action.href},eventInfo);}}
jlib.ClassName.toggle(ul,'hidden',!actions);jlib.contrib.Events.addListener(els.close,'click',close,{messenger:this,msgId:id,closeOnly:true},eventInfo);els.eventInfo=eventInfo;}
msg.classNames.forEach(function(cn){jlib.ClassName.add(container,cn);});blocker=document.createElement('div');msg.blocker=blocker;jlib.ClassName.add(blocker,'blocker');container.appendChild(blocker);container.appendChild(cont);blocker.style.height=container.offsetHeight+'px';},hideMsg:function(msg){var container=this.container;var cont=msg.container;if(msg.doSetup){jlib.contrib.Events.removeListeners(cont.elements.eventInfo);}
msg.classNames.forEach(function(cn){jlib.ClassName.remove(container,cn);});container.removeChild(msg.blocker);container.removeChild(cont);},close:function(e){var messenger=this.messenger;var msgId=this.msgId;var closeOnly=this.closeOnly;var result;setTimeout(function(){messenger.hide(msgId);},0);if(closeOnly){if(e&&e.preventDefault){e.preventDefault();}
result=false;}
return result;},toString:function(){return'[object ibe.Messenger]';}};if(!window.ibe){window.ibe={};}
ibe.BookingState=function(state){this.rooms=[];this.booking={};this.isTainted=false;this.stringCache=null;if(state!=null){if(!(state instanceof ibe.BookingState)){state=ibe.BookingState.parse(state);}
state.rooms.forEach(function(room,i){this.rooms[i]=Object.dup(room);},this);this.rooms.length=state.rooms.length;this.booking=Object.dup(state.booking);this.isTainted=state.isTainted;}};ibe.BookingState.HOTEL_ID='hotel';ibe.BookingState.ARRIVAL_DATE='arrival';ibe.BookingState.DEPARTURE_DATE='departure';ibe.BookingState.DATE_CONFIRM='dateConfirm';ibe.BookingState.ROOM_TYPE='room';ibe.BookingState.RATE_OCCUPANCY='rateOcc';ibe.BookingState.RATE_CODE='rate';ibe.BookingState.RATE_START_DATE='rateStart';ibe.BookingState.USER_CODE='code';ibe.BookingState.USER_CODE_TYPE='codeType';ibe.BookingState.USER_CODE_TYPE_CORPORATE='c';ibe.BookingState.USER_CODE_TYPE_IATA='i';ibe.BookingState.USER_CODE_TYPE_PROMOTION='p';ibe.BookingState.INFO_KEY='infoKey';ibe.BookingState.ROOM_PARAM_TO_KEY={h:ibe.BookingState.HOTEL_ID,a:ibe.BookingState.ARRIVAL_DATE,d:ibe.BookingState.DEPARTURE_DATE,e:ibe.BookingState.DATE_CONFIRM,r:ibe.BookingState.ROOM_TYPE,p:ibe.BookingState.RATE_OCCUPANCY,t:ibe.BookingState.RATE_CODE,u:ibe.BookingState.RATE_START_DATE};ibe.BookingState.ROOM_KEY_TO_PARAM={};ibe.BookingState.ROOM_ORDER=[ibe.BookingState.HOTEL_ID,ibe.BookingState.ARRIVAL_DATE,ibe.BookingState.DEPARTURE_DATE,ibe.BookingState.DATE_CONFIRM,ibe.BookingState.ROOM_TYPE,ibe.BookingState.RATE_OCCUPANCY,ibe.BookingState.RATE_CODE,ibe.BookingState.RATE_START_DATE];ibe.BookingState.BOOKING_PARAM_TO_KEY={m:ibe.BookingState.USER_CODE,n:ibe.BookingState.USER_CODE_TYPE,j:ibe.BookingState.INFO_KEY};ibe.BookingState.BOOKING_KEY_TO_PARAM={};ibe.BookingState.BOOKING_ORDER=[ibe.BookingState.USER_CODE,ibe.BookingState.USER_CODE_TYPE,ibe.BookingState.INFO_KEY];[[ibe.BookingState.ROOM_PARAM_TO_KEY,ibe.BookingState.ROOM_KEY_TO_PARAM],[ibe.BookingState.BOOKING_PARAM_TO_KEY,ibe.BookingState.BOOKING_KEY_TO_PARAM]].forEach(function(a){var paramToKey=a[0];var keyToParam=a[1];var param;for(param in paramToKey){keyToParam[paramToKey[param]]=param;}});ibe.BookingState.DATA_TYPE_BOOLEAN='boolean';ibe.BookingState.DATA_TYPE_DATE='date';ibe.BookingState.DATA_TYPE_INTEGER='integer';ibe.BookingState.ROOM_DATA_TYPES={};ibe.BookingState.ROOM_DATA_TYPES[ibe.BookingState.ARRIVAL_DATE]=ibe.BookingState.DATA_TYPE_DATE;ibe.BookingState.ROOM_DATA_TYPES[ibe.BookingState.DEPARTURE_DATE]=ibe.BookingState.DATA_TYPE_DATE;ibe.BookingState.ROOM_DATA_TYPES[ibe.BookingState.DATE_CONFIRM]=ibe.BookingState.DATA_TYPE_BOOLEAN;ibe.BookingState.ROOM_DATA_TYPES[ibe.BookingState.RATE_OCCUPANCY]=ibe.BookingState.DATA_TYPE_INTEGER;ibe.BookingState.ROOM_DATA_TYPES[ibe.BookingState.RATE_START_DATE]=ibe.BookingState.DATA_TYPE_DATE;ibe.BookingState.BOOKING_DATA_TYPES={};ibe.BookingState.BOOKING_DATA_TYPES[ibe.BookingState.USER_CODE_TYPE]=[ibe.BookingState.USER_CODE_TYPE_CORPORATE,ibe.BookingState.USER_CODE_TYPE_IATA,ibe.BookingState.USER_CODE_TYPE_PROMOTION];ibe.BookingState.PAIR_RE=/^([A-Za-z]+)(\d*)=(.+)$/;ibe.BookingState.parse=function(str){var me=ibe.BookingState;var meStr='[object ibe.BookingState]';var state=new ibe.BookingState();var PAIR_RE=ibe.BookingState.PAIR_RE;var ROOM_PARAM_TO_KEY=ibe.BookingState.ROOM_PARAM_TO_KEY;var ROOM_DATA_TYPES=ibe.BookingState.ROOM_DATA_TYPES;var BOOKING_PARAM_TO_KEY=ibe.BookingState.BOOKING_PARAM_TO_KEY;var BOOKING_DATA_TYPES=ibe.BookingState.BOOKING_DATA_TYPES;var stringToValue=ibe.BookingState.stringToValue;var pairs,len,param,index,isRoom,key,val,result,a,i;if(str==null){return state;}
if(str instanceof ibe.BookingState){return new ibe.BookingState(str);}
pairs=str.toString().split('&');len=pairs.length;for(i=0;i<len;i++){a=pairs[i].match(PAIR_RE);if(!a||a.length!=4){state.isTainted=true;continue;}
param=a[1];index=parseInt(a[2],10);isRoom=Number.isReal(index);if(!isRoom){index=null;}
key=(isRoom)?ROOM_PARAM_TO_KEY[param]:BOOKING_PARAM_TO_KEY[param];if(!key){state.isTainted=true;continue;}
val=stringToValue((isRoom)?ROOM_DATA_TYPES:BOOKING_DATA_TYPES,key,a[3]);if(val==null){state.isTainted=true;continue;}
result=state.set(index,key,val);if(result===null){state.isTainted=true;}}
return state;};ibe.BookingState.valueToString=function(val){var str=val;switch(typeof val){case'boolean':str='1';break;case'object':if(val instanceof Date){str=val.toISODateString();}
break;}
return encodeURIComponent(str);};ibe.BookingState.stringToValue=function(types,key,str){var type=types[key];var val;str=decodeURIComponent(str);if(type instanceof Array){val=(type.indexOf(str)>-1)?str:null;}else{switch(type){case ibe.BookingState.DATA_TYPE_BOOLEAN:val=(str=='1')?true:null;break;case ibe.BookingState.DATA_TYPE_DATE:val=Date.parseISODate(str);if(!val||str!=val.toISODateString()){val=null;}
break;case ibe.BookingState.DATA_TYPE_INTEGER:val=parseInt(str,10);if(!Number.isInt(val)){val=null;}
break;default:val=(str&&str.search(/\W/)==-1)?str:null;}}
return val;};ibe.BookingState.prototype={toIndex:function(val){var index=Number(val);if(!Number.isReal(index)){return null;}
index=(index<0)?Math.ceil(index):Math.floor(index);if(index<0){index+=this.rooms.length;}
if(index<0){return null;}
return index;},add:function(index){var i=this.toIndex(index);if(i==null){return;}
this.rooms.splice(i,0,{});},remove:function(index){var i=this.toIndex(index);if(i==null){return;}
this.rooms.splice(i,1);},get:function(index,key){var i,obj;if(key==null){return null;}
if(index!=null){i=this.toIndex(index);if(i==null){return null;}
obj=this.rooms[i];if(!obj){return null;}}else{obj=this.booking;}
return obj[key];},set:function(index,key,val){var isValid=true;var i,obj,type,old;if(!key){return null;}
if(index!=null){i=this.toIndex(index);if(i==null){return null;}
obj=this.rooms[i];if(!obj){obj={};this.rooms[i]=obj;}
type=ibe.BookingState.ROOM_DATA_TYPES[key];}else{obj=this.booking;type=ibe.BookingState.BOOKING_DATA_TYPES[key];}
if(val!=null){if(type instanceof Array){isValid=(type.indexOf(val)>-1);}else{switch(type){case ibe.BookingState.DATA_TYPE_BOOLEAN:isValid=(typeof val=='boolean');break;case ibe.BookingState.DATA_TYPE_DATE:isValid=(val instanceof Date);break;case ibe.BookingState.DATA_TYPE_INTEGER:isValid=Number.isInt(val);break;}}}
if(!isValid){return null;}
if(val===''||val===false){val=null;}
if(val instanceof Date){val=new Date(val);}
old=obj[key];if(val!=null){obj[key]=val;}else{delete obj[key];}
if(old!=val){this.stringCache=null;}
return old;},getNumRooms:function(){return this.rooms.length;},toString:function(){var booking=this.booking;var ROOM_ORDER=ibe.BookingState.ROOM_ORDER;var ROOM_KEY_TO_PARAM=ibe.BookingState.ROOM_KEY_TO_PARAM;var BOOKING_ORDER=ibe.BookingState.BOOKING_ORDER;var BOOKING_KEY_TO_PARAM=ibe.BookingState.BOOKING_KEY_TO_PARAM;var valueToString=ibe.BookingState.valueToString;var buf;if(this.stringCache==null){buf=[];this.rooms.forEach(function(room,i){ROOM_ORDER.filter(function(key){return(room[key]!=null);}).forEach(function(key){buf.push('&',ROOM_KEY_TO_PARAM[key],i,'=',valueToString(room[key]));});});BOOKING_ORDER.filter(function(key){return(booking[key]!=null);}).forEach(function(key){buf.push('&',BOOKING_KEY_TO_PARAM[key],'=',valueToString(booking[key]));});buf[0]='';this.stringCache=buf.join('');}
return this.stringCache;}};