var _TUITRACK={};var dlh_deals;var dlh_hotdeals=Class.create({initialize:function(a){this.instanceName=a;this.container=false;this.update_url="/hotdeals_update.cfm";this.data="";this.modal=false;this.boards_filter="";this.departs_filter="";this.months_filter="";this.nights_filter="7";this.initial_load=true;this.current_offer_id=0},getData:function(){var a=this;new Ajax.Request(this.update_url,{method:"get",parameters:{hotdeals_departs:a.departs_filter,hotdeals_boardbasis:a.boards_filter,hotdeals_nights:a.nights_filter,hotdeals_month:a.months_filter},onSuccess:function(c){var b=c.responseText.evalJSON();a.data=b}})},getDataAndUpdate:function(){var a=this;try{$("dlh_hotdeals_wait").style.display="block"}catch(b){}new Ajax.Request(this.update_url,{method:"get",parameters:{hotdeals_departs:a.departs_filter,hotdeals_boardbasis:a.boards_filter,hotdeals_nights:a.nights_filter,hotdeals_month:a.months_filter},onSuccess:function(g){var d=g.responseText.evalJSON();var c=a.data.optionsData;a.data=d;a.data.optionsData=c;a.update();try{$("dlh_hotdeals_wait").style.display="none"}catch(f){}}})},update:function(){var f=document.getElementById(this.id_Target);var a=2;var q=Math.floor(200/(6-a));while(f.hasChildNodes()){f.removeChild(f.firstChild)}var l=document.createElement("table");l.id=this.id_Target+"_table";l.cellSpacing="0px";l.cellPadding="0px";$(this.id_Target).appendChild(l);var d=l.insertRow(l.rows.length);var h=d.insertCell(0);h.style.width="140px";h.style.height="20px";var e=1;for(var r=a;r<6;r++){starCell=d.insertCell(e);e=e+1;starCell.style.width=q+"px";starCell.className="hd_matrix_star";starCell.innerHTML=r;starImg=document.createElement("img");starImg.src="http://www.directline-holidays.co.uk/images/spacer.gif";starImg.className="sprite_matrix_star";starCell.appendChild(starImg)}var n="";var o=a;var u=0;var t;if(this.data.data.DATA.length>0){for(var r=0;r<this.data.data.DATA.length;r++){if(u<9){var s;var v=this.data.data.DATA[r];for(var p=0;p<this.data.data.DATA[r].length;p++){window[this.data.data.COLUMNS[p]]=v[p]}if(TD_STAR_RATING>a-1){if(RESORT_DISPLAY_NAME!=n){u++;if(u<9){t=l.insertRow(l.rows.length);t.id=RESORT_DISPLAY_NAME+"_holder";o=a;n=RESORT_DISPLAY_NAME;if(u%2){s="#ffffff"}else{s="#f2f2f2"}var g=t.insertCell(0);g.id=RESORT_DISPLAY_NAME+"_holder";g.style.width="140px";g.style.height="20px";g.style.background=s;g.style.paddingLeft="3px";g.style.color="#666666";g.innerHTML=RESORT_DISPLAY_NAME;var e=1;for(var m=a;m<6;m++){var c=t.insertCell(e);e=e+1;c.style.background=s;c.style.width=q+"px";c.style.height="20px";c.style.textAlign="center";price_cell_link=document.createElement("a");price_cell_link.id=RESORT_DISPLAY_NAME+"_"+m+"_price";price_cell_link.style.textDecoration="underline";c.appendChild(price_cell_link)}}}if(u<9){var w=$(RESORT_DISPLAY_NAME+"_"+TD_STAR_RATING+"_price");w.innerHTML="&pound;"+TD_PRICE_SYSTEM;w.style.cursor="pointer";w.alt=ID;w.observe("click",this.clickedOfferPrice.bind(this))}}}}}if(this.initial_load){var b=document.createElement("div");b.className="hd_title";b.appendChild(document.createTextNode("HOT Deals filter"));$(this.id_Target+"_search").appendChild(b);var b=document.createElement("div");b.className="hd_blurb";b.appendChild(document.createTextNode("Click a price or filter"));b.appendChild(document.createElement("br"));b.appendChild(document.createTextNode("to find the best deal."));$(this.id_Target+"_search").appendChild(b);this.addSearchField("departs","Departure Airport");this.addSearchField("boards","Board Basis");this.addSearchField("nights","Duration");this.addSearchField("months","Month");this.initial_load=false}},addSearchField:function(f,a){var b=document.createElement("select");b.id=f+"_select";var e=document.createElement("option");e.value="";e.innerHTML=a;b.appendChild(e);for(var c=0;c<this.data.optionData[f].DATA.length;c++){var d=this.data.optionData[f].DATA[c];e=document.createElement("option");e.value=d[0];e.innerHTML=d[1];if(d[0]==this[f+"_filter"]){e.selected="selected"}b.appendChild(e)}$(this.id_Target+"_search").appendChild(b);$(b.id).observe("change",this.searchFieldChanges.bind(this));$(this.id_Target+"_search").appendChild(document.createElement("br"))},searchFieldChanges:function(b){try{var a=b.target.id.split("_")[0];var d=b.target.options[b.target.selectedIndex].value;try{if(pageTracker!==undefined){pageTracker._trackEvent("TUI Offers","Filter",a+" "+b.target.options[b.target.selectedIndex].text)}}catch(c){}this[a+"_filter"]=d;this.getDataAndUpdate()}catch(c){}},clickedOfferPrice:function(b){this.current_offer_id=b.target.alt;var a=b.target.id.split("_");_TUITRACK.country=a[0];_TUITRACK.stars=a[1];this.modal.tracker={active:true,cat:"TUI Offers",action:"Search",ident:_TUITRACK.country+" "+_TUITRACK.stars+" star"};this.modal.searchfor(b)}});
