/*______________
|       ______  |   B U I L T     O N     U I Z E     F R A M E W O R K
|     /      /  |   ---------------------------------------------------
|    /    O /   |   This JavaScript application is developed using the object
|   /    / /    |   oriented UIZE JavaScript framework as its foundation.
|  /    / /  /| |
| /____/ /__/_| |    ONLINE : http://www.uize.com
|          /___ |   LICENSE : UIZE is distributed under the GNU General Public License
|_______________|             http://www.gnu.org/licenses/gpl.txt
*/

Uize.module({name:'Uize.Widget.Fleeting',required:'Uize.Fade',builder:function(c_a){var c_b=true,c_c=false;var c_d=c_a.subclass(function(){var c_e=this;c_e.c_f=null;c_e.c_g=new Uize.Fade({deceleration:1,duration:750});c_e.c_g.wire({Start:function(){if(c_e.c_h)c_e.displayNode('',c_e.c_h);},'Changed.value':function(){c_e.setNodeOpacity('',c_e.c_g);},Done:function(){if(!c_e.c_h)c_e.displayNode('',c_e.c_h);}});}),c_i=c_d.prototype;c_i.show=function(){var c_e=this;if(c_e.c_f!=null){clearTimeout(c_e.c_j);c_e.c_j=null;}c_e.set({c_h:c_b});};c_d.registerProperties({c_k:{name:'maxOpacity',value:1},c_l:{name:'lifeSpan',value:5000},c_h:{name:'shown',onChange:function(){var c_e=this;if(c_e.c_h)c_e.fire('Before Show');c_e.c_g.start({startValue:c_e.c_h?0:c_e.c_k,endValue:c_e.c_h?c_e.c_k:0,deceleration:1});if(c_e.c_h){c_e.c_f=setTimeout(function(){c_e.set({shown:false});},c_e.c_l);}},value:c_c}});return c_d;}});
Uize.module({name:'Zazzle.RatingStars',superclass:'Uize.Widget',required:['Uize.Node','Uize.Widget.Fleeting'],builder:function(c_a){var c_b=navigator,c_c=c_b.userAgent.toLowerCase(),c_d=Uize.Node.isIe,c_e=null;var c_f=c_a.subclass(c_e,function(){var c_g=this;c_g.c_h=[];c_g.set({currentRating:c_g.getInherited('avgRating'),ratingBeforeInteraction:c_g.getInherited('avgRating')});c_g.c_i=c_g.addChild('ratingSuccess',Uize.Widget.Fleeting,{lifeSpan:3000,maxOpacity:1});c_g.c_j=c_g.addChild('ratingFailure',Uize.Widget.Fleeting,{lifeSpan:3000,maxOpacity:1});}),c_k=c_f.prototype;c_k.c_l=function(){var c_g=this,c_h=c_g.getNode('stars');if(c_g.isWired){if(c_g.c_m==''||c_g.c_m==c_e){c_h.src=c_g.c_n;}else{c_h.src=c_g.c_h[Math.floor(c_g.c_m)].src;}}};c_k.wireUi=function(){var c_g=this,c_h=c_g.getNode('stars'),c_o=c_g.getInherited('commObject');if(!c_g.isWired&&c_h){c_g.set({originalStarsSrc:c_h.src});function c_p(c_q){
return c_g.getInherited('env').imageRealview+'?action=ratingstar&colora='+c_g.c_r+'&colorb='+c_g.c_s+'&bg_color='+c_g.c_t+'&starid='+c_q;}for(var c_q=0;c_q<11;c_q++){c_g.c_h[c_q]=new Image;c_g.c_h[c_q].src=c_p(c_q);}c_g.wireNodeEvent('starsLink','onclick',function(c_u){return false;});c_g.wireNodeEvent('stars','onmousemove',function(c_u){var c_v=c_d?c_u.offsetX:c_u.layerX,c_w=c_h.width/5,c_x=(Math.floor(c_v/c_w)+1)*2;if(c_x>10)c_x=10;if(c_g.c_y){if(c_x!=c_g.c_m){c_g.set({currentRating:c_x});}}});c_g.wireNodeEvent('stars','onmouseout',function(c_u){if(c_g.c_y){c_g.set({currentRating:c_g.c_z});c_h.src=c_g.c_n;}});c_g.wireNodeEvent('stars','onclick',function(c_u){var c_A=c_h.src,c_B=c_g.c_m;if(c_g.c_y){c_g.callInherited('ensureLoggedIn')({lluser:1,callback:function(){c_o.request({url:c_g.getInherited('env').service+'rateproduct?id='+c_g.getInherited('productId')+'&rating='+c_B,returnType:'json',requestMethod:'GET',callback:function(c_C){if(c_C.error==c_e){var c_D=c_C.numRatings,
c_E='('+c_D+' '+(c_D<=1?'vote':'votes')+')';c_g.setNodeInnerHtml('numRatings',c_E);c_g.set({enabled:false});c_g.c_i.set({shown:true});c_g.fire('Rating Success');}else{c_g.c_j.set({shown:true});c_g.set({currentRating:c_g.c_z,enabled:false});if(c_C.error=='Already rated'){c_g.fire('Already Rated');}else{c_g.fire('Rating Failure');}}}});}});}});c_a.prototype.wireUi.call(c_g);}};c_f.registerProperties({c_m:{name:'currentRating',value:'',onChange:c_k.c_l},c_z:{name:'ratingBeforeInteraction',value:0,onChange:function(){var c_g=this;if(c_g.isWired){c_g.c_n=c_g.c_n.replace(/starid=\d+/,'starid='+c_g.c_z);c_g.c_l();}}},c_n:{name:'originalStarsSrc',value:''},c_r:{name:'colorA',value:'0xFFFFFF'},c_s:{name:'colorB',value:'0xffb310'},c_t:{name:'bgColor',value:'0xFFFFFF'},c_y:{name:'enabled',value:true}});return c_f;}});
Uize.module({name:'Zazzle.GridCell.Product.Full',required:['Uize.Widget.Fleeting','Zazzle.RatingStars'],builder:function(f_a){var f_b=Uize.Widget.Fleeting,f_c=true,f_d=false;var f_e=f_a.subclass(null,function(){var f_f=this;var f_g={lifeSpan:3000,maxOpacity:1};f_f.f_h=f_f.addChild('favoritesSuccess',f_b,f_g);f_f.f_i=f_f.addChild('favoritesDuplicate',f_b,f_g);f_f.f_j=f_f.addChild('favoritesError',f_b,f_g);f_f.f_k=f_f.addChild('ratingStars',Zazzle.RatingStars);f_f.f_k.wire('Rating Failure',function(){f_f.f_k.set({enabled:f_d})});}),f_l=f_e.prototype;f_l.wireUi=function(){var f_f=this;if(!f_f.isWired){var f_m=f_f.get('isPrivate'),f_n=f_f.get('productId'),f_o=f_f.get('productTypeDisplayName'),f_p=f_f.callInherited('ensureLoggedIn');f_f.wireNodeEvent('rateItLink','onclick',function(){f_p({lluser:1,callback:function(){f_f.callInherited('useDialog')({component:{name:'search/dialog/rateIt'},widgetClassName:'Zazzle.DialogRateIt',widgetProperties:{name:'dialogRateIt',productId:f_n,index:f_f.get('index')},
submitHandler:function(){}});}});return f_d;});f_a.prototype.wireUi.call(f_f);}};return f_e;}});

