var JKow = { DOM : { Event : {} }}; JKow.DOM.Event.addEventHandler = function(o, e, f){ if (o != null){ var old_eh = null; if (typeof o['_event_queue'] == "undefined"){ o['_event_queue'] = {}; } if (typeof o['_event_queue'][e] == "undefined"){ o['_event_queue'][e] = new Array(); old_eh = o['on' + e]; /* save previous event handler */ if (typeof old_eh == "function"){ o['_event_queue'][e][0] = old_eh; } o['on' + e] = function(event){ var _o = o; var _e = e; /* var _evt = event */ var _evt = event || window.event; for (var i = 0; i < _o['_event_queue'][_e].length; ++i){ _o['_event_queue'][_e][i](_evt); } _o = null; } } o['_event_queue'][e].push(f); } } var _menu_path = 'res/menu'; var _mouse_states = {}; var _menu_images = {}; var _event_handler_guid = 0; var _event_handlers = {}; function _init_menu2(id){ var el = document.getElementById(id); var depth = 1; __init_menu2(el, {}, depth); } function __init_menu2(parent_el, arg, depth){ for (var i = 0; i < parent_el.childNodes.length; ++i){ var c = parent_el.childNodes[i]; var _parent_id = parent_el.id; var f = function(){ var _c = c; if (_c.nodeName == 'LI'){ if (depth > 1){ JKow.DOM.Event.addEventHandler(_c, 'mouseover', function(){ _mouse_states[arg['li-id']] = true; }); JKow.DOM.Event.addEventHandler(_c, 'mouseout', function(){ _mouse_states[arg['li-id']] = false; }); __init_menu2(_c, arg, depth + 1); } else { _mouse_states[_c.id] = false; JKow.DOM.Event.addEventHandler(_c, 'mouseover', function(){ _mouse_states[_c.id] = true; }); JKow.DOM.Event.addEventHandler(_c, 'mouseout', function(){ _mouse_states[_c.id] = false; }); __init_menu2(_c, {'li-id': _c.id}, depth + 1); } } else if (_c.nodeName == 'UL'){ JKow.DOM.Event.addEventHandler(parent_el, 'mouseover', function(){ _c.style.display = 'block' }); JKow.DOM.Event.addEventHandler(parent_el, 'mouseout',function(){ _c.style.display = 'none'; }); __init_menu2(_c, arg, depth + 1); } else if (_c.nodeName == 'A'){ __init_menu2(_c, arg, depth + 1); } else if (_c.nodeName == 'IMG'){ if (arg['li-id'].length != 0){ var f2 = function(){ var __c = _c; __c.onmouseover = function(){ __c.src = _menu_path + '/' + arg['li-id'] + '-on.gif'; } __c.onmouseout = function(){ //__c.src = _menu_path + '/' + arg['li-id'] + '.gif'; var t = setInterval( function(){ var _t = t; var ___c = __c; if (!_mouse_states[arg['li-id']]){ ___c.src = _menu_path + '/' + arg['li-id'] + '-off.gif'; clearInterval(_t); } },25 ); } } f2(); } } } f(); } } function _init_menu(id){ var el = document.getElementById(id); var depth = 1; __init_menu(el, {}, depth); } function __init_menu(parent_el, arg, depth){ for (var i = 0; i < parent_el.childNodes.length; ++i){ var c = parent_el.childNodes[i]; var _parent_id = parent_el.id; var f = function(){ var _c = c; if (_c.nodeName == 'LI'){ if (depth > 1){ JKow.DOM.Event.addEventHandler(_c, 'mouseover', function(){ _mouse_states[arg['li-id']] = true; }); JKow.DOM.Event.addEventHandler(_c, 'mouseout', function(){ _mouse_states[arg['li-id']] = false; }); __init_menu(_c, arg, depth + 1); } else { _mouse_states[_c.id] = false; JKow.DOM.Event.addEventHandler(_c, 'mouseover', function(){ _mouse_states[_c.id] = true; }); JKow.DOM.Event.addEventHandler(_c, 'mouseout', function(){ _mouse_states[_c.id] = false; }); __init_menu(_c, {'li-id': _c.id}, depth + 1); } } else if (_c.nodeName == 'UL'){ JKow.DOM.Event.addEventHandler(parent_el, 'mouseover', function(){ _c.style.display = 'block' }); JKow.DOM.Event.addEventHandler(parent_el, 'mouseout',function(){ _c.style.display = 'none'; }); __init_menu(_c, arg, depth + 1); } else if (_c.nodeName == 'A'){ __init_menu(_c, arg, depth + 1); } else if (_c.nodeName == 'IMG'){ var f2 = function(){ var __c = _c; __c.onmouseover = function(){ __c.src = _menu_path + '/' + arg['li-id'] + '-over.gif'; } __c.onmouseout = function(){ //__c.src = _menu_path + '/' + arg['li-id'] + '.gif'; var t = setInterval( function(){ var _t = t; var ___c = __c; if (!_mouse_states[arg['li-id']]){ ___c.src = _menu_path + '/' + arg['li-id'] + '.gif'; clearInterval(_t); } },25 ); } } f2(); } } f(); } } /*function menu_submenu_visible(el, flag){ for (var i = 0; i < el.childNodes.length; ++i){ var child = el.childNodes[i]; if (child.nodeName == "UL"){ var f = function(){ var _child = child; _child.style.display = (flag) ? "block" : "none"; } f(); return false; } } } var _menu_path = 'res/menu'; var _mouse_states = { }; function _init_menu(id, add_timer){ var el = document.getElementById(id); if (el == null || typeof el == "undefined") { return false; } if ('undefined' == typeof lv1 || lv1 == null){ add_timer = true; } for (var i = 0; i < el.childNodes.length; ++i){ var child = el.childNodes[i]; if (child.nodeName == "LI"){ _mouse_states[child.id] = {}; _mouse_states[child.id]['over_child'] = false; var f = function(){ var _child = child; _mouse_states[_child.id]['over_child'] = false; _child.onmouseover = function(){ _child['_className'] = _child.className; _child.className += " over"; menu_submenu_visible(_child, true); } _child.onmouseout = function(){ _child.className = _child['_className']; menu_submenu_visible(_child, false); _mouse_states[_child.id]['over_child'] = false; } } f(); var parent_id = child.id; for (var j = 0; j < child.childNodes.length; ++j){ var child_2 = child.childNodes[j]; if (child_2.nodeName == "A") { // do image replace for images for (var k = 0; k < child_2.childNodes.length; ++k){ var child_3 = child_2.childNodes[k]; if (child_3.nodeName == "IMG"){ var f = function(){ var _child = child_3; _child.onmouseover = function(){ var _parent_id = parent_id; var t = setInterval( function(){ var _t = t; if (_mouse_states[_parent_id]['over_child'] == true){ _child.src = _menu_path + '/' + _parent_id + '-over.gif'; clearInterval(_t); } }, 100 ); } _child.onmouseout = function(){ var _parent_id = parent_id; var t = setInterval( function(){ var _t = t; if (_mouse_states[_parent_id]['over_child'] == false){ _child.src = _menu_path + '/' + _parent_id + '.gif'; clearInterval(_t); } }, 100 ); } } f(); } } } } } } }*/