var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');function LZ(x){return(x<0||x>9?"":"0")+x};function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}return true;};function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0||d2==0){return-1;}else if(d1>d2){return 1;}return 0;};function formatDate(date,format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=date.getYear()+"";var M=date.getMonth()+1;var d=date.getDate();var E=date.getDay();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length<4){y=""+(y-0+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=LZ(M);value["MMM"]=MONTH_NAMES[M-1];value["NNN"]=MONTH_NAMES[M+11];value["d"]=d;value["dd"]=LZ(d);value["E"]=DAY_NAMES[E+7];value["EE"]=DAY_NAMES[E];value["H"]=H;value["HH"]=LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=LZ(value["h"]);if(H>11){value["K"]=H-12;}else{value["K"]=H;}value["k"]=H+1;value["KK"]=LZ(value["K"]);value["kk"]=LZ(value["k"]);if(H>11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=LZ(m);value["s"]=s;value["ss"]=LZ(s);while(i_format=minlength;x--){var token=str.substring(i,i+x);if(token.length70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=="MMM"||token=="NNN"){month=0;for(var i=0;i11)){month=i+1;if(month>12){month-=12;}i_val+=month_name.length;break;}}}if((month<1)||(month>12)){return 0;}}else if(token=="EE"||token=="E"){for(var i=0;i12)){return 0;}i_val+=month.length;}else if(token=="dd"||token=="d"){date=_getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return 0;}i_val+=date.length;}else if(token=="hh"||token=="h"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return 0;}i_val+=hh.length;}else if(token=="HH"||token=="H"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return 0;}i_val+=hh.length;}else if(token=="KK"||token=="K"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return 0;}i_val+=hh.length;}else if(token=="kk"||token=="k"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return 0;}i_val+=hh.length;hh--;}else if(token=="mm"||token=="m"){mm=_getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return 0;}i_val+=mm.length;}else if(token=="ss"||token=="s"){ss=_getInt(val,i_val,token.length,2);if(ss==null||(ss<0)||(ss>59)){return 0;}i_val+=ss.length;}else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}else{return 0;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return 0;}else{i_val+=token.length;}}}if(i_val!=val.length){return 0;}if(month==2){if(((year%4==0)&&(year%100!=0))||(year%400==0)){if(date>29){return 0;}}else{if(date>28){return 0;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date>30){return 0;}}if(hh<12&&m=="PM"){hh=hh-0+12;}else if(hh>11&&m=="AM"){hh-=12;}var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();};function parseDate(val){var preferEuro=(arguments.length==2)?arguments[1]:false;generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');bo=new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');var bm=new Array('generalFormats',preferEuro?'bo':'monthFirst',preferEuro?'monthFirst':'bo');var d=null;for(var i=0;i0)for(i= -1,l=r.length;++im;j=c?m:(j=s.substr(0,m).match(/\S*$/)).input.length-j[0].length||j.input.length+(j=s.substr(m).match(/^\S*/)).input.length+j[0].length,r[i]+=s.substr(0,j)+((s=s.substr(j)).length?b:""));r[i]+=s;}return r.join("\n");};String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"");};String.prototype.ltrim=function(){return this.replace(/^\s+/,"");};String.prototype.rtrim=function(){return this.replace(/\s+$/,"");};if(typeof B=="undefined"){var B={};}B.namespace=function(){var a=arguments,o=null,i,j,d;for(i=0;i -1),isSafari=(ua.indexOf('safari')> -1),isGecko=(!isOpera&& !isSafari&&ua.indexOf('gecko')> -1),isIE=(!isOpera&&ua.indexOf('msie')> -1);var patterns={HYPHEN:/(-[a-z])/i};var toCamel=function(property){if(!patterns.HYPHEN.test(property)){return property;}if(al[property]){return al[property];}while(patterns.HYPHEN.exec(property)){property=property.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());}al[property]=property;return property;};if(document.defaultView&&document.defaultView.getComputedStyle){getStyle=function(el,property){var value=null;var computed=document.defaultView.getComputedStyle(el,'');if(computed){value=computed[toCamel(property)];}return el.style[property]||value;};}else if(document.documentElement.currentStyle&&isIE){getStyle=function(el,property){switch(toCamel(property)){case 'opacity':var val=100;try{val=el.filters['DXImageTransform.Microsoft.Alpha'].opacity;}catch(e){try{val=el.filters('alpha').opacity;}catch(e){}}return val/100;break;default:var value=el.currentStyle?el.currentStyle[property]:null;return(el.style[property]||value);}};}else{getStyle=function(el,property){return el.style[property];};}if(isIE){setStyle=function(el,property,val){switch(property){case 'opacity':if(typeof el.style.filter=='string'){el.style.filter='alpha(opacity='+val*100+')';if(!el.currentStyle|| !el.currentStyle.hasLayout){el.style.zoom=1;}}break;default:el.style[property]=val;}};}else{setStyle=function(el,property,val){el.style[property]=val;};}B.util.Dom={get:function(el){if(!el){return null;}if(typeof el!='string'&& !(el instanceof Array)){return el;}if(typeof el=='string'){return document.getElementById(el);}else{var collection=[];for(var i=0,len=el.length;i=this.left&®ion.right<=this.right&®ion.top>=this.top&®ion.bottom<=this.bottom);};B.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};B.util.Region.prototype.intersect=function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new B.util.Region(t,r,b,l);}else{return null;}};B.util.Region.prototype.union=function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new B.util.Region(t,r,b,l);};B.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};B.util.Region.getRegion=function(el){var p=B.util.Dom.getXY(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new B.util.Region(t,r,b,l);};B.util.Point=function(x,y){if(x instanceof Array){y=x[1];x=x[0];}this.x=this.right=this.left=this[0]=x;this.y=this.top=this.bottom=this[1]=y;};B.util.Point.prototype=new B.util.Region();B.util.CustomEvent=function(type,oScope,silent,signature){this.type=type;this.scope=oScope||window;this.silent=silent;this.signature=signature||B.util.CustomEvent.LIST;this.subscribers=[];if(!this.silent){}var onsubscribeType="_YUICEOnSubscribe";if(type!==onsubscribeType){this.subscribeEvent=new B.util.CustomEvent(onsubscribeType,this,true);}};B.util.CustomEvent.LIST=0;B.util.CustomEvent.FLAT=1;B.util.CustomEvent.prototype={subscribe:function(fn,obj,override){if(this.subscribeEvent){this.subscribeEvent.fire(fn,obj,override);}this.subscribers.push(new B.util.Subscriber(fn,obj,override));},unsubscribe:function(fn,obj){var found=false;for(var i=0,len=this.subscribers.length;i0){param=args[0];}ret=s.fn.call(scope,param,s.obj);}else{ret=s.fn.call(scope,this.type,args,s.obj);}if(false===ret){if(!this.silent){}return false;}}}return true;},unsubscribeAll:function(){for(var i=0,len=this.subscribers.length;i=0){cacheItem=listeners[index];}if(!el|| !cacheItem){return false;}if(this.useLegacyEvent(el,sType)){var legacyIndex=this.getLegacyIndex(el,sType);var llist=legacyHandlers[legacyIndex];if(llist){for(i=0,len=llist.length;i0);}var notAvail=[];for(var i=0,len=onAvailStack.length;i0){for(var i=0,len=listeners.length;i0){j=listeners.length;while(j){index=j-1;l=listeners[index];if(l){EU.removeListener(l[EU.EL],l[EU.TYPE],l[EU.FN],index);}j=j-1;}l=null;EU.bP();}for(i=0,len=legacyEvents.length;i=200&&httpStatus<300){try{responseObject=this.createResponseObject(o,A.argument);if(A.success){if(!A.scope){A.success(responseObject);}else{A.success.apply(A.scope,[responseObject]);}}}catch(e){}}else{try{switch(httpStatus){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:responseObject=this.createExceptionObject(o.tId,A.argument,(isAbort?isAbort:false));if(A.failure){if(!A.scope){A.failure(responseObject);}else{A.failure.apply(A.scope,[responseObject]);}}break;default:responseObject=this.createResponseObject(o,A.argument);if(A.failure){if(!A.scope){A.failure(responseObject);}else{A.failure.apply(A.scope,[responseObject]);}}}}catch(e){}}this.releaseObject(o);responseObject=null;},createResponseObject:function(o,callbackArg){var obj={};var headerObj={};try{var headerStr=o.conn.getAllResponseHeaders();var header=headerStr.split('\n');for(var i=0;i');if(typeof secureUri=='boolean'){io.src='javascript:false';}else if(typeof secureURI=='string'){io.src=secureUri;}}else{var io=document.createElement('iframe');io.id=frameId;io.name=frameId;}io.style.position='absolute';io.style.top='-1000px';io.style.left='-1000px';document.body.appendChild(io);},appendPostData:function(postData){var formElements=[];var postMessage=postData.split('&');for(var i=0;i0){try{for(var i=0;i0){for(var i=0,l=element.length;ithis.D.U){this.D.U=bM;this.D.startTime=now-bM;}};GWS.SalesBullyUI.prototype.getArguments=function(){var myKey=this.gC('key');var args=location.search;var st=args.indexOf(myKey+'=');var en=args.length;var a='';if(st!= -1){st+=myKey.length+1;}if(args.indexOf('&',st)!= -1){en=args.indexOf('&',st);}if(st!= -1){a=args.substring(st,en);}return a;};GWS.SalesBullyUI.prototype.bh=function(){var au=undefined;if(!GWS.bt(this.gC(['identifier','use']))){return au;}var iden=this.ident;if(!iden.mode){return au;}if(!iden.success){if(GWS.bt(this.gC('check'))){alert(iden.message);}return false;}switch(iden.mode){case 'hasActed':case 'noRecord':au=this.bS(iden.action);break;default:GWS.util.warning('There has been an issue communicating with the OTO-Identifier application.');break;}return au;};GWS.SalesBullyUI.prototype.as=function(){var testIdent=undefined;var args=this.getArguments();testIdent=this.bh();};GWS.SalesBullyUI.prototype.cp=function(args){if(!args||args!=this.gC('clear')){return false;}this.startTime='';this.returning=false;this.ident.action='';this.ident.message='';this.ident.success=true;if(GWS.bt(this.gC('useCookies'))){document.cookie=this.gC('cookie')+'=';}if(GWS.bt(this.gC(['identifier','use']))){B.util.Connect.asyncRequest('POST',this.gC(['identifier','data']),null,this.ident.clearVar+'=true');}return true;};GWS.SalesBullyUI.prototype.aC=function(doit){var action=doit?doit:'';if(GWS.bt(this.gC(['timer','track']))&&this.startTime){action+=this.cc+this.startTime;}if(!action){return;}if(GWS.bt(this.gC('useCookies'))){var ck=this.gC('cookie')+'='+action+'; max-age='+this.cookieExpiry;document.cookie=ck;}if(GWS.bt(this.gC(['identifier','use']))){var identCallback={success:this.bu,failure:this.bD,scope:this};var identArg=this.ident.bV+'='+action;var saveU=this.gC(['identifier','data']);if(this.gC(['identifier','requestType']).search(/^GET$/i)!= -1){B.util.Connect.asyncRequest('GET',saveU+'?'+identArg,identCallback);}else if(this.gC(['identifier','requestType']).search(/^POST$/i)!= -1){B.util.Connect.asyncRequest('POST',saveU,identCallback,identArg);}else{GWS.util.warning('The request type for the identifier needs to be'+'either GET or POST. Identifier functionality will not be used.');this.identifier.use='no';}}else{this.saveEvent.fire();}};GWS.SalesBullyUI.prototype.bu=function(obj){var a='('+obj.responseText+')';var res=eval(a);if(!res.success){GWS.util.warning('Unable to save Identifier information, received the following message:'+res.message);return false;}this.saveEvent.fire();return true;};GWS.SalesBullyUI.prototype.bD=function(obj){GWS.util.warning('There was an error in trying to connect to the Identifier to save the current state information. Please confirm its config.');};GWS.SalesBullyUI.prototype.accept=function(label,url,returnURL){if(this.bp){this.aF(label,url,returnURL);}else{this.aF(label,url,returnURL,1);this.bp=true;}};GWS.SalesBullyUI.prototype.decline=function(label,url,returnURL){this.aF(label,url,returnURL,0);};GWS.SalesBullyUI.prototype.aF=function(label,url,returnURL,pos){if(label==this.gC('visitAction')){GWS.util.warning('Actions with the same name as the oto.visitAction parameter'+'cannot be added. Ignoring action with label "'+label+'".');return;}returnURL=returnURL||'';var t=this.bb(label);if((!pos&&pos!==0)&&t){pos=t;}else if(!pos&&pos!==0){pos=this.C.length;}this.C[pos]=[label,url,returnURL];};GWS.SalesBullyUI.prototype.bb=function(arg){var au=undefined;if(!arg){return au;}var opts=this.C;if(arg&&arg.length>0){for(var i=0,l=opts.length;ithis.C.length){return undefined;}var loc=this.C[id];var ret=[loc[0],loc[1]];if(withReturn&&loc[2]){ret[1]=loc[2];}return ret;};GWS.SalesBullyUI.prototype.cj=function(which){var ch=parseInt(which);if(isNaN(ch)){ch=this.bb(which);}var a=this.ae(ch,false);var val=a[0];var url=a[1];this.saveEvent.subscribe(this.aQ,url,this);this.aC(val);};GWS.SalesBullyUI.prototype.aQ=function(eType,eArg,eObj){window.location.replace(eObj);};GWS.SalesBullyUI.prototype.ci=function(){if(!GWS.bt(this.gC('check'))){return;}var anchors=document.getElementsByTagName('a');if(anchors.length<=0){GWS.util.warning('The script cannot find any anchor tags. The user needs to be'+'able to accept the offer.');return false;}var R=[];var ag=false;var base=this.key+'=';var a=null;var att=null;for(var i=0;i=end){if(sau){this.af(sau);}else{this.af(0);}return true;}}if(aa){this.displays.am.refresh(start);}if(ai){this.displays.az.refresh(end);}if(aa&&ai){this.displays.ad.refresh((end-start)/1000);}if(ai){var Q=this;window.setInterval(function(){var t=Q.bz();if(t!==false){if(t<=0){if(sau){Q.af(sau);}else{Q.af(0);}}Q.displays.schedule.refresh(t);}},500);}};GWS.SalesBullyUI.prototype.cb=function(){if(!GWS.ct(this.gC(['stock','sourceURL']))){return;}var qen=this.gC(['stock','en']);var qto=this.gC(['stock','bj']);var qel=this.gC(['stock','element']);var qso=this.gC(['stock','sourceURL']);var en=parseInt(qen);var to=parseInt(qto);if(qel&&qel.indexOf('<')!= -1){GWS.util.warning('The stock elment has been set to an invalid value '+'you only need to have the letters that make up the name '+'of the element tag. It is currently set to: '+'oto.stock.element = \''+qel);return false;}if(!to){to=30;}en--;to=Math.max(to,2);to=Math.min(to,300);to*=1000;var A={success:this.bB,failure:this.Z,scope:this};var c=B.util.Connect.asyncRequest('GET',qso,A,null);window.setInterval(function(){c=B.util.Connect.asyncRequest('GET',qso,A,null);},to);};GWS.SalesBullyUI.prototype.ca=function(){if(!this.startTime){this.startTime=new Date().toString();if(GWS.bt(this.gC(['timer','track']))){this.aC();}}var hs=GWS.ct(this.gC(['timer','heartSource']));if(hs){if(!this.D.startTime){this.D.startTime=new Date().getTime();this.D.heartbeat=this.D.startTime;}now=this.ah();now=now?now:new Date();if(now){var A={success:this.aq,failure:this.Z,scope:this};now=new Date(now);now=now.getFullYear()+'/'+now.getMonth()+'/'+now.getDate()+' '+now.getHours()+':'+now.getMinutes()+':'+now.getSeconds();var args=this.projectVariable+'='+this.bf+'&'+this.heartbeatVariable+'='+now;this.D.request=B.util.Connect.asyncRequest('POST',hs,A,args);}Q=this;window.setInterval(function(){Q.aJ();},3000);}var timerSecs=parseInt(this.gC(['timer','seconds']));if(isNaN(timerSecs)){GWS.util.warning('An incorrect value has been supplied for oto.timer.seconds, it needs'+'to be an integer number of seconds, or zero to disable. It is currently'+'set to: '+timerSecs);}else if(timerSecs!=0&&timerSecs<10){GWS.util.warning('There is a very low value for oto.timer.seconds this is probably'+'incorrect. It is: '+timerSecs+' seconds.');}else if(timerSecs>(240*60)){GWS.util.warning('The value for oto.timer.seconds is very high. This is probably'+'incorrect, the value is: '+timerSecs+' seconds.');}if(timerSecs){var t=this.aV();if(t!==false&&t<=0){var endUrl=this.gC(['timer','endURL']);if(endUrl){this.af(endUrl);}else{this.af(0);}}var Q=this;window.setInterval(function(){Q.bq();},1000);this.bU=timerSecs*1000;}};GWS.SalesBullyUI.prototype.bB=function(response){var stock=this.gC('stock');var qen=this.gC(['stock','en']);var qel=GWS.ct(stock.element);var qde=this.gC(['stock','destination']);var qso=this.gC(['stock','sourceURL']);var a= -1;if(qel){var t=response.responseXML;var els=t.getElementsByTagName(qel);if(!els||els.length2){r=parseInt(sss[2]);}}else{n=parseInt(a.trim());}if((!n&&n!==0)||(n<0)){GWS.util.warning('The response from '+stock.source+' should be positive integer '+'but "'+a+'" was received. Please check the value for '+'oto.stock section of the config and that the file pointed '+'at is returning the appropriate text.');return false;}var tot=parseInt(stock.startAmount);if(isNaN(tot)){GWS.util.warning('The set value for the total stock to be sold was not a valid integer.');return false;}if(tot>n){this.displays.stock.refresh(tot-n,tot);this.displays.price.refresh(p);this.displays.cg.refresh(r);}else{if(stock.destination){u=stock.destination;}this.af(u);}return true;};GWS.SalesBullyUI.prototype.Z=function(){GWS.util.warning('There has been a failure trying to connect to '+'"'+this.gC(['stock','sourceURL'])+'". The return code was'+response.statusText);return false;};GWS.SalesBullyUI.prototype.noOfficial=function(obj){};GWS.SalesBullyUI.prototype.getDateField=function(obj){var os=this.gC(['official','sourceURL']);var ot=this.gC(['official','type']);var oe=this.gC(['official','element']);var on=this.gC(['official','en']);var od=this.gC(['official','display']);var dat=false;switch(ot){case 'xml':if(!oe){GWS.util.warning('The OTO program is set to get an XML file for the official time, but'+'does not have any element set to look up the time in.');}else{var roo=obj.responseXML;var elems=roo.getElementsByTagName(oe);if(elems&&elems.length>=on){dat=elems[on-1].firstChild.nodeValue;}else if(elems){dat=elems[0].firstChild.nodeValue;}}break;case 'text':dat=obj.responseText;break;case 'match':var pat=this.gC(['official','pattern']);if(!pat){GWS.util.warning('The OTO program is set to get the official time according to a text'+'match but the pattern is not set.');}if(!on||on<1){on=1;GWS.util.warning('The OTO program was configured with an invalid value for oto.official.en'+'It should be a positive integer.');}var ind=pat.indexOf('#!DATE!#');if(ind== -1){GWS.util.warning('The OTO pattern is set, but it does not contain #!DATE!#.');}else{var find=/#!DATE!#/i;pat=pat.replace(find,'(.*)');find=/#!NL!#/i;pat.replace(find,'$');pat=new RegExp(pat,'gi');dat=obj.responseText;var howMany=this.official.en?this.official.en-1:0;var matchResult;while((matchResult=pat.exec(dat))!=null){if(howMany==0){dat=matchResult[1];break;}howMany--;}if(howMany!=0){GWS.util.warning('The date could not be found, there were not enough matches for your pattern'+'in the oto.official.sourceURL to meet your oto.official.en sotting.');dat=false;}}break;default:dat=obj.getResponseHeader['Date'];break;}return dat;};GWS.SalesBullyUI.prototype.aM=function(obj){var n=new Date().getTime();var dateText=this.getDateField(obj);var d=Date.parse(dateText);var offd=this.O;if(d){if(d!=offd.aD){offd.aD=d;offd.aA+=n-d;offd.timeChecks++;offd.X= -1*offd.aA/offd.timeChecks;if(offd.timeChecks<5){Q=this;var A={success:this.aM,failure:this.noOfficial,scope:this};window.setTimeout(function(){B.util.Connect.asyncRequest('GET',offd.oSource,A,null);},2500);}}}else{if(!this.O.warned){this.O.warned=true;GWS.util.warning('The date text found in looking for an official date was "'+dateText+'" which '+'was not able to be parsed into an recognizeable date. Please check your settings'+"\n"+'and those of your oto.official.sourceURL.');}}};GWS.SalesBullyUI.prototype.bT=function(){if(GWS.ct(this.gC(['official','sourceURL']))){var off=this.gC(['schedule','offset'])*1000;var nt=new Date().getTime();if(this.O.X){return nt+this.O.X+off;}else{return false;}}else{return(new Date().getTime())+off;}};GWS.SalesBullyUI.prototype.submitForm=function(form){var aN=this.C[0][0];if(form.ay){var passed=false;for(var i=0;i