




function isNumeric(n) {return isNumber(n);}
function dw(str) {document.write(str);}
function charArray(str) {return str.split("");}
function split(str, chr) {return str.split(chr);}
function chr(nr) {return String.fromCharCode(nr);}
function asc(character) {return character.charCodeAt(0);}
function inStr(str1, str2) 
{
		if (str1 != '' && str2 != '' && str1 != null && str2 != null && str1 != undefined && str2 != undefined)
				return str1.indexOf(str2);
		else
			return -1;
}
function bullet(kolor) {return "<font color = '" + kolor + "'>&#149;</font>";}
function sortNrs(a, b) {return a - b;}
function toLower(txt) {return LCase(txt);}
function toUpper(txt) {return UCase(txt);}


function randomNr(upperbound)
{
	return Math.floor(Math.random() * upperbound);
}


function repSListVals(frm)
{
	var i = 0;
	for (i = 0; i < frm.elements.length; i++)
	{
		if (inStr(frm.elements[i].value, "&#") != -1)
		{
			frm.elements[i].value = replace(frm.elements[i].value, "&#", "");
		}
	}
}



function setQuotes(str)
{
	var arrTxt = null;
	var replaced = "&quot;";
	var r = replaced.split("");
	var isThere = -1;
	var i = 0;
	var counter = 0;
	for (;;)
	{
		try
		{
			isThere = inStr(str, replaced);
		}
		catch(e)
		{	
			isThere = -1
		}
		
		if (isThere == -1)
		{
			break;
		}
		arrTxt = str.split("");
		if (counter % 2 == 0)
			arrTxt[isThere] = "&#147;"
		else
			arrTxt[isThere] = "&#148;"
		counter ++;
		for (i = isThere + 1; i < isThere + r.length; i++)
		{
			arrTxt[i] = '';
		}
		str = arrTxt.join("");
	}
	return str;	
}


function isNumber(testNr)
{
	if (isNaN(parseFloat(testNr)))
		return false; 
	else
		return true;
} 

function lTrim(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	return sString;
}

