var UNDEFINED_ELEMENT="undefined";function AddSessionCookie(cookieName,cookieKey,cookieValue,path,domain,secure){if(typeof cookieKey==UNDEFINED_ELEMENT||cookieKey=="")SetSessionCookieValue(cookieName,cookieValue,path,domain,secure);else SetSessionCookieKeyValue(cookieName,cookieKey,cookieValue,path,domain,secure)}function AddCookie(cookieName,cookieKey,cookieValue,expires,path,domain,secure){if(typeof cookieKey==UNDEFINED_ELEMENT||cookieKey=="")SetCookieValue(cookieName,cookieValue,expires,path,domain,secure);else SetCookieKeyValue(cookieName,cookieKey,cookieValue,expires,path,domain,secure)}function GetCookie(cookieName,cookieKey){if(typeof cookieKey==UNDEFINED_ELEMENT||cookieKey=="")return GetCookieValue(cookieName);else return GetCookieKeyValue(cookieName,cookieKey)}function RemoveCookie(cookieName,cookieKey){var expiryDate=new Date;expiryDate.setFullYear(expiryDate.getFullYear()-1);AddCookie(cookieName,cookieKey,"",expiryDate,"","","")}function GetCookieValue(cookieName){var dc=document.cookie,prefix=cookieName+"=",begin=dc.indexOf("; "+prefix);if(begin==-1){begin=dc.indexOf(prefix);if(begin!=0)return null}else begin+=2;var end=document.cookie.indexOf(";",begin);if(end==-1)end=dc.length;return unescape(dc.substring(begin+prefix.length,end))}function GetCookieKeyValue(cookieName,cookieKey){var namedCookie=GetCookieAllKeys(cookieName);if(namedCookie!=null)for(var cookieElements=namedCookie.split("&"),i=0;i<cookieElements.length;i++){var cookieParts=cookieElements[i].split("=");if(cookieParts[0]==cookieKey)return unescape(cookieParts[1])}return null}function SetSessionCookieValue(cookieName,cookieValue,path,domain,secure){document.cookie=cookieName+"="+escape(cookieValue)+(path?"; path="+path:"")+(domain?"; domain="+domain:"")+(secure?"; secure":"")}function SetCookieValue(cookieName,cookieValue,expires,path,domain,secure){document.cookie=cookieName+"="+escape(cookieValue)+(expires?"; expires="+expires.toGMTString():"")+(path?"; path="+path:"")+(domain?"; domain="+domain:"")+(secure?"; secure":"")}function SetSessionCookieKeyValue(cookieName,cookieKey,cookieValue,path,domain,secure){var currentKey=ResetCookieKeyString(cookieName,cookieKey);document.cookie=cookieName+"="+currentKey+cookieKey+"="+escape(cookieValue)+(path?"; path="+path:"")+(domain?"; domain="+domain:"")+(secure?"; secure":"")}function SetCookieKeyValue(cookieName,cookieKey,cookieValue,expires,path,domain,secure){var currentKey=ResetCookieKeyString(cookieName,cookieKey);document.cookie=cookieName+"="+currentKey+cookieKey+"="+escape(cookieValue)+(expires?"; expires="+expires.toGMTString():"")+(path?"; path="+path:"")+(domain?"; domain="+domain:"")+(secure?"; secure":"")}function ResetCookieKeyString(cookieName,cookieKey){var currentKeys=GetCookieAllKeys(cookieName);if(currentKeys==null||typeof currentKeys==UNDEFINED_ELEMENT)currentKeys="";if(currentKeys!=""){var keyIndex=currentKeys.indexOf(cookieKey);if(keyIndex!=-1){var seperatorIndex=currentKeys.indexOf("&",keyIndex);if(seperatorIndex!=-1)if(seperatorIndex<currentKeys.length)currentKeys=currentKeys.replace(currentKeys.substring(keyIndex,seperatorIndex)+"&","");else currentKeys=currentKeys.replace(currentKeys.substring(keyIndex,seperatorIndex),"");else if(keyIndex!=0)currentKeys=currentKeys.replace("&"+currentKeys.substring(keyIndex,currentKeys.length),"");else currentKeys=currentKeys.replace(currentKeys.substring(keyIndex,currentKeys.length),"")}if(currentKeys.length>0)currentKeys+="&"}return currentKeys}function GetCookieAllKeys(cookieName){for(var cookies=document.cookie.split("; "),i=0;i<cookies.length;i++)if(cookies[i].indexOf(cookieName)==0)return cookies[i].substring(cookieName.length+1,cookies[i].length);return null};