var total_lnk_width = 0; var ie, ie6, ie7; ie = !window.getComputedStyle; ie6 = (ie && navigator.appVersion.indexOf('MSIE 7') == -1); ie7 = (ie && navigator.appVersion.indexOf('MSIE 7') != -1) var hover_pad2 = { main: { tag: "DIV", attributes: { className: "hover-pad2" }, RETURN: true, children: { corners_top: { tag: "DIV", attributes: { className: "corners top" }, children: { corner_left: { tag: "DIV", attributes: { className: "corner left" } }, corner_right: { tag: "DIV", attributes: { className: "corner right" } }, bgr: { tag: "DIV", attributes: { className: "bgr" } } } },//corners_top inner: { tag: "DIV", attributes: { className: "pad-inner" }, RETURN: true },//inner corners_bottom: { tag: "DIV", attributes: { className: "corners bottom" }, children: { corner_left: { tag: "DIV", attributes: { className: "corner left" } }, corner_right: { tag: "DIV", attributes: { className: "corner right" } }, bgr: { tag: "DIV", attributes: { className: "bgr" } } } }//corners_bottom } } } var _screen, screen_items, track, b_left, b_right, screen_item_width, move_items, m_item1, m_item2; var track2; var movs = []; var stepVal = 2; var accel = 0; var menu_root, m_width_div; var right_menu; function init_menu_resize(){ if(!menu_root) return; if(!menu_root.items){ menu_root.items = $C('m-item', menu_root); } if(total_lnk_width == 0){ menu_root.items.each(function(item){ var lnk_width = $T('A', item)[0].offsetWidth; item.lnk_width = lnk_width; total_lnk_width += lnk_width; }); } var item_padding = (menu_root.offsetWidth - total_lnk_width) / (menu_root.items.length * 2); if(window.opera){ // item_padding++; } var rest = menu_root.offsetWidth % menu_root.items.length; menu_root.rest = rest; menu_root.items.each(function(item, index){ item.style.paddingLeft = item_padding + "px"; item._width = item.lnk_width + item_padding * 2; if(index != menu_root.items.length - 1){ item.style.paddingRight = item_padding + "px"; }else{ item.style.paddingRight = item_padding + "px"; // item.style.paddingRight = item_padding + menu_root.rest + 5 + "px"; // item._width += menu_root.rest + 5; } if(item.className.indexOf('here') != -1){ if(item.pad){ item.pad.style.width = item._width + "px"; } } if(item.className.indexOf('last') != -1){ } item.style.visibility = "visible"; }) } function min_width(){ if(!ie6){ return; } var b_width = document.body.clientWidth; m_width_div.style.width = b_width <= 1000 ? '1000px' : 'auto'; } function flashSnow_width(){ var b_width = document.body.clientWidth; flashSnow_div.style.width = b_width <= 1000 ? '1000px' : (document.body.clientWidth + "px") ; } function init_vars(){ menu_root = $('main-menu'); m_item1 = $('move_item1'); m_item2 = $('move_item2'); right_menu = $('right-menu'); m_width_div = $('min-width'); flashSnow_div = $('flashSnow'); _screen = $('screen256'); track = $('track'); b_left = $('button-left'); b_right = $('button-right'); } function init_screen(){ if(!_screen){ return; } if(ie){ Movement.defaultIntervalValue = 50; }else{ Movement.defaultIntervalValue = 50; } screen_items = $C('item', _screen); move_items = $C('move-item', _screen); var track_width = 0; screen_items.each(function(item, index){ var i_width = parseInt(Style.getElementStyle(item, 'width')); item.style.left = track_width + "px"; track_width += i_width; item.label = $C('label', item)[0]; var over_func = function(){ this.label.style.display = 'block'; this.style.zIndex = 11; this.parentNode.style.zIndex = 11; Movement.mutualTimer.clear(); }; var out_func = function(){ this.label.style.display = 'none'; this.style.zIndex = 10; this.parentNode.style.zIndex = 10; Movement.mutualTimer.start(); }; item.onmouseover = over_func; item.onmouseout = out_func; var i_clone = item.cloneNode(true); m_item2.appendChild(i_clone); i_clone.label = $C('label', i_clone)[0]; i_clone.onmouseover = over_func; i_clone.onmouseout = out_func; }); track._width = track_width * 2; track.style.width = track._width * 2 + "px"; track.style.left = -track_width + "px"; move_items.each(function(m_item, index){ m_item.style.left = track_width * index + "px"; // m_item.style.width = track_width + "px"; var mov = new Movement(m_item); mov.onmove.register('check', function(){ if(this.Moveable.left > track._width){ var diff = this.Moveable.left - track._width; this.setSteps(-track._width + diff + stepVal + stepVal * accel, 0); this.Moveable.onmove.register('correct-steps', function(){ this.setSteps(stepVal + stepVal * accel, 0); }.bind(this), 1); }else if(this.Moveable.left < 0){ this.setSteps(track._width - stepVal - stepVal * accel, 0); this.Moveable.onmove.register('correct-steps', function(){ this.setSteps(-(stepVal + stepVal * accel), 0); }.bind(this), 1); } }.bind(mov)); mov.setSteps(stepVal + stepVal * accel, 0); mov.start(); movs.push(mov); }) init_buttons(); } function init_buttons(){ b_left.on = false; b_right.on = false; b_left.onmouseover = function(){ //return; if(this.on) return; accel = 2; this.on = true; movs.each(function(mov){ mov.setSteps(-(stepVal + stepVal * accel), 0); }); } b_left.onmouseout = function(){ //return; if(!this.on) return; accel = 0; this.on = false; movs.each(function(mov){ mov.setSteps(stepVal + stepVal * accel, 0); }); } b_right.onmouseover = function(){ //return; if(this.on) return; accel = 2; this.on = true; movs.each(function(mov){ mov.setSteps(stepVal + stepVal * accel, 0); }); } b_right.onmouseout = function(){ //return; if(!this.on) return; accel = 0; this.on = false; movs.each(function(mov){ mov.setSteps(stepVal + stepVal * accel, 0); }); } } function init_menu_hover(){ if(!menu_root){ return; } menu_root.items.each(function(item){ //item.link = $T('A', item)[0]; item.pad = create_hover_pad($T("A", item)[0]); item.pad.style.width = item._width + "px"; item.appendChild(item.pad); if(item.className.indexOf("here") != -1 && item.className.indexOf("last") != -1){ item.className += " here-last"; } if(item.className.indexOf("here") != -1 && item.className.indexOf("first") != -1){ item.className += " here-first"; } item.onmouseover = function(){ if(this.className.indexOf("here") != -1){ return; } this.className += " over"; this.pad.style.width = this._width + "px"; } item.onmouseout = function(){ if(this.className.indexOf("here") != -1){ return; } this.className = this.className.replace("over", ""); } }) } function init_right_hover(root){ if(!root) return; var items = $T('LI', right_menu); items.each(function(item){ item.link = $T('A', item)[0]; if(!item.link){ throw $continue; } item.pad = create_hover_pad(item.link); item.appendChild(item.pad); item.link.onmouseover = function(){ if(this.parentNode.className.indexOf('here') != -1) return; this.parentNode.className += " over"; }; item.link.onmouseout = function(){ if(this.parentNode.className.indexOf('here') != -1) return; this.parentNode.className = this.className.replace('over', ''); }; }) } function create_hover_pad(lnk){ var pad = document.createElement("DIV"); pad.className = "hover-pad"; var pad_inner = document.createElement("DIV"); pad.appendChild(pad_inner); // pad.style.width = lnk.offsetWidth + 22 + "px"; return pad; } function create_hover_pad2(item){ var link = $T("A", item)[0]; var unpacked = new Unpacker(hover_pad2, item); var pad = unpacked.ReturnElements.main; /// pad.style.width = link.offsetWidth + 15 + "px" pad.inner = unpacked.ReturnElements.inner; return pad; } function init_sec_menu_hover(){ var root = $('secondary-menu'); if(!root) return; var items = $T('LI', root); items.each(function(item){ item.pad = create_hover_pad2(item); item.link = $T("A", item)[0]; var minus = 15; if(ie6){ minus = 13 } if(item.link.offsetHeight > 15){ item.pad.inner.style.height = item.link.offsetHeight - minus + "px"; }else{ if(item.className){ item.className += " one-line"; }else{ item.className = "one-line"; } item.pad.removeChild(item.pad.inner); } item.link.onmouseover = function(){ if(this.className.indexOf('here') != -1){ return; } this.className += " over"; }.bind(item) item.link.onmouseout = function(){ this.className = this.className.replace("over", ""); }.bind(item) }); } function init_track2(){ track2 = $('track2'); if(!track2){ return; } track2.label = $C('label', track2, 'DIV')[0]; track2.onmouseover = function(){ this.label.style.display = "block"; } track2.onmouseout = function(){ this.label.style.display = "none"; } } function show_images(){ var imgs = $C("hidden", document.body, "IMG"); imgs.each(function(img){ img.style.visibility = "visible"; }) } window.onresize = function(){ init_menu_resize(); min_width(); flashSnow_width(); } window.onload = function(){ init_vars(); init_menu_resize(); init_menu_hover(); init_right_hover(right_menu); init_right_hover($("sec-menu2")); init_sec_menu_hover(); min_width(); init_screen(); init_track2(); show_images(); flashSnow_width(); }