//Function to set cookie
function setCookie(cookieName, cookieValue) {
	var cookieExpiration = new Date("January 1, 2108");
	cookieExpiration = cookieExpiration.toGMTString();
	document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + cookieExpiration;
}

//Function to get cookie
function getCookie(cookieName) {
   var search = cookieName + "=";
   
   //Determines if any cookies exist
	if (document.cookie.length > 0) {
		var offset = document.cookie.indexOf(search);

		//Ensures requested cookie exists
		if (offset != -1) {
			//Sets offset to beginning of the value
			offset += search.length;

         		//Sets index of the beginning of the value
         		end = document.cookie.indexOf(";", offset)

         		//If requested cookie is the only cookie
         		if (end == -1) {
            			end = document.cookie.length;
            		}

			//Returns requested cookie value
			return unescape(document.cookie.substring(offset, end));

		//Requested cookie doesn't exist
		} else {
			return "";
		}

	//No cookies exist
	} else {
		return "";
	}
}
