function str_repeat(c,a){for(var e=[];a>0;e[--a]=c);return e.join("")}
function sprintf(){for(var c=0,a,e=arguments[c++],b=[],d,h,g;e;){if(d=/^[^\x25]+/.exec(e))b.push(d[0]);else if(d=/^\x25{2}/.exec(e))b.push("%");else if(d=/^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(e)){if((a=arguments[d[1]||c++])==null||a==undefined)alert("sprintf: Too few arguments.");/[^s]/.test(d[7])&&typeof a!="number"&&alert("sprintf: Expecting number but found "+typeof a);switch(d[7]){case "b":a=a.toString(2);break;case "c":a=String.fromCharCode(a);break;case "d":a=
parseInt(a);break;case "e":a=d[6]?a.toExponential(d[6]):a.toExponential();break;case "f":a=d[6]?parseFloat(a).toFixed(d[6]):parseFloat(a);break;case "o":a=a.toString(8);break;case "s":a=(a=String(a))&&d[6]?a.substring(0,d[6]):a;break;case "u":a=Math.abs(a);break;case "x":a=a.toString(16);break;case "X":a=a.toString(16).toUpperCase();break}a=/[def]/.test(d[7])&&d[2]&&a>0?"+"+a:a;h=d[3]?d[3]=="0"?"0":d[3].charAt(1):" ";g=d[5]-String(a).length;h=d[5]?str_repeat(h,g):"";b.push(d[4]?a+h:h+a)}else alert("sprintf: Huh ?!");
e=e.substring(d[0].length)}return b.join("")}String.prototype.isString=1;Array.prototype.isArray=1;Array.prototype.max=function(){for(var c=this[0],a=this.length,e=1;e<a;e++)if(this[e]>c)c=this[e];return c};Boolean.prototype.isBoolean=1;Date.prototype.isDate=1;RegExp.prototype.isRegExp=1;Function.prototype.isFunction=1;
Number.prototype.format=function(c){if(c.isString){var a=c.replace(/[^\d\.]/gi,""),e=-1<c.indexOf(",");a=a.split(".");var b=this;if(1<a.length)b=b.toFixed(a[1].length);else if(2<a.length)alert("NumberFormatException: invalid format, formats should have no more than 1 comma: "+c);else b=b.toFixed(0);b=b.toString();if(e){a=b.split(".");e=a[0];b=[];for(var d=e.length,h=Math.floor(d/3),g=e.length%3||3,i=0;i<d;i+=g){if(i!=0)g=3;b[b.length]=e.substr(i,g);h-=1}b=b.join(",");if(a[1])b+="."+a[1]}return c.replace(/[\d,?\.?]+/,
b)}};function curFormat(c,a,e){if(a){var b=e?e:ajaxCurData.value;a="0%s0%s%0"+ajaxCurData.decimal_places+"d";a=sprintf(a,ajaxCurData.thousands_point,ajaxCurData.decimal_point,0);b=c*b;b=b.format(a);b=ajaxCurData.symbol_left+b+ajaxCurData.symbol_right}return b}function display_price(c,a){c=ajaxCurData.shTax===true||ajaxCurData.shTax=="true"?c+c*a/100:c;return curFormat(c,true,"")}
function buildTicketData(c){$("orderValue").set("html",$("orderValue").retrieve("html",$("orderValue").store("html",$("orderValue").get("html")).retrieve("html")));$(c.info[0].id).innerHTML=c.info[1].html;c.info[0].id=="VenueInfo"&&window.setTimeout(function(){var a=new Maps.Google(c.info[2].map.name,c.info[2].map.town,c.info[2].map.post_code,"float: none; margin: 0 auto 10px auto;",520);$("mapPlace").innerHTML=a.getHtml();a.addressOverride=c.info[2].map.lat_long;a.load()},250);if(c.info[0].id=="BuyTickets"){ajaxCurData=
c.info[3].jsCuData;ajaxLunchData=c.info[4].lJsData;ajaxPriceData=c.info[2].jsData;ajaxAreasSelected=c.info[5].areasSelected;ajaxProductData=c.info[6].jsProdData;window.setTimeout(function(){for(z=0;z<ajaxPriceData.length;z++)for(x=0;x<ajaxPriceData[z].length;x++)ajaxPriceData[z][x].ty&&ajaxPriceData[z][x].ty=="none"&&$("price_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id).addEvent("change",function(b){b.stop();calcTotalOrderValue(b)});if($$(".priceCheckers")){var a,e;$$(".priceCheckers").each(function(b){e=
a=null;b.addEvent("click",function(){a=$("price_"+b.id.split("_")[1]+"_"+b.id.split("_")[2]);e=b.id.split("_")[3];b.getProperty("type")=="radio"&&$$(".priceCheckers").each(function(d){d.getProperty("name")==b.getProperty("name")&&!d.checked&&d.getParent().getParent().removeClass("selected")});a.getChildren("option").each(function(d,h){if(h==e)if(b.checked){b.getParent().getParent().addClass("selected");d.set("selected","selected")}else{b.getParent().getParent().removeClass("selected");d.removeProperty("selected")}});
a.fireEvent("change",[{stop:$lambda(false),target:{name:a.id}}])})});$$(".radio-label")&&$$(".radio-label").each(function(b){b.addEvent("click",function(d){isScrolledIntoView($(b))||b.scrollIntoView(false);if(b.hasClass("label-disabled"))d.stop();else{d=b.getProperty("for");$(d).fireEvent("click")}})})}},250)}}
function makeLunchDropDown(c,a,e){for(var b="",d=0;d<ajaxLunchData.length;d++){if(d==0){b+='<input class="ptLunchVal" type="hidden" value="0" id="lunchId_'+c+"_"+a+"_"+e+'"/>';b+='<select class="ptLunchNum" id="lunch_'+c+"_"+a+"_"+e+'" name="lunch_'+c+"_"+a+"_"+e+'" rel="dropdown">'}if(ajaxLunchData[d].disabled==0)b+='<option value="'+ajaxLunchData[d].id+'" >'+ajaxLunchData[d].name+"</option>";if(d==ajaxLunchData.length.toInt-1)b+="</select>"}return b}
function calcTotalOrderValue(c){c.stop();var a=0,e=-1,b=0,d=[],h=[],g=new Hash,i=0,o=null,l=0,s=0,j=0,m=0,n=0;i=0;var p="",q="",k={};for(z=0;z<ajaxPriceData.length;z++)for(x=0;x<ajaxPriceData[z].length;x++){l=0;o=$("price_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id);if(o.get("multiple")){k=k||{};l=0;o.getChildren("option").each(function(f){if(f.get("selected")){l++;k[ajaxAreasSelected[z]]||(k[ajaxAreasSelected[z]]={});if(!k[ajaxAreasSelected[z]][ajaxPriceData[z][x].id]){k[ajaxAreasSelected[z]][ajaxPriceData[z][x].id]=
{};k[ajaxAreasSelected[z]][ajaxPriceData[z][x].id].quantity=0}k[ajaxAreasSelected[z]][ajaxPriceData[z][x].id].quantity++;k[ajaxAreasSelected[z]][ajaxPriceData[z][x].id].booking=ajaxPriceData[z][x].bf.toFloat()||0}})}else{l=o.options[$("price_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id).selectedIndex].value.toInt();k[ajaxAreasSelected[z]]||(k[ajaxAreasSelected[z]]={});if(!k[ajaxAreasSelected[z]][ajaxPriceData[z][x].id]){k[ajaxAreasSelected[z]][ajaxPriceData[z][x].id]={};k[ajaxAreasSelected[z]][ajaxPriceData[z][x].id].quantity=
0}k[ajaxAreasSelected[z]][ajaxPriceData[z][x].id].quantity=l;k[ajaxAreasSelected[z]][ajaxPriceData[z][x].id].booking=ajaxPriceData[z][x].bf.toFloat()}i=ajaxPriceData[z][x].pr.toFloat();if(ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id!=e||x==ajaxPriceData[z].length){if(b>0){j=d.max();if(j=="undefined"||j==void 0)j=0;m=h.max();if(m=="undefined"||m==void 0)m=0;if(g.getLength())n=g.get(g.getKeys().max());if(n=="undefined"||n==void 0)n=0;b-=j>m&&j>n?parseFloat(j):m>j&&m>n?parseFloat(m):parseFloat(n);
a+=b;$("priceTotal_"+e).value=b}b=l*i;e=ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id;n=m=j=0;d=[];h=[];g=new Hash;s+=l}switch(ajaxPriceData[z][x].ty){case "none":break;case "quantity":i=parseInt(ajaxPriceData[z][x].hu);l>=i?g.set(i,l*parseFloat(ajaxPriceData[z][x].di)):g.set(0,0);break;case "percentage":l>=parseInt(ajaxPriceData[z][x].hu)?h.push(b*parseFloat(ajaxPriceData[z][x].di)/100):h.push(0);break;case "fixed":l>=parseInt(ajaxPriceData[z][x].hu)?d.push(parseFloat(ajaxPriceData[z][x].di)):
d.push(0);break;default:alert("Error: calcTotalOrderValue - unknown discount");break}i="price_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id;j=i+"[]";if(ajaxPriceData[z][x].ty=="none"&&[i,j].contains(c.target.name))if(l>0){if(ajaxLunchData.length){p='<table class="lunches" summary="'+lunchSummary+'">\n';p+="<caption>"+lunchTitle+"</caption>\n";p+="<tbody>\n";for(i=0;i<l;i++){p+='\t<tr class="guest-lunch">\n';p+='\t\t<td class="lunch-options">'+makeLunchDropDown(ajaxAreasSelected[z],ajaxPriceData[z][x].id,
i)+"</td>\n";p+="\t</tr>\n"}p+="</tbody>\n";p+="</table>\n"}if(ajaxProductData.flags.collect_guest_names){q='<table class="guests" summary="'+guestSummary+'">\n';q+="<caption>"+guestTitle+"</caption>\n";q+="<tbody>\n";for(i=0;i<l;i++){q+='\t<tr class="guest-name">\n';q+='\t\t<td class="name-options"><input type="text" maxlength="255" size="24" value="'+defaultName+'" name="gname_'+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+i+'" id="gname_'+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+
"_"+i+'" /></td>\n';q+="\t</tr>\n"}q+="</tbody>\n";q+="</table>\n"}p.length||q.length?$("ptLName_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id).removeClass("wrapper-empty").set("html",p+q+'\n<div class="clear"></div>'):$("ptLName_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id).addClass("wrapper-empty").set("html","&nbsp;")}else $("ptLName_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id).addClass("wrapper-empty").set("html","&nbsp;")}if(0<=s)for(z=0;z<ajaxPriceData.length;z++)for(x=0;x<ajaxPriceData[z].length;x++){o=
$("price_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id);o.get("multiple")||(0==o.options[$("price_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id).selectedIndex].value.toInt()?o.getChildren("option").each(function(f){if(f.value.toInt()>ajaxProdMax-s){f.set("disabled","disabled");if($("priceCheck_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+f.value.toInt()).getProperty("type")=="radio"){$("priceCheck_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+f.value.toInt()).set("disabled",
"disabled");$("priceCheck_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+f.value.toInt()).getParent().getParent().addClass("option-disabled")}}else if(f.get("disabled")){f.removeProperty("disabled");if($("priceCheck_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+f.value.toInt()).getProperty("type")=="radio"){$("priceCheck_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+f.value.toInt()).removeProperty("disabled");$("priceCheck_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+
f.value.toInt()).getParent().getParent().removeClass("option-disabled")}}}):o.getChildren("option").each(function(f){var r=o.options[$("price_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id).selectedIndex].value.toInt();if(f.value.toInt()>ajaxProdMax-s+r){f.set("disabled","disabled");if($("priceCheck_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+f.value.toInt()).getProperty("type")=="radio"){$("priceCheck_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+f.value.toInt()).set("disabled",
"disabled");$("priceCheck_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+f.value.toInt()).getParent().getParent().addClass("option-disabled")}}else if(f.get("disabled")){f.removeProperty("disabled");if($("priceCheck_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+f.value.toInt()).getProperty("type")=="radio"){$("priceCheck_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+f.value.toInt()).removeProperty("disabled");$("priceCheck_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+
f.value.toInt()).getParent().getParent().removeClass("option-disabled")}}}))}var t=0;typeof k!=="undefined"&&$each(k,function(f){$each(f,function(r){t+=r.quantity})});if(t>0){if(s==t){$each(k,function(f){$each(f,function(r){if(r.quantity.toInt()>0)if(r.booking.toFloat()>0)b+=r.quantity.toInt()*r.booking.toFloat();else if(ajaxProductData.fees.booking)b+=ajaxProductData.fees.booking*r.quantity.toInt()})});if(ajaxProductData.fees.admin)b+=ajaxProductData.fees.admin;ajaxProductData.fees.additional.length&&
ajaxProductData.fees.additional.each(function(f){b+=f.amount.toFloat()})}}else if(s){if(ajaxProductData.fees.booking)b+=ajaxProductData.fees.booking*s;if(ajaxProductData.fees.admin)b+=ajaxProductData.fees.admin;ajaxProductData.fees.additional.length&&ajaxProductData.fees.additional.each(function(f){b+=f.amount.toFloat()})}if(b>0){j=d.max();if(j=="undefined"||j==void 0)j=0;m=h.max();if(m=="undefined"||m==void 0)m=0;if(g.getLength())n=g.get(g.getKeys().max());if(n=="undefined"||n==void 0)n=0;b-=j>m&&
j>n?parseFloat(j):m>j&&m>n?parseFloat(m):parseFloat(n);a+=b;$("priceTotal_"+e).value=b}a=Math.round(a*1E3)/1E3;if(a>0)$("orderValue").innerHTML=display_price(a,ajaxCurData.tax_rate);else $("orderValue").set("html",$("orderValue").retrieve("html"))}
function initSynchronizeConcurentAreaPrices(){var c=[],a=[];$$(".ptPriceNum").each(function(e){var b=e.id.split("_")[1];c.each(function(d){var h=d.id.split("_")[1];if(h==b){a.push(e);a.contains(d)||a.push(d)}});c.push(e)});a.each(function(e){e.addEvent("change",function(b){synchronizeDropDowns(e)})})}
function synchronizeDropDowns(c){var a=c.id,e=[],b=a.split("_")[0]+"_"+a.split("_")[1];$(a).getChildren("option").each(function(g,i){g.get("selected")&&e.push(g.value)});$$(".ptPriceNum").each(function(g){var i=g.id.split("_")[0]+"_"+g.id.split("_")[1];i==b&&g.id!=a&&$(g.id).getChildren("option").each(function(o,l){if(e.contains(o.value)&&o.get("selected")){o.removeProperty("selected");$("priceCheck_"+g.id.split("_")[1]+"_"+g.id.split("_")[2]+"_"+l).removeProperty("checked");$("priceCheck_"+g.id.split("_")[1]+
"_"+g.id.split("_")[2]+"_"+l).getParent().getParent().removeClass("selected")}})});for(z=0;z<ajaxPriceData.length;z++)for(x=0;x<ajaxPriceData[z].length;x++){curNumProds=0;curNumEl=$("price_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id);if(curNumEl.get("multiple")){curNumProds=0;curNumEl.getChildren("option").each(function(g){g.get("selected")&&curNumProds++})}if(ajaxPriceData[z][x].ty=="none")if(curNumProds>0){var d=c="";if(ajaxLunchData.length){c='<table class="lunches" summary="'+lunchSummary+
'">\n';c+="<caption>"+lunchTitle+"</caption>\n";c+="<tbody>\n";for(var h=0;h<curNumProds;h++){c+='\t<tr class="guest-lunch">\n';c+='\t\t<td class="lunch-options">'+makeLunchDropDown(ajaxAreasSelected[z],ajaxPriceData[z][x].id,h)+"</td>\n";c+="\t</tr>\n"}c+="</tbody>\n";c+="</table>\n"}if(ajaxProductData.flags.collect_guest_names){d='<table class="guests" summary="'+guestSummary+'">\n';d+="<caption>"+guestTitle+"</caption>\n";d+="<tbody>\n";for(h=0;h<curNumProds;h++){d+='\t<tr class="guest-name">\n';
d+='\t\t<td class="name-options"><input type="text" maxlength="255" size="24" value="'+defaultName+'" name="gname_'+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+h+'" id="gname_'+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id+"_"+h+'" /></td>\n';d+="\t</tr>\n"}d+="</tbody>\n";d+="</table>\n"}c.length||d.length?$("ptLName_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id).removeClass("wrapper-empty").set("html",c+d+'\n<div class="clear"></div>'):$("ptLName_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id).addClass("wrapper-empty").set("html",
"&nbsp;")}else $("ptLName_"+ajaxAreasSelected[z]+"_"+ajaxPriceData[z][x].id).addClass("wrapper-empty").set("html","&nbsp;")}}function checkSeatsForPrices(){var c=0,a=0;areaSeats.each(function(e){a+=e.seats});$$(".ptPriceNum").each(function(e){e.getChildren("option").each(function(b){b.get("selected")&&c++})});if(c==a&&a&&c)return false;return true}
function isScrolledIntoView(c){var a,e,b;a=$(c).getParent().getParent();e=a.getScroll().y;b=e+a.getSize().y;a=$(c).getCoordinates(a).top;c=a+$(c).getSize().y;return c>=e&&a<=b&&c<=b&&a>=e};

