<!--
//Author: Saulius Paukstys sauliusp@5ci.lt
//Company: "Penki kontinetai" www.5ci.lt

penkiCIMenu._maxZ = 100;
penkiCIMenu.backgroundColor = "#FFFFFF"; 
penkiCIMenu.backgroundPng = "Images/Menu3VerImages/white-90.png"; 
penkiCIMenu.dingbatOn = "Images/Menu3VerImages/submenu_on.gif"; 
penkiCIMenu.dingbatOff = "Images/Menu3VerImages/submenu_off.gif"; 
penkiCIMenu.dingbatSize = 7; 
penkiCIMenu.direction = {down:1,right:2};
penkiCIMenu.hideDelay = 1000; 
penkiCIMenu.menuitemPadding = 4; 
penkiCIMenu.menuPadding = 1; 
penkiCIMenu.shadowSize = 2; 
penkiCIMenu.shadowOffset = 3; 
penkiCIMenu.shadowColor = "#888888"; 
penkiCIMenu.shadowPng = "Images/Menu3VerImages/grey-40.png"; 
penkiCIMenu.slideTime = 200; 
penkiCIMenu.spacerGif = "Images/Menu3VerImages/spacer.gif"; 
penkiCIMenu.reference = {topLeft:1,topRight:2,bottomLeft:3,bottomRight:4};
penkiCIMenu.registry = [];


function penkiCIMenuPageReload(init) {
	if (init==true)
		with (navigator) {
			if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
				document.MM_pgW=innerWidth; 
				document.MM_pgH=innerHeight; 
				onresize=penkiCIMenuPageReload; 
				}
			}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) 
		location.reload();
	}

penkiCIMenuPageReload(true);

function penkiCIMenuLoadImages() {
	var d=document; 
	var i,j=d.MM_p.length,a=penkiCIMenuLoadImages.arguments; 
	if(d.images){ 
		if(!d.MM_p) 
			d.MM_p=new Array();
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0){ 
				d.MM_p[j]=new Image; 
				d.MM_p[j++].src=a[i];
				}
		}
	}

penkiCIMenu.isSupported = function() {
	if (typeof penkiCIMenu.isSupported.r == "boolean") 
	return penkiCIMenu.isSupported.r;
	var ua = navigator.userAgent.toLowerCase();
	var an = navigator.appName;
	var r = false;
	if (ua.indexOf("gecko") > -1) 
		r = true; 
	else if (an == "Microsoft Internet Explorer") {
		if (document.getElementById) 
			r = true; 
		}
	penkiCIMenu.isSupported.r = r;
	return r;
	}

penkiCIMenu.initialize = function() {
	for (var i = 0, menu = null; menu = this.registry[i]; i++) {
		menu.initialize();
		}
	}

penkiCIMenu.renderAll = function() {
	var aMenuHtml = [];
	for (var i = 0, menu = null; menu = this.registry[i]; i++) {
		aMenuHtml[i] = menu.toString();
		}
	document.write(aMenuHtml.join(""));
	}

