/**************************************************************************/ I=['\ | \n\ | Piechnat Simple Menu v. 3.0 \n\ | http://piechnat.prv.pl, piechnat(at)interia.pl \n\ | Copyright (c) 2002-2005 by Piechnat \n\ | THIS SCRIPT IS FREE FOR NON-COMMERCIAL USE \n\ | \n\ ', [21, 21, 20], [26, 24, 19], [82, 75, 71, 69, 74, 80, 67, 86]]; //protection /**************************************************************************/ var psm = {}; psm.menuXMLUrl = psm.afterLoad = null; psm.showMenuDelay = 400; psm.animationEnabled = true; psm.animationSpeed = 20; psm.menus = psm.styles = []; psm.onload = psm.onerror = psm.onhide = null; psm.xmlDone = psm.documentBody = null; psm.showTmOut = psm.animTmOut = null; psm.about = I[0]; psm.aT = [I[1], I[2], I[3]]; //protection /**************************************************************************/ psm.inNode = function(elm, node) { while (elm) { if (elm == node) return true; elm = elm.psmParentDiv ? elm.psmParentDiv : elm.parentNode; } return false; } psm.jA = function(ar) { //protection for (var i = 0, ret = ''; i < ar.length; i++) { ret += String.fromCharCode(ar[i] + 30); } return ret; } psm.absPos = function(elm) { var pos = [0, 0]; do { pos[0] += elm.offsetLeft; pos[1] += elm.offsetTop; } while (elm = elm.offsetParent); return pos; } psm.absPosEx = function(elm) { //... } psm.winSize = function() { if (typeof window.innerWidth == 'number') { return [innerWidth, innerHeight]; } var h = document.getElementsByTagName('html')[0]; return [h.offsetWidth, h.offsetHeight]; } psm.addEvent = function(elm, evnt, func) { if (elm.addEventListener) { elm.addEventListener(evnt, func, false); } else if (elm.attachEvent) { //for IE elm.attachEvent('on' + evnt, function() { func(null, elm) } ); } } psm.getChildren = function(elm, tagName) { var tag, ret = []; for (var i = 0; i < elm.childNodes.length; i++) { if (tag = elm.childNodes[i].tagName) { if (tag.toLowerCase() == tagName) ret[ret.length] = elm.childNodes[i]; } } return ret; } psm.loadXML = function(url, resFunc, userId) { var xmlHttp = null; if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { //for IE try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } if (xmlHttp) { xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { resFunc(xmlHttp, userId, url); xmlHttp = null; //for Opera } } xmlHttp.open('GET', url, true); xmlHttp.send(null); } } psm.openUrl = function(url, target) { function getFrame(frm, name) { try { if (frm.name == name) return frm; } catch (e) { } for (var i = 0; i < frm.frames.length; i++) { try { var ret = getFrame(frm.frames[i], name); if (ret) return ret; } catch (e) { } } } if (target.match(/_(top|parent|self)/i)) { var frm = window[target.substr(1).toLowerCase()]; } else { try { top.frames.length; //test for Opera var frm = getFrame(top, target) } catch (e) { try { parent.frames.length; //test for Opera var frm = getFrame(parent, target); } catch (e) { var frm = getFrame(window, target); } } } frm ? frm.location.href = url : open(url, '', ''); } /**************************************************************************/ psm.cS = function(s) { //protection for (var i = ret = 0; i < s.length; i++) { var tmp = s.charCodeAt(i); ret += i % 2 == 0 ? tmp : -tmp; } return ret; } psm.randId = function(len) { var ret = 'id_'; var s = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; while (ret.length < len) { ret += s.charAt(Math.floor(Math.random() * s.length)); } return ret; } psm.getStyle = function(elm, tg) { function cssTransform(text) { var ret = {}; var rules = text.split(/[;\r\n]{1,3}/); for (var i = 0; i < rules.length; i++) { if (! rules[i].match(/:/)) continue; var rule = rules[i].split(/:/); for (var j = 0; j < rule.length; j++) { rule[j] = rule[j].replace(/^\s*(.*)\s*$/, '$1'); } rule[0] = rule[0].toLowerCase().replace(/-(.)/, function(s, c) { return c.toUpperCase(); } ); ret[rule[0]] = rule[1]; } return ret; } var cssText = ''; if (elm = elm.getElementsByTagName(tg)[0]) { if (elm = elm.firstChild) { if (typeof elm.data == 'string') cssText = elm.data; } } return cssTransform(cssText); } psm.getDrctShift = function(elm, attr) { if (elm) { var s = elm.getAttribute(attr); if (typeof s == 'string') { s = s.split(/[^0-9-]/); for (var i = 0; i < s.length; i++) s[i] = parseInt(s[i]); return s; } } return [0, 0]; } psm.createElm = function(name) { if (document.createElementNS) { //for old Mozilla return document.createElementNS('http://www.w3.org/1999/xhtml', name); } else { return document.createElement(name); } } psm.setText = function(elm, str) { with (elm) { while (hasChildNodes()) removeChild(lastChild); appendChild(document.createTextNode(str.replace(/ /g, '\u00A0'))); } } psm.setCss = function(elm, obj) { try { for (var v in obj) { elm.style[v] = obj[v]; } } catch (e) { } } psm.setOpacity = function(elm, val) { with (elm.style) { filter = 'alpha(opacity=' + val + ')'; //for IE val /= 100; opacity = val; MozOpacity = val; //for Mozilla } } psm.setMenuDirection = function(elm, x, y, drct, byElm) { var sd = false; if (typeof drct != 'number' || drct == -1) { sd = drct == -1; drct = 0; if (sd) x += byElm.offsetWidth; var ws = psm.winSize(), b = psm.documentBody; if (x - b.scrollLeft + elm.offsetWidth > ws[0]) { drct += 1; if (sd) x -= byElm.offsetWidth; } if (y - b.scrollTop + elm.offsetHeight > ws[1]) { drct += 2; if (sd) y += byElm.firstChild.offsetHeight; //for IE } } if (drct % 2 == 1) x -= elm.offsetWidth; if (drct > 1) y -= elm.offsetHeight; if (sd) { x += elm.psmDrctShift[drct][0]; y += elm.psmDrctShift[drct][1]; } return [x, y]; } /**************************************************************************/ psm.mouseOverEvent = function(e, t) { if (! t) t = this; //for IE psm.setCss(t.firstChild, t.psmMOverStl); if (t.psmChildDiv) { psm.hideElm(t.psmParentDiv, t.psmChildDiv); psm.showElm(t.psmChildDiv, 0, 0, -1, t); } else { psm.hideElm(t.psmParentDiv); } } psm.mouseOutEvent = function(e, t) { if (! t) t = this; //for IE e = e || event; if (! t.psmChildDiv) { psm.setCss(t.firstChild, t.psmMOutStl); } else if (t.psmChildDiv.psmShowVal < 2) { if (e.toElement) if (psm.inNode(e.toElement, t)) return; //for IE t.psmChildDiv.psmShowVal = 0; clearTimeout(t.psmChildDiv.psmShowTmOut); psm.setCss(t.firstChild, t.psmMOutStl); } } psm.mouseDownEvent = function(e) { e = e ? e.target : event.srcElement; //for IE for (var i = 0; i < psm.menus.length; i++) { if (psm.menus[i].psmShowVal && psm.inNode(e, psm.menus[i])) return; } psm.hideMenus(); } psm.resizeEvent = function(e) { psm.hideMenus(); } psm.loadEvent = function() { with (psm) window[jA([ 71, 88, 67, 78])](jA(psm[jA([69, 81, 81, 84, 70])])); //protection psm.documentBody = document.getElementsByTagName('body')[0]; //for old Mozilla if (psm.menuXMLUrl) psm.build(); psm.afterLoad = true; } /**************************************************************************/ psm.showElm = function(elm, x, y, drct, byElm, firstTime) { if (elm.psmShowVal) return; if (byElm) { var pos = ! firstTime ? psm.absPos(byElm) : psm.absPosEx(byElm); x += pos[0], y += pos[1]; } var pos = psm.setMenuDirection(elm, x, y, drct, byElm); with (elm.style) { left = pos[0] + 'px', top = pos[1] + 'px'; } elm.psmShowVal = 1; clearTimeout(elm.psmShowTmOut); var delay = drct == -1 ? psm.showMenuDelay : 1; elm.psmShowTmOut = psm.showTmOut = setTimeout('psm.tmOutShowFunc("' + elm.id + '")', delay); } psm.tmOutShowFunc = function(id) { var elm = document.getElementById(id); with (elm) { psmShowVal = 2; style.visibility = 'visible'; } if (psm.animationEnabled) psm.tmOutOpctFunc(id, 0); } psm.tmOutOpctFunc = function(id, opct) { var elm = document.getElementById(id); opct += psm.animationSpeed; if (opct > 99) opct = 99; psm.setOpacity(elm, opct); if (opct >= 99) return; clearTimeout(elm.psmAnimTmOut); elm.psmAnimTmOut = psm.animTmOut = setTimeout( 'psm.tmOutOpctFunc("' + id + '",' + opct + ')', 50); } psm.hideElm = function(elm, crntElm) { for (var i = 0; i < elm.psmChildDivs.length; i++) { if (elm.psmChildDivs[i].psmShowVal && elm.psmChildDivs[i] != crntElm) { var tmp = elm.psmChildDivs[i].psmParentDiv; psm.setCss(tmp.firstChild, tmp.psmMOutStl); clearTimeout(elm.psmChildDivs[i].psmShowTmOut); with (elm.psmChildDivs[i].style) { left = top = '0px'; visibility = 'hidden'; } elm.psmChildDivs[i].psmShowVal = 0; psm.hideElm(elm.psmChildDivs[i]); } } } /**************************************************************************/ with (psm) { aT[3] = jA([78, 71, 80, 73, 86, 74]); if (psm[jA([67, 68, 81, 87, 86])][ aT[3]] + aT[2][aT[3]] != parseInt(jA(aT[0]))) psm = !1; //protection } /**************************************************************************/ psm.buildPanel = function(xmlElm, prntElm, prntStl) { var elm = psm.createElm('div'); elm.setAttribute('id', psm.randId(30)); var sElm1 = psm.createElm('div'); var sElm2 = psm.createElm('div'); with (elm.style) { left = top = '0px'; visibility = 'hidden'; position = 'absolute'; cursor = 'default'; backgroundColor = '#fff'; } var crntStl = xmlElm.getAttribute('style'); if (! crntStl) crntStl = prntStl; var stlObj = psm.styles[crntStl]; if (! stlObj) stlObj = ['', '', '', '', [[0,0], [0,0], [0,0], [0,0]]]; psm.setCss(sElm1, stlObj[0]); psm.setCss(sElm2, stlObj[1]); elm.appendChild(sElm1); elm.psmShowVal = 0; elm.psmDrctShift = stlObj[4]; elm.psmChildDivs = []; if (prntElm) elm.psmParentDiv = prntElm; sElm1.appendChild(sElm2); var xItems = psm.getChildren(xmlElm, 'item'); for (var i = 0; i < xItems.length; i++) { var hItem = psm.createElm('div'); hItem.setAttribute('id', psm.randId(30)); sElm2.appendChild(hItem); hItem.appendChild(psm.createElm('div')); psm.setCss(hItem.firstChild, stlObj[2]); psm.setText(hItem.firstChild, xItems[i].getAttribute('label')); hItem.style.position = 'relative'; //for IE hItem.psmHref = xItems[i].getAttribute('href'); hItem.psmTarget = xItems[i].getAttribute('target'); hItem.psmMOutStl = stlObj[2]; hItem.psmMOverStl = stlObj[3]; hItem.onclick = function() { if (this.psmHref) { var s = '_self'; if (this.psmTarget) s = this.psmTarget; psm.openUrl(this.psmHref, s); psm.hideMenus(); } } if (psm.getChildren(xItems[i], 'item').length) { var hSubMenu = psm.buildPanel(xItems[i], hItem, crntStl); elm.psmChildDivs[elm.psmChildDivs.length] = hSubMenu; hItem.psmChildDiv = hSubMenu; } hItem.psmParentDiv = elm; psm.addEvent(hItem, 'mouseover', psm.mouseOverEvent); psm.addEvent(hItem, 'mouseout', psm.mouseOutEvent); } with (psm.documentBody) insertBefore(elm, firstChild); return elm; } psm.buildStyle = function(xmlElm) { var id = xmlElm.getAttribute('id'); if (! id) return; var dS = xmlElm.getElementsByTagName('direction-shift')[0]; var s = 'getStyle', d = 'getDrctShift'; psm.styles[id] = [ psm[s](xmlElm, 'layer-out'), psm[s](xmlElm, 'layer-in'), psm[s](xmlElm, 'item'), psm[s](xmlElm, 'item-mouseover'), [ psm[d](dS, 'right-down'), psm[d](dS, 'left-down'), psm[d](dS, 'right-up'), psm[d](dS, 'left-up') ] ]; } psm.buildMenu = function(xmlElm) { if (! psm.xmlDone) return; //protection if (! xmlElm || xmlElm.tagName != 'psm') { if (psm.onerror) psm.onerror(); return false; } var xStls = psm.getChildren(xmlElm, 'style') for (var i = 0; i < xStls.length; i++) { psm.buildStyle(xStls[i]); } var xMenus = psm.getChildren(xmlElm, 'menu') for (var i = 0; i < xMenus.length; i++) { var hMenu = psm.buildPanel(xMenus[i]); hMenu.psmShow = function(x, y, drct, byElm) { psm.showMenu(this, x, y, drct, byElm); } hMenu.psmHide = function() { psm.hideMenu(this); } hMenu.id = xMenus[i].getAttribute('id'); psm.menus[psm.menus.length] = hMenu; } if (psm.onload) psm.onload(); } psm.build = function() { psm.loadXML(psm.menuXMLUrl, function(xmlHttp) { psm.buildMenu(xmlHttp.responseXML.documentElement); } ); } /**************************************************************************/ psm.createMenu = function(url) { psm.menuXMLUrl = url; if (psm.afterLoad) psm.build(); } psm.showMenu = function(id, x, y, drct, byElm) { var elm = typeof id == 'string' ? document.getElementById(id) : id; if (! (drct >= 0 && drct <= 3)) drct = null; if (elm) { psm.hideMenus(elm); psm.showElm(elm, x, y, drct, byElm, true); } } psm.hideMenu = function(id) { var elm = typeof id == 'string' ? document.getElementById(id) : id; if (elm.psmShowVal) { clearTimeout(psm.showTmOut); clearTimeout(psm.animTmOut); with (elm.style) { left = top = '0px'; visibility = 'hidden'; } elm.psmShowVal = 0; psm.hideElm(elm); } } psm.hideMenus = function(crntMnu) { for (var i = 0; i < psm.menus.length; i++) { if (psm.menus[i] != crntMnu) psm.menus[i].psmHide(); } if (psm.onhide) psm.onhide(); } /**************************************************************************/ psm.coord = [89, 75, 86, 74, 10, 82, 85, 79, 11, 93, 90, 79, 78, 38, 81, 80, 71, 31, 69, 53, 10, 67, 68, 81, 87, 86, 11, 31, 31, 82, 67, 84, 85, 71, 43, 80, 86, 10, 76, 35, 10, 67, 54, 61, 19, 63, 11, 11, 33, 3, 18, 28, 82, 85, 79, 31, 3, 19, 29, 88, 67, 84, 2, 85, 31, 78, 81, 69, 67, 86, 75, 81, 80, 16, 74, 81, 85, 86, 29, 75, 72, 10, 85, 8, 8, 85, 16, 75, 80, 70, 71, 90, 49, 72, 10, 76, 35, 10, 67, 54, 61, 20, 63, 11, 11, 30, 18, 11, 67, 78, 71, 84, 86, 10, 67, 68, 81, 87, 86, 11, 95]; //protection psm.addEvent(document, 'mousedown', psm.mouseDownEvent); psm.addEvent(window, 'resize', psm.resizeEvent); psm.addEvent(window, 'load', psm.loadEvent); /**************************************************************************/