// JavaScript Document
function createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = "; expires=" + date.toGMTString();
	}
	else var expires = "";
	
	document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	
	for(var i = 0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) {
			var value = c.substring(nameEQ.length,c.length);
			if (value.substring(0, 1) == "\"")
				value = value.substring(1, value.length - 1);
				
			if (value.substring(value.length - 1, 1) == "\"")
				value = value.substring(0, value.length - 1);

			return value;
		}
	}
	
	return null;
}

function eraseCookie(name) {
	createCookie(name, "", -1);
}

function cookieCheck(showMsg) {
	createCookie("allowCookies", "yes", 0);
	var allowCookies = readCookie("allowCookies");

	if (allowCookies == null || allowCookies != "yes") {
		if (showMsg != null && showMsg == true) {
			alert("Please Enable Cookies\n\nCookies are DISABLED on this browser.  Cookies are required" +
				  "\nfor Shopping Cart and Lightbox features.  Please see our Privacy" +
				  "\nPolicy if you have any concerns.");
		}
		
		return false;
		
	} else
		return true;
}