This Show/Hide Menu save in cookies, but how can an user have it open at the first time he visits my page? Thanks for help!
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
.open {display: block;}
.closed {display: none;}
</style>
<script type="text/javascript">
<!--
function toggle(id)
{
ul = "ul_" + id;
ulElement = document.getElementById(ul);
if (ulElement)
{
if (ulElement.className == 'closed')
{
ulElement.className = "open";
setCookie("autoOpen_" + id, ul, 1);
}
else
{
ulElement.className = "closed";
removeCookie("autoOpen_" + id);
}
}
}

function setCookie(name, value, days)
{
if (days) {
var theDate = new Date();
theDate.setTime(theDate.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + theDate.toGMTString();
}
else
expires = "";

document.cookie = name + "=" + value + expires + "; path=/";
}

function removeCookie(name)
{
document.cookie = name + "=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/";
}

function checkcookies()
{
if (document.cookie.length > 0)
{
var cookieParts = document.cookie.split(";");
for (var c = 0; c < cookieParts.length; c++)
{
var cookieBits = cookieParts[c].split("=");
var cookieElement = document.getElementById(cookieBits[1]);
if (cookieElement)
{
cookieElement.className = 'open';
}
}
}
}

window.onload = checkcookies;
//-->
</script>
</head>
<body>
<ul class="open" style="list-style-type: none; padding: 0 0 0 0;">
<li id="item1" class="subnav"><a onclick="toggle('item1');" style="cursor: hand; cursor: pointer;">Lorem Ipsum</a>
<ul id="ul_item1" class="closed" style="list-style-type : none; padding:0 0 0 0;">
<li id="item1_1">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
</ul>
</li>
</ul>
</boby>
</html>