var xPos = 0, yPos = 0, goPos = 0, loadDelay = false, pageInit = false;
var showTabRowDelay, tooltipFlag, xPosOffset, yPosOffset;
var nextImgData, prevImgData;

if(top.frames.length > 0 && self.name!="fileMngPreview" && self.name!="specProjFrame"){top.location.href=self.location;}

// -----------------------------------------------------------------------------

var preloadImages = new Array(); var j=0;
preloadImages[j] = "../pix/hlpBg.gif"; j++;
preloadImages[j] = "../pix/hlpClose.gif"; j++;
preloadImages[j] = "../pix/hlpDown.gif"; j++;
preloadImages[j] = "../pix/hlpLR.gif"; j++;
preloadImages[j] = "../pix/hlpReturn.gif"; j++;
preloadImages[j] = "../pix/hlpShadB.gif"; j++;
preloadImages[j] = "../pix/hlpShadBL.gif"; j++;
preloadImages[j] = "../pix/hlpShadBR.gif"; j++;
preloadImages[j] = "../pix/hlpShadR.gif"; j++;
preloadImages[j] = "../pix/hlpShadTR.gif"; j++;
preloadImages[j] = "../pix/hlpSpace.gif"; j++;
preloadImages[j] = "../pix/hlpUp.gif"; j++;

// ---------------------------------- Projekt ----------------------------------

