var month=new Array(12); month[0]="Jan"; month[1]="Feb"; month[2]="Mar"; month[3]="Apr"; month[4]="May"; month[5]="Jun"; month[6]="Jul"; month[7]="Aug"; month[8]="Sep"; month[9]="Oct"; month[10]="Nov"; month[11]="Dec"; var xhrLoading = 0; function showPreloader(objID){ var coords = dojo.coords(objID, true); dojo.style("loading_bg", { "width": coords.w + 'px', "height": coords.h + 'px', "left": coords.x + 'px', "top": coords.y + 'px', "display": "block" }); dojo.style("loading", { /*"left": (coords.x + coords.w/2 - 33) + 'px', "top": (coords.y + coords.h/2 - 33) + 'px',*/ "left": (coords.x + coords.w/2 - 60) + 'px', "top": (coords.y + coords.h/2 - 60) + 'px', "display": "block" }); } function hidePreloader(){ dojo.style("loading_bg", "display", "none"); dojo.style("loading", "display", "none"); } function setCookie( name, value, expires, path, domain, secure ) { // set time, it's in milliseconds var date = new Date(); date.setTime( date.getTime() ); /* if the expires variable is set, make the correct expires time, the current script below will set it for x number of days, to make it for hours, delete * 24, for minutes, delete * 60 * 24 */ if ( expires ) { expires = expires * 1000 * 60 * 60 * 24; } var expires_date = new Date( date.getTime() + (expires) ); document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" ); } function getCookie(name) { var cookie = " " + document.cookie; var search = " " + name + "="; var setStr = null; var offset = 0; var end = 0; if (cookie.length > 0) { offset = cookie.indexOf(search); if (offset != -1) { offset += search.length; end = cookie.indexOf(";", offset) if (end == -1) { end = cookie.length; } setStr = unescape(cookie.substring(offset, end)); } } return(setStr); } function setTimeStamp(){ var currentTime = new Date(); var cartStartTime = parseInt(getCookie("MontrealCartStartTime")); var timeStamp = parseInt(getCookie("MontrealTimeStamp")); if(cartStartTime && isNaN(timeStamp)){ setCookie("MontrealTimeStamp", (cartStartTime - parseInt(currentTime.getTime()/1000)), 300, '/'); } } function insertParam(key, value) { key = encodeURI(key); value = encodeURI(value); var kvp = document.location.search.substr(1).split('&'); var i=kvp.length; var x; while(i--) { x = kvp[i].split('='); if (x[0]==key) { x[1] = value; kvp[i] = x.join('='); break; } } if(i<0) {kvp[kvp.length] = [key,value].join('=');} //this will reload the page, it's likely better to store this until finished document.location.search = kvp.join('&'); } function updateLang(){ var obj = dijit.byId("selectLng"); insertParam("lng", obj.getValue()); } function updateLangPhone(pValue){ insertParam("lng", pValue); } function createStates(cID,sID){ var state = dijit.byId("state"); if(state) state.destroy(); var preloader = dojo.create("img", { src: "img/linePreloader.gif", id: "statePreloader", style: { position: "relative", left: "-4px", margin: 0 } }, "stateBox", "first"); handleButtons(1); dojo.xhrGet({ //url: "index.php?section=register&ajax=1&action=getStates&cID=" + cID, url: "index.php?section=general&ajax=1&action=getStates&cID=" + cID, handleAs: "json", preventCache: true, load: function(resJson){ var stateStore = new dojo.data.ItemFileReadStore({ data: resJson }); if(resJson.items.length > 0){ var filteringSelect = new dijit.form.Select({ id: "state", name: "state", style: { width: '100%' , height: '34px' }, required: true, value: sID, store: stateStore }, "statePreloader"); dojo.addClass(filteringSelect, "form-control"); }else{ var filteringSelect = new dijit.form.ValidationTextBox({ id: "state", name: "state", style: { width: '100%' , height: '34px' }, disabled: true, required: false }, "statePreloader"); } handleButtons(-1); }, error: function(error){ console.log(error); handleButtons(-1); } }); } /* function createStates(cID,sID){ var state = dijit.byId("state"); if(state) state.destroy(); var preloader = dojo.create("img", { src: "img/linePreloader.gif", id: "statePreloader", style: { position: "relative", left: "-4px", margin: 0 } }, "stateBox", "first"); handleButtons(1); dojo.xhrGet({ url: "?section=register&ajax=1&action=getStates&cID=" + cID, handleAs: "json", preventCache: true, load: function(resJson){ if(resJson.items.length > 0){ var filteringSelect = new dijit.form.FilteringSelect({ id: "state", name: "state", autoComplete: true, required: true, value: sID, store: new dojo.data.ItemFileReadStore({ data: resJson }), searchAttr: "name" }, "statePreloader"); }else{ var filteringSelect = new dijit.form.ValidationTextBox({ id: "state", name: "state", disabled: true, required: false }, "statePreloader"); } handleButtons(-1); }, error: function(error){ console.log(error); handleButtons(-1); } }); } */ function handleButtons(i){ var buttonsBox = dojo.query(".buttonsBox")[0]; if(!buttonsBox) return; var coords = dojo.coords(buttonsBox, true); var block = dojo.query(".buttonsBlock")[0]; xhrLoading += i; if(xhrLoading > 0 && !block){ block = dojo.create("div", { "class": "buttonsBlock", style: {width: coords.w + 'px', height: coords.h + 'px'} }, buttonsBox, "first"); }else if(xhrLoading == 0 && block){ dojo.destroy(block); } } function createPromoDialog(){ var dialog = new dijit.TooltipDialog({ content: '
' }); var button = new dijit.form.DropDownButton({ label: "PROMOCODE_TEXT_1", dropDown: dialog }); dojo.byId("promoCodeContainer").appendChild(button.domNode); var textBox = dijit.byId("promocode"); textBox.tooltipPosition = ["before"]; var button = dijit.byId("promocodeSave"); dialog.onHide = function(){ textBox.focus(); // need to hide message on dialog hide } // Focus on text field on create button.onFocus = function() { textBox.focus(); } button.onClick = function(){ var TooltipDialogBox = dojo.query(".TooltipDialogBox")[0]; var preloader = dojo.create("img", { src: "img/linePreloader.gif", id: "promoPreloader", style: { position: "absolute", left: "4px", top: "24px", margin: 0 } }, TooltipDialogBox, "first"); dojo.style(textBox.domNode, "visibility", "hidden"); dojo.style(button.domNode, "visibility", "hidden"); dojo.xhrGet({ url: "index.php?section=tickets&ajax=1&action=applyPromoCode&code=" + textBox.value, handleAs: "json", preventCache: true, load: function(data){ if(data.res){ document.location = window.location.pathname; }else{ dojo.destroy(preloader); dojo.style(textBox.domNode, "visibility", "visible"); dojo.style(button.domNode, "visibility", "visible"); textBox.displayMessage('TICKETS_PAGE_TEXT_7'); } }, error: function(error){ console.log(error); } }); } } function showError(data){ var sError = ''; var oDialog = dijit.byId("dialog"); if(dojo.isArray(data)){ dojo.forEach(data, function(val, i){ sError += val; if(i < data.length-1) sError += "

"; }); }else if(dojo.isString(data)){ sError = data; } if(sError){ dojo.attr("ErrorText", "innerHTML", sError); dojo.style("failure", "display", "block"); oDialog.show(); } } dojo.addOnLoad(function(){ dojo.addClass(dojo.body(), "tundra"); dojo.query(".dialogCancel").connect("onclick", function(e){ var oButton = dijit.getEnclosingWidget(e.target).domNode; var oDialog = dijit.getEnclosingWidget(oButton.parentNode); oDialog.hide(); }); });