/**
 * @author Marek BielaĆ?czuk
 */
var MaxItemHeight = 0;
var MinItemHeight = 25;
var ItemObj = null;
var Counter = 0;
var SleepInterval = 0;
/*
var ImageDown = "menudown.png";
var ImageDown_h = "menudown_h.png";
var ImageUp = "menuup.png";
var ImageUp_h = "menuup_h.png";
*/
var ImageDown = "images/collapsed_button.gif";
var ImageDown_h = "images/collapsed_button3.gif";
var ImageUp = "images/expanded_button.gif";
var ImageUp_h = "images/expanded_button3.gif";

function GetHeightPx(ItCount)
{
    ruler = document.createElement('div');	
	ruler.setAttribute("class", "menu");
	ruler.style.visibility = "hidden";
	//ruler.style.whiteSpace = "nowrap";
	
    rulerc = document.createElement('div');	
	rulerc.setAttribute("class", "item");
	ruler.appendChild(rulerc);
	ruler.style.position = 'absolute';
	ruler.style.top = '0px';
	ruler.style.left = '0px';
	rulerc.style.height = 'auto';
	document.body.appendChild(ruler);
	rulerc.innerHTML = "<a href='#'>A</a>";
	rulerc.innerHTML += "<br>";
			
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
		var iev = new Number(RegExp.$1);
		if (iev <= 6) {
			MinItemHeight = rulerc.offsetHeight+10;		
		} else {
			MinItemHeight = rulerc.offsetHeight;		
		}
	}

    for (i = 0; i < ItCount; i++) {
      	rulerc.innerHTML += "<a href='#' title='OPIS'><h2>OPIS</h2></a>";
    }
	MaxItemHeight = rulerc.offsetHeight;
	document.body.removeChild(ruler);
    //return ret;
}

function NoAnimate(Menu, ItemCount){
	if (ItemObj != null) return;
	ItemObj = document.getElementById(Menu);
//	GetHeightPx(ItemCount);
	MaxItemHeight = MinItemHeight + (ItemCount*20);
	SetImage(document.getElementById(Menu+"_img"), 1);
	ItemObj.style.height = MaxItemHeight + "px";
	ItemObj = null;
}
function Animate(Menu, ItemCount){
	if (ItemObj != null) return;
	ItemObj = document.getElementById(Menu);
	//GetHeightPx(ItemCount);
	MaxItemHeight = MinItemHeight + (ItemCount*20);
	Counter = ItemObj.offsetHeight;
	if (ItemObj.offsetHeight < MaxItemHeight) {
		SetImage(document.getElementById(Menu+"_img"), 1);
		Expand();
	}
	else {
		Collapse();
		SetImage(document.getElementById(Menu+"_img"), 0);
	}
}	
function Expand() {
	if (ItemObj.offsetHeight <= MaxItemHeight) {
		Counter = Counter+(Counter/8);
		ItemObj.style.height = Counter + "px";  //ItemObj.offsetHeight + 1 + "px";
		setTimeout('Expand()',SleepInterval);
		return;
	} else {
		ItemObj.style.height = MaxItemHeight + "px";  //ItemObj.offsetHeight + 1 + "px";
	}
	ItemObj = null;
}

function Collapse() {
	if (ItemObj.offsetHeight > MinItemHeight) {
		Counter = Counter - (Counter/8);
		ItemObj.style.height = Counter + "px"; //(ItemObj.offsetHeight - 3) + "px";
		setTimeout('Collapse()',SleepInterval);
		return;
	} else {
		ItemObj.style.height = MinItemHeight + "px";  //ItemObj.offsetHeight + 1 + "px";
	}
	ItemObj = null;
}

function SetImage(ItemLink, MenuStatus) {
	if (MenuStatus == 1) {
		ItemLink.setAttribute("src", ImageUp);
		ItemLink.onmouseover = function() {this.setAttribute("src", ImageUp_h);}
		ItemLink.onmouseout = function() {this.setAttribute("src", ImageUp);}
	} else {
		ItemLink.setAttribute("src", ImageDown);
		ItemLink.onmouseover = function() {this.setAttribute("src", ImageDown_h);}
		ItemLink.onmouseout = function() {this.setAttribute("src", ImageDown);}
	}
}