function penkiCIMenu(oActuator, iDirection, iLeft, iTop, iReferencePoint, parentMenuSet) {
	this.addItem = addItem;
	this.addMenu = addMenu;
	this.toString = toString;
	this.initialize = initialize;
	this.isOpen = false;
	this.show = show;
	this.hide = hide;
	this.menuitems = [];
	this.onactivate = new Function(); 
	this.ondeactivate = new Function(); 
	this.onmouseover = new Function(); 
	this.onqueue = new Function(); 
	this.index = penkiCIMenu.registry.length;
	penkiCIMenu.registry[this.index] = this;
	var id = "mtDropDown" + this.index;
	var contentHeight = null;
	var contentWidth = null;
	var childMenuSet = null;
	var animating = false;
	var childMenus = [];
	var slideAccel = -1;
	var kass = null;
	var ready = false;
	var _this = this;
	var a = null;
	var pos = iDirection == penkiCIMenu.direction.down ? "top" : "left";
	var dim = null;

	function addItem(sText, sUrl,sTarget,Img) {
		if (!sTarget) sTarget='_self'
		if (!Img) Img=''
		var menuitem = new mtDropDownmenuitem(sText, sUrl,sTarget,Img, this);
		menuitem._index = this.menuitems.length;
		this.menuitems[menuitem._index] = menuitem;
		}

	function addMenu(oMenumenuitem) {
		if (!oMenumenuitem.parentMenu == this) 
			throw new Error("Cannot add a menu here");
		if (childMenuSet == null) 
			childMenuSet = new mtDropDownSet(penkiCIMenu.direction.right, -5, 2, penkiCIMenu.reference.topRight);
		var m = childMenuSet.addMenu(oMenumenuitem);
		childMenus[oMenumenuitem._index] = m;
		m.onmouseover = child_mouseover;
		m.ondeactivate = child_deactivate;
		m.onqueue = child_queue;
		return m;
		}

	function initialize() {
		initCache();
		initEvents();
		initSize();
		ready = true;
		}

	function show() {
		if (ready) {
			_this.isOpen = true;
			animating = true;
			setContainerPos();
			kass["clip"].style.visibility = "visible";
			kass["clip"].style.zIndex = penkiCIMenu._maxZ++;
			slideStart();
			_this.onactivate();
			}
		}

	function hide() {
		if (ready) {
			_this.isOpen = false;
			animating = true;
			for (var i = 0, menuitem = null; menuitem = kass.menuitem[i]; i++) 
				dehighlight(menuitem);
			if (childMenuSet)
				childMenuSet.hide(); 
			slideStart();
			_this.ondeactivate();
			}
		}

	function setContainerPos() {
		var sub = oActuator.constructor == mtDropDownmenuitem; 
		var act = sub ? oActuator.parentMenu.kass["menuitem"][oActuator._index] : oActuator; 
		var el = act;
		var x = 0;
		var y = 0;
		var minX = 0;
		var maxX = (window.innerWidth ? window.innerWidth : document.body.clientWidth) - parseInt(kass["clip"].style.width)*0;
		var minY = 0;
		var maxY = (window.innerHeight ? window.innerHeight : document.body.clientHeight) - parseInt(kass["clip"].style.height)*0;
        
		while (sub ? el.parentNode.className.indexOf("mtDropDownMenu") == -1 : el.offsetParent) {
			x += el.offsetLeft;
			y += el.offsetTop;
			if (el.scrollLeft) 
				x -= el.scrollLeft;
			if (el.scrollTop) 
				y -= el.scrollTop;
			el = el.offsetParent;
			}
        
		if (oActuator.constructor == mtDropDownmenuitem) {
			x += parseInt(el.parentNode.style.left);
			y += parseInt(el.parentNode.style.top);
			}
        
		switch (iReferencePoint) {
			case penkiCIMenu.reference.topLeft:
				break;
			case penkiCIMenu.reference.topRight:
				x += act.offsetWidth;
				break;
			case penkiCIMenu.reference.bottomLeft:
				y += act.offsetHeight;
				break;
			case penkiCIMenu.reference.bottomRight:
				x += act.offsetWidth;
				y += act.offsetHeight;
				break;
			}
		x += iLeft;
		y += iTop;
		x = Math.max(Math.min(x, maxX), minX);
		y = Math.max(Math.min(y, maxY), minY);
		kass["clip"].style.left = x + "px";
		kass["clip"].style.top = y + "px";
		}

	function slideStart() {
		var x0 = parseInt(kass["content"].style[pos]);
		var x1 = _this.isOpen ? 0 : -dim;
		if (a != null) a.stop();
			a = new penkiCIMenuFX1(x0, x1, penkiCIMenu.slideTime, slideAccel);
			a.onframe = slideFrame;
			a.onend = slideEnd;
			a.start();
		}

	function slideFrame(x) {
		kass["content"].style[pos] = x + "px";
		}

	function slideEnd() {
		if (!_this.isOpen) 
			kass["clip"].style.visibility = "hidden";
		animating = false;
		}

	function initSize() {
		var ow = kass["menuitems"].offsetWidth;
		var oh = kass["menuitems"].offsetHeight;
		var ua = navigator.userAgent.toLowerCase();
		kass["clip"].style.width = ow + penkiCIMenu.shadowSize + 2 + "px";
		kass["clip"].style.height = oh + penkiCIMenu.shadowSize + 2 + "px";
		kass["content"].style.width = ow + penkiCIMenu.shadowSize + "px";
		kass["content"].style.height = oh + penkiCIMenu.shadowSize + "px";
		contentHeight = oh + penkiCIMenu.shadowSize;
		contentWidth = ow + penkiCIMenu.shadowSize;
		dim = iDirection == penkiCIMenu.direction.down ? contentHeight : contentWidth;
		kass["content"].style[pos] = -dim - penkiCIMenu.shadowSize + "px";
		kass["clip"].style.visibility = "hidden";
		if (ua.indexOf("mac") == -1 || ua.indexOf("gecko") > -1) {
			kass["background"].style.width = ow + "px";
			kass["background"].style.height = oh + "px";
			kass["background"].style.backgroundColor = penkiCIMenu.backgroundColor;
			kass["shadowRight"].style.left = ow + "px";
			kass["shadowRight"].style.height = oh - (penkiCIMenu.shadowOffset - penkiCIMenu.shadowSize) + "px";
			kass["shadowRight"].style.backgroundColor = penkiCIMenu.shadowColor;
			kass["shadowBottom"].style.top = oh + "px";
			kass["shadowBottom"].style.width = ow - penkiCIMenu.shadowOffset + "px";
			kass["shadowBottom"].style.backgroundColor = penkiCIMenu.shadowColor;
			}
		else {
			kass["background"].firstChild.src = penkiCIMenu.backgroundPng;
			kass["background"].firstChild.width = ow;
			kass["background"].firstChild.height = oh;
			kass["shadowRight"].firstChild.src = penkiCIMenu.shadowPng;
			kass["shadowRight"].style.left = ow + "px";
			kass["shadowRight"].firstChild.width = penkiCIMenu.shadowSize;
			kass["shadowRight"].firstChild.height = oh - (penkiCIMenu.shadowOffset - penkiCIMenu.shadowSize);
			kass["shadowBottom"].firstChild.src = penkiCIMenu.shadowPng;
			kass["shadowBottom"].style.top = oh + "px";
			kass["shadowBottom"].firstChild.height = penkiCIMenu.shadowSize;
			kass["shadowBottom"].firstChild.width = ow - penkiCIMenu.shadowOffset;
			}
		}

	function initCache() {
		var menu = document.getElementById(id);
		var all = menu.all ? menu.all : menu.getElementsByTagName("*"); 
		kass = {};
		kass["clip"] = menu;
		kass["menuitem"] = [];
		for (var i = 0, elm = null; elm = all[i]; i++) {
			switch (elm.className) {
				case "menuitems":
				case "content":
				case "background":
				case "shadowRight":
				case "shadowBottom":
					kass[elm.className] = elm;
					break;
				case "menuitem":
					elm._index = kass["menuitem"].length;
					kass["menuitem"][elm._index] = elm;
					break;
				}
			}
		_this.kass = kass;
		}

	function initEvents() {
		for (var i = 0, menuitem = null; menuitem = kass.menuitem[i]; i++) {
			menuitem.onmouseover = menuitem_mouseover;
			menuitem.onmouseout = menuitem_mouseout;
			menuitem.onclick = menuitem_click;
			}
		if (typeof oActuator.tagName != "undefined") {
			oActuator.onmouseover = actuator_mouseover;
			oActuator.onmouseout = actuator_mouseout;
			}
		kass["content"].onmouseover = content_mouseover;
		kass["content"].onmouseout = content_mouseout;
		}

	function highlight(oRow) {
		oRow.className = "menuitemHover";
		if (childMenus[oRow._index]) 
			oRow.lastChild.firstChild.src = penkiCIMenu.dingbatOn;
		}

	function dehighlight(oRow) {
		oRow.className = "menuitem";
		if (childMenus[oRow._index]) 
			oRow.lastChild.firstChild.src = penkiCIMenu.dingbatOff;
		}

	function menuitem_mouseover() {
		if (!animating) {
            
			highlight(this);
			if (childMenus[this._index]) 
				childMenuSet.showMenu(childMenus[this._index]);
			else if (childMenuSet) 
				childMenuSet.hide();
			}
		}

	function menuitem_mouseout() {
		if (!animating) {
			if (childMenus[this._index])
				childMenuSet.hideMenu(childMenus[this._index]);
			else 
				dehighlight(this);
			}
		}

	function menuitem_click() {
		if (!animating)
			if (_this.menuitems[this._index].url) 
				window.open(_this.menuitems[this._index].url,_this.menuitems[this._index].target)
		}

	function actuator_mouseover() {
		parentMenuSet.showMenu(_this);
		}

	function actuator_mouseout() {
		parentMenuSet.hideMenu(_this);
		}

	function content_mouseover() {
		if (!animating) {
			parentMenuSet.showMenu(_this);
			_this.onmouseover();
			}
		}

	function content_mouseout() {
		if (!animating)
			parentMenuSet.hideMenu(_this);
		}

	function child_mouseover() {
		if (!animating) {
			parentMenuSet.showMenu(_this);
			_this.onmouseover();
			}
		}

	function child_deactivate() {
		for (var i = 0; i < childMenus.length; i++) {
			if (childMenus[i] == this) {
				dehighlight(kass["menuitem"][i]);
				break;
				}
			}
		}

	function child_queue() {
		parentMenuSet.hideMenu(_this);
		}

	function toString() {
		var aHtml = [];
		var sClassName = "mtDropDownMenu" //+ (oActuator.constructor != mtDropDownmenuitem ? "Top" : "");
		for (var i = 0, menuitem = null; menuitem = this.menuitems[i]; i++)
			aHtml[i] = menuitem.toString(childMenus[i]);
		return	'<div id="' + id + '" class="' + sClassName + '" style="position: absolute; top:0px;left:0px">' + 
				'<div class="content" style="position: absolute;top:0px;left:0px"><table class="menuitems" style="position: relative;left: 0px;top: 0px;" cellpadding="0" cellspacing="0" border="0">' + 
				'<tr><td colspan="2"><img src="' + penkiCIMenu.spacerGif + '" width="1" height="' + penkiCIMenu.menuPadding + '"></td></tr>' + 
				aHtml.join('') + 
				'<tr><td colspan="2"><img src="' + penkiCIMenu.spacerGif + '" width="1" height="' + penkiCIMenu.menuPadding + '"></td></tr></table>' + 
				'<div class="shadowBottom"><img src="' + penkiCIMenu.spacerGif + '" width="1" height="1"></div>' + 
				'<div class="shadowRight"><img src="' + penkiCIMenu.spacerGif + '" width="1" height="1"></div>' + 
				'<div class="background"><img src="' + penkiCIMenu.spacerGif + '" width="1" height="1"></div>' + 
				'</div></div>';
		}
	}

