// Created by:	Ronnie T. Moore
// Updated on:	04/20/08 by Dave Henderson (dhenderson@cliquesoft.org)


// uncomment and adjust the below lines to have their values set
//var expDays = 30;
//var exp = new Date();
//exp.setTime(exp.getTime() + (expDays*24*60*60*1000));




function setCookie(strName, strValue) {
// This function adds a cookie to the browser via javascript.
// strName:	the name of the cookie to create
// strValue:	the value you want to assign to the cookie
// object list:	additional parameters include (optional, but in this order): expiration date, path (directory name), domain name, secure (ssl xfer only)

   var argv = setCookie.arguments;
   var argc = setCookie.arguments.length;
   var expires = (argc > 2) ? argv[2] : null;
   var path = (argc > 3) ? argv[3] : null;
   var domain = (argc > 4) ? argv[4] : null;
   var secure = (argc > 5) ? argv[5] : false;
   document.cookie = strName + "=" + escape(strValue) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}


function delCookie(strName) {
   var exp = new Date();
   exp.setTime (exp.getTime() - 1);
   var cval = getCookie(strName);
   document.cookie = strName + "=" + cval + "; expires=" + exp.toGMTString();
}


function getCookie(strName) {
   var arg = strName + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {
	var j = i + alen;
	if (document.cookie.substring(i, j) == arg) { return getCookieVal(j); }
	i = document.cookie.indexOf(" ", i) + 1;
	if (i == 0) break;
   }
   return null;
}


function getCookieVal(offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) { endstr = document.cookie.length; }
   return unescape(document.cookie.substring(offset, endstr));
}

