var expe={ sf:{ m:{} , v:{} , c:{} , initialize:function(){ this.parseQueryString(); document.write(expe.html.styleSheet(this.styleSheet)); document.write(expe.html.div('ExpeSf','ExpeSf',expe.html.div('ExpeSf_View','','') + '')); this.start(); } , start:function(){ if(document.getElementById('ExpeSf_View') && document.getElementById('ExpeSf_Data')){ this.m = expe.sf.model.create(); this.m.setProductList(this.queryList['product']); this.m.setProductType(this.queryList['default']); this.m.setCJData(this.queryList['aid'],this.queryList['pid'],this.queryList['sid']); this.m.setExpeData(this.queryList['tpid'],this.queryList['eapid']); this.m.setPopup(this.queryList['popup']); this.m.setTarget(this.queryList['target']); this.v = expe.sf.view.create(this.m); this.v.addSub(expe.sf.baseView.create(this.m)); this.c = expe.sf.controller.create(this.m,this.v); this.c.initialize(document.getElementById('ExpeSf_Data'),document.getElementById('ExpeSf_View')); } else{ setTimeout('expe.sf.start();',100); } } , parseQueryString:function(){ var list = this.queryString.split('&'); for(var pair in list){ var param = list[pair].split('='); this.queryList[param[0]] = param[1]; } } , queryList:{} , queryString:'' , styleSheet:'' } }; //***** Utility ***** expe.html = {} expe.html.styleSheet = function(_styleSheet){ return ''; }; expe.html.div = function(_id,_class,_html){ return '
' + _html + '
'; }; expe.html.label = function(_id,_class,_label){ _class = (_class) ? ' class="' + _class + '"' : ''; return ''; }; expe.html.radio = function(_id,_name,_value,_class,_label,_checked){ _checked = (_checked) ? ' checked="checked"' : ''; _class = (_class) ? ' class="' + _class + '"' : ''; return '' + expe.html.label(_id,_class,_label); }; expe.html.textbox = function(_id,_name,_value,_class,_label){ _label = (_label) ? expe.html.label(_id,_class,_label) : ''; _class = (_class) ? ' class="Text ' + _class + '"' : 'Text'; return _label + ''; };expe.sf.model = {}; expe.sf.model.create = function(){ var model = { productType:'' , bundleType:null , destination:'' , origin:'' , startDate:'' , endDate:'' , startTime:'' , endTime:'' , cruiseDate:'' , cruiseDestination:null , adults:null , seniors:null , kids:null , aid:'' , pid:'' , sid:'' , eapid:'' , tpid:'' , target:'' , loadData:function(_container){ if(_container){ var data = eval(_container.value); for(var property in data){ this[property] = data[property]; } } } , saveData:function(_container){ _container.value = this.getJson(); } , getDate:function(){ var date = new Date(); return (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear(); } , getJson:function(){ var json = []; for(var property in this){ if(typeof(this[property]) != 'object' && typeof(this[property]) != 'function'){ json[json.length] = property + ':"' + this[property] + '"'; } } return '({' + json.join(',') + '})'; } , getLabelOf:function(_property){ return (this.productType == 'bundles' && this.getBundle(this.bundleType).labelList && this.getBundle(this.bundleType).labelList[_property]) ? this.getBundle(this.bundleType).labelList[_property] : (this.getProduct(this.productType).labelList && this.getProduct(this.productType).labelList[_property]) ? this.getProduct(this.productType).labelList[_property] : this.labelList[_property] ? this.labelList[_property] : ''; } , getValueOf:function(_property){ return (this.getRawValueOf(_property)) ? this.getRawValueOf(_property) : (this.productType == 'bundles' && this.getBundle(this.bundleType).valueList && this.getBundle(this.bundleType).valueList[_property]) ? this.getBundle(this.bundleType).valueList[_property] : (this.getProduct(this.productType).valueList && this.getProduct(this.productType).valueList[_property]) ? this.getProduct(this.productType).valueList[_property] : (this.valueList[_property] != null) ? this.valueList[_property] : (this.getLabelOf(_property)) ? this.getLabelOf(_property).toString().replace(':','') : ''; } , getRawValueOf:function(_property){ return (this[_property]) ? this[_property] : ''; } , getProduct:function(_type){ return this.productList[_type]; } , getBundle:function(_type){ return this.bundleList[_type]; } , getTimeList:function(){ var list = []; if(this.productType == 'cars'){ for(var i = 0; i < this.timeList.length; i ++){ if(this.timeList[i].text.indexOf(' AM') > 0|| this.timeList[i].text.indexOf(' PM') > 0){ list[list.length] = this.timeList[i]; } } } else{ list = this.timeList; } return list; } , getProductList:function(){ var list = {}; for(var p in this.productList){ if(this.productList[p].bit & this.productSum){ list[p] = this.productList[p]; } } return list; } , getBundleList:function(){ return this.bundleList; } , getDestinationList:function(){ return this.destinationList; } , getMonthList:function(){ return this.monthList; } , getMaxAdults:function(){ return 6; } , getMaxKids:function(){ return 6; } , getMaxSeniors:function(){ return 6; } , getMaxCruiseMonths:function(){ return 18; } , getUrl:function(){ var u = []; var origin = this.origin.substring(0,100); var destination = this.destination.substring(0,100); if(this.aid && this.pid){ u[u.length] = 'http://www.anrdoezrs.net/click-' + this.pid + '-' + this.aid + '?'; if(this.sid){ u[u.length] = 'sid=' + this.sid + '&'; } } else{ u[u.length] = 'http://www.expedia.com/pubspec/scripts/eap.asp?'; if(this.tpid && this.eapid){ u[u.length] = 'eapid=' + this.eapid + '-' + this.tpid + '&'; } } switch(this.productType){ case 'flights': u[u.length] = 'goto=EXPFLTWIZ' + '&FrAirport=' + origin + '&ToAirport=' + destination + '&FromDate=' + this.startDate + '&ToDate=' + this.endDate; u[u.length] = '&NumAdult=' + this.getValueOf('adults') + '&NumChild=' + this.getValueOf('kids') + '&NumSenior=' + this.getValueOf('seniors'); break; case 'hotels': u[u.length] = 'goto=HOTSEARCH' + '&CityName=' + destination + '&InDate=' + this.startDate + '&OutDate=' + this.endDate; u[u.length] = '&NumAdult=' + this.getValueOf('adults') + '&NumChild=' + this.getValueOf('kids'); break; case 'cars': u[u.length] = 'goto=CARSEARCH' + '&PickUpLoc=' + origin + '&DropLoc=' + destination + '&FromDate=' + this.startDate + '&ToDate=' + this.endDate; u[u.length] = '&PickUpTime=' + this.startTime + '&DropTime=' + this.endTime; break; case 'cruises': u[u.length] = 'goto=CRUISESEARCH' + '&Destination=' + this.cruiseDestination + '&FromDate=' + this.cruiseDate; break; case 'bundles': if(this.bundleType == 5){ u[u.length] = 'goto=EXPFLTWIZ' + '&FrAirport=' + origin + '&ToAirport=' + destination + '&BundType=5'; } else{ u[u.length] = 'goto=PACKAGEWIZ' + '&FrAirport=' + origin + '&DestName=' + destination + '&FromDate=' + this.startDate + '&ToDate=' + this.endDate + '&packageType=' + this.bundleType; } u[u.length] = '&FromDate=' + this.startDate + '&ToDate=' + this.endDate + '&FromTime=' + this.startTime + '&ToTime=' + this.endTime; u[u.length] = '&NumAdult=' + this.getValueOf('adults') + '&NumChild=' + this.getValueOf('kids') + '&NumSenior=' + this.getValueOf('seniors'); break; case 'activities': u[u.length] = 'goto=TSHOPSSEARCH' + '&LocationName=' + destination + '&StartDate=' + this.startDate + '&EndDate=' + this.endDate; break; } return u.join(''); } , setProductList:function(_productSum){ this.productSum = (_productSum >= 1 && _productSum <= 63) ? _productSum : 63; for(var product in this.productList){ if(!this.productType && (this.productList[product].bit & this.productSum)){ this.productType = product; } } } , setProductType:function(_productBit){ if((_productBit >= 1 && _productBit <= 63) && !((_productBit - 1) & _productBit)){ for(var product in this.productList){ if(this.productList[product].bit & _productBit & this.productSum){ this.productType = product; } } } } , setCJData:function(_aid,_pid,_sid){ this.aid = (_aid) ? _aid : ''; this.pid = (_pid) ? _pid : ''; this.sid = (_sid) ? _sid : ''; } , setExpeData:function(_tpid,_eapid){ this.tpid = (_tpid) ? _tpid : ''; this.eapid = (_eapid) ? _tpid : ''; } , setPopup:function(_popup){ this.target = (_popup) ? "popup" : ''; } , setTarget:function(_target){ this.target = (_target) ? (_target) : this.target; } , bundleList:{ 2:{id:2,name:'Flight + Hotel'} , 5:{id:5,name:'Flight + Car',valueList:{adults:1}} , 1:{id:1,name:'Flight + Hotel + Car'} , 3:{ id:3,name:'Hotel + Car' , valueList:{adults:1} , labelList:{destination:'What city?',startDate:'Check-in:',endDate:'Check-out:'} , time:[ {value:'362',text:'Any'} , {value:'12AM',text:'12 AM'},{value:'1AM',text:'1 AM'},{value:'2AM',text:'2 AM'},{value:'3AM',text:'3 AM'},{value:'4AM',text:'4 AM'},{value:'5AM',text:'5 AM'},{value:'6AM',text:'6 AM'},{value:'7AM',text:'7 AM'},{value:'8AM',text:'8 AM'},{value:'9AM',text:'9 AM'},{value:'10AM',text:'10 AM'},{value:'11AM',text:'11 AM'},{value:'12AM',text:'12 AM'} , {value:'12PM',text:'12 PM'},{value:'1PM',text:'1 PM'},{value:'2PM',text:'2 PM'},{value:'3PM',text:'3 PM'},{value:'4PM',text:'4 PM'},{value:'5PM',text:'5 PM'},{value:'6PM',text:'6 PM'},{value:'7PM',text:'7 PM'},{value:'8PM',text:'8 PM'},{value:'9PM',text:'9 PM'},{value:'10PM',text:'10 PM'},{value:'11PM',text:'11 PM'},{value:'12PM',text:'12 PM'} , {value:'361',text:'Morn.'},{value:'721',text:'Noon'},{value:'1081',text:'Eve.'} ] } } , productList:{ bundles:{bit:1,name:'Package'} , flights:{ bit:2,name:'Flight' , valueList:{adults:1} , labelList:{origin:'Leaving from:',destination:'Going to:',startDate:'Departing:',endDate:'Returning:'} } , hotels:{ bit:4,name:'Hotel' , labelList:{destination:'What city?',startDate:'Check-in:',endDate:'Check-out:'} } , cars:{ bit:8,name:'Car' , labelList:{origin:'What airport or city?',destination:'Drop off airport or city:',startDate:'Pick-up:',endDate:'Drop-off:'} , time:[ {value:'12AM',text:'12 AM'},{value:'1AM',text:'1 AM'},{value:'2AM',text:'2 AM'},{value:'3AM',text:'3 AM'},{value:'4AM',text:'4 AM'},{value:'5AM',text:'5 AM'},{value:'6AM',text:'6 AM'},{value:'7AM',text:'7 AM'},{value:'8AM',text:'8 AM'},{value:'9AM',text:'9 AM'},{value:'10AM',text:'10 AM'},{value:'11AM',text:'11 AM'},{value:'12AM',text:'12 AM'} , {value:'12PM',text:'12 PM'},{value:'1PM',text:'1 PM'},{value:'2PM',text:'2 PM'},{value:'3PM',text:'3 PM'},{value:'4PM',text:'4 PM'},{value:'5PM',text:'5 PM'},{value:'6PM',text:'6 PM'},{value:'7PM',text:'7 PM'},{value:'8PM',text:'8 PM'},{value:'9PM',text:'9 PM'},{value:'10PM',text:'10 PM'},{value:'11PM',text:'11 PM'},{value:'12PM',text:'12 PM'} ] } , cruises:{ bit:16,name:'Cruise' , labelList:{destination:'Top destinations:',startDate:'Departure month:'} } , activities:{bit:32,name:'Activities', labelList:{destination:'What city?',startDate:'From:',endDate:'To:'} } } , labelList:{ origin:'Leaving from:' , destination:'Going to:' , startDate:'Departing:' , endDate:'Returning:' , startTime:'Time:' , endTime:'Time:' , adults:'Adults:' , kids:'Kids:' , seniors:'Seniors:' , bundleType:'Package Type:' , bundlePromo:'Book together and save!' } , valueList:{ startDate:'mm/dd/yy' , endDate:'mm/dd/yy' , startTime:'11AM' , endTime:'11AM' , adults:2 , kids:0 , seniors:0 } , timeList:[ {value:'362',text:'Any'} , {value:'12AM',text:'12 AM'},{value:'1AM',text:'1 AM'},{value:'2AM',text:'2 AM'},{value:'3AM',text:'3 AM'},{value:'4AM',text:'4 AM'},{value:'5AM',text:'5 AM'},{value:'6AM',text:'6 AM'},{value:'7AM',text:'7 AM'},{value:'8AM',text:'8 AM'},{value:'9AM',text:'9 AM'},{value:'10AM',text:'10 AM'},{value:'11AM',text:'11 AM'},{value:'12AM',text:'12 AM'} , {value:'12PM',text:'12 PM'},{value:'1PM',text:'1 PM'},{value:'2PM',text:'2 PM'},{value:'3PM',text:'3 PM'},{value:'4PM',text:'4 PM'},{value:'5PM',text:'5 PM'},{value:'6PM',text:'6 PM'},{value:'7PM',text:'7 PM'},{value:'8PM',text:'8 PM'},{value:'9PM',text:'9 PM'},{value:'10PM',text:'10 PM'},{value:'11PM',text:'11 PM'},{value:'12PM',text:'12 PM'} , {value:'361',text:'Morn.'},{value:'721',text:'Noon'},{value:'1081',text:'Eve.'} ] , destinationList:[ {id:6023184,name:'Africa'} , {id:203,name:'Alaska'} , {id:6050677,name:'Asia'} , {id:13,name:'Bahamas'} , {id:20,name:'Bermuda'} , {id:6023742,name:'Canada - New England'} , {id:6022969,name:'Caribbean'} , {id:6023743,name:'Caribbean - Eastern'} , {id:6023744,name:'Caribbean - Southern'} , {id:6023745,name:'Caribbean - Western'} , {id:6022967,name:'Europe'} , {id:213,name:'Hawaii'} , {id:3023183,name:'Mediterranean'} , {id:6023750,name:'Mediterranean - Eastern'} , {id:6023751,name:'Mediterranean - Western'} , {id:6050655,name:'Mexico'} , {id:6049796,name:'Northern Europe'} , {id:-2,name:'Nowhere (no port stops)'} , {id:6023753,name:'Panama Canal'} , {id:6050676,name:'South America'} , {id:6023738,name:'South Pacific'} , {id:-3,name:'Transatlantic'} , {id:-4,name:'Transpacific'} , {id:6050649,name:'United States & Canada'} , {id:6023746,name:'US Pacific Coast'} , {id:-5,name:'World'} ] , monthList:[ 'January' , 'February' , 'March' , 'April' , 'May' , 'June' , 'July' , 'August' , 'September' , 'October' , 'November' , 'December' ] }; model.bundleType = 2; model.cruiseDate = model.getDate(); model.cruiseDestination = 6022969; return model; };expe.sf.view = {}; expe.sf.view.create = function(_model){ return { m:_model , container:null , subList:[] , render:function(_container){ this.container = null; if(_container){ this.container = _container; this.renderThis(); this.renderSub(); } } , renderThis:function(){ if(!this.container.innerHTML){ this.container.innerHTML = this.getSub(); } } , renderSub:function(){ for(var i = 0; i < this.subList.length; i++){ this.subList[i].render(document.getElementById(this.container.id + '_' + i)); } } , addSub:function(_view){ this.subList[this.subList.length] = _view; } , clear:function(_view){ this.container.innerHTML = ''; this.container.className = 'Empty'; } , getSub:function(){ var s = []; for(var i = 0; i < this.subList.length; i++){ s[s.length] = expe.html.div(this.container.id + '_' + i,'Empty',''); } return s.join(''); } , getSubmit:function(){ return ''; } , getImpression:function(){ return (this.m.pid && this.m.aid) ? '' : ''; } , getOrigin:function(_labelSum){ var label = (_labelSum & 1) ? this.m.getLabelOf('origin') : ''; var value = (_labelSum & 2) ? this.m.getValueOf('origin') : this.m.getRawValueOf('origin'); var css = (_labelSum & 2) ? 'Origin Location InlineLabel' : 'Origin Location'; var empty = (this.m.origin) ? '' : ' Empty'; return expe.html.div('','origin',expe.html.textbox('ExpeSf_origin','origin',value,css + empty,label)); } , getDestination:function(_labelSum){ var label = (_labelSum & 1) ? this.m.getLabelOf('destination') : ''; var value = (_labelSum & 2) ? this.m.getValueOf('destination') : this.m.getRawValueOf('destination'); var css = (_labelSum & 2) ? 'Destination Location InlineLabel' : 'Destination Location'; var empty = (this.m.destination) ? '' : ' Empty'; return expe.html.div('','destination',expe.html.textbox('ExpeSf_destination','destination',value,css + empty,label)); } , getStartDate:function(){ var empty = (this.m.startDate) ? '' : ' Empty'; var s = expe.html.textbox('ExpeSf_startDate','startDate',this.m.getValueOf('startDate'),'Start Date InlineLabel' + empty,this.m.getLabelOf('startDate')); return expe.html.div('','startDate',s); } , getEndDate:function(){ var empty = (this.m.endDate) ? '' : ' Empty'; var s = expe.html.textbox('ExpeSf_endDate','endDate',this.m.getValueOf('endDate'),'End Date InlineLabel' + empty,this.m.getLabelOf('endDate')); return expe.html.div('','endDate',s); } , getAdults:function(){ var s = []; s[s.length] = expe.html.label('ExpeSf_adults','Adults',this.m.getLabelOf('adults')); s[s.length] = '"; return expe.html.div('','adults',s.join('')); } , getKids:function(){ var s = []; s[s.length] = expe.html.label('ExpeSf_kids','Kids',this.m.getLabelOf('kids')); s[s.length] = '"; return expe.html.div('','kids',s.join('')); } , getSeniors:function(){ var s = []; s[s.length] = expe.html.label('ExpeSf_seniors','Seniors',this.m.getLabelOf('seniors')); s[s.length] = '"; return expe.html.div('','seniors',s.join('')); } , getBundleList:function(){ var list = this.m.getBundleList(); var s = [expe.html.label('ExpeSf_bundleType','BundleType',this.m.getLabelOf('bundleType'))]; s[s.length] = '"; return expe.html.div('','bundle',s.join('')); } , getDestinationList:function(){ var list = this.m.getDestinationList(); var s = [expe.html.label('ExpeSf_cruiseDestination','destination',this.m.getLabelOf('destination'))]; s[s.length] = '"; return expe.html.div('','destination',s.join('')); } , getMonthList:function(){ var date = new Date(); var month = date.getMonth(); var year = date.getFullYear(); var list = this.m.getMonthList(); var s = [expe.html.label('ExpeSf_cruiseDate','month',this.m.getLabelOf('startDate'))]; s[s.length] = '"; return expe.html.div('','month',s.join('')); } , getStartTimeList:function(){ var s = [expe.html.label('','startTime',this.m.getLabelOf('startTime'))]; s[s.length] = '"; return expe.html.div('',"startTime",s.join('')); } , getEndTimeList:function(){ var s = [expe.html.label('','endTime',this.m.getLabelOf('endTime'))]; s[s.length] = '"; return expe.html.div('',"endTime",s.join('')); } , setFocus:function(_element){ if(!this.m[_element.name]){ _element.value = ''; _element.className = _element.className.replace(' Empty',''); } } , setBlur:function(_element){ if(!_element.value && _element.className.indexOf('InlineLabel') > -1){ _element.value = this.m.getValueOf(_element.name); _element.className += ' Empty'; } } }; }; expe.sf.baseView = {} expe.sf.baseView.create = function(_model){ var v = expe.sf.view.create(_model); v.addSub(expe.sf.productView.create(v.m)); v.addSub(expe.sf.bundleView.create(v.m)); v.addSub(expe.sf.flightView.create(v.m)); v.addSub(expe.sf.hotelView.create(v.m)); v.addSub(expe.sf.carView.create(v.m)); v.addSub(expe.sf.cruiseView.create(v.m)); v.addSub(expe.sf.activityView.create(v.m)); v.renderThis = function(){ var s = []; if(!this.container.innerHTML){ s[s.length] = expe.html.div('','headerContainer',expe.html.div('','headerLeft',expe.html.div('','headerRight',expe.html.div('','headerCenter1',expe.html.div('','headerCenter2',''))))); s[s.length] = expe.html.div('','bodyContainer1',expe.html.div('','bodyContainer2',expe.html.div('','bodyContainer3',expe.html.div('','bodyContainer4',this.getSub())))); s[s.length] = expe.html.div('','bottomContainer',this.getImpression()); this.container.innerHTML = s.join(''); this.container.className = 'baseView'; } }; return v; };expe.sf.productView = {}; expe.sf.productView.create = function(_model){ var v = expe.sf.view.create(_model); v.renderThis = function(){ if(!this.container.innerHTML){ var s = []; var productList = this.m.getProductList(); for(var i in productList){ s[s.length] = expe.html.radio(i,'product',i,'product',productList[i].name,false); } this.container.innerHTML = s.join(''); this.container.className = 'ProductView'; setTimeout('document.getElementById("' + this.m.productType + '").click();',100); } }; return v; }; expe.sf.bundleView = {}; expe.sf.bundleView.create = function(_model){ var v = expe.sf.view.create(_model); v.renderThis = function(){ if(this.m.productType != 'bundles'){ this.clear(); } else if(!this.container.innerHTML){ var s = []; s[s.length] = expe.html.div('','row nolabel',this.getOrigin(2) + this.getDestination(2)); s[s.length] = expe.html.div('','row label',this.getStartDate() + this.getEndDate()); s[s.length] = expe.html.div('','row submit',this.getAdults() + this.getKids() + this.getSeniors() + this.getSubmit()); this.container.innerHTML = s.join(''); this.container.className = 'BundleView ContentContainer'; } }; return v; }; expe.sf.flightView = {}; expe.sf.flightView.create = function(_model){ var v = expe.sf.view.create(_model); v.renderThis = function(){ if(this.m.productType != 'flights'){ this.clear(); } else if(!this.container.innerHTML){ var s = []; s[s.length] = expe.html.div('','row nolabel',this.getOrigin(2) + this.getDestination(2)); s[s.length] = expe.html.div('','row label',this.getStartDate() + this.getEndDate()); s[s.length] = expe.html.div('','row submit',this.getAdults() + this.getKids() + this.getSeniors() + this.getSubmit()); this.container.innerHTML = s.join(''); this.container.className = 'FlightView ContentContainer'; } }; return v; }; expe.sf.hotelView = {}; expe.sf.hotelView.create = function(_model){ var v = expe.sf.view.create(_model); v.renderThis = function(){ if(this.m.productType != 'hotels'){ this.clear(); } else if(!this.container.innerHTML){ var s = []; s[s.length] = expe.html.div('','row nolabel',this.getDestination(2)); s[s.length] = expe.html.div('','row label',this.getStartDate() + this.getEndDate()); s[s.length] = expe.html.div('','row submit',this.getAdults() + this.getKids() + this.getSubmit()); this.container.innerHTML = s.join(''); this.container.className = 'HotelView ContentContainer'; } }; return v; }; expe.sf.carView = {}; expe.sf.carView.create = function(_model){ var v = expe.sf.view.create(_model); v.renderThis = function(){ if(this.m.productType != 'cars'){ this.clear(); } else if(!this.container.innerHTML){ var s = []; s[s.length] = expe.html.div('','row nolabel',this.getOrigin(2) + this.getDestination(2)); s[s.length] = expe.html.div('','row label',this.getStartDate() + this.getStartTimeList() + this.getEndDate() + this.getEndTimeList()); s[s.length] = expe.html.div('','row submit',this.getSubmit()); this.container.innerHTML = s.join(''); this.container.className = 'CarView ContentContainer'; } }; return v; }; expe.sf.cruiseView = {}; expe.sf.cruiseView.create = function(_model){ var v = expe.sf.view.create(_model); v.renderThis = function(){ if(this.m.productType != 'cruises'){ this.clear(); } else if(!this.container.innerHTML){ var s = []; s[s.length] = expe.html.div('','row label',this.getDestinationList() + this.getMonthList()); s[s.length] = expe.html.div('','row nolabel',''); s[s.length] = expe.html.div('','row submit',this.getSubmit()); this.container.innerHTML = s.join(''); this.container.className = 'CruiseView ContentContainer'; } }; return v; }; expe.sf.activityView = {}; expe.sf.activityView.create = function(_model){ var v = expe.sf.view.create(_model); v.renderThis = function(){ if(this.m.productType != 'activities'){ this.clear(); } else if(!this.container.innerHTML){ var s = []; s[s.length] = expe.html.div('','row nolabel',this.getDestination(2)); s[s.length] = expe.html.div('','row label',this.getStartDate() + this.getEndDate()); s[s.length] = expe.html.div('','row submit',this.getSubmit()); this.container.innerHTML = s.join(''); this.container.className = 'ActivityView ContentContainer'; } }; return v; };expe.sf.controller = {}; expe.sf.controller.create = function(_model,_view){ return { m:_model , v:_view , dataContainer:null , viewContainer:null , initialize:function(_dataContainer,_viewContainer){ this.dataContainer = _dataContainer; this.viewContainer = _viewContainer; this.m.loadData(this.dataContainer); this.v.render(this.viewContainer); this.bindEvents(); } , bindEvents:function(){ this.viewContainer.onkeydown = expe.sf.c.handleKeydown; var inputs = this.v.container.getElementsByTagName('input'); for(var i = 0; i < inputs.length; i++){ inputs[i].onclick = function(){expe.sf.c.handleClick(this);}; inputs[i].onchange = function(){expe.sf.c.handleChange(this);}; inputs[i].onfocus = function(){expe.sf.c.handleFocus(this);}; inputs[i].onblur = function(){expe.sf.c.handleBlur(this);}; } var selects = this.v.container.getElementsByTagName('select'); for(var i = 0; i < selects.length; i++){ selects[i].onchange = function(){expe.sf.c.handleChange(this);}; } } , handleClick:function(_element){ switch(_element.type){ case 'radio': switch(_element.name){ case 'product': switch(_element.value){ case '1':case '2':case '3':case '5': this.m.productType = 'bundles'; this.m.bundleType = _element.value; break; default: this.m.productType = _element.value; break; } this.m.saveData(this.dataContainer); this.v.render(this.viewContainer); this.bindEvents(); break; } break; case 'image': this.submit(); break; } } , handleChange:function(_element){ switch(_element.type){ case 'text': _element.value = _element.value.replace(/^\s+|\s+$/g,''); switch(_element.name){ case 'origin': case 'destination': case 'startDate': case 'endDate': this.m[_element.name] = _element.value; this.m.saveData(this.dataContainer); break; } break; case 'select-one': switch(_element.name){ case 'adults': case 'kids': case 'seniors': case 'cruiseDestination': case 'cruiseDate': case 'startTime': case 'endTime': this.m[_element.name] = _element.value; this.m.saveData(this.dataContainer); break; case 'bundleType': this.m[_element.name] = _element.value; this.m.saveData(this.dataContainer); this.v.render(this.viewContainer); this.bindEvents(); break; } break; } } , handleBlur:function(_element){ if(_element.type == 'text'){ _element.value = _element.value.replace(/^\s+|\s+$/g,''); this.m[_element.name] = _element.value; this.v.setBlur(_element); } } , handleFocus:function(_element){ if(_element.type == 'text'){ this.v.setFocus(_element); } } , handleKeydown:function(_event){ var key = (_event) ? _event.which : window.event.keyCode; if(key == 13){ s = document.getElementById('ExpeSf_Submit'); s.focus(); s.click(); } } , submit:function(){ this.m.saveData(this.dataContainer); switch(this.m.target){ case "popup": window.open(this.m.getUrl(),"ExpeWindow"); break; case "parent": if(window.parent){ window.parent.document.location = this.m.getUrl(); } else{ document.location = this.m.getUrl(); } break; default: document.location = this.m.getUrl(); break; } } }; }; expe.sf.queryString = 'pid=2784097&aid=10520150&target=popup'; expe.sf.styleSheet = 'http://www.expedia.com/pubspec/scripts/storefront/css/expe.sf.horizontal.360.css'; expe.sf.initialize();