	var logCtrl ; var logBtn ; 

	var todayNow = new Date()
	var todayNowUTC = Date.UTC(todayNow.getYear(), todayNow.getMonth() +1, todayNow.getDate(), todayNow.getHours(), todayNow.getMinutes(), todayNow.getSeconds())

// BROWSER DETECTION

function navIE()
{
	return (navigator.appName.indexOf("Explorer") > -1)	
}



// STRING HANDLING
function text2html(itm)
{
	if(typeof(itm) == "undefined")
		return ""

	var s = ""; var sn = "" ;
	
	var arReplaces = new Array()
	arReplaces[0] = new Array("ä", "&auml;")
	arReplaces[1] = new Array("Ä", "&Auml;")
	arReplaces[2] = new Array("ö", "&ouml;")
	arReplaces[3] = new Array("Ö", "&Ouml;")
	arReplaces[4] = new Array("ü", "&uuml;")
	arReplaces[5] = new Array("Ü", "&Uuml;")
	arReplaces[6] = new Array("ß", "&szlig;")
	//aReplaces[7] = new Array("Ä", "&Auml;")
	
	for(var i = 0; i < arReplaces.length; i++)
	{
		itm = itm.replace(eval("/" + arReplaces[i][0] + "/g")	, arReplaces[i][1])
		
	}
	//itm = itm.replace(/'/g, "")
	for(var charPos = 0; charPos < itm.length ; charPos++)
	{
		if(itm.charCodeAt(charPos) > 125)
		{
			sn += "&#" + itm.charCodeAt(charPos) + ";"
		}else{
			sn += itm.substr(charPos,1)
		}
		//alert(charPos + "\t" + itm.substr(charPos,1) + "\t" + itm.charCodeAt(charPos) + "\n" + sn)
	}	
	//return itm
	return sn
}





function HTMLentities2text(s)
{
	var arX = s.split("&#")
	var sn = ""
	for(var i = 0; i < arX.length ; i++)
	{
		var arT = arX[i].split(";")
		if(Number(arT[0]) > 0 && arT.length > 1)
		{
			//alert(arT[0])	
			sn += String.fromCharCode(arT[0])
			arT.shift()
			sn += arT.join(";")
		}else{
			//alert("/" + arT.join(";") + "/")
			sn += arT.join(";")
		}
	}
	//alert(s + "\n" + sn)	
	return sn ;
}
// ARRAYS

function in_array(arIp, v)
{
	if(typeof(arIp) != "object")
		return false 
	
	for(var i = 0; i < arIp.length ; i++)
	{
		if(arIp[i] == v)
			return true
		
	}	
	return false ;
}


function number_format_leading_zero(n, dgt)
{
	var nm = n.toString()
	lgth = nm.length
	for(var i = lgth; i < dgt ; i++)
	{
		nm = "0" + nm
	}
	//alert(lgth + "\t" + nm)
	return nm
}
// TIME

function nm_number_seconds2timestr()
{
	var s = Number(this)
	var h = parseInt(s / 3600)
	s -= h * 3600
	var m = parseInt(s / 60)
	s -= m * 60
	var res = ""
	if(h > 0)
		res += h + " h, " 
	if(h > 0 || m > 0)
		res += number_format_leading_zero(m,2) + " min, " 
	res += number_format_leading_zero(parseInt(s),2) + " s"
	return res
	
	
}
Number.prototype.Seconds2Time = nm_number_seconds2timestr

// COOKIES *****************************************************************

function getCookie(pKey){
	var i
	strC = document.cookie
	
	arrC = strC.split("; ")
	//alert(arrC.length + "\n" + strC + "\n" + pKey + "\n" + arrC[0])
	for(i = 0; i < arrC.length; i++){
		arrEn = 	arrC[i].split("=")
		//alert(strC + "\n" + "Search: " + pKey +"\n" + "Line:"+arrC[i]+"/" + "\n" + arrEn[0] + "\n" + arrEn[1])
		if(arrEn[0].toLowerCase() == pKey.toLowerCase() && arrEn.length > 1 ){
			arrVal = arrEn[1].split("; ")
			//alert(arrC[i] + "\n" + pKey+ "\n\n" + strC)	
			return arrVal[0]
		}
	}
	return ""
}

