
function ProductComparison(){

   this.store=new cookieobj;
   
   this.DoSave=function (v){

       var s=this.DoLoad();
       if( s.length>0 ){
            var a=s.split(",");
            var l=a.length;  
            s="";
            for( var i=0;i<l;i++ ){  if( a[i]!="" && a[i]!=v  ) s+=a[i]+"," }
            s+=v+",";
       }else s=v;
      this.store.SetCookie("PComparison",s); 
   }
   this.DoLoad=function (){
       var o=this.store.GetCookie("PComparison");
       if( o!="undefined" ) return o;
       else return ""; 
   }
   this.DoDelete=function (v){

       var s=this.DoLoad();
       if( s.length>0 ){
            var a=s.split(",");
            var l=a.length;
            s="";
            for( var i=0;i<l;i++ ){  if( a[i]!="" && a[i]!=v  ) s+=a[i]+"," }
       }
       this.store.SetCookie("PComparison",s);
   }
   this.DoClear=function(){ this.store.DelCookie("PComparison"); }	
}

function cookieobj(){

   this.SetCookie=function(sName, sValue){
       date = new Date();
       document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 2020 23:59:59 GMT; path=/;";
   }
   this.GetCookie=function (sName){  
        // cookies are separated by semicolons
        var aCookie = document.cookie.split("; ");
        var m="";
        for (var i=0; i < aCookie.length; i++){
            // a name/value pair (a crumb) is separated by an equal sign
            var aCrumb = aCookie[i].split("=");
            if (sName == aCrumb[0]){ 
                if( aCrumb[1]=="undefined" ) return "";   	
                return unescape( aCrumb[1] );
            }  
        }
        // a cookie with the requested name does not exist
        return "";
   }
   this.DelCookie=function (sName){
          document.cookie =sName + "=   ; expires=Fri, 31 Dec 1970 23:59:59 GMT; path=/;";
   }

}
/*
 a=new ProductComparison;
 a.DoClear(); 
 a.DoSave(1);
 a.DoSave(2);
 a.DoSave(1);
 alert(a.DoLoad());
*/
