/*
	Extention for jQuery Cookie
	
	add 26/12/2007 16:26:40
	- function display cookie list
		return value in array cookieValue['name'] = value
	- $.cookie.list() = return all cookies
	- $.cookie.list('^xx') = return all cookie's name begin with ‘xx’
	- $.cookie.list('$xx') = return all cookie's name end with ‘xx’
  USE WITH CAUTION:
	- $.cookie.list('???',true) = return all cookie's like above, but convert result to object (if it's json)
	
*/

jQuery.cookie.list = function(name)
{
	var cookieValue = new Array();
	name = name || '';
	if (document.cookie && document.cookie != '')
	{
		$.each(document.cookie.split(';'), function (i, cookie)
		{
			var n = name.substr(1);
			var i = n.length || 0;
				
			cookie = $.trim(cookie);
			if(cookie.substr(0,2) != '__' && cookie.substr(0,9) != 'PHPSESSID' 
				&& cookie.substr(0,2) != 'CP' && cookie.substr(0,5) != 'style')
			{
				var tmp = cookie.split('=');
				var add = false;
				
				if(name.substr(0,1) == '^' && i > 0)
				{
					if(tmp[0].substr(0, i) == n)
						add = true;
				}
				else if(name.substr(0,1) == '$' && i > 0)
				{
					if(tmp[0].substr(-i) == n)
						add = true;
				}
				else
					add = true;
				
				if(add)
					cookieValue[tmp[0]] = decodeURIComponent(tmp[1]);
			  if(arguments[1])
          cookieValue[tmp[0]] = eval( '('+cookieValue[tmp[0]]+')' );

			}
		});
		
		return cookieValue;
	}
	return false;
};

jQuery.cookie.clear = function(name)
{
var c = $.cookie.list(name);
  for(var v in c)
    $.cookie(v, null);
};
