function MediasitePlayerCookie()
{
	this.name = "MediasitePlayerOptions";	
    this.expires = null;
	this.path = "/";
	
	this.values = new Object();
	this.valueDelimiter = "&";

	this.SetExpires = function(value)
	{
		this.expires = value;
	}
	
	this.SetValue = function(name, value)
	{
	    this.ReadCookieData();
	    this.values[name] = value;
	    this.WriteCookieData();
	}
	
    this.SetBoolValue = function(name, isTrue)
	{
	    this.ReadCookieData();
		if (isTrue)
		{
			this.values[name] = "true";
		}
		else
		{
			this.values[name] = "false";
		}
        this.WriteCookieData();
	}
	    
	this.GetValue= function(name)
	{
	    this.ReadCookieData();
	    return this.values[name];
	}

 	this.GetNumberValue = function(name, def)
	{
		this.ReadCookieData();
		if (this.values[name] == null)
		{
			return def;
		}
		
		return Number(this.values[name]);
	}
   
    this.GetBoolValue = function(name, def)
	{
	    this.ReadCookieData();
		if (this.values[name] == null)
		{
			return def;
		}
		
		if (this.values[name] == "true")
		{
			return true;
		}
		else
		{
			return false;
		}
	}
    
    this.WriteCookieData= function()
    {
		if (this.expires == null)
		{
			var now = new Date();
	        this.expires =  new Date(now.getFullYear()+1, now.getMonth(), now.getDate());			
		}
		var cookieData ="";
        for(var key in this.values)
        {
            cookieData += key;
            cookieData += "=";
            cookieData += escape(this.values[key]);
            cookieData += this.valueDelimiter;
        }
        cookieData = cookieData.substring(0,cookieData.length-1)
	    				
		var newCookie = this.name + "=" + cookieData +
		((this.path) ? "; path=" + this.path : "") +
		((this.expires) ? "; expires=" + this.expires.toGMTString() : "");
		
		document.cookie = newCookie;
    
    }
    	
	this.ReadCookieData= function()
	{
		if (document.cookie)
		{
			var begin = document.cookie.indexOf(this.name + "=");
			if (begin != -1)
			{
				begin += this.name.length + 1;
				var end = document.cookie.indexOf(";",begin);
				if (end == -1)
				{
					end = document.cookie.length;
				}
				
				var rawCookie = document.cookie.substring(begin,end);
				var entries = rawCookie.split(this.valueDelimiter);
				
				for(var i=0;i<entries.length;i++)
				{
				    var parts = entries[i].split("=");
				    
				    if(parts.length=2)
				    {
				        this.values[parts[0]] = unescape(parts[1]);				    
				    }
				}							
			}
		}
	}

	
}

