YAHOO.namespace("util"),YAHOO.util.Cookie={_createCookieString:function(e,n,o,t){var i=YAHOO.lang,n=encodeURIComponent(e)+"="+(o?encodeURIComponent(n):n);return i.isObject(t)&&(t.expires instanceof Date&&(n+="; expires="+t.expires.toUTCString()),i.isString(t.path)&&""!==t.path&&(n+="; path="+t.path),i.isString(t.domain)&&""!==t.domain&&(n+="; domain="+t.domain),!0===t.secure&&(n+="; secure")),n},_createCookieHashString:function(e){var n=YAHOO.lang;if(!n.isObject(e))throw new TypeError("Cookie._createCookieHashString(): Argument must be an object.");var o,t=[];for(o in e)!n.hasOwnProperty(e,o)||n.isFunction(e[o])||n.isUndefined(e[o])||t.push(encodeURIComponent(o)+"="+encodeURIComponent(String(e[o])));return t.join("&")},_parseCookieHash:function(e){var n,o=e.split("&"),t={};if(0<e.length)for(var i=0,r=o.length;i<r;i++)n=o[i].split("="),t[decodeURIComponent(n[0])]=decodeURIComponent(n[1]);return t},_parseCookieString:function(e,n){var o={};if(YAHOO.lang.isString(e)&&0<e.length)for(var t,i=!1===n?function(e){return e}:decodeURIComponent,r=e.split(/;\s/g),s=null,a=null,u=0,g=r.length;u<g;u++){if((t=r[u].match(/([^=]+)=/i))instanceof Array)try{s=decodeURIComponent(t[1]),a=i(r[u].substring(t[1].length+1))}catch(e){}else s=decodeURIComponent(r[u]),a="";o[s]=a}return o},exists:function(e){if(!YAHOO.lang.isString(e)||""===e)throw new TypeError("Cookie.exists(): Cookie name must be a non-empty string.");return this._parseCookieString(document.cookie,!0).hasOwnProperty(e)},get:function(e,n){var o,t=YAHOO.lang;t.isFunction(n)?(o=n,n={}):t.isObject(n)?o=n.converter:n={};n=this._parseCookieString(document.cookie,!n.raw);if(!t.isString(e)||""===e)throw new TypeError("Cookie.get(): Cookie name must be a non-empty string.");return t.isUndefined(n[e])?null:t.isFunction(o)?o(n[e]):n[e]},getSub:function(e,n,o){var t=YAHOO.lang,e=this.getSubs(e);if(null===e)return null;if(!t.isString(n)||""===n)throw new TypeError("Cookie.getSub(): Subcookie name must be a non-empty string.");return t.isUndefined(e[n])?null:t.isFunction(o)?o(e[n]):e[n]},getSubs:function(e){var n=YAHOO.lang.isString;if(!n(e)||""===e)throw new TypeError("Cookie.getSubs(): Cookie name must be a non-empty string.");var o=this._parseCookieString(document.cookie,!1);return n(o[e])?this._parseCookieHash(o[e]):null},remove:function(e,n){if(!YAHOO.lang.isString(e)||""===e)throw new TypeError("Cookie.remove(): Cookie name must be a non-empty string.");return n=YAHOO.lang.merge(n||{},{expires:new Date(0)}),this.set(e,"",n)},removeSub:function(e,n,o){var t=YAHOO.lang;if(o=o||{},!t.isString(e)||""===e)throw new TypeError("Cookie.removeSub(): Cookie name must be a non-empty string.");if(!t.isString(n)||""===n)throw new TypeError("Cookie.removeSub(): Subcookie name must be a non-empty string.");var i=this.getSubs(e);if(t.isObject(i)&&t.hasOwnProperty(i,n)){if(delete i[n],o.removeIfEmpty){for(var r in i)if(t.hasOwnProperty(i,r)&&!t.isFunction(i[r])&&!t.isUndefined(i[r]))return this.setSubs(e,i,o);return this.remove(e,o)}return this.setSubs(e,i,o)}return""},set:function(e,n,o){var t=YAHOO.lang;if(o=o||{},!t.isString(e))throw new TypeError("Cookie.set(): Cookie name must be a string.");if(t.isUndefined(n))throw new TypeError("Cookie.set(): Value cannot be undefined.");o=this._createCookieString(e,n,!o.raw,o);return document.cookie=o},setSub:function(e,n,o,t){var i=YAHOO.lang;if(!i.isString(e)||""===e)throw new TypeError("Cookie.setSub(): Cookie name must be a non-empty string.");if(!i.isString(n)||""===n)throw new TypeError("Cookie.setSub(): Subcookie name must be a non-empty string.");if(i.isUndefined(o))throw new TypeError("Cookie.setSub(): Subcookie value cannot be undefined.");var r=this.getSubs(e);return(r=!i.isObject(r)?{}:r)[n]=o,this.setSubs(e,r,t)},setSubs:function(e,n,o){var t=YAHOO.lang;if(!t.isString(e))throw new TypeError("Cookie.setSubs(): Cookie name must be a string.");if(!t.isObject(n))throw new TypeError("Cookie.setSubs(): Cookie value must be an object.");o=this._createCookieString(e,this._createCookieHashString(n),!1,o);return document.cookie=o}},YAHOO.register("cookie",YAHOO.util.Cookie,{version:"2.9.0",build:"2800"});