function setCookie(pKey, expression) {   
	dt = new Date()
	tm = Date.UTC(dt.getYear(), dt.getMonth() +1, dt.getDate(), dt.getHours(), dt.getMinutes(), dt.getSeconds())
	expDiff = dt.getTime() + (100 * 24 * 60 * 60 * 1000)
	dt.setTime(expDiff)
	//ck = "@" + pKey + "=" + expression  +"; expires=" + dt.toGMTString() + "; path=/"
	ck = pKey + "=" + expression  +"; expires=" + dt.toGMTString() + "; path=/"
	document.cookie = ck
	return
}


function getCookieDate(dt){
	yr = dt.getYear() +50
	yr = yr.toString()
	yr = yr.substring(2)
	strD = getWeekdayName(dt.getDay()) + ", " + strFormat(dt.getDate(), 2) + "-" + strFormat(dt.getMonth()+1, 2) + "-" + yr
	
	strD += " " + strFormat(dt.getHours(), 2) + ":" + strFormat(dt.getMinutes(), 2) + ":" + strFormat(dt.getSeconds(), 2) + " GMT"
	return strD
}


function strFormat(nm, dgt){
	st = nm.toString()
	for(i=st.length; i < dgt; i++){
		st = "0" + st
	}
		
	return st
}

function getWeekdayName(n) {
	arW = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
	return arW[n]
	
}


function getQuery(itm){
	strSearch = document.location.search
	if(strSearch.length <=3)
		return ""
	strSearch = strSearch.substring(1)
	var arEnt = strSearch.split("&")
	for(i=0; i< arEnt.length; i++){
		arItm = arEnt[i].split("=")
		if(arItm.length > 1){
			if(arItm[0].toLowerCase() == itm.toLowerCase()){
				return arItm[1]
			}
		}
	}
	return ""
}


function accessCounter(){
	//setCookie("ACCESS_COUNTS", "")
	aa = getCookie("ACCESS_COUNTS")
	if(isNaN(parseInt(aa))){
		aa = 0
	}else{
		aa = parseInt(aa)
	}
	//alert(typeof(aa)+ " " + aa.toString())
	aa += 1
	setCookie("ACCESS_COUNTS", aa.toString())
}

function trueFalseRandom(){
	bV = Math.random()
	return (bV >= 0.5)	
	
}

function parseDate(strD){
	//23.09.2005
	arD = strD.split(".")
	dDate = new Date(arD[2], arD[1]-1, arD[0])
	//alert(dDate)
	return dDate
	
}


function Date2Str(tDate){
	day = tDate.getDate()
	month =  tDate.getMonth()+1
	year = tDate.getYear()
	//alert(day + "\t" + number_format_leading_zero(day, 2))
	return number_format_leading_zero(day, 2) + "." + number_format_leading_zero(month, 2)	+ "." + year.toString()
}



/* ******** FILTER HELPERS ********************************** */

function getRandomIris(){
	var idx = Math.min(Math.round(Math.random() * arrIrisStyles.length), arrIrisStyles.length-1)
	return arrIrisStyles[idx]
}

function getRandomMotion(){
		if(trueFalseRandom())
			return "in"

		return "out"			
}



/* MISCELLANEOUS */

function timeTicker(){
	if(!tickerInfo){
		window.clearInterval(IDTickerInterval)
		return
	}
	var Now = new Date()
	var NowUTC = Date.UTC(Now.getYear(), Now.getMonth() +1, Now.getDate(), Now.getHours(), Now.getMinutes(), Now.getSeconds())

	ellapsed = (NowUTC - todayNowUTC ) / 1000
	acc = ";   times accessed: " + getCookie("ACCESS_COUNTS")
	try {
		window.status = "Seconds: " + ellapsed.toString() + "    Iris: " + IDIrisTimeout.toString() + "   Mover: " + IDMoverPlayTimeout.toString() + " Mover playing:" + moverPlaying.toString() + acc
	}catch(e){}
	
}

