// Toolbar 
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;
var toolbar = 0;

function mopen(id, elem) {

    if (typeof (toolbar) == "object" && (toolbar != null) && (toolbar != 0)) {
	try
		{
			toolbar.style.background = "url('/images/nav_bg_off.png') repeat-x 0 0";   
		}
	catch(err)
		{
		}
    }


    toolbar = elem
    elem.style.background = "url('/images/nav_bg_on.png') repeat-x 0 0";
    elem.style.color = "#FFF";
    

    mcancelclosetime();

    if (ddmenuitem) ddmenuitem.style.display = 'none';
    if (document.getElementById(id)) {
        ddmenuitem = document.getElementById(id);
        id = id.split(".")
        id = parseInt(id[1])

        if (id > 2 && id < 5) {
		
            if (ddmenuitem.childNodes.length == 6) {
                ddmenuitem.style.right = "0";
            }
        } else if (id >= 5) {
	
            if (ddmenuitem.childNodes.length > 2) {
				
                ddmenuitem.style.right = "0";
            }
        }
        ddmenuitem.style.display = 'block';

    }
}

function mclose() {
    if (ddmenuitem) ddmenuitem.style.display = 'none';
    toolbar.style.background = "none";
    delete toolbar;

}

function mclosetime() {
    closetimer = window.setTimeout(mclose, timeout);
}

function mcancelclosetime() {
    if (closetimer) {
        window.clearTimeout(closetimer);
        closetimer = null;
    }
}