function initAll(){
	// ggf. Weiterleiten bei Direkt-Aufruf der Seite nach einem Ajax-Caching
	if(!previewCache[0]){
		var dUrl = window.location.href;
		var urlBase = dUrl.replace(/#.+/gi,"")	
		var urlChk = dUrl.search(/#image\d+$/);
		if(urlChk != -1) {
			var x = dUrl.substring(urlChk+6,dUrl.length);
			if(x>0) {
				if(dUrl.search(/\?/) == -1) urlBase = document.getElementById("previewNextImgLink").href;
				location.replace(urlBase.replace(/img=(\d+),(\d+),(\d+)/i, "img=$1," + x + ",$3"));
				document.getElementById("previewImg").src = "pix/image.gif";
			}
		}
	}
	// ggf. Hintergrund-Style aus Cookie restaurieren
	resetBgFromCookie()
	// Initialisierung Gallery + ImgInfo
	var dC = document.getElementById("container").className;
	var chkGallery = getCookie("galleryCss"); 
	if(dC=="image" && chkGallery!="") setClassName("container", chkGallery);
	if(dC=="gallery"){ galleryFlag = 1; setCookie("galleryCss","gallery",1); }
	if(chkGallery=="gallery") galleryFlag = 1;
	var chkImgInfo = getCookie("imgInfoCss"); 
	if(document.getElementById("imgArea") && chkImgInfo!="") setClassName("imgArea", chkImgInfo);
	if(chkImgInfo=="showInfo") imgInfoFlag = 1;
	// ggf. kurze Seiten verlaengern
	if(document.getElementById('mainNaviArea')){
		var dN = document.getElementById('mainNaviArea').offsetHeight; 
		var dC = document.getElementById('mainContWrapper').offsetHeight;
		var xh = 20 + dN - dC;
		if(xh>0) document.getElementById('flexBottom').style.paddingTop = xh + "px";
	}
	// checkScrollPos
	if(window.name.indexOf('pos')!=-1){
		window.scrollBy(0,parseInt(window.name.slice(3)));
		window.name='cont';
	}
	// ggf. cooliris-Link
	if(PicLensLite.hasCooliris()){
		var nLi = document.createElement("li");
		nLi.innerHTML = "<a class='aTT' href='javascript:void(0);' title='Galerie in der Cooliris Wall zeigen...' onClick='javascript:if(!stopAutoControl()){ PicLensLite.DEBUG_NOCLIENT=false; PicLensLite.start();}'>Cooliris-Wall</a>..."
		document.getElementById('galleryUl').appendChild(nLi);
	}
	// DOM-Events
	initDomEvents();
	pageInit = true;
	
	
	// Bilder vorladen
	for (i=0; i < preloadImages.length; i++) { var b = new Image(); b.src = preloadImages[i];	}
}

function exitAll(){
	
}

// ------------------------------ Ajax-Caching --------------------------------

window.setInterval("chkUrl()", 250);

function chkUrl(){
	var dUrl = window.location.href;
	if(dUrl.search(/#image\d+$/)==-1 || (!previewCache[0])) return true;
	var x = dUrl.substring(dUrl.search(/#image\d+$/)+6,dUrl.length);
	// document.getElementById("helpLnk").innerHTML = x + ":" + previewCache[0] + ":" + window.location.hash;
	if(previewCache[0] && previewCache[0]!=x && previewCache[x]!=""){
		execJsFromTxt(previewCache[x]);
		document.getElementById("previewWrapper").innerHTML = previewCache[x];
		initDomEvents();
		previewCache[0] = previewImgID;
		stopAutoControl();
	}
}

// --------------------------------- DOM-Events -------------------------------

function initDomEvents(){
	// Tooltip
	execFctByClassName("aTT",function(o){
		o.onmouseover = showTTByEvent;
		o.onmouseout = hideTT;
	})
	// Formulare schalten Tasten-Handling aus...
	keyHandlerSwitchEvent("input");
	keyHandlerSwitchEvent("textarea");
	keyHandlerSwitchEvent("select");
}

function keyHandlerSwitchEvent(tagName){
	execFctByTagName(tagName,function(o){
		if(typeof o.onfocus!="function") o.onfocus = switchKeyHandlerOff;
		if(typeof o.onblur!="function") o.onblur = switchKeyHandlerOn;
	})	
}

function showTTByEvent(e){ showTT(this,""); }


// ---------------------------------- Events ----------------------------------

document.onmousedown = onMouseDownEvent;
document.onmouseup = onMouseUpEvent;
document.onmousemove = setShowDivPos;

function onMouseDownEvent(e){
	getPos(e);
}

function onMouseUpEvent(e){
	stopAutoControl()
}

function getPos(e){
	if(document.all){
		xPos = (document.compatMode=='CSS1Compat') ? window.event.clientX + document.documentElement.scrollLeft : window.event.clientX + document.body.scrollLeft;
		yPos = (document.compatMode=='CSS1Compat') ? window.event.clientY + document.documentElement.scrollTop : window.event.clientY + document.body.scrollTop;
	}else{	/* pageXY = Fensterrelativ / screenXY = Bildschirmabsolut */
		xPos = e.pageX;
		yPos = e.pageY;
	}
	// document.body.scrollTop fuer nicht Standardkonforme Seiten
	goPos = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : window.pageYOffset;
	if(goPos==null) goPos=0;
}

function clPos(){window.name="pos" + goPos;}

function setShowDivPos(e){
if(pageInit && tooltipFlag){
	getPos(e);
	var sD = document.getElementById("tooltipDiv");
	sD.style.right = "auto";
	sD.style.left = (xPos + xPosOffset) + "px";
	sD.style.top = (yPos + yPosOffset) + "px";
	var innerW = (document.all) ? document.documentElement.clientWidht : window.innerWidth;
	if((xPos + xPosOffset + 200) > innerW && innerW > 300){
		sD.style.left = "auto";
		sD.style.right = (innerW - xPos) + "px";
	}
}}

// ----------------------------- Tasten-Handling ------------------------------

var keyStrgFlag, useKeyHandlerFlag = true;

document.onkeydown = keyDownHandler;
document.onkeyup = keyUpHandler;

// Formulare schalten Tasten-Handling aus...
function switchKeyHandlerOn(){ useKeyHandlerFlag = true; }
function switchKeyHandlerOff(){ useKeyHandlerFlag = false; }

// Tasten-Handling
function keyDownHandler(e){
	if(!document.getElementById("galleryArea")) return true;
	if(!useKeyHandlerFlag) return true;
  var k = "";
  if(!e) e = window.event;
  if(e.which){
    k = e.which;
  } else if (e.keyCode) {
    k = e.keyCode;
  }
  if(cOverlay && k!=32)	closeOverlay();	// ggf. Overlay schliessen
  switch(k){
  	case "" : break;
  	case 13 : 	// Return: Bildinfos
		if(imgInfoFlag==1) imgInfoFade('hideInfo');
  		if(imgInfoFlag==0) imgInfoFade('showInfo');
  		break;
  	case 17 : 	// Strg
  		keyStrgFlag = true; break;
	case 37 : 	// Pfeiltasten links
  		if(prevImgData) chgPreview(prevImgData); break;
  	case 38 : 	// Pfeiltaste hoch: Diashow
		if(!stopAutoControl()){
			setAutoControl(3);
			getNewPreview(nextImgData);
		}
		break;
  	case 39 : 	// Pfeiltasten rechts
  		if(nextImgData) chgPreview(nextImgData); break;
  	case 40 : 	// Pfeiltaste runter: Gallerie
  		if(galleryFlag==1) galleryFade('image');
  		if(galleryFlag==0) galleryFade('gallery');
  		break;
  	case 32 : 	// Leertaste: Uebersicht
  		if(cOverlay){
  			closeOverlay()
  		}else{
			stopAutoControl();
  			showGroupOverlay();
  		}
  		break;
  	default : 	// alert(k); 
  		break;
  }
}

function keyUpHandler(e){
	if(!document.getElementById("galleryArea")) return true;
  var k = "";
  if(!e) e = window.event;
  if(e.which){
    k = e.which;
  } else if (e.keyCode) {
    k = e.keyCode;
  }
  switch(k){
  	case "" : break;
  	case 17 : 	// Strg
  		keyStrgFlag = false; break;
  	default : 	// alert(k); 
  		break;
  }	
}

// --------------------------------- Standard ---------------------------------

function topInfo(cont,target,w,h)
{var topInf = window.open(cont,target,'width='+w+',height='+h+',dependent=yes,resizable=yes,scrollbars=yes,menubar=yes,status=yes'); topInf.focus(); return false;}

function setClassName(x,y){
	document.getElementById(x).className = y;
}

function hideTooltip(){
	clearTimeout(showTabRowDelay);
	document.getElementById("tooltipDiv").style.display = "none";
	tooltipFlag = false;
}

function uncoverTooltip(){
	document.getElementById("tooltipDiv").style.display = "block";
}

// ------------------------------------ Skin ----------------------------------

function toggleBg(cObj, cStyle){
	var newStyle = (cStyle == "ws") ? "sw" : "ws";
	styleSwitch("bg", cStyle, newStyle);
	// Anzeige Toogle-Tool
	cObj.className = newStyle;
}

function resetBgFromCookie(){
	var newStyle = getCookie("bgStyleCss");
	if(!document.getElementById("toggleBgTool")) return true;
	var tTool = document.getElementById("toggleBgTool");
	var cStyle = tTool.className;
	if(newStyle!="" && newStyle!=cStyle) {
		styleSwitch("bg", cStyle, newStyle);
		tTool.className = newStyle;
	}
}

// Styles umschalten
function styleSwitch(switchName, cStyle, newStyle){
	var cCssLnk = document.getElementById("cssLnk_" + cStyle);
	var nCssLnk = document.getElementById("cssLnk_" + newStyle);
	// umschalten
	nCssLnk.rel = "stylesheet"; 
	nCssLnk.disabled = false;
	cCssLnk.rel = "alternate stylesheet"; 
	cCssLnk.disabled = true;
	// Zustand merken
	setCookie(switchName + "StyleCss",newStyle,60);
	sendStatus("setCssStatus", newStyle);
}


// ----------------------------------- Tooltip --------------------------------

var cTTObj, cTitle

function showTT(obj,x){
	if(x!="") var ttNode = document.getElementById(x).firstChild;
	var ttTxt; 
	ttNode ? ttTxt = ttNode.nodeValue : ttTxt = obj.title;
	
	cTTObj = obj; cTitle = obj.title; obj.title = ""; 
	var sD = document.getElementById("tooltipDiv");
	var sDf = sD.firstChild;
	while (sDf!=null){
		sD.removeChild(sDf); 
		sDf = sD.firstChild;}
	if(ttTxt!=null && ttTxt!=""){
		var newEntry = document.createTextNode(ttTxt);
		sD.appendChild(newEntry);
		tooltipFlag = true; xPosOffset = 15; yPosOffset = 20;
		showTabRowDelay = setTimeout("uncoverTooltip()",500);}
}

function hideTT(){
	if(cTTObj!=null) {cTTObj.title = cTitle; cTTObj = null; cTitle = "";}
	hideTooltip(); 
}

function showTabRow(xy){ 
	clearTimeout(showTabRowDelay);
	var sD = document.getElementById("tooltipDiv");
	var sDf = sD.firstChild;
	var xNode = xy.firstChild;
	while (sDf!=null){
		sD.removeChild(sDf);
		sDf = sD.firstChild;}
	var counter = 0; 
	while (xNode!=null){
		if(xNode.nodeType==1 && xNode.childNodes[0].nodeValue!=null){
			counter+=1; 
			var xNV = xNode.childNodes[0].nodeValue
			var newEntry = document.createTextNode(counter + ": " + xNV);
			var newBr = document.createElement("br");
			// ggf. Bild einfuegen
			xNV = xNV.replace(/\s/,"");
			if(xNV.search(/.jpg$/) != -1 || xNV.search(/.jpeg$/) != -1){
				xNV = xNV.replace(/^images\//,"");
				var newImg = document.createElement("img");
			var newImgAlt = document.createAttribute("class");
			newImgAlt.nodeValue = "showTabRowImgPreview";
			newImg.setAttributeNode(newImgAlt);
			var newImgSrc = document.createAttribute("src");
			newImgSrc.nodeValue = "images/minSize/" + xNV;
			newImg.setAttributeNode(newImgSrc);
			sD.appendChild(newImg);
			}
			sD.appendChild(newEntry);
			sD.appendChild(newBr); 
		}
		xNode = xNode.nextSibling; }
	/* var x = 0, p = 40;
		if(document.all){p = p + document.body.scrollTop;}
		else if(document.getElementById){p = p + window.pageYOffset;}
		if(p<80) p = 80; 
		sD.style.top = p + "px";
		sD.style.right = "20px"; */
	tooltipFlag = true; xPosOffset = 50; yPosOffset = -60;
	showTabRowDelay = setTimeout("uncoverTooltip()",500);
}

function hideTabRowShowDiv(){
	hideTooltip();
}

// ----------------------------------- Hilfe ----------------------------------

var hlpFlag, showHlpAutoObj;

function showHlpAuto(){
	if(navigator.cookieEnabled && hlpFlag != true){
		if(getCookie("showHelp")!="1"){
			window.clearTimeout(showHlpAutoObj);
			showHlpAutoObj = window.setTimeout("showHlp()",2500);
		}
	}
}

function showHlp(){
	var t = (document.all) ? "help" : "helpArea";
	if(!hlpFlag){
		var f = new fadeObj(t,"none",function(obj){});
		f.fade(1,99.99,5,10,function(obj){
			hlpFlag = true;
		});
	}
	document.getElementById("helpArea").style.display = "block";
}

function hideHlp(){
	flyObj("helpArea","help","helpLnk",36, 20, 0, 0, 0, 30, "10px");
	document.getElementById("helpArea").style.display = "none";
	hlpFlag = false;
	setCookie("showHelp","1",60);
}

// ---------------------------------- Fading ----------------------------------

var imgInfoFlag = 0, galleryFlag = 0, fadeObjArr = new Array();

// imgInfo einblenden
function imgInfoFade(targetClass, endFct){
	if(arguments.length<2) endFct = function(){};
	if(!document.getElementById("imgArea")) return true;
	if(document.getElementById("imgArea").className == targetClass){
		endFct();
		return true;
	}
	imgInfoFlag = -1;
	fadeObjArr["imgInfoWrapper"] = new fadeObj("imgInfoWrapper","none",function(obj){});
	fadeObjArr["imgInfoWrapper"].endFct = endFct;
	if(targetClass=="showInfo"){
		fadeObjArr["imgInfoWrapper"].fade(1,99.99,7,2,function(obj){
			imgInfoFlag = 1;
			sendStatus("setImgInfoStatus", 1);
			showHlpAuto();
			fadeObjArr["imgInfoWrapper"].endFct();
		});
		setClassName("imgArea", targetClass)
	}else{
		fadeObjArr["imgInfoWrapper"].fade(99.99,1,-7,2,function(obj){
			setClassName("imgArea", targetClass)
			imgInfoFlag = 0;
			sendStatus("setImgInfoStatus", 0);
			fadeObjArr["imgInfoWrapper"].endFct();
		});
	}
	setCookie("imgInfoCss",targetClass,1);
}

// ggf. Gallerie einblenden bei Klick auf Std.-Navigation "Bilder"
function checkGallery(){
	var d = document.getElementById("container").className;
	if(d=="gallery") return false;
	if(d=="image"){ galleryFade('gallery'); return false;	}
	return true;
}

// Gallerie einblenden
function galleryFade(targetClass){
	galleryFlag = -1
	var foa = fadeObjArr, g = "galleryArea", c = "container";
	if(typeof foa[g] != "object") foa[g] = new fadeObj(g,"none");
	if(typeof foa[c] != "object")	foa[c] = new fadeObj(c,targetClass);
	if(targetClass=="gallery"){
		document.getElementById(g).style.display = "none";
		foa[c].proportionAndSetClass(targetClass,1,3,1,function(obj,targetClass){
			fadeObjArr["galleryArea"].fade(1,100,6,2,function(obj){
				obj.stl.opacity = '1'; 
				obj.stl.filter = 'alpha(opacity:99.999)';
				galleryFlag = 1;
				sendStatus("setGalleryStatus", 1);
				showHlpAuto()
			});
		 	document.getElementById(g).style.display = "block";
		});
	}else{
		foa[g].fade(100,1,-8,2,function(obj){
			document.getElementById(g).style.display = "none";
			fadeObjArr["container"].proportionAndSetClass(targetClass,1,3,1,function(obj,targetClass){
				galleryFlag = 0;
				sendStatus("setGalleryStatus", 0);
			});
		});
	}
	setCookie("galleryCss",targetClass,1);
}

function sendStatus(target,x){
	var sendUrl = target + ".asp?value=" + x;
	var con = new getHiddenConn();
	if(!con) return false;
	con.onreadystatechange = function(){}
	con.open("GET", document.getElementsByTagName("base")[0].getAttribute("href") + sendUrl, true);
	con.send(null);
}

// einfaches ein- und ausblenden
function simpleFadeById(cID, cStart, cEnd, cStep, cSpeed, cbFct){
	if(arguments.length<6) cbFct = function(obj){};
	fadeFct({
		obj:document.getElementById(cID),
		stl:document.getElementById(cID).style,
		cOpacity:1,
		fadeCallBackFct:function(){cbFct(fadeObjArr[cID])}
	}, cStart, cEnd, cStep, cSpeed);
}

// x = Element-ID; y = Ziel-CSS-Klasse
function fadeObj(x,y){
		this.emH = document.getElementById("emHeightHlp").offsetHeight;
		this.obj = document.getElementById(x);
		this.stl = this.obj.style;
		this.classData = new Array();
		this.initClass = function(a,b){
			if(typeof this.classData[b] != "object"){
				this.classData[b] = new initClassFct(a,b,this);
		}};
		// nClass=Ziel-CSS-Klasse; 
		// wStep=Schrittbreite(Pixel/Std=1); 
		// wRaise=Anstieg der Schrittbreite(Pixel/Std:0);
		// proportionTimeout=Schrittdauer(ms)
		this.proportionAndSetClass = function(nClass,wStep,wRaise,proportionTimeout, cbFct){
			this.proportionCallBackFct = function(){cbFct(this,nClass)};
			this.initClass(x,nClass);
			if(this.emH != document.getElementById("emHeightHlp").offsetHeight){
				setClassName(x,nClass);
				this.setEmW(this.classData[nClass].w);
				this.proportionCallBackFct();
			}else{
				this.setEmW(this.classData[this.obj.className].w);
				this.obj.className = nClass;
				this.proportion(this,nClass,wStep,wRaise,proportionTimeout);
			}
		};
		this.cOpacity = 1;
		this.fade = function(cStart, cEnd, cStep, cSpeed, cbFct){
			this.fadeCallBackFct = function(){cbFct(this)};
			fadeFct(this, cStart, cEnd, cStep, cSpeed);
		};
		this.proportion = function(xObj,nClass,wStep,wRaise,proportionTimeout){
			var cw = xObj.obj.offsetWidth, ch = xObj.obj.offsetHeight;
			var tw = xObj.classData[nClass].w, th = xObj.classData[nClass].h;
			// alert(cw + ":" + tw);
			if(tw<cw){
				var w = Math.round(cw-wStep); if (w<=tw) w = tw;
			}else{
				var w = Math.round(cw+wStep); if (w>=tw) w = tw;
			}
			xObj.setEmW(w)
			if(w==tw){
				xObj.proportionCallBackFct();
			}else{
				wStep = (wRaise<0) ? wStep * wStep : wStep + wRaise;
				window.setTimeout(function(){xObj.proportion(xObj,nClass,wStep,wRaise,proportionTimeout)}, proportionTimeout);
			}
		};
		this.setEmW = function(w){
			this.stl.width = Math.round(w/this.emH*40000)/10000 + 'em';
		};
		this.setPxW = function(w){
			this.stl.width = w + 'px';
		};
		this.initClass(x,this.obj.className);
		this.initClass(x,y);
}

function initClassFct(x,y,parent){
	var cClassName = parent.obj.className;
	parent.stl.visibility = "hidden";
	parent.obj.className = y;
	this.name = y;
	this.h = parent.obj.offsetHeight;
	this.w = parent.obj.offsetWidth;
	parent.obj.className = cClassName;
	parent.stl.visibility = "visible";
}

// Achtung! Bug bei opacity = 100 in einigen Browsern. Deshalb Maximal-Wert = 99.999
function fadeFct(obj, cStart, cEnd, cStep, cSpeed){
	var speedX = 0, hlp = 1; 
	if(cStep<0){ speedX = 3; hlp=-1};
	if((hlp * cStart) < (hlp * cEnd)){
		if(cStart < 1) cStart = 1;
		obj.stl.opacity = cStart/100;
		obj.stl.filter = 'alpha(opacity:' + cStart + ')';
		obj.cOpacity = cStart
		setTimeout(function(){fadeFct(obj, (cStart + cStep), cEnd, cStep, (cSpeed + speedX))}, cSpeed);
	}else{
		obj.fadeCallBackFct();
	}
	if(obj.cOpacity <= 1 + Math.abs(cStep)){obj.cOpacity=1; obj.stl.opacity = '0'; obj.stl.filter = 'alpha(opacity:0)';}
}


// -------------------------------- Schnellkontakt ---------------------------- //

function cFocus(x,txt){
x.className = x.className.replace(/On/, "") + "On";
if(x.value==txt)x.value = "";
}

function cBlur(x,txt){
if(x.value==""){
	x.value = txt; 
	x.className = x.className.replace(/On/, "");
	}
}

function checkCallback(){
var cN = document.callbackForm.callbackName.value;
var cT = document.callbackForm.callbackNumb.value;
if(cN == "" || cT == "" || cN == "Ihr Name" || cT == "Telefon-Nummer")
{alert("Bitte geben Sie Name und Telefon-Nummer ein"); return false;} else {return true;}
}

// -------------------------------- flying Objects ----------------------------

var foObj;

function flyingGadget(o){
	flyObj("imgInfoImg", "imgInfoImg", "userColLnk", 26, 20, 5, 5, -30, 20, "11px");
	window.setTimeout("setUserColLnkInfo()",500); 
	window.setTimeout(function(){ window.location.href = o.href }, 1000);
	return false;
}

function setUserColLnkInfo(){
	var d = document.getElementById('userColLnk');
	d.style.background = "url(pix/userColWait.gif) no-repeat left center";
	d.innerHTML = 'Bildauswahl aktualisieren...';
}

function flyObj(sourceDiv, flyerDivClass, targetPosDiv, steps, stepTime, topOffset, topOffsetIE, endXOffset, endTopOffset, startFontSize){
	var al = arguments.length;
	if(al<6) topOffset = 0;
	if(al<7) topOffsetIE = 0;
	if(al<8) endXOffset = 0;
	if(al<9) endTopOffset = 0;
	if(al<10) startFontSize = "10px";
	var tOffset = (document.all) ? topOffsetIE : topOffset;
	// Objekte auswerten	
	var flyer = document.getElementById("flyingDiv");
	var startDiv = document.getElementById(sourceDiv);
	var startPt = getObjPosById(startDiv);
	var endPt = getObjPosById(document.getElementById(targetPosDiv));
	var endX = endPt.left + endXOffset;
	var endT = endPt.top + endTopOffset + tOffset;
	// Flyer bauen
	flyer.innerHTML = startDiv.innerHTML;
	flyer.className = flyerDivClass;
	with(flyer.style){
		fontSize = startFontSize;
		top = startPt.top + tOffset + "px";
		left = startPt.left + "px";
		height = startDiv.offsetHeight + "px";
		// width = startDiv.offsetWidth + "px";
		overflow = "hidden";
		display = "block";
	}
	// Select-Felder fuer IE ausblenden
	if(document.all){ 
		ds = document.getElementsByTagName("select");
		for(var i = 0; i < ds.length; i++){ ds[i].style.visibility = "hidden"; }
   }
	// Fly-Out
	foObj = new flyOutObj(flyer,steps,stepTime,endX,endT);
	foObj.flyOut();
	return true;
}

function flyOutFoObj(){
	if(typeof foObj == "object") foObj.flyOut();
}

function flyOutObj(obj,steps,stepTime,x,t){
	var os = obj.style;
	this.flyOut = function(){
		var xCurve = -10, tCurve = 4, out = "";
		if(steps<=1){
			// Select-Felder fuer IE ausblenden
			if(document.all){ 
				ds = document.getElementsByTagName("select");
				for(var i = 0; i < ds.length; i++){ ds[i].style.visibility = "visible"; }
   		}
			os.display = "none";
			foObj = null;
		} else {
			var hlp = os.left; hlp = hlp.replace(/px/,""); hlp = Math.round(hlp);
			os.left = Math.round(hlp + (((x-hlp)/steps)/(steps/6)) + xCurve) + "px";
			
			var hlp = os.top; hlp = hlp.replace(/px/,""); hlp = Math.round(hlp);
			var hlpH = os.height; hlpH = hlpH.replace(/px/,""); hlpH = Math.round(hlpH/2);
			os.top = Math.round(hlp + ((((t-hlpH)-hlp)/steps)/(steps/6)) - tCurve) + "px";
			
			// var hlp = os.width; hlp = hlp.replace(/px/,""); hlp = Math.round(hlp);
			// os.width = Math.round(hlp-((hlp/steps)/(steps/3))) + "px";
			
			var hlp = os.height; hlp = hlp.replace(/px/,""); hlp = Math.round(hlp);
			os.height = Math.round(hlp-((hlp/steps)/(steps/3))) + "px";
			
			var hlp = os.fontSize; hlp = hlp.replace(/px/,""); hlp = Math.round(hlp);
			if (hlp>0) os.fontSize = Math.round(hlp-((hlp/steps)/(steps/4))) + "px";
			
			steps--;
			window.setTimeout("flyOutFoObj();", stepTime);
		}		
	}
}

// -------------------------------- pageOverlay -------------------------------

var cOverlay, overlayFlag = 0, overlaySortMode = false;

function showGroupOverlay(){
	if(!document.getElementById('galleryImages')) return false;
	// Uebersicht-Daten vorbereiten
	var c = document.getElementById('galleryImages').innerHTML;
	c = "<div id=ovGalleryImages>" + c + "</div>"
	c = c.replace(/ id="imgBox/gi, "id=" + unescape("%22") + "ovImgBox")		// "
	c = c.replace(/ id="imgBoxWrapper/gi, "id=" + unescape("%22") + "ovImgBoxWrapper")	// "
	c = c.replace(/images\/minSize\//gi, "images/medSize/")
	// Uebersicht anzeigen
	getOverlay(c, 'galleryOverlay');
	// ggf. Erweiterung fuer Sortierung
	if(typeof showGroupOverlayForOrder == "function") showGroupOverlayForOrder();
}

function getOverlay(overlayHTML, stlyeClass, useMaxH, overlayCloseHTML){
	if(arguments.length<1) overlayHTML = "";
	if(arguments.length<2) stlyeClass = "";
   if(arguments.length<3) useMaxH = true;
   if(arguments.length==4)
		cOverlay = new overlayObj(overlayHTML, stlyeClass, useMaxH, overlayCloseHTML);
	else
		cOverlay = new overlayObj(overlayHTML, stlyeClass, useMaxH);
	return cOverlay;
}

function overlayObj(overlayHTML, stlyeClass, useMaxH, overlayCloseHTML){
   if(arguments.length<1) overlayHTML = "";
   if(arguments.length<2) stlyeClass = "";
   if(arguments.length<3) useMaxH = true;
   if(arguments.length==4) document.getElementById("pageOverlayClose").innerHTML = overlayCloseHTML;
   var b = document.getElementsByTagName("body")[0];
   var c = document.getElementById("specWrapper");
   var d = document.getElementById("pageOverlay");
   var e = document.getElementById("pageOverlayCont");
   var tH = (document.getElementById("specNavi")) ? document.getElementById("specNavi").offsetHeight : 0;
   var x = document.getElementById("pageOverlayBody");
   // Inhalte
   if(overlayHTML!="") x.innerHTML = overlayHTML;
   // Hoehe Gesamtseite
   var innerH = (document.all) ? document.documentElement.clientHeight : window.innerHeight;
   if(tH>0) innerH-=tH; 
   var bH = (c.offsetHeight > b.offsetHeight) ? c.offsetHeight +20 : b.offsetHeight +20;
   if(innerH > bH) bH = innerH;
   d.style.height = bH + "px";
   // Hoehe OverlayBody
   if(innerH>0 && useMaxH) x.style.height = Math.round(innerH*0.85) + "px";
   // CSS-Klasse
   if(stlyeClass!="") document.getElementById("pageOverlayBodyWrapper").className = stlyeClass;
	// Select-Felder fuer IE ausblenden
	if(document.all){ 
		ds = document.getElementsByTagName("select");
		for(var i = 0; i < ds.length; i++){ ds[i].style.visibility = "hidden"; }
   }   // anzeigen

	d.style.opacity = ".9";
	d.style.filter = "alpha(opacity:90)";
   d.style.display = "block";
   // simpleFadeById("pageOverlay",0,90,90,5,function(o){
   	document.getElementById("pageOverlayCont").style.display = "block";
   	initDomEvents();
   	overlayFlag = 1;
   // });
}

function closeOverlay(){
	if(!cOverlay) return true;
	if(overlaySortMode){
		if(!confirm("Die neue Sortierung geht verloren, wenn die Übersicht geschlossen wird. \n\nSoll die neue Sortierung verworfen werden?")) return true;
	}
   document.getElementById("pageOverlayCont").style.display = "none";
   // simpleFadeById("pageOverlay",90,1,-22,5,function(o){
		document.getElementById("pageOverlay").style.display = "none";
		if(document.all){ 
			ds = document.getElementsByTagName("select");
			for(var i = 0; i < ds.length; i++){ ds[i].style.visibility = "visible"; }
   	}
		if(typeof cOverlay.closeOverlayEvent == "function") cOverlay.closeOverlayEvent();
		cOverlay = undefined;
		overlayFlag = 0;
		showHlpAuto()
   // });
}

// ------------------------------- Inhalte ersetzen ---------------------------

var previewCache = new Array();
// previewImgID wird in Preview mitgeliefert...

function chgPreview(newPrevData){
	stopAutoControl();
	getNewPreview(newPrevData);
}

function getNewPreview(newPrevData){
	if(typeof newPrevData != "object") return false;
	cHref = newPrevData.href.replace(/&amp;/gi,"&");
	cImgHref = newPrevData.imgHref;
	cTargetID = "previewWrapper";
	// Tooltip ausblenden (wichtig fuer Cache!)
	hideTT();
	// Url anpassen + aktuelle Preview cachen
	var cUrl = window.location.href;
	// window.location.href = cUrl.replace(/#.+/gi,"") + "#image" + previewImgID;
	window.location.hash = "image" + previewImgID;
	previewCache[previewImgID] = document.getElementById(cTargetID).innerHTML;
	// Warte-Anzeige (erst nach dem Cachen!)
	waitGimmick();
	// Verbindung herstellen + ggf. Bild laden
	var con = new getHiddenConn();
	if(!con){window.location.href = cHref; return false;}
	if(cImgHref!=""){
		con.onreadystatechange = function(){ 
			if(con.readyState != 4) return false; 
			if(con.status != 200) window.location.href = cHref;
			loadPreviewHtml(cHref, cTargetID);
		}
		con.open("GET", document.getElementsByTagName("base")[0].getAttribute("href") + cImgHref, true);
		con.send(null);
	}else{
		loadPreviewHtml(cHref, cTargetID);
	}
}

function loadPreviewHtml(cHref, cTargetID){
	var con = new getHiddenConn();
	if(!con){window.location.href = cHref; return false;}
	con.onreadystatechange = function(){
		if(con.readyState != 4) return false; 
		if(con.status != 200) window.location.href = cHref;
		var cData = con.responseText;
		if(cData!="")
			writeResponseAsNewPreview(cData, cHref, cTargetID); 
		else
			window.location.href = cHref;
	}
	var qHlp = (cHref.search(/\?/) != -1) ? "&" : "?";
	con.open("GET", cHref + qHlp + "extractData=preview", true);
	con.send(null);
}

/* Serverdaten auswerten */
function writeResponseAsNewPreview(cData,cHref,cTargetID){
	if(cData=="") return false;
	// ggf. Daten auswerten per Response-Event-Fkt + mitgeliefertes JS ausfuehren
	if(typeof newPreviewResponseEvent == "function") cData = newPreviewResponseEvent(cData);
	execJsFromTxt(cData);
	// Daten uebernehmen; DOM-Events setzen
	document.getElementById(cTargetID).innerHTML = cData;
	initDomEvents();
	// ggf. Bild-Info einblenden
	var chkImgInfo = getCookie("imgInfoCss"); 
	if(document.getElementById("imgArea") && chkImgInfo!="") setClassName("imgArea", chkImgInfo);
	// Cache-Info setzen; ggf. Diashow starten
	previewCache[0] = previewImgID;
	if(autoCTime > 0) setAutoControl(autoCTime);
	// Url anpassen + aktuelle Preview cachen
	var cUrl = window.location.href;
	// window.location.href = cUrl.replace(/#.+/gi,"") + "#image" + previewImgID;	
	window.location.hash = "image" + previewImgID;
	previewCache[previewImgID] = cData;
	// Ladeanzeige + Ready-Event-Fkt
	// document.getElementById("imgPreviewLoadWaiting").style.display = "none";
	if(typeof newPreviewReadyEvent == "function") newPreviewReadyEvent();
	// ggf. Analytics-Tracker aufrufen
	if(typeof urchinTracker == "function") urchinTracker(cHref.replace(trackerBaseUrl,""));
}

/* liefert XMLHttpReq-Objekt */
function getHiddenConn(){
	if(navigator.appVersion.indexOf("IE 5.5")>0) return false;
	try{ var hc = new XMLHttpRequest();												// Firefox
		}catch(eX){ try{ hc = new ActiveXObject("Msxml2.XMLHTTP");			// IE 1
			}catch(eY){ try{ hc = new ActiveXObject("Microsoft.XMLHTTP");	// IE 2
				}catch(eZ){ hc = false; }}}
	return hc;
}

function waitGimmick(){
	execFctByClassName("wait",function(o){
		o.innerHTML = "<div><img src='pix/wait.gif'></div>";
	})
}

// -------------------------------- AutoControl -------------------------------

var autoCTime, nPage;

function setAutoControl(ct){
	window.clearTimeout(nPage);
	if(ct!="" && ct>0){
		autoCTime = ct;
		document.getElementById("autoControlImg").src = "pix/stop.gif";
		nPage = window.setTimeout("reloadPage();", ct * 1000);
	}else{
		autoCTime = 0;
	}
}

function reloadPage(){
	window.clearTimeout(nPage);
	if(overlayFlag != 0) nPage = window.setTimeout("reloadPage();", autoCTime * 1000);
	if(overlayFlag == 0 && nextImgData) getNewPreview(nextImgData);
}

function startAutoControlFromOverlay(){
	setAutoControl(3);
	closeOverlay();
	getNewPreview(nextImgData);
}

function stopAutoControl(){
	if(!document.getElementById("galleryArea")) return true;
	if(!document.getElementById("autoControlImg")) return true;
	document.getElementById("autoControlImg").src = "pix/play.gif";
	if(autoCTime>0){
		setAutoControl(0);
		return true;
	}
	return false;
}

// ------------------------------- Kleine Helferlein --------------------------

// Funktion fuer Elemente mit einer bestimmten CSS-Klasse ausfuehren
function execFctByClassName(className,cFct){
	if(className == "" || typeof cFct != "function") return false;
	if(document.all)
		var ao = document.all;
  	else if(document.getElementsByTagName)
		var ao = document.getElementsByTagName("*");
	for(var i=0; i < ao.length; i++){
		if(ao[i].className.indexOf(className)!=-1) cFct(ao[i]);
	}
}

// Funktion fuer bestimmte Tags ausfuehren
function execFctByTagName(tagName,cFct){
	if(tagName == "" || typeof cFct != "function") return false;
	var ao = document.getElementsByTagName(tagName);
	for(var i=0; i < ao.length; i++){
		cFct(ao[i]);
	}
}

// JS in Txt ausfuehren
function execJsFromTxt(x){
	var scriptT = x.match(/<script[^>]*>[\s\S.]*?<\/script>/gi);
	if (scriptT)
		for (var i = 0; i < scriptT.length; ++i){
			var eScr = scriptT[i].replace(/<script[^>]*>/gi, "");
			eScr = eScr.replace(/<\/script>/gi, "");
			eval(eScr);
			//try{eval(eScr)}
			//	catch(e){alert("Hinweis: JavaScript-Funktionen nicht geladen...\n\n" + eScr )};
		}
}

// Cookies holen
function getCookie(x){
	var k = document.cookie.split(";");
	for (var i = 0; i < k.length; ++i){
		k[i] = k[i].replace(/\s/,"");
		if(x==k[i].substr(0,k[i].search('='))) return k[i].substr(k[i].search('=')+1,k[i].length);
	}
	return "";
}

function setCookie(xName,xValue,expDays){
	var d = new Date(); d = new Date(d.getTime() + (expDays * 24 * 60 * 60 * 1000));
	document.cookie = xName + "=" + xValue + "; expires=" + d.toGMTString(); 
}

function killCookie(xName){
	document.cookie = xName + "=; ; expires=Thu, 01-Jan-70 00:00:01 GMT;";
}

// Objekt-Position

function getObjPosById(o){
	var p = {left:0, top:0};
	if(typeof o != "object") return p;

	if(typeof o.offsetLeft != 'undefined'){
		while(o) {
			 p.left += o.offsetLeft;
			 p.top += o.offsetTop;
			 o = o.offsetParent;
		}
	} else {
		p.left = o.left ;
		p.top = o.top ;
	}
	return p;
}

