Where did you get this function from? If you can use it (license, etc.) then it would be good to link in a commenter where did you get it from. Also, maybe something like this is easier: http://www.quirksmode.org/js/cookies.html#script