function updateCookie(form) {
	var pubNum     = form.reportNum.value;
	var pubName    = form.reportName.value;
	var the_cookie = readCookie('pubBasket');
	
	//IF COOKIE EXISTS, APPEND NEW DATA
	if(the_cookie) {
		the_cookie = the_cookie + ' :: ' + pubNum + ' -- ' + pubName + ' -- 1';
		document.cookie = 'pubBasket=' + escape(the_cookie);
	
	//ELSE...CREATE A NEW COOKIE
	} else {
		the_cookie = pubNum + ' -- ' + pubName + ' -- 1';
		document.cookie = 'pubBasket=' + escape(the_cookie);
	}
}

function remove(item) {
	var the_cookie = readCookie('pubBasket');
	var broken_cookie = the_cookie.split(" :: ");
	var firstTime = 1;
	
	//IF THERE'S ONLY ONE REPORT STORED IN THE COOKIE, DELETE THE COOKIE
	if(broken_cookie.length == 1) {
		deleteCookie('pubBasket');
		
	//ELSE...REMOVE THE INDICATED REPORT FROM COOKIE
	} else {
		//SEARCH THROUGH THE COOKIE PEICES TO FIND THE PUB TO BE DELETED
		for(i = 0; i < broken_cookie.length; i++) {
			//IF CURRENT COOKIE PEICES IS NOT THE ONE WE ARE LOOKING FOR STORE IT FOR LATER
			if(i != item) {
				if(firstTime) {
					var the_newCookie = broken_cookie[i];
					firstTime = 0;
				} else {
					the_newCookie = the_newCookie + " :: " + broken_cookie[i];
				}
			}
		}
		document.cookie = "pubBasket=" + escape(the_newCookie);
	}
}

function deleteCookie(name) {
	var theValue = readCookie(name);
	if(theValue) {
		document.cookie = name + '=' + escape(theValue) + '; expires=Fri, 13-Apr-1970 00:00:00 GMT';
	}
}

function readCookie(name) {
	if(document.cookie == '') return false;  //if no cookies found, return false
	else       return getCookieValue(name);  //else...search cookies for "pubBasket" cookie (return value if found)
}

function getCookieValue(name) {
	var firstChar, lastChar;
	var theBigCookie = document.cookie;  //GET ENTIRE STRING (CONTAINS ALL COOKIE NAMES)

	//GRAB THE DESIRED COOKIE FROM ENTIRE STRING
	firstChar = theBigCookie.indexOf(name);  //INITIALIZE POINTER TO BEGINNING OF 'name'
	if(firstChar != -1) {  //if found, continue
		firstChar += name.length + 1;  //UPDATE POINTER TO BEGINNING OF THE VALUE FOR 'name' (SKIP 'name=')
		lastChar = theBigCookie.indexOf(';', firstChar);  //FIND THE END OF THE VALUE FOR 'name' (THE NEXT ;)
		if(lastChar == -1)   lastChar = theBigCookie.length;
		return unescape(theBigCookie.substring(firstChar, lastChar)); //RETURN THE VALUE OF 'name'
	} else {
		return false;  //COOKIE NOT FOUND, RETURN FALSE
	}
}