mtDropDownSet.registry = [];

function mtDropDownSet(iDirection, iLeft, iTop, iReferencePoint) {
	this.addMenu = addMenu;
	this.showMenu = showMenu;
	this.hideMenu = hideMenu;
	this.hide = hide;
	var menus = [];
	var _this = this;
	var current = null;
	this.index = mtDropDownSet.registry.length;
	mtDropDownSet.registry[this.index] = this;

	function addMenu(oActuator) {
		var m = new penkiCIMenu(oActuator, iDirection, iLeft, iTop, iReferencePoint, this);
		menus[menus.length] = m;
		return m;
		}

	function showMenu(oMenu) {
		if (oMenu != current) {
			if (current != null) 
				hide(current);
			current = oMenu;
			oMenu.show();
			}
		else {
			cancelHide(oMenu);
			}
		}

	function hideMenu(oMenu) {
		if (current == oMenu && oMenu.isOpen)
			if (!oMenu.hideTimer) 
				scheduleHide(oMenu);
		}

	function scheduleHide(oMenu) {
		oMenu.onqueue();
		oMenu.hideTimer = window.setTimeout("mtDropDownSet.registry[" + _this.index + "].hide(penkiCIMenu.registry[" + oMenu.index + "])", penkiCIMenu.hideDelay);
		}

	function cancelHide(oMenu) {
		if (oMenu.hideTimer) {
			window.clearTimeout(oMenu.hideTimer);
			oMenu.hideTimer = null;
			}
		}

	function hide(oMenu) { 
		if (!oMenu && current)
			oMenu = current;
		if (oMenu && current == oMenu && oMenu.isOpen) {
			cancelHide(oMenu);
			current = null;
			oMenu.hideTimer = null;
			oMenu.hide();
			}
		}
	}

