I have been working on a cookie script with a multi search, but I can't get it to work how I planned. Any suggestions would be appreciated.

These are a few sections of the code (you can view the whole source at http://multiz.com/search4.htm ):

This is where I want the cookie text to be made and displayed:
<input type="Text" name="Search" size=80 onChange="writeCookie('kw', document.SearchForm.Search.value, '24')" onFocus="readCookie('kw')">

My cookie script is:
<script language="JavaScript">
// Example:
// readCookie("myCookie")
function readCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
{
offset = document.cookie.indexOf(search);
if (offset != -1)
{
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
cookieValue = unescape(document.cookie.substring(offset, end))
}
}
return cookieValue;
}
// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
var expire = "";
if(hours != null)
{
expire = new Date((new Date()).getTime() + hours * 3600000);
expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire;
}
</script>


I think I have the right idea, but I can't get it to work properly. If you want to see the full code, visit http://multiz.com/search4.htm

Thanks
Mike