foswiki.Pref={FOSWIKI_PREF_COOKIE_NAME:"FOSWIKIPREF",COOKIE_PREF_SEPARATOR:"|",COOKIE_PREF_VALUE_SEPARATOR:"=",COOKIE_EXPIRY_TIME:365*24*60*60*1000,setPref:function(d,b){var g=foswiki.Pref._getPrefCookie();var f=g.split(foswiki.Pref.COOKIE_PREF_SEPARATOR);var a=foswiki.Pref._getSafeString(d);var e=foswiki.Pref._getKeyValueLoc(f,a);if(e!=-1){f.splice(e,1)}var c=(isNaN(b))?foswiki.Pref._getSafeString(b):b;var h=a+foswiki.Pref.COOKIE_PREF_VALUE_SEPARATOR+c;f.push(h);foswiki.Pref._writePrefValues(f)},clearPref:function(b){var e=foswiki.Pref._getPrefCookie();var d=e.split(foswiki.Pref.COOKIE_PREF_SEPARATOR);var a=foswiki.Pref._getSafeString(b);var c=foswiki.Pref._getKeyValueLoc(d,a);if(c!=-1){d.splice(c,1)}foswiki.Pref._writePrefValues(d)},getPref:function(b){var a=foswiki.Pref._getSafeString(b);return foswiki.Pref.getPrefValueFromPrefList(a,foswiki.Pref.getPrefList())},getPrefValueFromPrefList:function(b,c){var a=foswiki.Pref._getKeyValue(c,b);if(a!=null){return a[1]}return""},getPrefList:function(){var a=foswiki.Pref._getPrefCookie();if(!a){return null}return a.split(foswiki.Pref.COOKIE_PREF_SEPARATOR)},getCookie:function(f){var b=f+"=";var e=b.length;var a=document.cookie.length;var d=0;while(d<a){var c=d+e;if(document.cookie.substring(d,c)==b){return foswiki.Pref._getCookieVal(c)}d=document.cookie.indexOf(" ",d)+1;if(d==0){break}}return null},setCookie:function(g,c,f,b,a,d){var e=g+"="+escape(c)+((f)?"; expires="+f.toGMTString():"")+((b)?"; path="+b:"")+((a)?"; domain="+a:"")+((d)?"; secure":"");document.cookie=e},deleteCookie:function(c,b,a){if(foswiki.Pref.getCookie(c)){document.cookie=c+"="+((b)?";path="+b:"")+((a)?"; domain="+a:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT"}},_getKeyValue:function(a,c){if(!a){return null}var d=a.length;while(d--){var b=a[d].split(foswiki.Pref.COOKIE_PREF_VALUE_SEPARATOR);if(b[0]==c){return b}}return null},_getKeyValueLoc:function(a,c){if(!a){return null}var d=a.length;while(d--){var b=a[d].split(foswiki.Pref.COOKIE_PREF_VALUE_SEPARATOR);if(b[0]==c){return d}}return -1},_writePrefValues:function(c){var b=(c!=null)?c.join(foswiki.Pref.COOKIE_PREF_SEPARATOR):"";var a=new Date();foswiki.Pref._fixCookieDate(a);a.setTime(a.getTime()+foswiki.Pref.COOKIE_EXPIRY_TIME);foswiki.Pref.setCookie(foswiki.Pref.FOSWIKI_PREF_COOKIE_NAME,b,a,"/")},_getPrefCookie:function(){var a=foswiki.Pref.getCookie(foswiki.Pref.FOSWIKI_PREF_COOKIE_NAME);if(a==undefined){a=""}return a},_getSafeString:function(b){var a=new RegExp(/[|=]/);return b.replace(a,"")},_getCookieVal:function(a){var b=document.cookie.indexOf(";",a);if(b==-1){b=document.cookie.length}return unescape(document.cookie.substring(a,b))},_fixCookieDate:function(c){var b=new Date(0);var a=b.getTime();if(a>0){c.setTime(c.getTime()-a)}}};