Uize.module({name:'Uize.Date',builder:function(){var _a=function(){};var _b={ms:1,seconds:1000,minutes:60000,hours:3600000,days:86400000,weeks:604800000,months:2629743840,years:31556926080};var _c=_a.convert=function(_d,_e,_f){return _d*_b[_e+'']/_b[_f+''];};var _g=_a.resolve=function(_h){return _h?(typeof _h=='string'?_a.fromIso8601(_h):_h):new Date;};_a.toIso8601=function(_h){return((_h=_g(_h)).getFullYear()+'-'+('0'+(_h.getMonth()+1)).slice(-2)+'-'+('0'+_h.getDate()).slice(-2));};_a.fromIso8601=function(_i){var _j=_i.split('-'),_h=new Date;_h.setFullYear(_j[0]);_h.setDate(1);_h.setMonth(_j[1]-1);_h.setDate(_j[2]);_h.setHours(0,0,0,0);return _h;};_a.toPretty=function(_h){_h=_g(_h);var _k=_h.getDate(),_l=_k%10,_m=(_l>3||Math.floor(_k/10)%10==1)?'th':['th','st','nd','rd'][_l];return(_n[_h.getDay()]+', '+_k+_m+' '+_o[_h.getMonth()]+' '+_h.getFullYear());};_a.isLeapYear=function(_p){return _p%4==0&&(_p%100!=0||_p%400==0);};_a.getDaysInMonth=function(_q,_p){
return _q==1?(_a.isLeapYear(_p)?29:28):(30+((2773>>_q)&1));};_a.isRecent=function(_h,_r){return Math.round(_c(new Date-_g(_h),'ms','days'))<=_r;};var _n=_a.dayNames=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],_o=_a.monthNames=['January','February','March','April','May','June','July','August','September','October','November','December'];return _a;}});