function mtDropDownmenuitem(sText, sUrl,sTarget, Img, oParent) {
	this.toString = toString;
	this.text = sText;
	this.url = sUrl;
	this.target = sTarget;
	this.parentMenu = oParent;
	
	function toString(bDingbat) {
		bDingbat= (bDingbat!=null)
		var sDingbat = bDingbat ? penkiCIMenu.dingbatOff : penkiCIMenu.spacerGif;
		var iEdgePadding = penkiCIMenu.menuitemPadding + penkiCIMenu.menuPadding;
		var sPaddingLeft = "padding:" + penkiCIMenu.menuitemPadding + "px; padding-left:" + iEdgePadding + "px;"
		var sPaddingRight = "padding:" + penkiCIMenu.menuitemPadding + "px; padding-right:" + iEdgePadding + "px;"
        var TRclass='menuitem';
        if (sUrl=="") TRclass='menuitemNoOver';
        var r=''
		r='<tr class="' + TRclass + '" >'
		r= r + '<td valign=top nowrap="nowrap" style="' + sPaddingLeft + '"' + ">"
		if (Img!='') r= r + '' + Img + ''
		r=r + sText + '</td><td style="' + sPaddingRight + '">' + 
				'<img src="' + sDingbat + '" width="' + penkiCIMenu.dingbatSize + '" height="' + penkiCIMenu.dingbatSize + '"></td></tr>';
        return r				
		}
	}