/* FORM MANIPULATION */

function formQuerySet(quer, doDoc, queryString)
{
		//alert(quer)
		if(typeof(doDoc) == "undefined" || ! doDoc)
		{
			var frm = document.forms[0]
			var arAction = frm.action.split("\?")
		}else{
			var arAction = window.location.href.split("\?")
		}
		//alert(typeof(queryString))
		if(typeof(queryString) == "string")
		{
			var arAction = queryString.split("\?")
			doDoc = true
		}
		var fl = arAction[0]
		var hash = ""
		if(arAction.length > 1)
		{
			var strQuery = ""
			var arNewPar = quer.split("=")
			var isFound = false
			arQuery = arAction[1].split("&")
			for(var i = 0; i < arQuery.length; i++)
			{
				
				var arParCrude = arQuery[i].split("#")
				
				if(arParCrude.length > 1)
					hash = arParCrude[1]
				//alert(arQuery[i] + "\t" + arParCrude.length + "\t" +  hash + "\n" + strQuery)
				var arPar = arParCrude[0].split("=")
				if(arNewPar[0]==arPar[0])
				{
					strQuery +=quer + "&"
					isFound = true
				}else{
					if(arPar.length > 1)
						strQuery +=arQuery[i] + "&"
				}
				//alert(strQuery)
			}
			if(! isFound)
				strQuery += quer

		}else{
			strQuery = quer
		}
		var strAction = fl + "?" + strQuery
		if(hash != "")
			strAction += "#" + hash
		//alert(frm.action + "\n" + strAction)
		//alert(frm.action)
		//frm.action += "&" + quer
		if(typeof(doDoc) == "undefined" || ! doDoc)
		{
			frm.action = strAction
		}else{
			return strAction
		}
		//alert(frm.action)
}

function formHashSet(hash, strAct)
{
		doReturnString = ! (typeof(strAct) == "undefined")
		if(! doReturnString)
		{
			var frm = document.forms[0]
			var strAct = frm.action 
		}else{
		
		}
		var arAct = strAct.split("#")
		strAct = arAct[0] + "#" + hash
		//alert(strAct + "\n" + doReturnString) 
		if(doReturnString)
			return strAct
		frm.action = strAct + "#" + hash
		//alert(frm.action)
}





function ctrl_value2cookie(obj)
{
	if(obj.type == "checkbox")
	{
		setCookie(obj.id, Number(obj.checked).toString())
			
	}
	if(obj.type == "text")
	{
		setCookie(obj.id, obj.value)
	}
}

function frm_get_settings()
{
	for(var i =0; i < document.forms.length; i++)
	{
		var frm = document.forms[i]
		for(var n = 0; n < frm.elements.length; n++)
		{
			var obj = frm.elements[n]
			//alert(obj.name)
			var id = typeof(obj.id) == "undefined" ||obj.id.length == 0 ? obj.name : obj.id
			//alert(id)
			var ck = getCookie(id)
			//alert(obj.id + "\t" + ck + "\t" + ck.length + "\t" + typeof(ck))
			if(ck.length >  0)
			{
				switch(obj.type.toLowerCase())
				{
					case "checkbox" :
						obj.checked = Number(ck)
						break ;
					default:
						obj.value = ck					
				}	
				
			}
		}		
	}

}






/* MISCELLANEOUS */

function str_RemoveLastHTMLTag(NotBefore){
	var t = this.toString()
	var stPos = 0
	if(typeof(NotBefore) != "undefined")
		stPos = NotBefore
	
	var lstIdx = -1
	idx = t.indexOf("<", stPos)
	while(idx >=0)
	{	
		lstIdx = idx
		stPos = idx +1
		idx = t.indexOf("<", stPos) 
	}
	if(lstIdx >= 0)
	{
		if(t.indexOf(">", lstIdx) <0)
			t = t.substring(0, lstIdx)
	}
	
	return t
	
}
String.prototype.RemoveLastHTMLTag = str_RemoveLastHTMLTag