function rTrim(sString)
	{
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function trim(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function LCase(txt)
{
	try
	{
		return txt.toLowerCase();
	}
	catch(e){}
	return txt;
}

function UCase(txt) 
{
	try
	{
		return txt.toUpperCase();
	}
	catch(e){}
	return txt;	
}

function noCaseCriterium(a, b)
{
	//for case insensitive sort
	if (LCase(a) > LCase(b))
		return 1;
	return -1;
}

function Character(MyString, thePlace)
{
	var arrStr = MyString.split('');
	return arrStr[thePlace];
}

function replace(theStr, replaced, replacee)
{
	if (theStr == null || theStr == '' || theStr == undefined)
		return '';
	if (replaced ==  null || replaced == '' || replaced == undefined)
		return theStr;
	if (replacee ==  null || replacee == undefined)
		return theStr;
	for(;;)
	{
		if (inStr(theStr, replaced) == -1)
			break;
		theStr = theStr.replace(replaced, replacee);
	}
	return theStr;
}

function purge(d)
{
/*
	code below in this function courtesy of:
	http://www.crockford.com/javascript/memory/leak.html
*/
   		var a = d.attributes, i, l, n;
                    if (a) {
                        l = a.length;
                        for (i = 0; i < l; i += 1) {
                            n = a[i].name;
                            if (typeof d[n] === 'function') {
                                d[n] = null;
                            }
                        }
                    }
                    a = d.childNodes;
                    if (a) {
                        l = a.length;
                        for (i = 0; i < l; i += 1) {
                            purge(d.childNodes[i]);
                        }
                    }
}


function str2Bool(value)
{
	if (value == 'true')
		return true;
	else
	{
		if (value == 'false')
			return false;
		else
			return returnUndefined();
	}
}

function returnUndefined()
{
	var it;
	try
	{
		it = undefined;
	}
	catch(e)
	{
		it = 'undefined';
	}
	return it;
}

function getKey(e)
{
	var myKey = -1;
	try
	{
		return window.event.keyCode;	
	}
	catch(missed)
	{
		try
		{
			return e.keyCode;
		}
		catch(missed)
		{
			try
			{
				return e.which;
			}
			catch(missed)
			{
					return myKey;
			}
		}	
	}	
}

function noLTGT(field, e)
{
	var c = getKey(e);
	c = chr(c);
	if (c == "<")
	{
		field.value = field.value + "&lt;"
		return false;
	}
	if (c == ">")
	{
		field.value = field.value + "&gt;"
		return false;
	}
	return true;
}

function isNr(nr)
{
	if (parseFloat(nr) != nr)
		return false;
	return true;
}

function hex(d)
{
	var h = '0123456789ABCDEF';
	var i, ii;
	if (d > 255)
		return -1;
	i = d % 16;
	ii = (d - i) / 16;
	return h.charAt(ii) + h.charAt(i);
}


function tab(ile)
{
	var str = "";
	var i;
	for (i = 0; i < ile - 1; i++)
	{
		str += "&nbsp;&nbsp;";
	}
	return " " + str + " ";
}

function escApo(str)
{
	var i, chrs;
	chrs = charArray(str);
	for (i = 0; i < chrs.length; i++)
	{
		if (chrs[i] == "'") chrs[i] = "\'";
	}
	return chrs.join("");
}

function replaceChar(str, oldChr, newChr)
{
	var chrs, newChrs, i;
	newChrs = '';
	chrs = charArray(str);
	for (i = 0; i < chrs.length; i++)
	{
		if (chrs[i] == oldChr) 
			newChrs += "" + newChr;
		else
			newChrs = chrs[i];
	}
	return newChrs;
}


function getCookie(name)
{
	var cname = name + "=";
	var dc = document.cookie;
	if (dc.length > 0) 
	{
		var begin = dc.indexOf(cname);       
		if (begin != -1) 
		{           
			begin += cname.length;
			var end = dc.indexOf(";", begin);
			if (end == -1) end = dc.length;
			return unescape(dc.substring(begin, end));
		}
	}
	return "";
}


function setCookie(name, value)
{
	document.cookie = name + "=;";
	document.cookie = name + "=" + escape(value) + ";";
}


function getCookieNoEncoding(name)
{
	var cname = name + "=";
	var dc = document.cookie;
	if (dc.length > 0) 
	{
		var begin = dc.indexOf(cname);       
		if (begin != -1) 
		{           
			begin += cname.length;
			var end = dc.indexOf(";", begin);
			if (end == -1) end = dc.length;
			return dc.substring(begin, end);
		}
	}
	return "";
}


function setCookieNoEncoding(name, value)
{
	document.cookie = name + "=;";
	document.cookie = name + "=" + value + ";";
}



function setCookieExpiration(cookieName, YearOrDayOrHourOrMinOrSec, num)
{
	/* use deleteCookie(cookie) to delete them, not this function! */

	var cookieVal = getCookieNoEncoding(cookieName);
	var exp = new Date();
	var oneYear = 365 * 24000 * 3600;  /* no leap */
	var oneDay = 24000 * 3600;
	var oneHour = 3600 * 1000;
	var oneMin = 60000;
	var periodFromNow;
	if (YearOrDayOrHourOrMinOrSec == "Year") periodFromNow = oneYear * num;
	if (YearOrDayOrHourOrMinOrSec == "Day") periodFromNow = oneDay * num;
	if (YearOrDayOrHourOrMinOrSec == "Hour") periodFromNow = oneHour * num;
	if (YearOrDayOrHourOrMinOrSec == "Min") periodFromNow = oneMin * num;
	if (YearOrDayOrHourOrMinOrSec == "Minute") periodFromNow = oneMin * num;
	if (YearOrDayOrHourOrMinOrSec == "Second") periodFromNow = num;
	if (YearOrDayOrHourOrMinOrSec == "Sec") periodFromNow = num;
	var setPeriod = exp.getTime() + periodFromNow;
	exp.setTime(setPeriod);
	document.cookie = cookieName + "=" + cookieVal + "; expires=" + exp.toGMTString() + ";";
}


function setPermanentCookie(cookieName)
{
	var cookieVal = getCookieNoEncoding(cookieName);
	document.cookie =  cookieName + "=" + cookieVal + "; expires=Wed, 17-Jan-38 00:00:00 GMT;";
}


function deleteCookie(cookieName)
{	
	document.cookie =  cookieName + "=" + "" + "; expires=Thu, 01-Jan-70 00:00:01 GMT;";
}


function getSubCookie(cookieName, subCookieName, cookieDelimiter)
{
	if (cookieDelimiter == null)
		cookieDelimiter = '&';
	var cookieVal = getCookieNoEncoding(cookieName);
	if (cookieVal == "" || cookieVal.indexOf(cookieDelimiter) == -1) 
	{
		if (cookieVal.indexOf(subCookieName) != -1 && cookieVal != "") 
		{
			var arrVal = cookieVal.split("=");
			return unescape(arrVal[1]);
		}
		return "";
	}
	else
	{
		var arrSubCookies = cookieVal.split(cookieDelimiter);
		var i, arrNameValCollection;
		CookieVal = "";
		for (i = 0; i < arrSubCookies.length; i++)
		{
			arrNameValCollection = arrSubCookies[i].split("=");	
			if (arrNameValCollection[0] == subCookieName) return unescape(arrNameValCollection[1]);
		}
	}
	return "";
}



function setSubCookie(cookieName, subCookieName, subcookieValue, cookieDelimiter)
{
	function weed(cookieName, subCookieName, subcookieValue, delimiter, cVal)
	{
		var counter = 0;
		var str = delimiter;
		var c = '';
		var arrNameValColl = null;
		if (inStr(cVal, delimiter) == -1)
			return cVal;
		var arrsubs = cVal.split(delimiter);
		for (counter = arrsubs.length -1; counter >= 0; counter--)
		{
			arrNameValColl = arrsubs[counter].split("=");
			if (inStr(str + "", delimiter + arrNameValColl[0] + delimiter) ==  -1)
			{
				str += delimiter + arrNameValColl[0] + delimiter;
				if (getCookieNoEncoding(cookieName) != "")
				{
					c += delimiter;
				}
				c += arrNameValColl[0] + "=" + escape(arrNameValColl[1]);
			}
		}
		if (c.charAt(0) == delimiter)
		{
			c = c.substring(1, c.length);
		}
		return c;
	}

	if (cookieDelimiter == null)
		cookieDelimiter = '&';
	var isC = getCookieNoEncoding(cookieName);
	var cookieVal = subCookieName + "=" + subcookieValue;
	var isSC = getSubCookie(cookieName, subCookieName);
	if (isC != "" && isSC == "")
	{
		cookieVal = isC + cookieDelimiter + cookieVal;
	}
	if (isSC != "")
	{
		var arrSubCookies = isC.split(cookieDelimiter);	
		var i, arrNameValCollection;
		cookieVal = "";
		for (i = 0; i < arrSubCookies.length; i++)
		{
			arrNameValCollection = arrSubCookies[i].split("=");	
			if (arrNameValCollection[0] == subCookieName) 
				arrNameValCollection[1] = escape(subcookieValue);
			cookieVal += arrNameValCollection[0] + "=" + escape(arrNameValCollection[1]);
			if (i < arrSubCookies.length - 1) 
				cookieVal  = cookieVal + cookieDelimiter;
		}
	}
	cookieVal = weed(cookieName, subCookieName, subcookieValue, cookieDelimiter, cookieVal);
	setCookieNoEncoding(cookieName, cookieVal)
}


function setPermSubCookie(cookieName, subCookieName, subCookieValue, cookieDelimiter)
{
	if (cookieDelimiter == null)
		cookieDelimiter = '&';
	setSubCookie(cookieName, subCookieName, subCookieValue, cookieDelimiter);
	setPermanentCookie(cookieName);
}


function sendCookieString(URL, cookieName)
{
	location.href = URL + "?" + getCookieNoEncoding(cookieName);
}


function sendCookieStringChangeDelimiter(URL, cookieName, oldDel, newDel)
{
	location.href = URL + "?" + replaceDelimiter(cookieName, oldDel, newDel);
}


function sendSubCookieString(URL, cookieName, subCookieName, cookieDelimiter)
{
	location.href = URL + "?" + subCookieName + "=" + getSubCookie(cookieName, subCookieName, cookieDelimiter);
}


function replaceDelimiter(cookieName, oldDel, newDel)
{
	var isC = getCookieNoEncoding(cookieName);
	if (isC.indexOf(oldDel) == -1) return isC;
	var arrSubCookies = isC.split(oldDel);	
	var i, arrNameValCollection;
	var CookieVal = "";
	for (i = 0; i < arrSubCookies.length; i++)
	{
		arrNameValCollection = arrSubCookies[i].split("=");	
		CookieVal += arrNameValCollection[0] + "=" + arrNameValCollection[1];
		if (i < arrSubCookies.length - 1) CookieVal  = CookieVal + newDel; 
	}
	return CookieVal;
}



function EksendiaDropDownMenu()
{
	this.printAsTop = false;
	this.top = 0;
	this.left = 0;
	this.arrMenuPos = null;
	this.lastClick = 0;
	this.menuItems = '';
	this.menuBar = '';
	this.menuBar2 = '';
	this.print1 = '';
	this.print2 = '';
	this.geckoAlignDiff = 10;
	this.align = 0;
	
	this.glClose = function()
	{
		var dstamp = new Date();
		dstamp = dstamp.valueOf().toString();
		if ((dstamp - this.lastClick) > 100)
		{
			if (isVisible(this.menuItems))
			{
				this.findMenuPos(this.menuBar);
			}
		}
	}
	
	this.findMenuPos = function(id)
	{
		var dstamp = new Date();	
		this.lastClick = dstamp.valueOf().toString();
		var ua = LCase(navigator.userAgent);
		var align = this.align;
		if (this.printAsTop)
			align = 0;
		if (this.left == 0)
		{
			if (inStr(LCase(ua), "gecko") != -1)
			{
				align = align - this.geckoAlignDiff;
			}
			this.left = findLeft(id);
			this.top = findTop(id);
			moveElem(this.menuItems, this.left, this.top + align);
		}
		toggle(this.menuItems);
		toggle(this.menuBar2);
		toggle(this.menuBar);
		if (this.printAsTop)
		{
			toggle(this.print1);
			toggle(this.print2);
		}
	}
}



function conAnima()
{
	this.isVB = false;
	this.errorMsg = '';
	this.testing = true;
	this.IntID = new Array();	//just a data container for all globals
	this.allowDefault = true;
	this.lockID = false;
	this.whichButton = "";
	this.serveRClick = false;
	this.DivLastClicked = "none";
	this.objOutOfBoundsJustOnce = 0;
	this.chk4OutOfBounds = false;
	this.catchErr = false;
	this.inChangeOpacity = false;
	this.setNoOp = false;
	this.scr_w = 0;
	this.scr_h = 0;
	this.border_thicknes = 0;
	this.isNotMoved = true;
	this.isDivMovedSaved = true;
		//for next line to work you have to set the mouseonmove function in the specific pages
	this.showMousePos = false;
	this.showDivPos = false;
	this.myDivX = 0;
	this.myDivY = 0;
	this.myDivPosOffsetX = 0;
	this.myDivPosOffsetY = 0;
	this.whichDiv = "none";
	this.counter = 0;
	this.x = 0;
	this.y = 0;
	this.BoundsXMin = 3;
	this.BoundsXMax = 2;
	this.BoundsYMin = 3;
	this.BoundsYMax = 2;
	this.isCSS = false;
	this.ns4 = (document.layers)? true:false;
	this.ie4 = (document.all)? true:false;
	this.ns6 = (document.getElementById)? true:false;
	this.ie6 = false;
	if (this.ie4 == true && this.ns6 == true) this.ie6 = true; 
	if (this.ns6 == true) this.ie4 = false;
	if (this.ns4 || this.ie4 || this.ns6 || this.ie6) this.isCSS = true;
	this.ieVersion = 1000;
	if (this.ie6 && (navigator.userAgent.indexOf("Opera")==-1))
	{
		if (navigator.appName == "Microsoft Internet Explorer")
			this.ieVersion = parseInt(navigator.appVersion.split("MSIE ")[1]);
	}
	this.ua = navigator.appName;
	this.uaVersion = parseFloat(navigator.appVersion);
	this.changeImagesLock = false;
	
	
	this.changeImages = function() 
	{
		if (document.images && (!this.changeImagesLock)) 
		{
			for (var i = 0; i < this.changeImages.arguments.length; i+=2) 
			{
				document[this.changeImages.arguments[i]].src = this.changeImages.arguments[i+1];
			}
		}
	}
	


	

	function Ajax(URL, div4iFrame, queryStr, msg4ajax)
	{
		/*
		requires:
		1)function animato.exeAjax = exeAjax(text2displOrDoSomething)
		2)variable animato.IntID['msg4ajax'] - for iFrame
		3)div or span to contain iFrame to be written by this function (div4iFrame) 
		*/

		var str = '';
		var xh = null;
		query4iFrame = '';
		if (window.XMLHttpRequest)
			xh = new XMLHttpRequest();
		if (window.ActiveXObject)
		{
			try
			{
				xh = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e){}
			if (xh == null)
			{
				try
				{
					xh = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e){}
			}
		}
		if (queryStr != '')
			query4iFrame = "&" + queryStr;
		if (xh == null)
		{
			str += "<iframe id = 'frame4Ajax' width = '0' height = '0' src = '" + URL +"?iframe=true"+ query4iFrame + "' frameborder = '0'>";
			str += "</iframe>";
			document.getElementById(div4iFrame).innerHTML = str;
			exeAjax(animato.IntID['msg4ajax']);
			return '';
		}
		if (queryStr != '')
			URL += "?" + queryStr;
		xh.open("GET", URL, true);
		xh.onreadystatechange = function()
		{
			if (xh.readyState == 4)
			{
				animato.exeAjax(xh.responseText);
			}
		}
		xh.send(null);	
		return '';
	}
	this.ajax = Ajax;





	function Ajaxi(URL, queryStr)
	{
		/*
		requires:
			function animato.exeAjax = exeAjax(text2displOrDoSomething)
		*/
		
		var str = '';
		var xh = null;
		if (window.XMLHttpRequest)
			xh = new XMLHttpRequest();
		if (window.ActiveXObject)
		{
			try
			{
				xh = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e){}
			if (xh == null)
			{
				try
				{
					xh = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e){}
			}
		}
		if (xh == null)
		{
			alert("Cannot send ajax msg to server - maybe the browser is too old.");
			return '';
		}

		if (queryStr != '')
			URL += "?" + queryStr;
		xh.open("GET", URL, true);
		xh.onreadystatechange = function()
		{
			if (xh.readyState == 4)
			{
				animato.exeAjax(xh.responseText);
			}
		}
		xh.send(null);	
		return '';
	}
	this.ajaxi = Ajaxi;



	function ExeAjax(msg)
	{
		//nothing  - overwrite for code
	}
	this.exeAjax = ExeAjax;


	function MyErrors()
	{
		if (animato.errorMsg != '')
			alert(animato.errorMsg);
	}
	this.myErrors = MyErrors;


	//start SlideShow functions


		//helper function for slideShow()
	function HelpWriteSlides(name, len)
	{
		var i = 0;
		var chk = '';
		var n = '';
		for (i = 0; i < len; i++)
		{
			n = name + "_" + i;
			try
			{
				chk = document.getElementById(n).id	
			}
			catch(e)
			{
				dw("<span id = '" + n + "'></span>");
			}
			hideObject(n);
		}
	}
	this.helpWriteSlides = HelpWriteSlides;
	
	
	this.initSlides = function(myFades, slideDelay)
	{
		var i, tmpID;
		for (i = 0; i < myFades.length; i++)
		{
			tmpID = myFades[i];
			myFades[i] = document.getElementById(tmpID).innerHTML;
			document.getElementById(tmpID).innerHTML = '';
		}
		animato.helpWriteSlides("fade", myFades.length);
		animato.IntID['pm_mySlides'] = new animato.slideShow();
		animato.IntID['pm_mySlides'].init(myFades.length, "animato.IntID['pm_mySlides']", "fades", "fade",	slideDelay, true, myFades);
	}
}	


conAnima.prototype.slideShow = function()
{
	this.arrFadeHTML = null;
	this.fades = '';
	this.fadeElemsName = '';
	this.name = '';
	this.numOfEls = 0;
	this.counter = 0;
	this.fadeDelay = 20;
	this.slideDelay = this.fadeDelay * 500;
	this.fadeActive = true;
	this.opacity = 100;
	this.ieOpacityChk = -1;
	this.numOfEls = 0;
	this.current = 0;
	this.fadeCounter = -1;


	function Init(numOfEls, instanceName, fades, fadeElemsName, delay, fadeActive, arrFadeHTML)
	{
		if (fadeActive != null)
			this.fadeActive = fadeActive;
		this.fades = fades;			// element (canvas) for fading
		this.fadeElemsName = fadeElemsName; 	// elems being faded; for inst: fade = fade_0, fade_1, etc.
		this.name = instanceName;		// this class instance name
		if (delay != null)
		{
			this.fadeDelay = delay * 5; 		// leave it for now - how fast it changes
			this.slideDelay = this.fadeDelay * 500; // leave it for now
		}
		this.opacity = 100;
		this.numOfEls = numOfEls;
		this.current = 0;
		showObject(this.fadeElemsName + 'Dir');	// director element has name this.fadeElemsName + "Dir"
		if (arrFadeHTML != null)
		{
				// preloaded only part of imgs array for speed, write the whole set here
			this.arrFadeHTML = arrFadeHTML;
			this.writeFadeHTMLs();
		}
		document.getElementById(this.fades).innerHTML = document.getElementById(this.fadeElemsName + '_' + this.current).innerHTML;
		this.nextSlide();
	}
	this.init = Init;


	function WriteFadeHTMLs()
	{
		var i;
		var chk;
		for (i = 0; i < this.arrFadeHTML.length; i++)
		{
			document.getElementById(this.fadeElemsName + '_' + i).innerHTML = this.arrFadeHTML[i];
		}
	}
	this.writeFadeHTMLs = WriteFadeHTMLs;


	function ChangeOpacity(id, op)
	{
		if (!this.fadeActive)
			return;

		try
		{
			document.getElementById(id).filters.alpha.opacity = op * 1;
		}
		catch(e)
		{		
			try
			{
				document.getElementById(id).style.MozOpacity = op/100;
			}
			catch(e){}
		}	
	}
	this.changeOpacity = ChangeOpacity;


	function CancelInts()
	{
		clearTimeout(animato.IntID['homeSlide']);
		clearTimeout(animato.IntID['homeSlideFade']);
		this.changeOpacity(this.fades, 100)
		this.fadeActive = false;
	}
	this.cancelInts = CancelInts;


	function Fade()
	{
		if (this.opacity > 0)
		{
			this.opacity--;
			animato.IntID['homeSlideFade'] = setTimeout(this.name + ".fade()", this.fadeDelay);
			this.changeOpacity(this.fades, this.opacity);
		}
		else
		{
			clearTimeout(animato.IntID['homeSlide']);
			this.nextSlide();
		}
	}
	this.fade = Fade;


	function Unfade()
	{
		if (this.opacity < 100)
		{
			this.opacity++;
			animato.IntID['homeSlideFade'] = setTimeout(this.name + ".unfade()", this.fadeDelay);
			this.changeOpacity(this.fades, this.opacity);
		}
		else
		{
			clearTimeout(animato.IntID['homeSlideFade']);
		}
	}
	this.unfade = Unfade;


	function NextSlide()
	{
		var changeSlide = false;
		clearTimeout(animato.IntID['homeSlideFade']);
		if (this.opacity == 0)
		{
			this.counter++;
			this.unfade();
			changeSlide = true;
		}
		else
		{
			this.fade();
		}
		this.current = this.counter % this.numOfEls;	
		if (this.current < 0)
			this.current = this.current * (-1);
		if (changeSlide == true)
			document.getElementById(this.fades).innerHTML = document.getElementById(this.fadeElemsName + '_' + this.current).innerHTML;
		animato.IntID['homeSlide'] = setTimeout(this.name + ".nextSlide()", this.slideDelay);	
	}
	this.nextSlide = NextSlide;


	function Next_slide()
	{
		this.current++;
		if (this.current * 1 > (this.numOfEls - 1))
			this.current = 0;
		document.getElementById(this.fades).innerHTML = document.getElementById(this.fadeElemsName + '_' + this.current).innerHTML;
	}
	this.next_slide = Next_slide;

	function PrevSlide()
	{
		this.current--;
		if (this.current * 1 < 0)
			this.current = (this.numOfEls -1) * 1;
		document.getElementById(this.fades).innerHTML = document.getElementById(this.fadeElemsName + '_' + this.current).innerHTML;
	}
	this.prevSlide = PrevSlide;
		
}	//end SlideShow functions and conAnima prototype
	
//end conAnima
var animato = new conAnima();


if (document.captureEvents) document.captureEvents(Event.MOUSEMOVE | Event.MOUSEDOWN | Event.MOUSEUP);


function showHtml(id, innerHTM)
{
	if (!document.getElementById) return false;
	document.getElementById(id).innerHTML = innerHTM; 
	return true; 
}


function stickVert(id, offset)
{
		/* use animato.IntID[divName] with setInterval for it */
	if (!document.getElementById) return false;
	moveElem(id, ObjLeft(id), document.body.scrollTop + offset);
	return true;
}


function stick(id, offsetTop, offsetLeft)
{
		/* use animato.IntID[divName] with setInterval for it */
	if (!document.getElementById) return false;
	moveElem(id, document.body.scrollLeft + offsetLeft, document.body.scrollTop + offsetTop);
	return true;
}


function inner_height()
{	
	if (window.innerHeight)
		return (window.innerHeight);	
	if(document.body.offsetHeight)
		return (document.body.offsetHeight);
}


function inner_width()
{	
	if (window.innerWidth)
		return (window.innerWidth);
	if(document.body.offsetWidth)
		return (document.body.offsetWidth);
}


function isVisible(id)
{	
	if (animato.ns4) 
	{
		if (document[id].visibility == "show") 
			return true;
	}
	if (animato.ie4) 
	{
		if (document.all(id).style.display == '')
			return true;
	}
	if (animato.ns6 || animato.ie6) 
	{
		if (document.getElementById(id).style.display == '')
			return true;
	}
	return false;
}

function mouse_pos(e)
{
	if (animato.allowDefault == false)
	{
		if (animato.ie6) window.event.returnValue = false;
		if (animato.ns6) try{e.preventDefault();}catch(e){}
	}

	if (!animato.ie4 && !animato.ie6) 
	{
		animato.x = e.pageX;
		animato.y = e.pageY;
	}
	else
	{
		animato.x = event.x; 
		animato.y = event.y;
	}	
	MoveDown();
	if (animato.showMousePos) 
		window.status = "x = " + animato.x + ", y = " + animato.y;
}


function moveElem(id, px, py)
{	
	if (animato.ie4) 
	{
		document.all(id).style.left = px; 
		document.all(id).style.top = py;
	}
	if (animato.ns4) document[id].moveToAbsolute(px, py);
	if(animato.ns6 || animato.ie6)
	{
		document.getElementById(id).style.left = px; 
		document.getElementById(id).style.top = py;
	}	
}


function showObject(id) 
{	
	if (!animato.testing)
	{
		if (animato.ns4) document[id].visibility = "show";
		if (animato.ie4) document.all(id).style.display = '';
		if (animato.ns6 || animato.ie6) document.getElementById(id).style.display = '';
	}
	else
	{
		try
		{
			if (animato.ns4) document[id].visibility = "show";
			if (animato.ie4) document.all(id).style.display = '';
			if (animato.ns6 || animato.ie6) document.getElementById(id).style.display = '';
		}
		catch(e)
		{
			animato.errorMsg += "error from showObject: cannot find " + id + "\n";
		}
	}
}

function hideObject(id) 
{
	if (!animato.testing)
	{
		if (animato.ns4) document[id].visibility = "hide";
		if (animato.ie4) document.all(id).style.display = 'none';
		if (animato.ns6 || animato.ie6) document.getElementById(id).style.display = 'none';
	}
	else
	{
		try
		{
			if (animato.ns4) document[id].visibility = "hide";
			if (animato.ie4) document.all(id).style.display = 'none';
			if (animato.ns6 || animato.ie6) document.getElementById(id).style.display = 'none';
		}
		catch(e)
		{
			animato.errorMsg += "error from hideObject: cannot find " + id + "\n";
		}
	}
}


function toggle(id)
{	
	if (!isVisible(id)) 
		showObject(id);
	else
		hideObject(id);	
}


function ObjTop(id)
{
		/*for absolute pos. only*/
	var XTop = 0;
	try
	{
		if (animato.ns4) XTop = document[id].top;
		if (animato.ie4) XTop = document.all(id).style.pixelTop;
		if (animato.ns6 || animato.ie6) XTop = document.getElementById(id).style.top;
	}
	catch(e){}	
	return(parseInt(parseFloat(XTop)));
}


function ObjLeft(id)
{	
		/*for absolute pos. only*/
	var YLeft = 0;
	try
	{
		if (animato.ns4) YLeft = document[id].left;
		if (animato.ie4) YLeft = document.all(id).style.pixelLeft;
		if (animato.ns6 || animato.ie6) YLeft = document.getElementById(id).style.left;	
	}
	catch(e){}
	return(parseInt(parseFloat(YLeft)));
}


function findAbsPos(id)
{
	return [ObjTop(id), ObjLeft(id)];
}


function findTop(elid)
{
	if (!document.getElementById)
		return -1000;
	var Y;
	id  = document.getElementById(elid);
	for(Y = 0; id.offsetParent; id = id.offsetParent )
	{
		Y += id.offsetTop;
	}
	return Y;
}


function findLeft(elid)
{
	if (!document.getElementById)
		return -1000;
	var X;
	id  = document.getElementById(elid);
	for(X = 0; id.offsetParent; id = id.offsetParent )
	{
		X += id.offsetLeft;
	}
	return X;
}


function findPos(elid)
{
	if (!document.getElementById)
		return [-1000, -1000];
	var X, Y;
	id  = document.getElementById(elid);
	for(X = 0, Y = 0; id.offsetParent; id = id.offsetParent )
	{
		X += id.offsetLeft;
		Y += id.offsetTop;
	}
	return [X, Y];
}


function objectOutOfBounds()
{
	if (animato.whichDiv != "none") 
	{
		animato.myDivX = ObjTop(animato.whichDiv);
		animato.myDivY = ObjLeft(animato.whichDiv);
		if (!(animato.x > animato.BoundsXMin && animato.y > animato.BoundsYMin && animato.x < animato.scr_w - animato.BoundsXMax && animato.y < animato.scr_h - animato.BoundsYMax))
		{
			if (animato.chk4OutOfBounds) 	
			{
					 /*Funkcje MouseMsg() musze napisac sam w aplikacji*/
				return MouseMsg();
			}
			else 
			{
				moveElem(animato.whichDiv, 50, 50);
				return true;
			}
		}
		return false;
	}
	return false;	
}


function MoveDown()
{
	if (animato.whichDiv != "none" && animato.whichButton == "left") 
	{
		if (objectOutOfBounds() && animato.chk4OutOfBounds == true)
		{}
		else
		{
			moveElem(animato.whichDiv, animato.x - animato.myDivPosOffsetX, animato.y - animato.myDivPosOffsetY);
			animato.isNotMoved = false;
			animato.myDivX = ObjTop(animato.whichDiv);
			animato.myDivY = ObjLeft(animato.whichDiv);
			if (animato.showDivPos) window.status = "x = " + animato.myDivY + ", y = " + animato.myDivX;
		}
	}
}


function onerror()
{
	if ((animato.catchErr == true) && (animato.inChangeOpacity == true))
	{
		window.onerror = null;	
		animato.lockID = false;
		animato.setNoOp = true;
		unChooseDiv();
		return true;
	}	
}


function changeOpacity(id, op)
{
	animato.inChangeOpacity = true;	
	var alertMe = false;
	if (animato.setNoOp == false)
	{
		if ((animato.ie6) && (navigator.userAgent.indexOf("Opera")==-1))
		{
			try{
				document.getElementById(id).filters.alpha.opacity = op;
			}
			catch(e){
				if (alertMe)
					alert("error in animato.ie6 changeOpacty function: " + e.description);
			}
		}
		if ((animato.ns6) && (navigator.userAgent.indexOf("Gecko")!=-1))
		{
			try{
				document.getElementById(id).style.MozOpacity = op/100;
			}
			catch(e){
				if (alertMe)
					alert("error in animato.ie6 changeOpacty function: " + e.description);	
			}
		}
	}
	animato.inChangeOpacity = false;
}


function getOpacity(id)
{
	animato.inChangeOpacity = true;
	if (animato.setNoOp == false)
	{
		if ((animato.ie6) && (navigator.userAgent.indexOf("Opera")==-1))
			try{return document.getElementById(id).filters.alpha.opacity;}catch(e){return false;}
		if ((animato.ns6) && (navigator.userAgent.indexOf("Gecko")!=-1))
			try{return (document.getElementById(id).style.MozOpacity * 100);}catch(e){return false;}
	}
	animato.inChangeOpacity = false;
	return false;
}


function getZindex(id)
{
	if (document.getElementById)
		return document.getElementById(id).style.zIndex;
	return false;
}


function chooseDiv(id)
{
	if (!document.getElementById) return false;
	if (animato.lockID) return false;
	animato.allowDefault = false;
	if (animato.whichDiv != "none")
		unChooseDiv();
	if (animato.DivLastClicked != "none") 
		document.getElementById(animato.DivLastClicked).style.borderWidth = 0;
	changeOpacity(id, 100);
	animato.objOutOfBoundsJustOnce = 0;
	animato.whichDiv = id;
	animato.DivLastClicked = id;
	animato.isNotMoved = true;
	animato.scr_w = inner_width();
	animato.scr_h = inner_height();
	animato.divsY = ObjTop(id);
	animato.divsX = ObjLeft(id);
	animato.myDivPosOffsetX = animato.x - animato.divsX;
	animato.myDivPosOffsetY = animato.y - animato.divsY;
	changeOpacity(id, 70);
	window.status = " ";
	var tmpY = ObjTop(animato.whichDiv) - animato.border_thicknes;
	var tmpX = ObjLeft(animato.whichDiv) - animato.border_thicknes;
	document.getElementById(animato.whichDiv).style.borderWidth = animato.border_thicknes;
	moveElem(animato.whichDiv, tmpX, tmpY);
	return true;
}


function unChooseDiv()
{
	if (!document.getElementById) return false;
	if (animato.lockID) return false;
	animato.allowDefault = true;
	if ((animato.whichDiv != "none") && (!objectOutOfBounds()))
	{
		if (animato.isDivMovedSaved)
		{
			if(!animato.isNotMoved) animato.isDivMovedSaved = false;
		}
			/*Funkcje unChooseDiv_onMouseUpHandler() musze napisac sam w aplikacji*/
		unChooseDiv_onMouseUpHandler();
		if (animato.whichButton == "right") 
		{
				/*Funkcje unChooseDiv_rightClickHandler() musze napisac sam w aplikacji*/
			unChooseDiv_rightClickHandler();
		}
		changeOpacity(animato.whichDiv, 99);
		if (animato.whichDiv != "none")
		{
			var tmpY = ObjTop(animato.whichDiv) + animato.border_thicknes;
			var tmpX = ObjLeft(animato.whichDiv) + animato.border_thicknes;
			if (animato.whichButton != "right") document.getElementById(animato.whichDiv).style.borderWidth = 0;
			moveElem(animato.whichDiv, tmpX, tmpY);
		}
		animato.whichDiv = "none";
		animato.myDivPosOffsetX = 0;
		animato.myDivPosOffsetY = 0;
	}
	return true;
}


function whichButtonClicked(e)
{
	animato.whichButton = "left";
	if (navigator.appName == "Netscape" && (e.which > 1))
		animato.whichButton = "right";
	if (navigator.appName == "Microsoft Internet Explorer" && (event.button > 1)) 
		animato.whichButton = "right";
	if (animato.serveRClick) animato.whichButton = "right";
	if (animato.whichButton == "left")
	{
	if (animato.allowDefault == false)
		{
			if (animato.ns6) try{e.preventDefault();}catch(e){}
		}
	}
}


function choosePagingSelect(form) 
{
	var Page = form.PagingNrSelectOption.options[form.PagingNrSelectOption.selectedIndex].value;
	if (Page != '')
	{
		if (isNr(Page))
		{
			form.writePaging_PageNumber.value = Page;
			form.submit();
		}
	}
}



function generatePagingSelect(topNr, selected, URL, RsCount)
{
	dw("<FORM NAME='PagingNrForm' method='POST' action  = '" + URL + "'>");
	dw("<SELECT NAME='PagingNrSelectOption' onChange='choosePagingSelect(this.form);'>");
	var i;
	for (i = 1; i <= topNr; i++)
	{
		dw("<Option value = '" + i + "' ");
		if (i == selected)
			dw("selected");
		dw(">" + i + "</option>");
	}
	dw("</select>");
	dw("<Input type = 'hidden' name = 'writePaging_PageNumber' Value = ''>");
	if (RsCount != null) 
		dw("<Input type = 'hidden' name = 'RsCount' Value = '" + RsCount + "'>");
	dw("</form>");
}



function nr2date(theNr)
{
	if (theNr == '')
		return '';
	var rok, mies, dzien, miesiacName;
	var i, d;
	rok = "";
	mies = "";
	dzien = "";
	miesiacName = "";
	for (i = 0; i < 8; i++)
	{
		if (i < 4)
			rok = rok + Character(theNr, i);
		if (i == 4 || i == 5)
			mies = mies + Character(theNr, i);
		if (i > 5)
			dzien = dzien + Character(theNr, i);
	}
	if (mies == "01") miesiacName = "Jan.";
	if (mies == "02") miesiacName = "Feb.";
	if (mies == "03") miesiacName = "March";
	if (mies == "04") miesiacName = "Apr.";
	if (mies == "05") miesiacName = "May";
	if (mies == "06") miesiacName = "June";
	if (mies == "07") miesiacName = "July";
	if (mies == "08") miesiacName = "Aug.";
	if (mies == "09") miesiacName = "Sept.";
	if (mies == "10") miesiacName = "Oct.";
	if (mies == "11") miesiacName = "Nov.";
	if (mies == "12") miesiacName = "Dec.";
	return (miesiacName + " " + dzien + ", " + rok);
}


function nr_to_date(theNr)
{
	if (theNr == '')
		return '';
	var rok, mies, dzien, miesiacName;
	var i, d;
	rok = "";
	mies = "";
	dzien = "";
	miesiacName = "";
	for (i = 0; i < 8; i++)
	{
		if (i < 4)
			rok = rok + Character(theNr, i);
		if (i == 4 || i == 5)
			mies = mies + Character(theNr, i);
		if (i > 5)
			dzien = dzien + Character(theNr, i);
	}
	return new Array(dzien, mies, rok);
}


function date2Nr(d, m, y)
{
	var day = d.toString();
	var month = m.toString();
	if (day.length < 2)
		day = "0" + day;
	if (month.length < 2)
		month = "0" + month;
	return y + "" + month + "" + day + "";
}



function nr2time(theNr)
{
	if (theNr == '')
		return '';
	var i = 0;
	h = "";
	m = "";
	s = "";
	if (theNr.length == 5) 
		theNr = "0" + theNr;
	for (i = 0; i < 6; i++)
	{
		if (i < 2) 
			h = h + Character(theNr, i);
		if (i == 2 || i == 3)
			m = m + Character(theNr, i);
		if (i > 3)
			s = s + Character(theNr, i);
	}
	return h + ":" + m + ":" + s;
}


function genericClassObject()
{
	this.outerClass = null;
	this.name = '';
}




