/**
* @version 1.5.8
* @package Joomla 1.5
* @subpackage DT Menu
* @copyright Copyright (C) 2009 DTH Development
* @copyright contact dthdev@dthdevelopment.com
* @license GPL - "GNU General Public License" (GPL) is available at
*  http://www.gnu.org/copyleft/gpl.html
*/

function init_menu(element_id, sm_open, active_state) {
    dt_id[dt_id.length] = element_id;
    if (active_state && !isLoaded2) {
        isLoaded2 = 1;
        if (window.attachEvent) {
            window.attachEvent('onload', DTSetPressedItem);
        } else {
            userLoadFunc2 = (typeof(onload) == 'function') ? onload: null;
            onload = DTSetPressedItem
        }
    }
    //window.addEvent('domready', dm_init);
    //window.attachEvent('onload', dm_init);
    
    dm_init();
    if (sm_open > 0) {
        DTShowSubmenu(element_id)
    }
}
function DTSetPressedItem() {
    if (dt_id.length > 0) {
        for (var i = 0; i < dt_id.length; i++) {
            if (dt_id[i].length > 0) {
                var ex = regexp_i.exec(dt_id[i]);
                toggleRec.pressedSelf = 1;
                dm_ext_setPressedItem(parseInt(ex[1]) , parseInt(ex[2]) ,  parseInt(ex[3]), 1);
                if (userLoadFunc2) userLoadFunc2();
            }
        }
    }
}
function DTShowSubmenu(id) {
    if (id.length > 0) {
        var ex = regexp_i.exec(id);
        var menu_idx = dm_menu.length - 1;
        if (menu_idx == parseInt(ex[1])) {
            if (parseInt(ex[2]) > 0) {
                sm_showid = "dm" + ex[1] + "m" + ex[2];
                var smVar = dm_menu[parseInt(ex[1])].m[parseInt(ex[2])];
                smVar.showTimer = setTimeout('dm_waitForSubmenu("", "' + sm_showid + '", "")', 0)
            } else {
                sm_showid = ''
            }
        }
    }
}
function DTPopupWindow(url, width, height, toolbar, location, status, menubar, scrollbars) {
    var options = 'toolbar=' + toolbar + ',location=' + location + ',status=' + status + ',menubar=' + menubar + ',scrollbars=' + scrollbars + ',resizable=yes';
    if (width > 0 && height > 0) {
        var centered;
        x = (screen.availWidth - width) / 2;
        y = (screen.availHeight - height) / 2;
        centered = 'width=' + width + ',height=' + height + ',left=' + x + ',top=' + y + ',' + options
    } else {
        centered = options
    }
    var popup = window.open(url, '_blank', centered);
    if (!popup.opener) popup.opener = self;
    popup.focus()
}
function DTStyleSheet(sheetName) {
    var link = document.createElement('link');
    link.setAttribute('href', sheetName);
    link.setAttribute('type', 'text/css');
    link.setAttribute('rel', 'stylesheet');
    var head = document.getElementsByTagName('head').item(0);
    head.appendChild(link)
}