/* TIME LINE MANAGEMENT */

function timer(nm)
{
	this.tmID = 0
	this.timers = new Array()
	this.active = true
	this.name= nm
	
}

function timer_setTimeout(strTime, wait)
{
	if(! this.active)	
	{
		this.timers.push(array(strTime, wait))
		return
	}
	this.tmID = window.setTimeout(strTime, wait)
	
}
timer.prototype.setTimeout = timer_setTimeout


function timer_wait(wait)
{
	window.clearTimeout(this.tmID) 
	this.active = false	
	window.setTimeout(this.name + ".resume()", wait)
	
}
timer.prototype.wait = timer_wait

function timer_resume()
{
	this.active = true
	if(this.timers.length == 0)
		return
			
	window.setTimeout(this.timers[0][0], this.timers[0][1])
	this.timers.shift()
	if(this.timers.length == 0)
		return
	window.setTimeout(this.name + ".resume()", this.timers[0][1])
}
timer.prototype.resume = timer_resume

// POSITIONING

function safePos(obj, posPar)
{
	var eObj = obj
	var pPar = 0
	while(eObj != null)
	{
		if(posPar == "top")
		{
			pPar += eObj.offsetTop 
		}
		if(posPar == "left")
		{
			pPar += eObj.offsetLeft
		}
		eObj = eObj.offsetParent
	}
	return pPar
}

function winsize_adapt(incWidth, incHeight)
{
	var chlds = document.body.childNodes
	var maxL = 0 ;
	var maxT = 0 ;
	
	for(var i = 0; i < chlds.length; i++)
	{
		var obj = chlds[i]
		//alert(obj.nodeType)
		if(obj.nodeType == 1)
		{
			with(obj)
			{
				//alert(nodeName + "\n" + "Top:\t" + offsetTop + "\t" + offsetHeight + "\n" + "Left:\t" + offsetLeft + "\t" + offsetWidth)
				omaxL= maxL
				omaxT = maxT
				maxT = (offsetTop + offsetHeight) > maxT ? (offsetTop + offsetHeight) : maxT
				maxL = (offsetLeft + offsetWidth) > maxL ? (offsetLeft + offsetWidth) : maxL
				if((omaxL != maxL || omaxT != maxT ) && 1 == 2)
					alert(obj.nodeName + "\n" + obj.innerHTML)
			}
		}
	}
	var bdL = document.body.currentStyle.marginLeft
	var bdT = document.body.currentStyle.marginTop
	//alert(bdT)
	//alert((maxL + 2 * parseInt(bdL)) + "\t" + (maxT + 2 * parseInt(bdT)))
	maxL  += typeof(incWidth) == "number" ? incWidth : 0 ;
	maxT  += typeof(incHeight) == "number" ? incHeight : 0 ;
	
	
	window.resizeTo(maxL + 2 * parseInt(bdL), maxT + 2 * parseInt(bdT))
}


// DEBUGGING , DEVELOPMENT ******************************************************************

function helpers_property_display(obj)
{
	var s = ""
	var msg = "Properties: " + obj.tagName + "\tid: " + obj.id
	var arProp = new Array()
	for(var prop in obj)
	{
		arProp[arProp.length] = prop
	}
	arProp.sort()
	for(var i = 0; i < arProp.length; i++)
	{
		prop = arProp[i] ;
		try
		{
			s += prop + "\t" + obj[prop] + "\n"
		}catch(e){
			s += prop + "\tnot available:\t" + typeof(obj[prop]) + "\n"
		}
		if(s.length > 750)
		{
			if(! confirm(msg + "\n\n" + s))
				return ;
			s = "" 
		}	
	}
		
	alert(msg + "\n\n" + s)
	
	
}


