var CookieHandler = function(cookie_name, display_page, expiry, type){
	this._cookie_name = cookie_name;
	this._display_page = display_page;
	this._expiry = expiry;
	this._type = type;
	
	this.Display = function(){
		if(CookiesEnabled()){
			location.href = this._display_page;
		}
	}
	
	this.Clear = function(){
		$.Jookie.Delete(this._cookie_name);
		location.href = this._display_page;
	}
	
	this.Add = function(click_obj, id){
		if(CookiesEnabled()){
			$.Jookie.Initialise(this._cookie_name, this._expiry);
			
			//id must be added to cookie
			if(click_obj.checked === true){
				$.Jookie.Set(this._cookie_name, id, '');
				alert(id + ' added to ' + this._type);
			//id must be removed from cookie
			} else if(click_obj.checked === false){
				$.Jookie.Unset(this._cookie_name, id);
				alert(id + ' removed from ' + this._type);
			} else {
				$.Jookie.Set(this._cookie_name, id, '');
				alert(id + ' added to ' + this._type);
			}
		} else {
			click_obj.checked = false;
			alert('Not activated: ' + this._type);
		}
	}
		
	this.Remove = function(id){
		$.Jookie.Initialise(this._cookie_name, this._expiry);
		$.Jookie.Unset(this._cookie_name, id);
		location.href = this._display_page;
	}
}

var CompareCookie = new CookieHandler('radiant_compare', '?page=Compare', -1, 'compare');
var WishlistCookie = new CookieHandler('radiant_wishlist', '?page=Wishlist', 43200, 'wishlist');
