var messageY=0;function setMousePosition(){var f=$("items");var e=f.cumulativeOffset()[1];var d=document.documentElement.clientHeight;messageY=document.documentElement.scrollTop+document.body.scrollTop+d/2;if(messageY<e){messageY=e+100;}}var Pager=Class.create();Pager.prototype={initialize:function(p,o,i,j,k,l,m,n){this.button={};
this.iconLoader=l;this.searchedItems=k;this.searchContent=$$(p);this.setPagerValues(i);this.prefix_item="page_";this.setcriterions(j);this.label=$(o);this.strings=n;this.pagerValues=i;this.setPagerButtonTexts(m,n);this.setPagerViewAndListeners();},setPagerButtonTexts:function(f,e){try{this.pager_template=new Template($(f).innerHTML,/(^|.|\r|\n)(\__(\w+)__)/);
}catch(d){}try{this.button["first"]=this.pager_template.evaluate({text:e["first"]});this.button["last"]=this.pager_template.evaluate({text:e["last"]});this.button["next"]=this.pager_template.evaluate({text:e["next"]});this.button["prev"]=this.pager_template.evaluate({text:e["prev"]});}catch(d){this.button["first"]="<<";
this.button["last"]=">>";this.button["next"]=">";this.button["prev"]="<<";}},drawPagers:function(){if(this.pagerValues.countPages>1){var f=this.strings.productsFound.replace("{0}",this.pagerValues.countItems);f=f.replace("{1}",this.pageFrom);f=f.replace("{2}",this.pagerValues.countPages);this.label.innerHTML=f;
}else{var d=this.strings.oneProductFound.replace("{0}",this.pagerValues.countItems);this.label.innerHTML=d;}if(this.countPages==1){return;}var e=true;$A(this.searchContent).each(function(a){this.drawPager(a,e);e=false;}.bind(this),this);this.showPagers();},setPagerViewAndListeners:function(){this.drawPagers();
this.setListeners();},drawPager:function(i,h){var j=[];if(h){j["next"]="<span id ='next_page'";j["first"]="<span id ='first_page'";j["previous"]="<span id ='previous_page'";j["last"]="<span id ='last_page'";}else{j["next"]=j["first"]=j["previous"]=j["last"]="<span";}i.innerHTML="";if(this.left>1){i.insert(j["first"]+" class='"+this.prefix_item+"1 column button' onclick='setMousePosition(event)'>"+this.button["first"]+"</span>"+'<span class="space">&nbsp;&nbsp;&nbsp;</span>');
}if(this.pageFrom>1){i.insert(j["previous"]+" class='"+this.prefix_item+""+(this.pageFrom-1)+" column button' onclick='setMousePosition(event)'>"+this.button["prev"]+"</span>"+'<span class="space">&nbsp;&nbsp;&nbsp;</span>');}var g;for(var f=this.left;f<=this.right;f++){if(f==this.right){g='<span class="column bullet">&nbsp;&nbsp;&nbsp;</span>';
}else{g='<span class="column bullet">&nbsp;&bull;&nbsp;</span>';}if(f==this.pageFrom){i.insert('<span class="'+this.prefix_item+""+f+'  column current">'+f+"</span>"+g);}else{i.insert('<span class="'+this.prefix_item+""+f+" column\" onclick='setMousePosition(event)'>"+f+"</span>"+g);}}if(this.pageFrom<this.countPages){i.insert(j["next"]+" class='"+this.prefix_item+""+(this.pageFrom+1)+" column button' onclick='setMousePosition(event)'>"+this.button["next"]+"</span>"+'<span class="space">&nbsp;&nbsp;&nbsp;</span>');
}if(this.right<this.countPages){i.insert(j["last"]+" class='"+this.prefix_item+""+this.countPages+" column button' onclick='setMousePosition(event)'>"+this.button["last"]+"</span>");}},reDrawPagers:function(b){$A(this.searchContent).each(function(d,a){(d).select(".current")[0].className="";}.bind(this),this);
},setcriterions:function(b){this.style=b.style;this.category=b.category;},setPagerValues:function(b){if(b!=null){this.left=b.left;this.right=b.right;this.pageFrom=b.pageFrom;this.countPages=b.countPages;this.countItems=b.countItems;}else{this.left=1;this.right=1;this.pageFrom=1;this.countPages=1;this.countItems=1;
}},setListeners:function(){$A(this.searchContent).each(function(b){$A(b.childElements()).each(function(a){if($(a).className.indexOf("page_")!=-1){$(a).observe("click",function(f){var e=parseInt(a.className.replace(this.prefix_item,""));this.pageFrom=e;this.searchItemsByPagerParams();}.bind(this),this);
}}.bind(this),this);}.bind(this),this);},hidePagers:function(){$A(this.searchContent).each(function(b){b.parentNode.style.display="none";});},showPagers:function(){$A(this.searchContent).each(function(b){b.parentNode.style.display="";});},searchItemsByPagerParams:function(){this.pagerItemAjaxListener();
},pagerItemAjaxListener:function(){var b="pageFrom="+this.pageFrom+"&ajax=true";if(this.style!="null"){b+="&style="+this.style;}if(this.category!="null"){b+="&category="+this.category;}this.infoPageAjax=new Ajax.Request(this.iconLoader.searchUrl,{parameters:b,onComplete:function(a){this.processReceivedData(a);
this.iconLoader.messagesManager.hide();}.bind(this),onCreate:function(){this.iconLoader.messagesManager.setText($(this.iconLoader.messages["loading"]).innerHTML);this.iconLoader.messagesManager.show();}.bind(this)});},processReceivedData:function(c){var d=[];d=c.responseText.evalJSON();this.searchedItems=d[0];
this.setPagerValues(d[1]);if(this.countPages>1){this.setPagerViewAndListeners();}else{this.hidePagers();}this.iconLoader.setSearchedIcons(this.searchedItems);this.iconLoader.drawSearchedIcons();this.iconLoader.setNewHash(this.searchedItems);this.iconLoader.mergeIcons(true,"icon",true);}};var MessagesManager=Class.create();
MessagesManager.prototype={initialize:function(b){this.template=$(b);this.templateText=$(b+"_text");},setText:function(b){this.templateText.update(b);},show:function(){setMousePosition();$(this.template).setOpacity(1);$(this.template).style.top=messageY+"px";$(this.template).show();},hide:function(b){if(arguments.length==0){b=2;
}Effect.Fade($(this.template),{duration:b});}};var ColumnManager=Class.create();ColumnManager.prototype={initialize:function(){this.column=$$(".main_indent")[0];Event.observe(window,"resize",function(){}.bindAsEventListener(this));}};var loader;var IconLoader=Class.create();IconLoader.prototype={initialize:function(e,f,d){this.searchType=e;
this.searchContent=$(f);this.searchUrl=d;this.ajax={};this.searchedIcons=[];loader=this;},setMessagesManager:function(b){this.messagesManager=b;},setMessages:function(b){this.messages=b;},mergeAllIcons:function(m,n,r){var e=false;var j=2;for(var p=0;p<n.length;p++){e=false;try{var o=$(m+n[p].id);for(var q=0;
q<r.length;q++){try{if(n[p].id==r[q].id){o.style.filter="alpha(opacity="+j+"0)";o.style.opacity="0."+j;e=true;break;}}catch(i){}}if(!e){o.style.opacity="1";o.style.filter="alpha(opacity=100)";}}catch(i){}}},mergeIcons:function(p,o,l){if(p){var e=cart.cartIcons;cart.cartIcons=cart.cartIcons.compact();
if(l||cart.cartIcons.length==0){this.mergeAllIcons(o,loader.searchedIcons,e);}for(var q=0;q<cart.cartIcons.length;q++){if(l){loader=this;if(loader==null){loader=cart.getLoader("0");}}else{var k=cart.cartIcons[q];var r=k.packName;loader=cart.getLoader(r);}this.mergeAllIcons(o,loader.searchedIcons,e);}cart.setCartEmpty();
}try{var m=$("cart_count_items");if(cart.cartIcons.size()>=19||cart.cartIcons.size()==0){$("shopping_cart_row").style.display="none";}else{$("shopping_cart_row").style.display="block";}m.update("("+cart.cartIcons.size()+")");}catch(n){}},setPager:function(b){this.pager=new Pager(b.pager_class,b.totalLabelId,b.pager_values,b.pager_criterions,this.searchedIcons,this,b.pager_template,b.pager_texts);
},setTemplates:function(f,e,g){try{this.icon_template=new Template($(f).innerHTML,/(^|.|\r|\n)(\_(\w+)_)/);}catch(h){}try{this.tooltip_template=new Template($(e).innerHTML,/(^|.|\r|\n)(\_(\w+)_)/);}catch(h){}try{this.search_params_template=new Template($(g).innerHTML,/(^|.|\r|\n)(\_(\w+)_)/);}catch(h){}},showNoMoneyContent:function(d,c){if(c){this.block=new Element("div",{style:"position:absolute; z-index:100;display:none;padding:0;margin:0; background:white;top:10px;left:10px"});
document.body.appendChild(this.block);this.block.update($(d).innerHTML);Effect.Appear(this.block);}},searchItemsByParams:function(){this.setSearchParams();this.pager.setcriterions({style:$F(this.stylesId),category:$F(this.categoriesId)});this.pager.pageFrom=1;this.pager.searchItemsByPagerParams();},staticSearchItemsByParams:function(){$(this.stylesId).form.submit();
},processAndViewResult:function(){this.drawSearchedIcons();},setSearchedIcons:function(b){this.searchedIcons=b;},drawSearchedIcons:function(e,f,d){if(arguments.length>0){this.drawIcons(this.searchedIcons,this.searchContent,e,f,d);}else{this.drawIcons(this.searchedIcons,this.searchContent,false,true,false);
}},drawIcons:function(h,f,g,i,j){$(f).update("");$A(h).each(function(a){this.drawIcon(a,f,"icon",g,j);if(i){this.setIconDraggable(a,"icon");}}.bindAsEventListener(this));},drawIcon:function(n,l,q,m,e){var r={id:q+n.id,src:n.src,alt:n.alt,title:n.title};l.insert({bottom:this.icon_template.evaluate(r)});
if(m){this.removeBuyIconWidget(n,q);}else{try{$("buyicon"+n.id).observe("click",function(){cart.addIconToShoppingCart(r.id,null,null);}.bindAsEventListener(this),this);}catch(o){}}try{var s=$$("#"+q+n.id+" .info")[0];var p={productNumber:n.productNumber,size:n.size,software:n.software,format:n.format};
var t=this.tooltip_template.evaluate(p);new ToolTip(s,t,{className:"tooltip"});}catch(o){}if(e){this.drawRemoveIconWidget(n,q);}},drawRemoveIconWidget:function(e,g,h){var f=$$("#"+g+e.id+" .remove")[0];f.style.visibility="visible";Event.observe(f,"click",function(){cart.removeIconFromShoppingCart(e,g,h);
}.bindAsEventListener(this),this);},removeBuyIconWidget:function(e,d){try{$$("#"+d+e.id+" .buy")[0].style.display="none";}catch(f){}},setBuyIcon:function(e,f){if(f){try{$(e).observe("click",function(){this.messagesManager.setText($(this.messages["noMoney"]).innerHTML);this.messagesManager.show();this.messagesManager.hide(4);
}.bind(this));}catch(d){}}},setIconDraggable:function(d,c){new Draggable($(c+d.id),{revert:true,reverteffect:function(b,g,h){var a=Math.sqrt(Math.abs(g^2)+Math.abs(h^2))*0.02;new Effect.Move(b,{x:-h,y:-g,duration:a,queue:{scope:"_draggable",position:"end"}});},endeffect:function(a){}});},setParamsListeners:function(d,c){this.stylesId=$(d);
this.categoriesId=$(c);},setSearchParamsParentDiv:function(b){this.searchParamsParentDiv=$(b);},setNewHash:function(c){for(var d=0;d<c.length;d++){searchedIconsArray.set("'"+c[d].id+"'",c[d].packName);}}};var TransactionStatusRefresher=Class.create({initialize:function(h,g,e,f){this.operationId=h;this.timeout=g;
this.status=f;this.url=e;this.timer={};this.startTimer();},setInitialText:function(b){if((b=="Purchases Approved"||b=="Subscription")&&$("orderInfoText")){this.setVisibleElement(false,"orderInfoText");}},startTimer:function(){var b=1000*this.timeout;this.timer=setInterval(function(){this.onTimer();}.bind(this),b);
},onTimer:function(){new Ajax.Request(this.url,{method:"post",parameters:{"operationId":this.operationId,"status":this.status},onComplete:function(b){this.onRequest(b.responseText.evalJSON());}.bindAsEventListener(this)});},onRequest:function(b){if(b["error"]!=null){window.location="/";}else{if(b["status"]!=this.status){this.status=b["status"];
this.setInitialText(this.status);if(b["view"]!=null){$(this.operationId).update(b["view"]);}if(b["topText"]!=null){$("topText").update(b["topText"]);}if(b["bottomText"]!=null){$("bottomText").update(b["bottomText"]);}}if((b["isContinue"]!=null)&&(b["isContinue"]=="false")){clearInterval(this.timer);}}},setVisibleElement:function(c,d){if(c){document.getElementById(d).style.display="block";
}else{document.getElementById(d).style.display="none";}}});