var a;function virtualpaginate(b,d,e){e=typeof e=="undefined"?"div":e;this.pieces=virtualpaginate.collectElementbyClass(b,e);this.chunksize=typeof d=="undefined"?1:d>0&&d<this.pieces.length?d:this.pieces.length;this.pagecount=Math.ceil(this.pieces.length/this.chunksize);this.showpage(-1);this.currentpage=0;this.showpage(this.currentpage)}
virtualpaginate.collectElementbyClass=function(b,d){b=new RegExp("(^|\\s+)"+b+"($|\\s+)","i");var e=[];d=document.getElementsByTagName(d);for(var c=0;c<d.length;c++)if(typeof d[c].className=="string"&&d[c].className.search(b)!=-1)e[e.length]=d[c];return e};a=virtualpaginate.prototype;
a.showpage=function(b){for(var d=this.pieces.length,e=b*this.chunksize,c=e+this.chunksize-1,f=0;f<d;f++)this.pieces[f].style.display=f>=e&&f<=c?"block":"none";this.currentpage=parseInt(b);if(this.cpspan)this.cpspan.innerHTML="Page "+(this.currentpage+1)+"/"+this.pagecount;if(this.previouslink)if(this.previouslink&&this.currentpage==0&&this.previouslink.style.display=="block")this.previouslink.style.display="none";else if(this.currentpage>0&&this.previouslink.style.display!="block")this.previouslink.style.display=
"block";if(this.nextlink)if(this.currentpage==this.pagecount-1&&this.nextlink.style.display=="block")this.nextlink.style.display="none";else if(this.currentpage<this.pagecount-1&&this.nextlink.style.display!="block")this.nextlink.style.display="block"};
a.paginate_build_selectmenu=function(b,d){var e=this;d=d||[];this.selectmenupresent=1;for(var c=0;c<this.pagecount;c++)b.options[c]=typeof d[c]!="undefined"?new Option(d[c],c):new Option("Page "+(c+1)+" of "+this.pagecount,c);b.selectedIndex=this.currentpage;b.onchange=function(){e.showpage(this.selectedIndex)}};
a.paginate_build_regularlinks=function(b){for(var d=this,e=0;e<b.length;e++){var c=b[e].getAttribute("rel");if(c=="previous"||c=="next"||c=="first"||c=="last"){b[e].onclick=function(){d.navigate(this.getAttribute("rel"));return false};if(c=="previous")this.previouslink=b[e];else if(c=="next")this.nextlink=b[e]}}this.previouslink.style.display="none";this.nextlink.style.display="block"};
a.paginate_build_flatview=function(b,d){var e=this,c='<ul class="list_Pagination">';d=d||[];for(var f=0;f<this.pagecount;f++){c+=f==0?'<li class="li_First">':f==this.pagecount-1?'<li class="li_Last">':"<li>";c+=typeof d[f]!="undefined"?'<a href="#flatview" rel="'+f+'">'+d[f]+"</a>":'<a href="#flatview" rel="'+f+'">'+(f+1)+"</a>";c+="</li>"}c+="</ul>";b.innerHTML=c;this.flatviewlinks=b.getElementsByTagName("a");for(f=0;f<this.flatviewlinks.length;f++)this.flatviewlinks[f].onclick=function(){e.flatviewlinks[e.currentpage].className=
"";this.className="selected";e.showpage(this.getAttribute("rel"));return false};this.flatviewlinks[this.currentpage].className="selected";this.flatviewpresent=true};a.paginate_build_cpinfo=function(b){this.cpspan=b;b.innerHTML="Page "+(this.currentpage+1)+"/"+this.pagecount};
a.buildpagination=function(b,d){b=document.getElementById(b);if(this.chunksize==this.pieces.length)b.style.visibility="hidden";else{b.getElementsByTagName("select").length>0&&this.paginate_build_selectmenu(b.getElementsByTagName("select")[0],d);b.getElementsByTagName("a").length>0&&this.paginate_build_regularlinks(b.getElementsByTagName("a"));for(var e=b.getElementsByTagName("span"),c=0;c<e.length;c++)if(e[c].className=="flatview")this.paginate_build_flatview(e[c],d);else e[c].className=="paginateinfo"&&
this.paginate_build_cpinfo(e[c]);this.paginatediv=b}};
a.navigate=function(b){if(this.flatviewpresent)this.flatviewlinks[this.currentpage].className="";if(b=="previous")this.currentpage=this.currentpage>0?this.currentpage-1:this.currentpage==0?this.pagecount-1:0;else if(b=="next")this.currentpage=this.currentpage<this.pagecount-1?this.currentpage+1:0;else if(b=="first")this.currentpage=0;else if(b=="last")this.currentpage=this.pieces.length-1;this.showpage(this.currentpage);if(this.selectmenupresent)this.paginatediv.getElementsByTagName("select")[0].selectedIndex=this.currentpage;
if(this.flatviewpresent)this.flatviewlinks[this.currentpage].className="selected"};
function updatePrice(){$$("span.txt_OldPrice").each(function(b){try{var d=b.getAttribute("prodcode");d.length>0&&new Ajax.Updater(b,"/dati/prodotti/prezzi/"+d+"_web.html",{method:"get",insertion:"bottom"})}catch(e){}});$$("span.txt_NewPrice").each(function(b){try{var d=b.getAttribute("prodcode");if(d.length>0){b.update("&euro;&nbsp;");new Ajax.Updater(b,"/dati/prodotti/prezzi/"+d+".html",{method:"get",insertion:"bottom"})}}catch(e){}})};
