function elem(elemid)
{
    return document.getElementById(elemid);
}


function CheckForm(f)
{
    if (f.name.value=="")
        alert("You need to specify a name for the link!");
    else
        if (f.url.value=="")
            alert("You need to specify an URL for your link!");
        else
            if (f.category.selectedIndex==0)
                alert("You must specify a category");
            else
                return true;
    return false;
}

  function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}



function ToggleCategory(CatID)
{
    State=elem("cat_"+CatID+"_state").value;
    if(State=='closed')
    {
        elem("cat_"+CatID+"_content").style.display="";
        elem("cat_"+CatID+"_toggle").style.backgroundImage=elem("cat_"+CatID+"_toggle").style.backgroundImage.replace("plus","minus");
        elem("cat_"+CatID+"_state").value="opened";
    }
    else
    {
        elem("cat_"+CatID+"_content").style.display="none";
        elem("cat_"+CatID+"_toggle").style.backgroundImage=elem("cat_"+CatID+"_toggle").style.backgroundImage.replace("minus","plus");
        elem("cat_"+CatID+"_state").value="closed";
    }
    Set_Cookie( 'cat_'+CatID, elem("cat_"+CatID+"_state").value, 365, '/', '', '' );
}