function SwitchPane(panId) {
	for (i=1;i<11;i++) {
		pan = document.getElementById('pan_'+i);
		npan= document.getElementById('nap_'+i);
		if (pan)
			if (i == panId) 
			{
				pan.style.overflow = "auto";
				pan.style.height = "auto";
				pan.style.width = "auto";
				npan.style.fontWeight = "bold";
				npan.style.textDecoration = "underline";
			} else {
				pan.style.overflow = "hidden";
				pan.style.height = "0px";
				pan.style.width = "0px";
				if (npan)
				{
					npan.style.fontWeight = "normal";
					npan.style.textDecoration = "none";
				}
			}
	}
	
}

 var t;
 function Wait(text, cnt) 
 {
 
	document.body.style.overflow = 'hidden';
 
    if (window.addEventListener) { window.addEventListener('unload', StopWait, false); }
    else if (window.attachEvent) { window.attachEvent('onunload', StopWait); }
    else { window.onunload += StopWait; }
	
	if (!cnt) cnt = 0;
 	var _wdot = document.getElementById("dot");
	if (!_wdot)
	{
		var _wdotp = document.createElement('div');
		_wdotp.style.font = "12pt Arial,Tahoma";
		_wdotp.style.color = "#000";
		_wdotp.style.textAlign = "center";
		_wdotp.style.position = "absolute";
        _wdotp.style.top = "0px";
		_wdotp.style.left = "0px";
		
/////
	var wX=0;
		wY=0;
		//IE
		if(!window.innerWidth)
		{
		//strict mode
			if(!(document.documentElement.clientWidth == 0))
			{
			wX = document.documentElement.clientWidth;
			wY = document.documentElement.clientHeight;
			}
			//quirks mode
			else
			{
			wX = document.body.clientWidth;
			wY = document.body.clientHeight;
			}
		}
		//w3c
		else
		{
			wX = window.innerWidth;
			wY = window.innerHeight;
		}
		
/////
		
		_wdotp.style.backgroundColor = "#fff";
	 	_wdotp.style.mozOpacity = "0.75";
	 	_wdotp.style.opacity = "0.75";
		_wdotp.style.filter = "alpha(opacity=75)";
		
		document.body.style.filter = "blur(add=0, direction=90, strength=15)";
 		document.body.style.filter +="blur(add=0, direction=0, strength=10)";
		
		_wdotp.setAttribute("id", "dotp");
		var _wdot = document.createElement('a');
		_wdot.style.position = "absolute";
		_wdot.style.width = "500px";
		 
/////
		var offsetX = 0;
		var offsetY = 0;

		//IE
		if(!window.pageYOffset)
		{
		//strict mode
			if(!(document.documentElement.scrollTop == 0))
			{
			offsetY = document.documentElement.scrollTop;
			offsetX = document.documentElement.scrollLeft;
			}
			//quirks mode
			else
			{
			offsetY = document.body.scrollTop;
			offsetX = document.body.scrollLeft;
			}
		}
		//w3c
		else
		{
			offsetX = window.pageXOffset;
			offsetY = window.pageYOffset;
		}

		_wdot.style.left =  ((wX-500)/2)+offsetX + "px";
		_wdot.style.top = ((wY-50)/2)+offsetY + "px";
/////		 
		 
		 _wdot.style.lineHeight = "50px";
	     _wdot.style.border = "1px dotted #b7c4d3";	 
		 _wdot.style.backgroundColor = "#eef0eb";
		 _wdot.setAttribute("id", "dot");
		 
		_wdotp.style.width = wX +offsetX+ "px";
		_wdotp.style.height = wY +offsetY+ "px";
		_wdotp.appendChild(_wdot);
		document.body.appendChild(_wdotp);
	}
	txt = text;

	switch(cnt)
	{
	case 0: txt += "&nbsp;&nbsp;&nbsp;"; cnt++; break;
	case 1: txt += ".&nbsp;&nbsp;"; cnt++; break;
	case 2: txt += "..&nbsp;"; cnt++; break;
	case 3: txt += "..."; cnt = 0; break;
	}

	_wdot.innerHTML = txt.bold();
	t = setTimeout("Wait('"+text+"', "+cnt+")",200);
 }
 function StopWait() 
 {
	var _wdot = document.getElementById("dotp");
	while (_wdot)
	{
		document.body.removeChild(_wdot);
		_wdot = document.getElementById("dotp");
	}
	clearTimeout(t);
 }