var bV=parseInt(navigator.appVersion);
NS4=(document.layers) ? true : false;
IE4=((document.all)&&(bV>=4)) ? true : false;
DOM=(!document.layers && !document.all && bV>=4) ? true : false;
var RefBildStep = new Object();
var RefBildArray= new Array();
// A hack to guess if the browser supports the DOM
capable = (NS4 || IE4 || DOM) ? true : false;

function initIt(){
	if(DOM){
		tempColl = document.getElementsByTagName("a");
		for (i=0;i<tempColl.length; i++) {
			tempColl[i].addEventListener("mouseover", mousePos, true);
		}
	} else if(IE4){
		document.onmousemove = mousePos;
	} else if(NS4){
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = mousePos;
	}
}


function scaleContent(){
 var wH = -1;
  if (window.innerHeight) {
    wH = window.innerHeight;
  } else if (document.body.offsetHeight) {
    wH = document.body.offsetHeight;
  }
  if (wH!=-1) {
// header 241
// footer 51
wH=wH-51-241-12;
    var NewMiddleHeight = wH;
// startseite 371
// middle 371
    if(NewMiddleHeight<371) NewMiddleHeight=371;

    var ContentHeight = wH-58;
// content 314
    if(ContentHeight<314) ContentHeight=314;

// alert(NewMiddleHeight+":"+ContentHeight);
	if (IE4) {
		if(document.all['Content']) document.all['Content'].style.height = ContentHeight+"px";
		if(document.all['StartseitenContainer']) document.all['StartseitenContainer'].style.height = NewMiddleHeight+"px";
		if(document.all['pageregionMiddle']) document.all['pageregionMiddle'].style.height = NewMiddleHeight+"px";

	} else if(NS4) {
		whichEl = eval("document.Content");
		whichEl.height = parseInt(ContentHeight);
		whichEl = eval("document.pageregionMiddle");
		whichEl.height = parseInt(NewMiddleHeight);
	} else if(DOM) {
if(document.getElementById('Content')){
		whichEl = document.getElementById('Content');
		whichEl.style.height = ContentHeight+"px";
}

if(document.getElementById('StartseitenContainer')){
		whichEl = document.getElementById('StartseitenContainer');
		whichEl.style.height = NewMiddleHeight+"px";
}
if(document.getElementById('pageregionMiddle')){
		whichEl = document.getElementById('pageregionMiddle');
		whichEl.style.height = NewMiddleHeight+"px";
}
	}
	
   }
}

function mousePos(Ereignis){
	if(DOM){
		MouseX = Ereignis.pageX;
		MouseY = Ereignis.pageY;
	} else if(IE4){
		MouseX = window.event.clientX;
		MouseY = window.event.clientY;
	} else if(NS4){
		Ev = Ereignis;
		MouseX = Ev.pageX;
		MouseY = Ev.pageY;
	}
}

var active;
function startclose(){
     active = window.setTimeout("closeAll()",1000);
}
function stopclose(){
     if(active){
		window.clearTimeout(active);
	}
}
function expandIt(el, id, OffsX, OffsY) {
	if (!capable) return;
	// closeAll();
	
	var coords;
	var MouseX=0;
	var MouseY=0;
	if (DOM || IE4) {
		coords = {x: 0, y: 0};
		var element = document.getElementById('POSER_'+id);
		while (element) {
			coords.x += element.offsetLeft;
			coords.y += element.offsetTop;
			element = element.offsetParent;
		}
	} else if (NS4) {
		var element = document.links['POSER_'+id];
		coords = {x: element.x, y: element.y};
	} else {
		return false;
	}
	
	if (coords){
		var poserX = coords['x'];
		var poserY = coords['y'];
	}
	MouseX=(poserX+OffsX);
	MouseY=(poserY+OffsY);
	
	if(DOM) {
		whichEl = document.getElementById(el);
		whichEl.style.top = MouseY+"px";
		whichEl.style.left = MouseX+"px";
		whichEl.style.visibility = "visible";
		whichEl.style.display = "block";
	} else if (IE4) {
		document.all[eval('el')].style.top = MouseY+"px";
		document.all[eval('el')].style.left = MouseX+"px";
		document.all[eval('el')].style.display = "block";
		document.all[eval('el')].style.visibility = "visible";
	} else if(NS4) {
		whichEl = eval("document." + el);
		whichEl.top = parseInt(MouseY);
		whichEl.left = parseInt(MouseX);  
		whichEl.visibility = "show";
		whichEl.display = "block";
	} 
}

function closeAll(){
  closeAllByName("child");
  closeAllByName("subchild");
}

function openStandort(el){
	if (!capable) return;
	if(DOM) {
		whichEl = document.getElementById(el);
		whichEl.style.visibility = "visible";
		whichEl.style.display = "block";
	} else if (IE4) {
		document.all[eval('el')].style.display = "block";
		document.all[eval('el')].style.visibility = "visible";
	} else if(NS4) {
		whichEl = eval("document." + el);
		whichEl.visibility = "show";
		whichEl.display = "block";
	} 

}

function closeAllByName(name){
	stopclose();
	if (NS4) {
		for (i=0; i<document.layers.length; i++) {
			whichEl = document.layers[i];
			if (whichEl.id.toLowerCase().indexOf(name) != -1) {
				whichEl.visibility = "hide";
				whichEl.display = "none";
			}
		}
	} else if(IE4) {
		tempColl = document.all.tags("DIV");
		for (i=0; i<tempColl.length; i++) {
			whichEl = tempColl(i);
			if (whichEl.className == name){
				whichEl.style.display = "none";
				whichEl.style.visibility = "hidden";
			}
		}
	} else if(DOM) {
		tempColl = document.getElementsByTagName("DIV");
		for (i=0; i<tempColl.length; i++) {
			whichEl = tempColl[i];
			if (whichEl.className == name){
				whichEl.style.visibility = "hidden";
				whichEl.style.display = "none";
			}
		}
	}
}

function setPointer(theRow, thePointerColor){
    if(DOM||IE4) theRow.style.backgroundColor = thePointerColor;
    return true;
} 

function stepRef(el,to){
 RefBildStep[el]=RefBildStep[el]+to;
 rb='RefBild'+el;
 if(RefBildArray[el].length==parseInt(RefBildStep[el])) RefBildStep[el]=0;
 if(RefBildStep[el]<0) RefBildStep[el] =RefBildArray[el].length-1;
// alert(RefBildArray[el].length + " " +RefBildStep[el] + " "+RefBildArray[el][RefBildStep[el]]);

 if(RefBildArray[el][RefBildStep[el]]){ 
  document.getElementById(rb).src=RefBildArray[el][RefBildStep[el]]['s'];
  document.getElementById(rb).width=RefBildArray[el][RefBildStep[el]]['w'];
  document.getElementById(rb).height=RefBildArray[el][RefBildStep[el]]['h'];
 }
return false;
}


