function MyCookie()
{
	// them 1 cookie vao bo nho. e.g arguments --> add('huy=123','bao=345');
    this.add = function()     
    {
         len = arguments.length
         for(i=0;i<len;i++) document.cookie=arguments[i]+";";
    }
    
    this.remove = function(){/* e.g arguments 'huy=123'*/       
        date = new Date();
        len = arguments.length
        for(i=0;i<len;i++) document.cookie =arguments[i]+";expires=" + date.toGMTString();         
    }
    /**
    * Lay gia tri cookie boi khoa ; e.g arguments get('huy')
    */
    this.get = function(v)    
    {        
        aCookie = document.cookie.split(';')//alert(aCookie.length)
        for(i=0;i<aCookie.length;i++)
        {
            var aCrumb = aCookie[i].split("=");           
            if (v == aCrumb[0].trim()) 
            return (aCrumb[1]);            
        }
    }
    /**
    * Lay gia tri cookie boi khoa ; e.g arguments get('huy')
    */
    this.getAll = function()    
    {        
        aCookie = document.cookie.split(';')//alert(aCookie.length)
    	aArray = new Object();    	
        for(i=0;i<aCookie.length;i++)
        {
            var aCrumb = aCookie[i].split("=");           
            aArray[aCrumb[0].trim()] = aCrumb[1].trim();
        }
        return aArray;
    }
    /* debug */
    this.debugGetAll = function()
    {
        alert(document.cookie);
    }
    this.removeAll = function() {
        date = new Date();
        len = document.cookie.split(';')
        for(i=0;i<len.length;i++) document.cookie =len[i]+";expires=" + date.toGMTString(); 
    }
    
    //this.trimF = function(v){while(v.indexOf(' ')!=-1)v=v.substr(v.indexOf(' ')+1,v.length);return v;}
}
/* remove all spaces first*/
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
myCookie= new MyCookie();
