// This is where we hold what we get from the cookie
valuesObject = new Object();
var searchCookie = "none";
// Now we can read the cookie.
getSearchCookie();

// This reads the cookie and puts the values into the object.
function getSearchCookie() {
        // Get the list of cookies.
        var cookies = document.cookie.split(";");
        // Get just the cookie we want by name.
        for (i=0; i<cookies.length; i++) {
                var searchCookieName = cookies[i].substring(0, cookies[i].indexOf("=", 0));
                searchCookieName = searchCookieName.replace(" ", "");
                if (searchCookieName === "OSOSearchResults") {
                searchCookie = cookies[i].substring(cookies[i].indexOf("=", 0)+1, cookies[i].length);
                }
        }

}

// This returns 1 if vales exist or else 0
function searchCookieExists() {
        if (searchCookie == "none") {
                return false;
        } else {
                return true;
        }
}

function crossrefSearch(){
	if (searchCookie != "none") {
		var cookieVal = searchCookie.split("&");
		for (i=0; i<cookieVal.length; i++){
			var pairs = cookieVal[i].split("=");
			if (pairs[0] === "view" && pairs[1]==="crossref") {
				alert("crossref");
				return true;
			}
		}
		return false;
	}
}

