//********************************************************************
//	PacketShaper /scripts/cookies.js (legacy file "wui/libbanr.js")
//	Copyright (c) 1996-2010, Blue Coat Systems, Inc. All rights reserved.
//********************************************************************

//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function getCookie(name) {
	var cookies	= document.cookie;
	var crumb	= null;
	var start	= cookies.indexOf(name + '=');

	if (start > -1) {

		var len	= start + name.length + 1;
		var end	= cookies.indexOf(';',len);
		if (end == -1)
			end = cookies.length;
		crumb = unescape(cookies.substring(len,end));
	}
	return crumb;
}

function setCookie(name, value, expires, path) {
	var next_year = new Date();

	//...ASSUMPTION:  add a year to today's date if no expiration provided
	if ((expires == null) || (expires == '')) {

		next_year.setFullYear(next_year.getFullYear()+1);
		expires = next_year;
	};

	document.cookie = name + '=' + escape(value)
        + '; expires=' + expires.toGMTString()
		+ (((path == null) || (path == '')) ? '' : ('; path=' + path));
}

function deleteCookie(name) {
	var expires	= new Date();
	expires.setTime(expires.getTime() - 1);	 //...age it - set it to a past date
	setCookie(name, null, expires, '/');
}

