//holds the array ofcookies
var item_number = new Array();



var today = new Date();
//expires in a year....
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);
if(document.cookie && document.cookie != ""){process_cookie()}//ends IF

//Processes the cookie, splits up the cookie
function process_cookie(){
var whole_cookie = unescape(document.cookie);
var theCookie = document.cookie;
var drop_name = whole_cookie.split("=");
var cookieSplit = theCookie.split("=");
if (drop_name[1] != ""){

item_number = drop_name[1].split("xxxxyxy");
}
}	



//Removes the cookie
//removes it from the cookie array
//parameters:val the number it is in the array
function remove(val){


cookie_array.splice(val+3,1);
cookie_array.splice(val+2,1);
cookie_array.splice(val+1,1);
cookie_array.splice(val, 1);

var newCookie = "";
if(cookie_array.length == 1)
{
kill_cookies();

}
else{
for (var i=0;i<cookie_array.length;i++)
{
	newCookie = newCookie + cookie_array[i] + "xxxxyxy";
}
document.cookie = "stuff=" + escape(newCookie) + "; expires=" + expiry.toGMTString();
}

}


//kills the cookies
//seperates each 'part' of the cookie with the string 'xxxxyxy' so that we can retreive the information later
function kill_cookies(){
var kill_date = new Date("January 1, 1970");
document.cookie = "stuff=stub;expires=" + kill_date.toGMTString();
}


//makes a new cookie
function place(new_item, new_title, new_actor, new_rating){

//the old cookie
if (document.cookie && document.cookie != ""){
	
var old_cookie = document.cookie;
document.cookie = old_cookie + escape(new_item + "xxx" + "xyxy" + new_title + "xxx"+ "xyxy"+ new_actor + "xxx"+ "xyxy"+ new_rating + "xxx"+ "xyxy") +"; expires=" + expiry.toGMTString();
}

else{
document.cookie = "stuff=" + escape(new_item + "xxx" + "xyxy" + new_title+ "xxx" + "xyxy"+ new_actor + "xxx"+ "xyxy"+ new_rating + "xxx"+ "xyxy") +"; expires="+ expiry.toGMTString();
}//ends ELSE
}//ends function