// FSO ******************************

function sizeStr(sz)
{
	var arRadix = new Array( Array(1024 * 1024 * 1024, "GB"),  Array(1024 * 1024, "MB") , Array(1024, "kb")  )
	for(var i = 0; i < arRadix.length; i++)
	{
		if(sz > (arRadix[i][0] / 1024) * 1000)
		{
			return (Math.round(sz / arRadix[i][0] * 100) / 100).toString().replace(/\./, ",") + " " + arRadix[i][1]
		}
	
	}

	return sz + " byte"
}

// SELECT TITLE ******

function selectTitleBind(tgID)
{
	//alert(tgID)
	$("#" + tgID).bind("mouseover", function(e){ 
		
		if(typeof(tg_selectTitle) == "undefined")
		{
			tg_selectTitle = document.createElement("DIV")
			with(tg_selectTitle.style)
			{
				fontFamily="Arial"
				fontWeight="normal"
				fontSize="7pt"
				padding="1px"
				border="1px solid midnightblue"
				position = "absolute"
				verticalAlign="middle"
				paddingBottom="1px"
				backgroundColor="#FFFACD"
				color="midnightblue"	
			}
			document.body.appendChild(tg_selectTitle)
		}
		var srcTg = document.getElementById(tgID)
		tg_selectTitle.innerHTML = srcTg.value
		with(tg_selectTitle.style)
		{
			display="inline"
			top = safePos(srcTg ,"top") - 5
			left = safePos(srcTg ,"left") + srcTg.offsetWidth
		}
		
	})
	
	$("#" + tgID).bind("mouseout", function(e){ 
		if(typeof(tg_selectTitle) != "undefined")
			tg_selectTitle.style.display="none"
			
	}) 
}


// **** POSITIONING *****

function position_correct(moveObj, refObj, direction)
{
	if(moveObj.style.position != "absolute")
		return 

	while(position_overlap(moveObj, refObj))
	{
		/* if(! confirm("OK"))
			return 
			*/
		switch(direction)
		{
			case "up" :
				moveObj.style.top = parseInt(moveObj.style.top) - 1	
				break ;
			default:
				alert("direction param in\nhelpers.js\tposition_correct()\nnot yet implented!!")
				return ;
			
		}	
		
	}
	
	
	
	
}

function position_overlap(o1, o2)
{
	var o1t = safePos(o1, "top")
	var o1l = safePos(o1, "left")
	

	var o2t = safePos(o2, "top")
	var o2l = safePos(o2, "left")

	if(o1t <= o2t + o2.clientHeight && o1t + o1.clientHeight > o2t)
		return true

	return false
}


// SAFE QUERY

function safePath2URL(pth)
{
	var arRep = new Array("+", ",", "!", ":", "?", "(", ")", "[", "]", "+", "&", "ü", "ö", "ä", "Ü", "Ö", "Ä", "é", "è", "ê", "á", "à", "â", "ë")
	var opth = pth
	for(var i = 0; i < arRep.length ; i++)
	{
		//alert(arRep[i].charCodeAt(0));
		pth = pth.replace(eval("/[" + arRep[i] + "]/g"), "@@@"+arRep[i].charCodeAt(0)+"@@@" )
	}
	//pth = pth.replace(/[+]/g, "@@@43@@@" )
	return pth
	//alert(pth) ;
	if(opth != pth)
		alert(pth + "\n" + opth)
	return pth
}
function safePath2URL_Reverse(pth)
{
	for(var i = 1; i < 256 ; i++)
	{
		pth = pth.replace(eval("/@@@" + i + "@@@/g"), String.fromCharCode(i) )
	}
	return pth
}


//window.onerror = errDisplay

function errDisplay(msg, file, ln)
{
	alert("HO")	
	
  alert("Error:\t" + msg + "\nFile:\t" + file + "\nLine:\t" + ln)
  return true;
}

//crunchy()
	
	


