function initialize()
{
if(typeof(subcats)!="undefined" && document.getElementById("moreimg"))
{
menuOpen=false;
div="";
count=0;
maxLength=0;
del="";
del2="";
tempLength=0;
for(i in subcats)
{
if(count==0)
div+="<tr>";
div+="<td><a href=\"index.php?sid="+sid+"&c="+subcats[i]+"\">"+i+"</a></td>";
tempLength+=i.length;
del+=i+":";
if(count<3)
div+="<td width=5></td>";
if(count==3)
{
div+="</tr>";
count=-1;
if(tempLength>maxLength)
{
maxLength=tempLength;
del2=del;
}
tempLength=0;
del="";
}
count++;
}
imgLoc=new Array();
if(navigator.userAgent.match(/msie|internet explorer/i))
{
temp=document.getElementById("moreimg");
imgLoc["x"]=temp.offsetLeft+temp.width;
imgLoc["y"]=temp.offsetTop+temp.height;
temp = temp.offsetParent; 
while (temp != null)
{ 
imgLoc["x"]+=temp.offsetLeft; 
imgLoc["y"]+=temp.offsetTop; 
temp=temp.offsetParent; 
} 
}
else
{
temp=document.getElementById("moreimg");
imgLoc["x"]=temp.x+temp.width;
imgLoc["y"]=temp.y+temp.height;
}
menu=document.getElementById("divmenu");
sortby=document.getElementById("sortby");
tw=Math.ceil(9.3*maxLength);
if((tw+5)>imgLoc["x"])
tw=imgLoc["x"]-6;
menu.innerHTML="<table width="+tw+" id=\"menutable\" class=\"amenu\">"+div+"</table>";
menu.style.left=(imgLoc["x"]-tw+5)+"px";
menu.style.top=(imgLoc["y"]-1)+"px";
}
}

function openMenu()
{
if(menuOpen!=true)
{
menu.style.display="";
if(sortby)
sortby.style.display="none";
}
menuOpen=true;
}
function closeMenu()
{
menuOpen=false;
setTimeout("checkClose()",100);
}
function checkClose()
{
if(menuOpen==false)
{
menu.style.display="none";
if(sortby)
sortby.style.display="";
}
}
