Create a cookie to handle java:function();

Is it doable to use javascript functions to set a cookie parameter
and call the function if the cookie is detected?

heres the javascript that changes the background attribute.

<script language="javascript" type="text/javascript">


function Blacker(){
document.getElementById('background_colour').style.background="#000000";
}
function Blacker2(){
document.getElementById('background_colour').style.background="#333333";
}
function Blacker3(){
document.getElementById('background_colour').style.background="#666666";
}
</script>
</head>

<body id="background_colour" style="background:#000000;">
<a href="javascript:Blacker()">adasdasdasdasada</a><br>
<a href="javascript:Blacker2()">adasdasdasdasada</a><br>
<a href="javascript:Blacker3()">adasdasdasdasada</a>
</body>

Can I store this data in acookie so when the user goes to the next page it automatically remembers the colour they have selected??

if this makes any sense