String.prototype.ellipse=function(A){if(this.length>A){return this.substr(0,A-3)+"..."}return this};ProductPanel=Ext.extend(Ext.Panel,{autoScroll:true,gst:1.1,gstText:"(inc. 10% GST)",lookup:{},constructor:function(B){this.thumbTemplate=new Ext.XTemplate('<tpl for=".">','<div class="product-thumb-wrap" id="{id}">','<div class="product-thumb"><img src="product/images/{id}-preview.jpg?_dc={dateNumber}" title="{title}"></div>',"<span>{shortName}</span></div>","</tpl>");this.thumbTemplate.compile();this.detailsTemplate=new Ext.Template('<div id="{id}-details">','<div class="thumbnailpin"><a href="product/images/{id}.jpg" rel="{id}" title="{title}"><img src="product/images/{id}-thumb.jpg"></a></div>',"<h2>{title}</h2>{priceText}{specialPriceText}{status}{description}",'<p><b>Email <a href="mailto&#58;{emailAddress}{emailSubject}">{emailAddress}</a></b> to place your order.</p>',"<p><b>Order Note:</b> Please provide your full name and delivery address in the email. We will generate a Tax Invoice for you with our bank account details to pay into. We will send your order (to the delivery address provided) as soon as your payment is received.</p>","</div>");this.detailsTemplate.compile();this.store=new Ext.data.JsonStore({url:"product/index.json",root:"products",fields:["brand","category","container","date","description","id","name",{name:"price"},{name:"quantity",type:"int"},{name:"size",type:"int"},{name:"special",type:"int"},{name:"specialPrice"}],listeners:{load:{fn:function(){this.doLayout(false);this.showDetails()},scope:this,single:true}},sortInfo:{field:"special",direction:"DESC"}});var C=function(E){E.date=new Date.parseDate(E.date,"Y-m-d H:i:s");E.dateNumber=new Date(E.date).getTime();E.dateString=new Date(E.date).format("Y-m-d H:i:s");if(Ext.type(E.container)=="string"){var D=E.container.split(" ");E.size=D[3]?parseInt(D[3],10):-1}else{E.size=-1}E.shortName=E.name.ellipse(30);E.title=E.name.replace(/["]/g,"&quot;");this.lookup[E.name]=E;return E};this.customView=new Ext.DataView({tpl:this.thumbTemplate,singleSelect:true,overClass:"x-view-over",itemSelector:"div.product-thumb-wrap",emptyText:'<div style="padding:10px;">No products match the specified filter</div>',store:this.store,listeners:{selectionchange:{fn:this.showDetails,scope:this,buffer:100},loadexception:{fn:this.onLoadException,scope:this},beforeselect:{fn:function(D){return D.store.getRange().length>0}}},prepareData:C.createDelegate(this)});this.searchFilter=new Ext.form.TriggerField({emptyText:"Search...",id:"searchFilterText",listeners:{render:{fn:function(){Ext.getCmp("searchFilterText").getEl().on("keyup",function(){this.filterProducts()},this,{buffer:500})},scope:this}},minLength:1,onTriggerClick:this.reset.createDelegate(this),selectOnFocus:true,triggerClass:"x-form-clear-trigger",width:150});var A=new Ext.form.TriggerField();A.onTriggerClick=this.reset;B.items=this.customView;B.tbar=[{text:"Filter:"},{id:"brandSelect",xtype:"combo",typeAhead:true,triggerAction:"all",width:100,editable:false,mode:"local",displayField:"desc",valueField:"name",lazyInit:false,value:"",store:new Ext.data.SimpleStore({fields:["name","desc"],data:[["","Any Brand"],["IMPACT","IMPACT"],["Qu-ax","Qu-ax"],["QX-series","QX-series"],["Team Rider","Team Rider"]]}),listeners:{select:{fn:this.filterProducts,scope:this}}},{id:"categorySelect",xtype:"combo",typeAhead:true,triggerAction:"all",width:150,editable:false,mode:"local",displayField:"desc",valueField:"name",lazyInit:false,value:"",store:new Ext.data.SimpleStore({fields:["name","desc"],data:[["","Any Category"],["Misc","Accessories"],["Parts","Parts"],["Tools","Tools"],["Unicycles","Unicycles"],["BE","Unicycles (Beginner)"],["FL","Unicycles (Flatland)"],["FR","Unicycles (Freestyle)"],["MU","Unicycles (Mountain)"],["RO","Unicycles (Road)"],["ST","Unicycles (Street)"],["TR","Unicycles (Trials)"]]}),listeners:{select:{fn:this.filterProducts,scope:this}}},this.searchFilter,"->",{text:"Sort By:"},{id:"sortSelect",xtype:"combo",typeAhead:true,triggerAction:"all",width:100,editable:false,mode:"local",displayField:"desc",valueField:"name",lazyInit:false,value:"special",store:new Ext.data.SimpleStore({fields:["name","desc"],data:[["brand","Brand"],["category","Category"],["name","Name"],["price","Price"],["size","Size"],["special","Special"]]}),listeners:{select:{fn:this.sortProducts,scope:this}}}];ProductPanel.superclass.constructor.call(this,B)},filterProducts:function(){var C=Ext.getCmp("brandSelect").getValue();var B=Ext.getCmp("categorySelect").getValue();var A=Ext.getCmp("searchFilterText").getValue();this.customView.store.filterBy(function(F,I){var H=F.get("brand"),E=F.get("category");var G=((C&&H)?H.indexOf(C,0)!=-1:true)&&((B&&E)?E.indexOf(B,0)!=-1:true);if(Ext.type(A)=="string"&&G){var D=Ext.util.Format.lowercase(F.get("name"));G=D.indexOf(Ext.util.Format.lowercase(A),0)!=-1}return G},this);this.customView.select(0)},onLoadException:function(A,B){this.customView.getEl().update('<div style="padding:10px;">Error loading products.</div>')},onRender:function(B,A){ProductPanel.superclass.onRender.call(this,B,A);this.store.load()},showDetails:function(){var I,K=Ext.getDom("content");var G,A,B,J,E=this.customView.getSelectedNodes(),M,D;var O,H,N,L,C,F;if(!this.detailsElement){I=Ext.getCmp(this.mainID).body;I.update("").setStyle("background","#fff");this.detailsElement=I.createChild()}if(E&&E.length>0){E=E[0];B=E.id+"-details";if(!Ext.get(B)){J=this.store.findBy(function(P){return P.get("id")===E.id},this);if(J!=-1){D=this.store.getAt(J)}}if(D){O=D.get("description");A=document.createElement("div");A.setAttribute("id",B);M={forIE:Ext.isIE};G=new Parse.Simple.Creole(M);G.parse(A,O,M);O=A.innerHTML;O=O.replace(/<em>/g,"<i>").replace(/<\/em>/g,"</i>");O=O.replace(/<strong>/g,"<b>").replace(/<\/strong>/g,"</b>");H=D.get("price");quantity=D.get("quantity");L=D.get("specialPrice");NMP2.console.log(H,L,this.gst,this.gstText);N="<p><b>PRICE "+Ext.util.Format.usMoney(H*this.gst)+"</b> AUD "+this.gstText+"</p>";if(L){N="<del>"+N+"</del>";C='<p><span style="color:red"><b>SALE '+Ext.util.Format.usMoney(L*this.gst)+"</b> AUD "+this.gstText+"</span></p>";if(quantity==0){C="<del>"+C+"</del>"}}else{C=""}if(quantity==0){F='<p><span style="color:red">SOLD OUT, NOT AVAILABLE</span></p>'}else{F='<p><span style="color:blue">IN STOCK, AVAILABLE NOW</span></p>'}this.detailsTemplate.append(K,{id:D.get("id"),title:D.get("title"),description:O,priceText:N,specialPriceText:C,status:F,emailAddress:mail.orders,emailSubject:""});Ext.ux.Lightbox.register("a[rel^="+D.get("id")+"]")}}else{B="welcome-details"}if(B){this.detailsElement.hide().update(Ext.getDom(B).innerHTML).slideIn("l",{stopFx:false,duration:0.2})}else{Ext.MessageBox.alert("Program Error","An unknown error occurred.")}},sortProducts:function(){var A=Ext.getCmp("sortSelect").getValue();this.customView.store.sort(A,(A==="brand"||A==="category"||A==="name")?"ASC":"DESC");this.customView.select(0)},reset:function(){Ext.getCmp("brandSelect").setValue("");Ext.getCmp("categorySelect").setValue("");Ext.getCmp("searchFilterText").setValue("");this.customView.store.clearFilter();this.customView.clearSelections()}});Ext.reg("productpanel",ProductPanel);TeamRiderPanel=Ext.extend(Ext.Panel,{autoScroll:true,lookup:{},constructor:function(A){this.thumbTemplate=new Ext.XTemplate('<tpl for=".">','<div class="team-rider-thumb-wrap" id="{id}">','<div class="team-rider-thumb"><img src="teamrider/images/{id}.jpg" title="{title}"></div>',"<span>{shortName}</span></div>","</tpl>");this.thumbTemplate.compile();this.store=new Ext.data.JsonStore({url:"teamrider/index.json",root:"teamriders",fields:["date","id","name","path",{name:"sort",type:"int"}],listeners:{load:{fn:function(){this.doLayout(false);this.customView.select(0)},scope:this,single:true}},sortInfo:{field:"sort",direction:"ASC"}});var B=function(C){C.shortName=C.name.ellipse(30);C.title=C.name.replace(/["]/g,"&quot;");this.lookup[C.name]=C;return C};this.customView=new Ext.DataView({tpl:this.thumbTemplate,singleSelect:true,overClass:"x-view-over",itemSelector:"div.team-rider-thumb-wrap",emptyText:'<div style="padding:10px;">No team riders match the specified filter</div>',store:this.store,listeners:{selectionchange:{fn:this.showDetails,scope:this,buffer:100},loadexception:{fn:this.onLoadException,scope:this},beforeselect:{fn:function(C){return C.store.getRange().length>0}}},prepareData:B.createDelegate(this)});A.items=this.customView;TeamRiderPanel.superclass.constructor.call(this,A)},onLoadException:function(A,B){this.customView.getEl().update('<div style="padding:10px;">Error loading team riders.</div>')},onRender:function(B,A){TeamRiderPanel.superclass.onRender.call(this,B,A);this.store.load()},showDetails:function(){var D=Ext.getCmp(this.mainID);var F,E,C=this.customView.getSelectedNodes(),B;if(C&&C.length>0){C=C[0];E=C.id+"-content"}if(E){var A=D.getComponent(C.id+"-panel");if(!A){A=D.add({border:false,id:C.id+"-panel",autoLoad:{callback:function(I,J,H,G){if(J){}},nocache:false,page:C.id+"-page",scripts:false,text:"Loading...",timeout:60,url:"teamrider/html/"+C.id+".html"},autoScroll:true})}D.layout.setActiveItem(A)}}});Ext.reg("teamriderpanel",TeamRiderPanel);Ext.ux.IFrameComponent=Ext.extend(Ext.BoxComponent,{onRender:function(B,A){this.el=B.createChild({tag:"iframe",id:"iframe-"+this.id,frameBorder:0,src:this.url})}});Ext.Ajax.on("requestcomplete",function(A,C,B){if(typeof (pageTracker)!="undefined"&&B&&B.url){if(typeof (pageTracker._trackPageview)=="function"){pageTracker._trackPageview(B.url);NMP2.console.log(B.url)}}});Ext.BLANK_IMAGE_URL="images/s.gif";Ext.onReady(function(){Ext.ux.Lightbox.init();var B=new Ext.TabPanel({activeItem:0,border:false,defaults:{layout:"fit"},region:"center",tabPosition:"top",items:[{title:"News &amp; Events",border:false,id:"team-rider-news-panel",html:Ext.getDom("news-and-events").innerHTML,autoScroll:true}]});var A=new Ext.Viewport({layout:"border",items:[{applyTo:"header",height:30,region:"north",xtype:"box"},B]});A.doLayout();setTimeout(function(){Ext.get("loading").remove();Ext.get("loading-mask").fadeOut({remove:true})},250)});
