var cpArray=[];
function PropertyInfo(v,i,u,s){this.value=v;this.img=i;this.url=u;var p=new DOMParser();var d=p.parseFromString("<template>"+s+"</template>","text/xml");this.desc=d.firstChild;}
function CompareProperties(m,n,c,sc,pc,bc,nc,cb,tcb,bcb){this.inited=false;this.max=m;this.name=n;this.pCss=c;this.sCss=sc;this.pContainer=pc;this.bContainer=bc;this.nContainer=nc;this.checkBox=cb;this.topCB=tcb;this.bottomCB=bcb;this.props=[];cpArray[cpArray.length]=this;}
CompareProperties.prototype.Init=function(){if(!this.inited){this.pContainer=GetElem(this.pContainer);this.bContainer=GetElem(this.bContainer);this.nContainer=GetElem(this.nContainer);this.checkBox=eval("document.forms[0]."+this.checkBox);this.topCB=GetElem(this.topCB);this.bottomCB=GetElem(this.bottomCB);this.inited=true;}}
CompareProperties.prototype.Show=function(){ShowWin("CompareWin","/Popups/CompareProperties.aspx",750,670);}
CompareProperties.prototype.Add=function(v,i,u,d,c){this.Init();if(this.props.length<this.max){this.props[this.props.length]=new PropertyInfo(v,i,u,d);if(c&&this.checkBox){if(this.checkBox.length){for(var i=0;i<this.checkBox.length;i++)if(this.checkBox[i].value==v)this.checkBox[i].checked=true;}else if(this.checkBox.value==v)this.checkBox.checked=true;}this.Update();this.ToggleLayers(true);}if(this.props.length>=this.max)this.EnableCheckBoxes(false);}
CompareProperties.prototype.Toggle=function(e){this.Init();if(e.checked){this.Add(e.value,e.getAttribute("img"),e.getAttribute("url"),MakeXMLSafe(e.getAttribute("desc")),false);}else{for(var i=0;i<this.props.length;i++)if(this.props[i].value==e.value){this.Remove(i);break;}this.EnableCheckBoxes(true);}}
CompareProperties.prototype.EnableCheckBoxes=function(b){if(!this.checkBox)return;if(this.checkBox.length){for(var i=0;i<this.checkBox.length;i++)if(!this.checkBox[i].checked)this.checkBox[i].disabled=!b;}else if(!this.checkBox.checked)this.checkBox.disabled=!b;}
CompareProperties.prototype.Remove=function(n){this.Init();if(this.checkBox){if(this.checkBox.length){for(var i=0;i<this.checkBox.length;i++){if(this.checkBox[i].value==this.props[n].value)this.checkBox[i].checked=false;this.checkBox[i].disabled=false;}}else if(this.checkBox.value==this.props[n].value){this.checkBox.checked=false;this.checkBox.disabled=false;}}for(var i=0,j=0;j<this.props.length;i++,j++){if(i==n)j++;if(i!=j)this.props[i]=this.props[j];}this.props.length--;if(this.props.length==0)this.ToggleLayers(false);this.Update();}
CompareProperties.prototype.RemoveAll=function(){this.Init();if(!confirm("Are you sure you want to remove all of the selected properties?"))return;this.props=[];ClearContainer(this.pContainer);SetDisplay(this.pContainer,false);document.cookie="CompareProperties=;Expires=Thu,01-Jan-70 00:00:01 GMT";if(this.checkBox.length){for(var i=0;i<this.checkBox.length;i++)this.checkBox[i].disabled=this.checkBox[i].checked=false;}else this.checkBox.disabled=this.checkBox.checked=false;this.ToggleLayers(false);}
CompareProperties.prototype.ToggleLayers=function(b){SetDisplay(this.bContainer,b);SetDisplay(this.nContainer,!b);SetDisplay(this.topCB,b);SetDisplay(this.bottomCB,b);}
CompareProperties.prototype.Update=function(){this.Init();ClearContainer(this.pContainer);var s="";SetDisplay(this.pContainer,this.props.length);for(var i=0;i<this.props.length;i++){if(s.length>0){s+="|";this.pContainer.innerHTML+="<table class=\""+this.sCss+"\"><tr><td class=\"Top\"></td></tr></table>";}s+=this.props[i].value;this.pContainer.innerHTML+="<table class=\""+this.pCss+"\"><tr><td class=\"Top\"><img onclick=\"self.location.href='"+this.props[i].url+"';\" src=\""+this.props[i].img+"\" width=\"48\" height=\"36\" class=\"ListingSumImgBorder Pointer\"></td><td class=\"ComparePanelText Top\" style=\"padding:0px 5px 5px 5px;\" width=\"100%\">"+SerializeXML(this.props[i].desc)+"</td><td class=\"Top\"><div class=\"RemoveButton Button\"><a href=\"javascript:"+this.name+".Remove("+i+");\" title=\"Remove\"></a></div></td></tr></table>";}document.cookie="CompareProperties="+s;}