Uize.module({name:'Uize.Widget.Calendar',required:['Uize.Node','Uize.Widget.Button','Uize.Date'],builder:function(c_a){var c_b=true,c_c=false,c_d=null,c_e=Uize.Node,c_f=Uize.Widget,c_g=Uize.Date,c_h=c_g.dayNames,c_i=c_g.monthNames;var c_j=c_a.subclass(null,function(){var c_k=this,c_l=c_k.c_l;c_k.c_m=c_k.c_n('nextMonth',function(){c_k.nextMonth();});c_k.c_o=c_k.c_n('previousMonth',function(){c_k.previousMonth();});c_k.c_p=c_k.c_n('nextYear',function(){c_k.nextYear();});c_k.c_q=c_k.c_n('previousYear',function(){c_k.previousYear();});c_k.c_r=c_l.getFullYear();c_k.c_s=c_l.getMonth();}),c_t=c_j.prototype;c_t.c_n=c_f.Button.addChildButton;c_t.nextMonth=function(){this.set({c_s:this.c_s+1});};c_t.previousMonth=function(){this.set({c_s:this.c_s-1});};c_t.nextYear=function(){this.set({c_r:this.c_r+1});};c_t.previousYear=function(){this.set({c_r:this.c_r-1});};c_t.updateUi=function(){var c_k=this,c_l=c_k.c_l;if(c_k.isWired){var c_u='<table class="calendarGrid" cellpadding="0" cellspacing="0"><tr>',
c_v=new Date(c_k.c_r,c_k.c_s,1),c_w=c_v.getDay(),c_x=0,c_y=c_g.getDaysInMonth(c_k.c_s,c_k.c_r),c_z=new Date(c_v),c_A=c_k.get('idPrefix');c_z.setDate(c_z.getDate()+c_y);if(c_k.c_o)c_k.c_o.set({enabled:(c_k.c_B.start==null||c_v>c_k.c_B.start)});if(c_k.c_m)c_k.c_m.set({enabled:(c_k.c_B.end==null||c_z<c_k.c_B.end)});for(var i=0;i<7;i++){c_u+='<th title="'+c_h[i]+'">'+c_h[i].charAt(0)+'</th>';}c_u+='</tr><tr>';if(c_w>0){c_u+='<tr>';for(var i=0;i<c_w;i++)c_u+='<td></td>';}for(var i=c_w;i<c_y+c_w;i++){var c_C=i-c_w+1,c_D=new Date(c_k.c_r,c_k.c_s,c_C),c_E=c_k.c_r==c_l.getFullYear()&&c_k.c_s==c_l.getMonth()&&c_C==c_l.getDate();if(i%7==0)c_u+='<tr>';if((!c_k.c_B.start||c_D>=c_k.c_B.start)&&(!c_k.c_B.end||c_D<c_k.c_B.end)){c_u+='<td'+(c_E?' class="selected"':'')+'><a href="javascript://" id="'+c_A+'-day'+c_C+'">'+c_C+'</a></td>';}else{c_u+='<td class="'+(c_E?'selected ':'')+'grayed">'+c_C+'</td>';}c_u+='</td>';if(i%7==6)c_u+='</tr>';}if((c_w+c_y)%7!=6){for(var i=(c_w+c_y)%7;i<6;i++)c_u+='<td></td>';c_u+='</tr>'}
c_u+='</table>';c_k.setNodeInnerHtml('grid',c_u);c_k.setNodeInnerHtml('month',c_i[c_k.c_s]);c_k.setNodeInnerHtml('year',c_k.c_r);function c_F(c_G){c_k.wireNodeEvent('day'+c_G,'onclick',function(){c_k.set({c_l:new Date(c_k.c_r,c_k.c_s,c_G)})});}for(var c_G=1;c_G<=c_y;c_G++)c_F(c_G);}};function c_H(){var c_k=this;if(c_k.isWired){for(var c_G=1,c_y=c_g.getDaysInMonth(c_k.c_s,c_k.c_r);c_G<=c_y;c_G++){var c_I='day'+c_G;c_k.unwireNodeEventsByMatch(c_I);c_k.flushNodeCache(c_I);}c_k.updateUi();}}c_j.registerProperties({c_J:{name:'firstDayOfWeek',value:0},c_s:{name:'month',conformer:function(c_l){var c_K=Math.floor(c_l/12);if(c_K)this.set({c_r:this.c_r+c_K});return((c_l%12)+12)%12;},onChange:c_H},c_B:{name:'validDateRange',value:{start:null,end:null}},c_l:{name:'value',value:new Date,onChange:c_H},c_r:{name:'year',onChange:c_H}});return c_j;}});
Uize.module({name:'Zazzle.Page.Search.Full',required:['Zazzle.GridCell.Product.Full','Uize.Widget.Calendar'],builder:function(f_a){var f_b=f_a.subclass(null,function(){var f_c=this;var f_d={},f_e=f_c.getInherited('env').params.day,f_f=f_c.f_f;if(f_e)f_d.value=new Date(f_e);if(f_f)f_d.validDateRange=f_f;f_c.f_g=f_c.addChild('calendar',Uize.Widget.Calendar,f_d);}),f_h=f_b.prototype;f_h.wireUi=function(){var f_c=this;if(!f_c.isWired){f_c.f_g.wire('Changed.value',function(){var f_i=f_c.getInherited('env').params,f_j=f_c.f_g.get('value');f_i.day=''+(f_j.getMonth()+1)+'/'+f_j.getDate()+'/'+f_j.getFullYear();f_i.pg='1';location.href=f_c.callInherited('wwwSearchPag')(f_i,'pd/awards');});f_a.prototype.wireUi.call(f_c);}};f_b.itemWidgetClass=Zazzle.GridCell.Product.Full;f_b.registerProperties({f_f:'validDateRange'});return f_b;}});

