// Slideshow Image PopUp

function openDynamicImageWindow(file,w,h,typ,closeText) {
	if(typ == "dhtml") {
		if(document.all) {
			var windowWidth = self.document.body.clientWidth;
			var windowHeight = self.document.body.clientHeight;
			var scrolltop = document.body.scrollTop;
			var scrollleft = document.body.scrollLeft;
		} else {
			var windowWidth = self.innerWidth;
			var windowHeight = self.innerHeight;
			var scrolltop = document.documentElement.scrollTop;
			var scrollleft = document.documentElement.scrollLeft;
		}
		var postop =(windowHeight/2)-(h/ 2)+scrolltop+document.body.style.padding;
		var posleft =(windowWidth/2)-(w/ 2)+scrollleft+document.body.style.padding;
		var hh =(windowHeight)+500+scrolltop+document.body.style.padding;
		var ww =(windowWidth)+scrollleft+document.body.style.padding;
		//var hh='100%';
		//var ww = 1000;
		//alert(hh + "::" + ww);
		///// just testing:
		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();
			//// resizing ////
			var postop = arrayPageScroll[1] + (arrayPageSize[3] / 15);
			var hh = arrayPageSize[1];
			
		if(document.all) {
			if(postop >= 20) { postop = postop-20; }
		} else {
			if(postop >= 30) { postop = postop-30; }
		}
		var bodyObj = document.getElementsByTagName('BODY')[0];
		if(!document.getElementById("dynamicImageContainer")) {
			divObjContainer = document.createElement("div");
			divObjContainer.setAttribute("id", "dynamicImageContainer");
			bodyObj.appendChild(divObjContainer);
			//bodyObj.insertBefore(divObjContainer, bodyObj.firstChild);
		} else {
			divObjContainer = document.getElementById("dynamicImageContainer");
		}
		divObjContainer.style.display = "block";
		divObjContainer.innerHTML = "<div class=\"imageContainer\" style=\"top:"+postop+"px; left:"+posleft+"px; position: absolute; z-index:100000; display:block; \"><div class=\"imageBorder\" style=\"background-color: #fff; padding: 4px; border: solid 1px #ccc\"><img onclick=\"closeDynamicImageWindow();\" style=\"cursor:pointer;max-width:"+w+"px;border: solid 1px #000\" src=\""+file+"\" title=\"Zum Schliessen klicken\" alt=\""+closeText+"\" \/><\/div><br \/><div class=\"imageBorder\" style=\"background-color: #fff; padding: 4px; border: solid 1px #ccc;width:150px\">"+closeText+"<\/div><\/div><div onclick=\"closeDynamicImageWindow();\" style=\"width:"+ ww + "px;height:"+ hh + "px;position: absolute; z-index:1000;filter:alpha(opacity=75);-moz-opacity: 0.75;opacity: 0.75;left:0px;top:0px;;background-color:#795955;\"><\/div>";
	} else if(typ == "javascript") {
		// center popup
		var postop =(screen.height /2)-(h/ 2);
		var posleft =(screen.width /2)-(w/ 2);
		window.open(file+'&closeText='+encodeURI(closeText)+'', '', 'dependent=yes,width='+w+',height='+h+',left='+posleft+',top='+postop+',scrollbars=no,resizable=no,menubar=no,location=no,status=no');
	}
}
function closeDynamicImageWindow() {
	document.getElementById("dynamicImageContainer").style.display = "none";
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

// -----------------------------------------------------------------------------------


// Related Article ToolTip

function enableTooltips(id){
var links,i,h;
if(!document.getElementById || !document.getElementsByTagName) return;
h=document.createElement("span");
h.id="btc";
h.setAttribute("id","btc");
h.style.position="absolute";
document.getElementsByTagName("body")[0].appendChild(h);
if(id==null) links=document.getElementsByTagName("a");
else links=document.getElementById(id).getElementsByTagName("a");
for(i=0;i<links.length;i++){
    Prepare(links[i]);
    }
}

function Prepare(el){
var tooltip,t,b,s,l;
t=el.getAttribute("title");
if(t==null || t.length==0) t="link:";
el.removeAttribute("title");
tooltip=CreateEl("span","tooltip");
s=CreateEl("span","top");
s.appendChild(document.createTextNode(t));
tooltip.appendChild(s);
b=CreateEl("span","bottom");
l=el.getAttribute("href");
if(l.length>90) l=l.substr(0,87)+"...";
b.appendChild(document.createTextNode(l));
tooltip.appendChild(b);
setOpacity(tooltip);
el.tooltip=tooltip;
el.onmouseover=showTooltip;
el.onmouseout=hideTooltip;
el.onmousemove=Locate;
}

function showTooltip(e){
document.getElementById("btc").appendChild(this.tooltip);
Locate(e);
}

function hideTooltip(e){
var d=document.getElementById("btc");
if(d.childNodes.length>0) d.removeChild(d.firstChild);
}

function setOpacity(el){
el.style.filter="alpha(opacity:90)";
el.style.KHTMLOpacity="0.9";
el.style.MozOpacity="0.9";
el.style.opacity="0.9";
}

function CreateEl(t,c){
var x=document.createElement(t);
x.className=c;
x.style.display="block";
return(x);
}

function Locate(e){
var posx=0,posy=0;
if(e==null) e=window.event;
if(e.pageX || e.pageY){
    posx=e.pageX; posy=e.pageY;
    }
else if(e.clientX || e.clientY){
    if(document.documentElement.scrollTop){
        posx=e.clientX+document.documentElement.scrollLeft;
        posy=e.clientY+document.documentElement.scrollTop;
        }
    else{
        posx=e.clientX+document.body.scrollLeft;
        posy=e.clientY+document.body.scrollTop;
        }
    }
document.getElementById("btc").style.top=(posy+10)+"px";
document.getElementById("btc").style.left=(posx-20)+"px";
}


//---------------------------------------------------------------------------