var P = 'prototype'; var TUserAgent = { }; TUserAgent.AGENT = navigator.userAgent; TUserAgent.PLATFORM = navigator.platform; TUserAgent.OPERA = typeof opera != "undefined"; TUserAgent.IE = !TUserAgent.OPERA && TUserAgent.AGENT.indexOf('MSIE') != -1; TUserAgent.SAFARI = !TUserAgent.OPERA && TUserAgent.AGENT.indexOf('WebKit') != -1; TUserAgent.KONQUEROR = !TUserAgent.OPERA && TUserAgent.AGENT.indexOf('Konqueror') != -1; TUserAgent.GECKO = !TUserAgent.OPERA && TUserAgent.AGENT.product == 'Gecko'; TUserAgent.CAMINO = TUserAgent.GECKO && TUserAgent.AGENT.vendor == 'Camino'; TUserAgent.MAC = TUserAgent.PLATFORM.indexOf('Mac'); TUserAgent.WIN = TUserAgent.PLATFORM.indexOf('Win'); TUserAgent.LINUX = TUserAgent.PLATFORM.indexOf('Linux'); var TDOM = function() { }; TDOM.getElement = function(el) { return typeof el == "string" ? document.getElementById(el) : el; }; TDOM.getDocumentNode = function(el) { el = TDOM.getElement(el) || document; return el.nodeType == 9 ? el : el.ownerDocument || el.document || document; }; TDOM.getDocumentElement = function(el) { var doc = TDOM.getDocumentNode(el); return document.compatMode == 'CSS1Compat' ? doc.documentElement : doc.body; }; TDOM.resolveTextNode = function(node) { return node && node.nodeType == 3 && node.parentNode ? node.parentNode : node; }; TDOM.seekElement = function(node, prev) { while (node && node.nodeType != 1) { node = prev ? node.previousSibling : node.nextSibling; }; return node; }; TDOM.nextElement = function(node) { return TDOM.seekElement(node ? node.nextSibling : null); }; TDOM.previousElement = function(node) { return TDOM.seekElement(node ? node.previousSibling : null, true); }; TDOM.firstChild = function(node) { return TDOM.seekElement(node ? node.firstChild : null); }; TDOM.lastChild = function(node) { return TDOM.seekElement(node ? node.lastChild : null); }; TDOM.insertElement = function(a, after, b) { if (b && b.parentNode) { b = after ? TDOM.nextElement(b) : b; if (b) { b.parentNode.insertBefore(a,b); } else { b.parentNode.appendChild(a); }; }; }; TDOM.removeElement = function(el) { if (el && el.parentNode) { el.parentNode.removeChild(el); }; }; TDOM.getSize = function(el, autoWidth) { var w = h = 0; el = TDOM.getElement(el); if (TDOM.getStyle(el, "display") != "none") { w = el.offsetWidth ? el.offsetWidth : 0; h = el.offsetHeight ? el.offsetHeight : 0; } else { var style = el.style; w = TDOM.getStyle(el, "width"); if (!autoWidth) { if (w == "auto" || w.indexOf("%") != -1) { var parent = el.parentNode; while (parent && TDOM.getStyle(parent, "display") == "none") { parent = parent.parentNode; }; if (parent) { w = parent.offsetWidth ? parent.offsetWidth : 0; }; }; }; var oldPos = style.position; var oldVis = style.visibility; var oldWidth = style.width; style.width = isNaN(parseInt(w)) ? w : w + 'px'; style.visibility = "hidden"; style.position = "absolute"; style.display = ""; w = el.offsetWidth ? el.offsetWidth : 0; h = el.offsetHeight ? el.offsetHeight : 0; style.width = oldWidth; style.display = "none"; style.position = oldPos; style.visibility = oldVis; }; return {width:w, height:h}; }; TDOM.getPos = function(el) { el = TDOM.getElement(el); var doc = TDOM.getDocumentNode(el); if (el.getBoundingClientRect) { var box = el.getBoundingClientRect(); var scroll = TDOM.getScroll(doc); return {x:box.left + scroll.x, y:box.top + scroll.y}; } else { var y = el.offsetTop; var x = el.offsetLeft; var parent = el.offsetParent; if (parent != el) { while (parent) { y += parent.offsetTop; x += parent.offsetLeft; parent = parent.offsetParent; }; }; if (TUserAgent.OPERA || TUserAgent.SAFARI && TDOM.getStyle(el, "position") == "absolute") { y -= doc.body.offsetTop; }; parent = el.parentNode; var body = TDOM.getDocumentElement(doc); while (parent && parent != body) { x -= parent.scrollLeft; if (!TUserAgent.OPERA || parent.tagName != "TR") { y -= parent.scrollTop; }; parent = parent.parentNode; }; return {x:x, y:y}; }; }; TDOM.getBounds = function(el, autoWidth) { var size = TDOM.getSize(el, autoWidth); var pos = TDOM.getPos(el); return {top:pos.y, left:pos.x, width:size.width, height:size.height}; }; TDOM.getViewportSize = function() { var w = window.innerWidth; var h = window.innerHeight; if (!w && !h) { var b = TDOM.getDocumentElement(); var w = b ? b.clientWidth : 0; var h = b ? b.clientHeight : 0; }; return {width:w, height:h}; }; TDOM.getDocumentSize = function() { var v = TDOM.getViewportSize(); var b = TDOM.getDocumentElement(); return {width:Math.max(b.scrollWidth, v.width), height:Math.max(b.scrollHeight, v.height)}; }; TDOM.getScroll = function(doc) { var b = TDOM.getDocumentElement(doc); return {x:b.scrollLeft, y:b.scrollTop}; }; TDOM.getViewportBounds = function() { var pos = TDOM.getScroll(); var size = TDOM.getViewportSize(); return {top:pos.y, left:pos.x, width:size.width, height:size.height}; }; TDOM.hasClass = function(el,cl) { var re = new RegExp('(^|\\s+)?' + cl + '(\\s+|$)?'); return re.test(el.className); }; TDOM.addClass = function(el,cl) { if (TDOM.hasClass(el,cl)) return; if (!el.className) { el.className = cl; } else { el.className = [el.className, cl].join(' '); }; }; TDOM.removeClass = function(el,cl) { if (!TDOM.hasClass(el,cl)) return; var re = new RegExp('(^|\\s+)?' + cl + '(\\s+|$)?','g'); var cl = el.className; el.className = cl.replace(re,' '); }; TDOM.getStyle = function(el, property) { el = TDOM.getElement(el); var doc = TDOM.getDocumentNode(el); if (doc.defaultView && doc.defaultView.getComputedStyle) { property = property == 'float' ? 'cssFloat' : property; var styles = doc.defaultView.getComputedStyle(el, ""); if (styles) { if (property == 'opacity') { property = "MozOpacity" in styles ? "MozOpacity" : property; property = "KhtmlOpacity" in styles ? "KhtmlOpacity" : property; }; return styles[property]; }; } else if (el.currentStyle) { if (property == 'opacity' && el.filters) { var val = 100; try { val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity; } catch(e) { try { val = el.filters('alpha').opacity; } catch(e) { }; }; return val / 100; }; property = property == 'float' ? 'styleFloat' : property; return el.currentStyle[property]; }; return el.style[property]; }; TDOM.setStyle = function(el, property, value) { el = TDOM.getElement(el); if (property == 'opacity') { if (value < 0 || value > 1) { return; }; if ("opacity" in el.style) { el.style.opacity = value; } else if ("MozOpacity" in el.style) { el.style.MozOpacity = value; } else if ("KhtmlOpacity" in el.style) { el.style.KhtmlOpacity = value; } else if ("filter" in el.style) { el.style.filter = "alpha(opacity=" + value * 100 + ")"; }; return; }; if (property == 'float') { property = TUserAgent.IE ? 'styleFloat' : 'cssFloat'; }; el.style[property] = value; }; if (!Function[P].apply) { Function[P].apply = function (scope, args) { args = args || []; scope = scope || window; var argument = []; for (var i = 0; i < args.length; i++) { argument[i] = "args[" + i + "]"; }; scope.__applyTemp__ = this; result = eval("scope.__applyTemp__(" + argument.join(",") + ");"); scope.__applyTemp__ = null; return result; }; }; Function[P].inherits = function(a) { this.prototype = new a; this[P].constructor = this; }; String[P].trim = function() { return this.replace(/^\s+|\s+$/, ''); }; if (!Array[P].push) { Array[P].push = function () { for (var i = 0; i < arguments.lenght; i++) { this[this.length] = arguments[i]; }; return this.length; }; }; if (!Array[P].pop) { Array[P].pop = function () { var el = null; if (this.length > 0) { el = this[this.length - 1]; this.length--; }; return el; }; }; if(!Array[P].unshift) { Array[P].unshift = function() { this.reverse(); for(var i = arguments.length-1; i >= 0; i--) { this[this.length] = arguments[i]; }; this.reverse(); return this.length; }; }; if (!Array[P].shift) { Array[P].pop = function () { var el = null; if (this.length > 0) { el = this[0]; this.reverse(); this.length--; this.reverse(); }; return el; }; }; if (!Array[P].splice) { Array[P].splice = function(index, count) { var len = this.length; var arglen = arguments.length; if (arglen == 0) { return index; }; if (typeof(index) != "number") { index = 0; } else if (index < 0) { index = Math.max(0, len + index); }; if (index > len) { if (arglen > 2) { index = len; } else { return []; }; if (arglen < 2) { count = len - index; count = (typeof(count) == "number") ? Math.max(0,count) : 0; var removeArray = this.slice(index, index + count); var endArray = this.slice(index + count); len = this.length = index; for (var i = 2; i < arglen; i++) { this[len++] = arguments[i]; for (var i = 0, endlen = endArray.length; i < endlen; i++) { this[len++] = endArray[i]; return removeArray; }; }; }; }; }; }; var TEvent = function (type, target) { this.type = type; this.target = target; this.currentTarget = target; }; TEvent[P].free = function() { }; TEvent[P].stopPropagation = function() { }; TEvent[P].preventDefault = function() { }; TDOMEvent = function (e, target) { TEvent[P].constructor.call(this, e.type, target); this.event = e; target = e.target || e.srcElement; this.target = TDOM.resolveTextNode(target); this.relatedTarget = e.relatedTarget; if (!this.relatedTarget) { if (this.type == "mouseover") { this.relatedTarget = e.fromElement; } else if (this.type == "mouseout") { this.relatedTarget = e.toElement; }; }; this.keyCode = e.keyCode || e.which || 0; this.charCode = e.charCode || (this.type == "keypress" ? e.keyCode : 0); this.ctrlKey = e.ctrlKey; this.altKey = e.altKey; this.shiftKey = e.shiftKey; this.metaKey = e.metaKey; this.screenX = e.screenX || 0; this.screenY = e.screenY || 0; this.offsetX = typeof e.layerX != "undefined" ? e.layerX : e.offsetX; this.offsetY = typeof e.layerY != "undefined" ? e.layerY : e.offsetY; this.clientX = typeof e.clientX != "undefined" ? e.clientX : e.pageX; this.clientY = typeof e.clientY != "undefined" ? e.clientY : e.pageY; this.buttons = TUserAgent.IE ? { left: e.button & 1, middle: e.button & 4, right: e.button & 2 } : { left: e.button == 0, middle: e.button == 1, right: e.which ? e.which == 3 : e.button == 2 }; }; TDOMEvent.inherits(TEvent); TDOMEvent[P].stopPropagation = function () { if(this.event.stopPropagation){ this.event.stopPropagation(); }else{ this.event.cancelBubble = true; }; }; TDOMEvent[P].preventDefault = function () { if(this.event.preventDefault){ this.event.preventDefault(); }else{ this.event.returnValue = false; }; }; var TEventDispatcher = function () { }; TEventDispatcher[P].isDispatcher = true; TEventDispatcher[P].addEventListener = function (type, callback, scope) { TEvents.listen(this, type, callback, scope); }; TEventDispatcher[P].removeEventListener = function (type, callback, scope) { TEvents.unlisten(this, type, callback, scope); }; TEventDispatcher[P].dispatch = function (type) { var args = Array[P].slice.call(arguments,0); args.unshift(this); return TEvents.dispatch.apply(this, args); }; TEventDispatcher[P].free = function () { TEvents.unlistenAll(this); }; var TEvents = function() {}; TEvents.nextIndex = 1; TEvents.listeners = {}; TEvents._items = []; TEvents.getIndex = function (obj) { var prop = "dispatcher_unique_index"; if (obj.hasOwnProperty && obj.hasOwnProperty(prop)) { return obj[prop]; }; if (!obj[prop]) { obj[prop] = 'e' + TEvents.nextIndex++; }; return obj[prop]; }; TEvents.getListener = function (src, type, callback, scope) { src = TDOM.getElement(src); var id = TEvents.getIndex(src); var list = TEvents.listeners; if (list[id] && list[id][type]) { list = list[id][type]; for (var i = 0; i < list.length; i++) { if (list[i].callback == callback && list[i].scope == scope) { return list[i]; }; }; }; return null; }; TEvents.listen = function (src, type, callback, scope) { src = TDOM.getElement(src); if (!src || !callback || !callback.call) { return false; }; scope = scope ? scope : src; var l = TEvents.getListener(src, type, callback, scope); if (!l) { var id = TEvents.getIndex(src); var list = TEvents.listeners; list[id] = list[id] || {}; list[id][type] = list[id][type] || []; list = list[id][type]; l = {src:src, type:type, callback:callback, scope:scope}; var wrapper = function (e) { return TEvents.fireListener(l, e); }; l.wrapper = wrapper; list.push(l); if (src.addEventListener) { if (!src.isDispatcher) { src.addEventListener(type, wrapper, false); }; } else if (src.attachEvent) { src.attachEvent("on" + type, wrapper); } else { return false; }; }; return true; }; TEvents.unlisten = function(src, type, callback, scope) { src = TDOM.getElement(src); var l = null; var id = TEvents.getIndex(src); var list = TEvents.listeners; scope = scope ? scope : src; if (list[id] && list[id][type]) { list = list[id][type]; for (var i = 0; i < list.length; i++) { if (list[i].callback == callback && list[i].scope == scope) { l = list[i]; list.splice(i, 1); break; }; }; }; if (l) { if (src.removeEventListener) { if (!src.isDispatcher) { src.removeEventListener(type, l.wrapper, false); }; } else if (src.detachEvent) { src.detachEvent("on" + type, l.wrapper); }; }; }; TEvents.unlistenAll = function(src) { src = TDOM.getElement(src); var id = TEvents.getIndex(src); if (TEvents.listeners[id]) { for (var type in TEvents.listeners[id]) { TEvents.unlistenType(src, type); }; delete TEvents.listeners[id]; }; }; TEvents.unlistenType = function (src, type) { src = TDOM.getElement(src); var id = TEvents.getIndex(src); if (TEvents.listeners[id] && TEvents.listeners[id][type]) { var l = TEvents.listeners[id][type][0]; while (l) { TEvents.unlisten(l.src, l.type, l.callback, l.scope); l = TEvents.listeners[id][type][0]; }; delete TEvents.listeners[id][type]; }; }; TEvents.fireListener = function(l, e) { if (!l) { return true; }; e = e || window.event; var event = new TDOMEvent(e, l.src); try { return l.callback.call(l.scope, event) !== false; } finally { event.event = null; }; }; TEvents.dispatch = function (src, e) { src = TDOM.getElement(src); e = new TEvent(e, src); var id = TEvents.getIndex(src); var result = true; if (TEvents.listeners[id] && TEvents.listeners[id][e.type]) { var list = TEvents.listeners[id][e.type]; var args = Array[P].slice.call(arguments,2); args.unshift(e); for (var i = 0; i < list.length; i++) { result = result && list[i].callback.apply(list[i].scope, args) !== false; }; }; return result; }; TSwf = function(name, movie, width, height) { this._vars = []; this._eattrs = {}; this._oattrs = {}; this._params = {}; this.name = name; this.movie = movie; this.width = width ? width : 150; this.height = height ? height : 150; this.version = '9,0,0,0'; this.transparent = false; this.preventcache = false; this.set('id', name); this.set('src', movie); this.set('menu', false); this.set('quality', 'high'); this.set('allowScriptAccess','sameDomain'); this.set('type', 'application/x-shockwave-flash'); this.set('classid', 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'); this.set('pluginspage', 'http://www.macromedia.com/go/getflashplayer'); }; TSwf[P].addVar = function(name, value) { this._vars.push(name + '=' + escape(value)); }; TSwf[P].addVars = function(vars) { if (vars) { vars = vars.split('&'); for (var i = 0; i < vars.length; i++) { this._vars.push(vars[i]); }; }; }; TSwf.draw = function(movie, width, height, transparent, vars) { var swf = new TSwf('', movie, width, height); swf.transparent = transparent ? true : false; swf.addVars(vars); swf.draw() }; TSwf[P].draw = function(container) { container = TDOM.getElement(container); if (container) { container.innerHTML = this.toHTML(); } else { document.write(this.toHTML()); }; }; TSwf[P].toHTML = function() { if (this.preventcache) { var src = this._params["movie"]; src += src.indexOf('?') != -1 ? '&' : '?'; src += Math.random(); this.set('src', src); }; this.set('width', this.width); this.set('height', this.height); this.set('wmode', this.transparent ? 'transparent' : 'window'); this.set('codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.version); if (this._vars.length > 0) { this.addVars(this._params['flashvars']); this.set('flashvars', this._vars.join('&')); }; var html = ''; if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { html += '<embed '; for (var i in this._eattrs) { html += i + '="' + this._eattrs[i] + '" '; }; html += '> </embed>'; } else { html += '<object '; for (var i in this._oattrs) { html += i + '="' + this._oattrs[i] + '" '; }; html += '>'; for (var i in this._params) { html += '<param name="' + i + '" value="' + this._params[i] + '" /> '; }; html += '</object>'; }; return html; }; TSwf[P].set = function(name, value) { switch (name){ case "classid": this._oattrs[name] = value; break; case "pluginspage": this._eattrs[name] = value; break; case "src": case "movie": this._eattrs["src"] = this._params["movie"] = value; break; case "id": case "name": this._eattrs["id"] = this._eattrs["name"] = this._oattrs["id"] = this._oattrs["name"] = value; break; case "width": case "height": case "align": case "vspace": case "hspace": case "class": case "title": case "accesskey": case "tabindex": this._eattrs[name] = this._oattrs[name] = value; break; case "onafterupdate": case "onbeforeupdate": case "onblur": case "oncellchange": case "onclick": case "ondblclick": case "ondrag": case "ondragend": case "ondragenter": case "ondragleave": case "ondragover": case "ondrop": case "onfinish": case "onfocus": case "onhelp": case "onmousedown": case "onmouseup": case "onmouseover": case "onmousemove": case "onmouseout": case "onkeypress": case "onkeydown": case "onkeyup": case "onload": case "onlosecapture": case "onpropertychange": case "onreadystatechange": case "onrowsdelete": case "onrowenter": case "onrowexit": case "onrowsinserted": case "onstart": case "onscroll": case "onbeforeeditfocus": case "onactivate": case "onbeforedeactivate": case "ondeactivate": case "codebase": this._oattrs[name] = value; break; default: this._eattrs[name] = this._params[name] = value; }; }; var THttp = function () { this.xhr = null; this.open = false; this.params = []; this.aborted = false; this.error = false; this.lastError = ''; }; THttp.inherits(TEventDispatcher); THttp.msxml = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]; THttp[P].free = function () { if (this.xhr) { this.abort(); }; this.xhr.onreadystatechange = function() { }; this.xhr = null; TEventDispatcher[P].free.call(this); }; THttp[P].clear = function() { this.params = []; }; THttp[P].getParams = function() { return this.params.join('&'); }; THttp[P].addParam = function(name,value) { this.params.push(name+'='+value); }; THttp[P].addParams = function(params) { if (params) { params = params.split('&'); for (var i = 0; i < params.length; i++) { this.params.push(params[i]); }; }; }; THttp[P].toString = function() { return this.xhr ? this.xhr.responseText : ''; }; THttp[P].toXML = function() { return this.xhr ? this.xhr.responseXML : null; }; THttp[P].toScript = function() { try { return this.xhr ? eval("(" + this.xhr.responseXML + ")") : null; } catch (e) { }; }; THttp[P].getResponseHeader = function(hdr) { if (this.xhr && this.xhr.readyState == 4) { return this.xhr.getResponseHeader(hdr); }; }; THttp[P].getXhr = function() { if (this.xhr) { return this.xhr; }; if (typeof XMLHttpRequest != 'undefined') { return new XMLHttpRequest; } else { if (typeof THttp.msxml == "string") { return new ActiveXObject(THttp.msxml); } else { for(var i=0; i < THttp.msxml.length; i++){ try { var xhr = new ActiveXObject(THttp.msxml[i]); THttp.msxml = THttp.msxml[i]; return xhr; } catch(e){}; }; }; }; throw new Error("Could not create XML HTTP Request Object.\nUpdate your browser"); }; THttp[P].readyStateChange = function() { if (!this.xhr || this.aborted) { return; }; this.dispatch("readystatechange"); if (this.xhr.readyState == 4) { this.open = false; if (this.xhr.status == 200) { this.dispatch("complete"); this.dispatch("success"); } else { this.error = true; this.lastError = "[" + this.xhr.status + "] " + this.xhr.statusText; this.dispatch("complete"); this.dispatch("error", this.xhr.status, this.xhr.statusText); }; this.dispatch("ready"); }; }; THttp[P].abort = function() { if (this.open) { this.open = false; this.aborted = true; this.dispatch("complete"); this.dispatch("abort"); this.dispatch("ready"); }; }; THttp.send = function (url, callback, method, params) { var http = new THttp; http.addEventListener("complete", callback); http.addEventListener("ready", http.free, http); http.send(url, method, params); }; THttp[P].send = function (url, method, params) { this.abort(); this.xhr = this.getXhr(); this.open = true; this.error = false; this.aborted = false; this.addParams(params); var This = this; var params = this.getParams(); method = method && method.toUpperCase() == 'POST' ? 'POST' : 'GET'; if (method == 'GET' && params != '') { url += url.indexOf('?') ? '&'+params : '?'+params; params = ''; }; this.dispatch("open"); try { this.xhr.open(method,url,true); this.xhr.onreadystatechange = function() { This.readyStateChange.call(This); }; this.xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=iso-8859-1"); if (method == 'POST') { this.xhr.setRequestHeader("Content-Length", params.length); }; this.xhr.send(params); } catch (e) { this.error = true; this.lastError = "Error while opening connection"; this.dispatch("complete"); this.dispatch("error", 0, "Error while opening connection"); }; }; THttp[P].get = function (url) { this.send(url, 'GET'); }; THttp[P].post = function (url, params) { this.send(url, 'POST', params); }; var TTabSet = function (tabset, selected) { this.count = 0; this.tabset = TDOM.getElement(tabset); this.selected = typeof selected == "number" || selected >= 0 ? selected : -1; if (this.tabset) { var tab = TDOM.firstChild(this.tabset); while (tab) { var id = this.count++; tab[TTabSet.ownAttr] = id; this.selected == id ? TDOM.addClass(tab, 'selected') : TDOM.removeClass(tab, 'selected'); TEvents.listen(tab, 'click', this.doClick, this); TEvents.listen(tab, 'mouseout', this.doOut, this); TEvents.listen(tab, 'mouseover', this.doOver, this); tab = TDOM.nextElement(tab); }; this.selected = this.selected > this.count-1 ? -1 : this.selected; }; }; TTabSet.inherits(TEventDispatcher); TTabSet.ownAttr = "tabset_tab_unique_id"; TTabSet[P].doOut = function (e) { TDOM.removeClass(e.currentTarget, 'over'); }; TTabSet[P].doOver = function (e) { TDOM.addClass(e.currentTarget, 'over'); }; TTabSet[P].doClick = function (e) { this.dispatch("click", e.currentTarget); this.select(e.currentTarget); }; TTabSet[P].getTabById = function (id) { var tab = TDOM.firstChild(this.tabset); while (tab) { if (tab[TTabSet.ownAttr] == id) { return tab; }; tab = TDOM.nextElement(tab); }; return null; }; TTabSet[P].select = function (tab) { if (typeof tab == 'number') { var id = tab; tab = this.getTabById(tab); } else { var id = tab[TTabSet.ownAttr]; }; if (id == this.selected) { return; }; id = id > this.count-1 || id < 0 ? -1 : id; var old = this.getTabById(this.selected); var canchange = this.dispatch("canchange", old, tab, id) !== false; if (canchange) { if (old) { TDOM.removeClass(old, 'selected'); }; if (tab) { TDOM.addClass(tab, 'selected'); }; this.selected = id; this.dispatch("change", tab, id); }; }; TAccMenu = function(menu, opened) { this.menu = TDOM.getElement(menu); this.opened = opened && opened.length ? opened : []; this.count = 0; this.speed = 13; this.multiOpen = true; this._anims = []; this._recs = []; if (this.menu && this.menu.tagName.toUpperCase() == 'DL') { var dt = TDOM.firstChild(this.menu); while (dt && dt.nodeName.toUpperCase() != 'DT') { dt = TDOM.nextElement(dt); }; while (dt) { var dd = TDOM.nextElement(dt); if (dd && dd.nodeName.toUpperCase() == 'DD') { var id = this.count++; dt[TAccMenu.ownAttr] = id; TDOM.addClass(dt, 'menu'); TEvents.listen(dt, 'click', this.doClick, this); TEvents.listen(dt, 'mouseover', this.doOver, this); TEvents.listen(dt, 'mouseout', this.doOut, this); var opened = this.tabOpen(id); opened ? TDOM.addClass(dt, 'open') : TDOM.removeClass(dt, 'open'); while (dd && dd.nodeName.toUpperCase() == 'DD') { opened ? TDOM.addClass(dd, 'open') : TDOM.removeClass(dd, 'open'); dd[TAccMenu.ownAttr] = id; dd.style.display = opened ? 'block' : 'none'; dd = TDOM.nextElement(dd); }; }; dt = dd; }; }; }; TAccMenu.inherits(TEventDispatcher); TAccMenu.ownAttr = "accmenu_tab_unique_id"; TAccMenu[P].tabOpen = function (id) { id = typeof id == "number" ? id : (typeof id == "object" ? id[TAccMenu.ownAttr] : id); if (!isNaN(parseInt(id))) { for (var i = 0; i < this.opened.length; i++) { if (this.opened[i] == id) { return true; }; }; }; return false; }; TAccMenu[P].getTab = function(id) { var dt = TDOM.firstChild(this.menu); while (dt) { if (dt.nodeName.toUpperCase() == 'DT') { if (dt[TAccMenu.ownAttr] == id) { return dt; }; }; dt = TDOM.nextElement(dt); }; return null; }; TAccMenu[P].doOver = function(e) { var id = parseInt(e.currentTarget[TAccMenu.ownAttr]); if (!isNaN(id)) { TDOM.addClass(e.currentTarget, 'over'); this.dispatch("mouseover", id); }; }; TAccMenu[P].doOut = function(e) { var id = parseInt(e.currentTarget[TAccMenu.ownAttr]); if (!isNaN(id)) { TDOM.removeClass(e.currentTarget, 'over'); this.dispatch("mouseout", id); }; }; TAccMenu[P].doClick = function(e) { var dt = e.currentTarget; var id = parseInt(dt[TAccMenu.ownAttr]); if (isNaN(id)) { return; }; this.dispatch("click", dt, id); this.tabOpen(id) ? this.setOpen(dt, false) : this.setOpen(dt, true); }; TAccMenu[P].stopAnim = function (id) { var anims = this._anims[id]; if (anims && anims.length) { while (anims.length > 0) { var anim = anims.shift(); window.clearInterval(anim); }; }; }; TAccMenu[P].initAnim = function (dd, open) { var rec = TDOM.getBounds(dd); var to = open ? rec.height : 0; var from = open ? 0 : rec.height; var speed = this.speed; dd.style.overflow = 'hidden'; if (open) { dd.style.height = '0px'; dd.style.display = 'block'; }; var anim = window.setInterval( function () { from = open ? from + speed : from - speed; if (open && from > to) { dd.style.height = ''; window.clearInterval(anim); return; } else if (!open && from < to) { dd.style.display = 'none'; dd.style.height = ''; window.clearInterval(anim); return; }; dd.style.height = from + 'px'; }, 10); return anim; }; TAccMenu[P].setOpen = function(dt, open) { dt = typeof dt == "number" ? this.getTab(dt) : dt; if (dt && dt.nodeName && dt.nodeName.toUpperCase() == 'DT') { var id = parseInt(dt[TAccMenu.ownAttr]); this._anims[id] = this._anims[id] || []; if (open) { if (this.tabOpen(id)) { return; }; if (!this.multiOpen) { for (var i = 0; i < this.opened.length; i++) { this.setOpen(this.opened[i], false); }; }; TDOM.addClass(dt, 'open'); this.opened.push(id); } else { if (!this.tabOpen(id)) { return; }; TDOM.removeClass(dt, 'open'); for (var i = 0; i < this.opened.length; i++) { if (this.opened[i] == id) { this.opened.splice(i, 1); break; }; }; }; this.stopAnim(id); var dd = TDOM.nextElement(dt); while (dd && dd.nodeName.toUpperCase() == 'DD') { open ? TDOM.addClass(dd, 'open') : TDOM.removeClass(dd, 'open'); if (dd[TAccMenu.ownAttr] == dt[TAccMenu.ownAttr]) { if (this.speed != 0) { this._anims[id].push(this.initAnim(dd, open)); } else { dd.style.display = 'block'; }; }; dd = TDOM.nextElement(dd); }; }; }; var TModalWin = function(clickclose) { this.modal = null; this.color = '#000'; this.opacity = 0.8; this.content = null; this.topstick = -1; this.back = document.createElement('div'); this.back.style.zIndex = TModalWin.nextZIndex++; this.back.style.display = 'none'; this.back.style.position = 'absolute'; if (clickclose) { TEvents.listen(this.back, 'click', this.close, this); }; this.front = document.createElement('div'); this.front.style.zIndex = TModalWin.nextZIndex++; this.front.style.display = 'none'; this.front.style.position = 'absolute'; this.front.style.textAlign = 'center'; document.body.appendChild(this.back); document.body.appendChild(this.front); }; TModalWin.nextZIndex = 9998; TModalWin[P].show = function(content) { if (this.content) { this.front.removeChild(this.content); this.content = null; }; if (typeof content == "string") { this.content = document.createElement('div'); this.content.innerHTML = content; } else { this.content = TDOM.getElement(content); }; this.open(); }; TModalWin[P].open = function() { if (!this.content) { return; }; this.resize(); if (!this.modal) { TEvents.listen(window, 'resize', this.resize, this); TEvents.listen(window, 'scroll', this.resize, this); }; }; TModalWin[P].resize = function() { if (this.modal) { var rec2 = TDOM.getBounds(this.modal, true); if (TUserAgent.IE) { rec2.top -= 2; rec2.left -= 2; }; } else { var size = TDOM.getDocumentSize(); var rec2 = {top:0, left:0, width:'100%', height:size.height}; }; this.front.style.top = ''; this.front.style.left = ''; this.front.style.width = ''; this.front.style.height = ''; this.front.appendChild(this.content); var rec1 = TDOM.getBounds(this.front, true); if (this.modal) { this.front.style.top = (this.topstick >= 0 ? this.topstick + rec2.top : rec2.top + Math.round(rec2.height / 2) - Math.round(rec1.height / 2)) + 'px'; this.front.style.left = rec2.left + Math.round(rec2.width / 2) - Math.round(rec1.width / 2) + 'px'; } else { var rec3 = TDOM.getViewportBounds(); this.front.style.top = (this.topstick >= 0 ? this.topstick + rec3.top : rec3.top + Math.round(rec3.height / 2) - Math.round(rec1.height / 2)) + 'px'; this.front.style.left = rec3.left + Math.round(rec3.width / 2) - Math.round(rec1.width / 2) + 'px'; }; this.back.style.top = rec2.top + 'px'; this.back.style.left = rec2.left + 'px'; this.back.style.height = rec2.height + 'px'; this.back.style.width = typeof rec2.width == "string" ? rec2.width : rec2.width + 'px'; TDOM.setStyle(this.back, 'opacity', this.opacity); TDOM.setStyle(this.back, 'backgroundColor', this.color); this.back.style.display = 'block'; this.front.style.display = 'block'; }; TModalWin[P].close = function() { this.back.style.display = 'none'; this.front.style.display = 'none'; TEvents.unlisten(window, 'resize', this.resize, this); TEvents.unlisten(window, 'scroll', this.resize, this); };
