var createLMDGrid=function(n){var O=new Element("table");var v=new Element("thead");var B=new Element("tbody");var j=new Element("tr");var I=new Element("td");var H=new Element("th");var k=new Element("input");k.setProperty("type","hidden");var z=new Element("form");z.setProperty("method","POST");z.setProperty("action","https://www.trekam.net/trek/BookingDirect.asp");z.adopt(k.clone().setProperty("name","Currency").setProperty("value",this.currency)).adopt(k.clone().setProperty("name","Offer").setProperty("value","internal"));O.addClass("price-grid");var e=j.clone().addClass("header").addClass("even");e.adopt(H.clone().set("text","Start Date").setProperty("width","14%")).adopt(H.clone().set("text","Tour Name").setProperty("width","14%")).adopt(H.clone().set("text","Days").setProperty("width","14%")).adopt(H.clone().set("text","Departs").setProperty("width","14%")).adopt(H.clone().set("text","Save").setProperty("width","14%")).adopt(H.clone().set("text","Price\n"+this.currencyPrefix).setProperty("width","14%")).adopt(H.clone().set("text","Ref #").setProperty("width","14%"));v.adopt(e);var c=n.getElementsByTagName("Trip");var g=true;var l="";var K="";var A="";var G="";var D=function(s){$(this.getProperty("formId")).submit()};var o=new Element("input");o.setProperty("type","button").setProperty("value","Book");for(i=0;i<c.length;i++){var J=getElementTextValue(c[i].getElementsByTagName("RecID")[0]);var N=getElementTextValue(c[i].getElementsByTagName("Ref")[0]);var h=getElementTextValue(c[i].getElementsByTagName("Depart")[0]);var d=getElementTextValue(c[i].getElementsByTagName("Name")[0]);var b=getElementTextValue(c[i].getElementsByTagName("AvailabilityReal")[0]);var a=c[i].getElementsByTagName("Cost");var E=c[i].getElementsByTagName("Closed")[0];var C=(E.childNodes.length>0)?E.firstChild.nodeValue:"N";var r=getElementTextValue(c[i].getElementsByTagName("Options")[0]);var f=getElementTextValue(c[i].getElementsByTagName("Availability")[0]);var u=c[i].getElementsByTagName("Offer")[0];var x=c[i].getElementsByTagName("Offer_Percent")[0];if(u.childNodes.length>0){u=u.firstChild.nodeValue}else{u=""}if(x.childNodes.length>0){x=x.firstChild.nodeValue}else{x=""}if((!this.offers_only)||(this.offers_only&&(u>""))){var m=j.clone();if(!g){m.addClass("alt")}g=!g;var w=N.match(/^[A-Z]\w[A-Z]?/);m.setAttribute("tour",w);for(ii=0;ii<a.length;ii++){if(a[ii].getElementsByTagName("Currency")[0].firstChild.nodeValue==this.currency){var K=this.currencyPrefix+getElementTextValue(a[ii].getElementsByTagName("Value")[0])}}var M=o.clone().setProperty("formId","booking-form-"+J);M.addEvent("click",D);b=parseInt(b);var y=I.clone();if(u>""){y.addClass("redtxt");K="Web Special\n"+K}y.set("text",K);var p=z.clone().setProperty("id","booking-form-"+J);p.adopt(k.clone().setProperty("name","recId").setProperty("value",J)).adopt(k.clone().setProperty("name","Offer"+J).setProperty("value",u));l=this.calendarDate(h);G=this.paxSelect(b);p.adopt(G);var A=this.AvailDisp(f,r,C);m.adopt(I.clone().set("text",l)).adopt(I.clone().set("text",d).addClass("Name")).adopt(I.clone().addClass("Days")).adopt(I.clone().addClass("Town")).adopt(I.clone().set("text",x+"%")).adopt(y).adopt(I.clone().set("text",u));B.adopt(m)}}O.adopt(v);O.adopt(B);var t=new Element("p");t.addClass("txt");var L='The following prices are in <span class="header">'+this.currencyName+"</span> and only valid for online bookings.";z.adopt(t.clone().set("html",L));this.currency_flags(z);z.adopt(O);z.replaces($(this.div_id));z.setProperty("id",this.div_id);document.body.style.cursor="default";var q=new XML();q.div_id=this.div_id;var F={};F.onSuccess=function(s){XmlTours=s.getElementsByTagName("Tour");if(XmlTours.length==0){return false}$(this.div_id).getElements("tr").each(function(P){w=P.getAttribute("tour");if(w){for(i=0;i<XmlTours.length;i++){TourRefNode=XmlTours[i].getElementsByTagName("Ref");if(TourRefNode.length==1){if(TourRefNode[0].childNodes.length>0){TourRef=TourRefNode[0].childNodes[0].nodeValue;if(TourRef==w){tourUrl=XmlTours[i].getElementsByTagName("URL")[0].firstChild.nodeValue;tourLength=XmlTours[i].getElementsByTagName("Days")[0].firstChild.nodeValue;tourTown=XmlTours[i].getElementsByTagName("Departs")[0].firstChild.nodeValue;P.getElements("td").each(function(Q){if(Q.hasClass("Name")){tourname=Q.get("text");Q.empty();Q.set("html",'<a href="'+tourUrl+'">'+tourname+"</td>")}if(Q.hasClass("Days")){Q.set("text",tourLength)}if(Q.hasClass("Town")){Q.set("text",tourTown)}})}}}}}})};if(this.tourDetailsXml){q.loadRemote(this.tourDetailsXml,F)}};var lmd=function(b){var c=escape("Brand="+b.program);var a="https://www.trekam.net/trek/API/HTTP-API.asp";a+="?service=LastMinuteDiscountsByBrand&params="+c;prices=new priceLoader(b);prices.program=b.program;prices.offers_only=false;if(b.offers_only){prices.offers_only=b.offers_only}if(b.tourDetailsXml){prices.tourDetailsXml=b.tourDetailsXml}prices.createPriceGrid=createLMDGrid;prices.onParseSuccess=function(d){this.the_xml=d;this.createPriceGrid(d);this.makeSortable()};prices.loadRemote(a);return prices};