function cookieExists(cookieName) {
	if (document.cookie != "") {
		var theCookieList = document.cookie.split(";");
		
		for (var i = 0; i < theCookieList.length; i++) {
			var currCookieName = theCookieList[i].split("=")[0];
			var currCookieValue = theCookieList[i].split("=")[1];
			
			if (currCookieName.indexOf(cookieName) != -1) {
				return currCookieValue != "null";
			}
		}
	}
	
	return false;
}

function getCookie(cookieName) {
	if (cookieExists(cookieName)) {
		var theCookieList = document.cookie.split(";");
		
		for (var i = 0; i < theCookieList.length; i++) {
			if (theCookieList[i].split("=")[0].indexOf(cookieName) != -1) {
				return theCookieList[i].split("=")[1];
			}
		}
	}
	
	return "null";
}

function setCookie(cookieName, cookieValue) {
    var future = new Date();
	var year = future.getFullYear();
	future.setFullYear(year + 1);
	future.setDate(1);
	document.cookie = cookieName + "=" + cookieValue + ";" + "path=/;" + "host="+getDomain()+";" + 
	                  "expires=" + future.toGMTString() + ";";
}

function setStylesheet(styleTitle) {
	$('link[title][rel*="style"]').attr('disabled', function() {
		return this.title != styleTitle;
	});
}

function getDomain() {
	return window.location.host;
}