function penkiCIMenuFX1(from, to, time, zip) {
	if (typeof zip == "undefined") 
		zip = 0;
	if (typeof unit == "undefined") 
		unit = "px";
	this.x0 = from;
	this.x1 = to;
	this.dt = time;
	this.zip = -zip;
	this.unit = unit;
	this.timer = null;
	this.onend = new Function();
	this.onframe = new Function();
	}
	
penkiCIMenuFX1.prototype.start = function() {
	this.t0 = new Date().getTime();
	this.t1 = this.t0 + this.dt;
	var dx = this.x1 - this.x0;
	this.c1 = this.x0 + ((1 + this.zip) * dx / 3);
	this.c2 = this.x0 + ((2 + this.zip) * dx / 3);
	penkiCIMenuFX1._add(this);
	}

penkiCIMenuFX1.prototype.stop = function() {
	penkiCIMenuFX1._remove(this);
	}

penkiCIMenuFX1.prototype._paint = function(time) {
	if (time < this.t1) {
		var elapsed = time - this.t0;
		this.onframe(penkiCIMenuFX1._getBezier(elapsed/this.dt,this.x0,this.x1,this.c1,this.c2));
		}
	else 
		this._end();
	}

penkiCIMenuFX1.prototype._end = function() {
	penkiCIMenuFX1._remove(this);
	this.onframe(this.x1);
	this.onend();
	}

penkiCIMenuFX1._add = function(o) {
	var index = this.instances.length;
	this.instances[index] = o;
	if (this.instances.length == 1)
		this.timerID = window.setInterval("penkiCIMenuFX1._paintAll()", this.targetRes);
	}

penkiCIMenuFX1._remove = function(o) {
	for (var i = 0; i < this.instances.length; i++) {
		if (o == this.instances[i]) {
			this.instances = this.instances.slice(0,i).concat( this.instances.slice(i+1) );
			break;
			}
		}
	if (this.instances.length == 0) {
		window.clearInterval(this.timerID);
		this.timerID = null;
		}
	}

penkiCIMenuFX1._paintAll = function() {
	var now = new Date().getTime();
	for (var i = 0; i < this.instances.length; i++)
		this.instances[i]._paint(now);
	}

penkiCIMenuFX1._B1 = function(t) { 
	return t*t*t 
	}

penkiCIMenuFX1._B2 = function(t) { 
	return 3*t*t*(1-t) 
	}

penkiCIMenuFX1._B3 = function(t) { 
	return 3*t*(1-t)*(1-t) 
	}

penkiCIMenuFX1._B4 = function(t) { 
	return (1-t)*(1-t)*(1-t) 
	}

penkiCIMenuFX1._getBezier = function(percent,startPos,endPos,control1,control2) {
	return endPos * this._B1(percent) + control2 * this._B2(percent) + control1 * this._B3(percent) + startPos * this._B4(percent);
	}

penkiCIMenuFX1.instances = [];
penkiCIMenuFX1.targetRes = 10;
penkiCIMenuFX1.timerID = null;




function delayedClosemenu(activate) {
	// if activate==true activate timer that closes open menu in 10ms
	// if activate==false deactivate that timer
	if (activate)
		timerID = setTimeout(showMenu,10,null)
	  else {
		if (timerID)
			clearTimeout(timerID)
		timerID = null
		}
	}


function RemoveHTML( strText )
{
	var regEx = /<[^>]*>/g;
	return strText.replace(regEx, "");
}
function StrReplaceForJS(Str){
    var r='';
    var r, re;
    var s = Str;

    re = /\"/g;
    r = s.replace(re, 'quot;');

    re = /\'/g;
    r = r.replace(re, 'apos;');
    

    return r;
}
//-->