var Compare=new Object();Compare={add:function(E,C,D){var A=0;for(var B in this.data){if(typeof(this.data[B])=="function"){continue}if(this.data[B].t!=D){alert(goods_type_different.replace("%s",C));return}A++}if(this.data[E]){alert(exist.replace("%s",C));return}else{this.data[E]={n:C,t:D}}this.save();this.init()},relocation:function(){if(this.compareBox.style.display!=""){return}var A=Math.max(document.documentElement.scrollTop,document.body.scrollTop);var B=0.2*(A-this.lastScrollY);if(B>0){B=Math.ceil(B)}else{B=Math.floor(B)}this.compareBox.style.top=parseInt(this.compareBox.style.top)+B+"px";this.lastScrollY=this.lastScrollY+B},init:function(){this.data=new Object();var E=document.getCookie("compareItems");if(E!=null){this.data=E.parseJSON()}if(!this.compareBox){this.compareBox=document.createElement("DIV");var C=document.createElement("INPUT");this.compareList=document.createElement("UL");this.compareBox.id="compareBox";this.compareBox.style.display="none";this.compareBox.style.top="200px";this.compareBox.align="center";this.compareList.id="compareList";C.type="button";C.value=button_compare;this.compareBox.appendChild(this.compareList);this.compareBox.appendChild(C);C.onclick=function(){var I=document.getCookie("compareItems");var L=I.parseJSON();var H=document.location.href;H=H.substring(0,H.lastIndexOf("/")+1)+"compare.php";var J=0;for(var K in L){if(typeof(L[K])=="function"){continue}if(J==0){H+="?goods[]="+K}else{H+="&goods[]="+K}J++}if(J<2){alert(compare_no_goods);return}document.location.href=H};document.body.appendChild(this.compareBox)}this.compareList.innerHTML="";var G=this;for(var F in this.data){if(typeof(this.data[F])=="function"){continue}var A=document.createElement("LI");var D=document.createElement("SPAN");D.style.overflow="hidden";D.style.width="100px";D.style.height="20px";D.style.display="block";D.innerHTML=this.data[F].n;A.appendChild(D);A.style.listStyle="none";var B=document.createElement("IMG");B.src="themes/bao/images/drop.gif";B.className=F;B.onclick=function(){document.getElementById("compareList").removeChild(this.parentNode);delete G.data[this.className];G.save();G.init()};A.insertBefore(B,A.childNodes[0]);this.compareList.appendChild(A)}if(this.compareList.childNodes.length>0){this.compareBox.style.display="";this.timer=window.setInterval(this.relocation.bind(this),50)}else{this.compareBox.style.display="none";window.clearInterval(this.timer);this.timer=0}},save:function(){var A=new Date();A.setTime(A.getTime()+99999999);document.setCookie("compareItems",this.data.toJSONString())},lastScrollY:0};
