// JavaScript Document

// *** cookie FUNCTIONS *** 
// cookies.js
// -- setcookie() 
// The cookieName and cookieValue arguments are mandatory but all other arguments are optional. 
// expires - (optional) is a Date object. 
// path - the part of the document tree on the server that the cookie is valid for. 
// domain - allows multiple server hosts to be used. 
// secure - boolean and only applicable for use with HTTPS: connections. 
// Example... 
// var today = new Date(); 
// var expires = new Date(today.getMilliseconds() + (10 * 86400000)); // +10 days 
// setcookie('foo', 'bar', expires, '/'); 
function setcookie(cookieName, cookieValue, path, expires, domain, secure) { 
	document.cookie = escape(cookieName) + "=" + escape(cookieValue) 
	+ ((path)? "; path=" + path : "") 
	+ ((expires)? "; expires=" + expires.toGMTString() : "") 
	+ ((domain)? "; domain=" + domain : "") 
	+ ((secure)? "; secure" : ""); 
}

// -- getcookie() 
// eg. myVar = getcookie("foo"); 
// Returns null if no cookie 
function getcookie(cookieName) { 
	var cookie = " " + document.cookie; 
	var search = " " + escape(cookieName) + "="; 
	var setStr = null; 
	var offset = 0; 
	var end = 0; 
	if (cookie.length > 0) { 
	offset = cookie.indexOf(search); 
	if (offset!= -1) { 
		offset += search.length; 
		end = cookie.indexOf(";", offset) 
		if (end == -1) { 
			end = cookie.length; 
		} 
		setStr = unescape(cookie.substring(offset, end)); 
		} 
	} 
	return(setStr); 
}
