/* Browserabfrage auf Netscape oder IExplorer */
var ie4,ns4,ie5,ns6;
var divInhalt,divHline,divVline,diffHX,diffHY,diffVX,diffVY,divScrollbar,darfScrollen,scrollTimeout;

function init()
{
ie4 = (document.all && !document.getElementById) ? true : false;
ns4 = (document.layers) ? true : false;
ie5 = (document.all && document.getElementById) ? true : false;
ns6 = (document.getElementById && !document.all) ? true : false;
initDivInhalt();
}

/**********************/
/* DHTML - Bibliothek */
/**********************/

function initDivInhalt()
{
 if(ns4){
      divInhalt=document.layers["inhalt"];
      divHline =document.layers["hline"];
      divVline =document.layers["vline"];
      divScrollbar=(document.layers["scrollpf"]) ? document.layers["scrollpf"] : null;
   } else if (ie4) {
      divInhalt=document.all.inhalt.style;
      divHline =document.all.hline.style;
      divVline =document.all.vline.style;
      divScrollbar=(document.all.scrollpf) ? document.all.scrollpf.style : null;
   } else if (ns6  || ie5) {
      divInhalt=document.getElementById("inhalt").style;
      divHline =document.getElementById("hline").style;
      divVline =document.getElementById("vline").style;
      divScrollbar=(document.getElementById("scrollpf")) ? document.getElementById("scrollpf").style : null;
   }
   divInhalt.hoehe = 375;
   divInhalt.breite= 560;
   divInhalt.minHoehe = 0;
   divInhalt.minBreite =0;
   // horizontale Linie
   divHline.startX=parseInt(divHline.left);
   divHline.startY=parseInt(divHline.top);
   divHline.endX= divHline.startX + 572 - parseInt(divHline.width);
   divHline.endY=divHline.startY + divInhalt.hoehe+6;
   // vertikale Linie
   divVline.startX=parseInt(divVline.left);
   divVline.startY=parseInt(divVline.top);
   divVline.endX = divVline.startX + divInhalt.breite+6;
   divVline.endY=divVline.startY + 387 - parseInt(divVline.height);
   // Steps
   var steps = 50;
   diffHX = Math.round((divHline.endX-divHline.startX) / steps);
   diffHY = Math.round((divHline.endY-divHline.startY) / steps);
   diffVX = Math.ceil((divVline.endX-divVline.startX) / steps);  // weitester Weg
   diffVY = Math.round((divVline.endY-divVline.startY) / steps);
   
   // Scroll-Flag
   darfScrollen = false;
}

/* neue Inhalt-Seite aufblenden */
function inhaltClip(pScrl)
{
	 if(parseInt(divVline.top) < divVline.endY && parseInt(divVline.left) < divVline.endX &&
		 parseInt(divHline.top) < divHline.endY && parseInt(divHline.left) < divHline.endX) {
		 var dvx=(diffVX<(divVline.endX-parseInt(divVline.left)))?diffVX:(divVline.endX-parseInt(divVline.left));
		 var dvy=(diffVY<(divVline.endY-parseInt(divVline.top)))?diffVY:(divVline.endY-parseInt(divVline.top));
		 var dhx=(diffHX<(divHline.endX-parseInt(divHline.left)))?diffHX:(divHline.endX-parseInt(divHline.left));
		 var dhy=(diffHY<(divHline.endY-parseInt(divHline.top)))?diffHY:(divHline.endY-parseInt(divHline.top));
		 bewegeUm(divVline,dvx,dvy);
		 bewegeUm(divHline,dhx,dhy);
		 clipAbsolut(divInhalt,0,parseInt(divVline.left)-divVline.startX-6,
					 parseInt(divHline.top)-divHline.startY-6,0);
	  } else {
		 bewegeZu(divHline,divHline.endX,divHline.endY);
		 bewegeZu(divVline,divVline.endX,divVline.endY);
		 clipAbsolut(divInhalt,0,divInhalt.breite,divInhalt.hoehe,0);
		 // Scroller init
		 if (divScrollbar != null && pScrl) {
			divScrollbar.left = parseInt(divVline.endX) - Math.floor(parseInt(divScrollbar.width)/2);
			divScrollbar.top = parseInt(divVline.endY);
			einblenden(divScrollbar);		
		 }
		
		 var hlink = "" + window.location.search;
		 if (hlink != "") {
		  // Anchor bezogene Contents zeigen
			if(hlink.indexOf("anc=") >= 0) {
				showAnchor(hlink);
			}	
		 }
		// notwendige Korrektur für NS 6 / 7 und Mozilla für Scrollpfeile - NOT FF
		// corrScrlMoz(-2,0);		 
		return true;
	}
	setTimeout("inhaltClip("+pScrl+")",20);
}

function corrScrlMoz(dX,dY)
{
	if (ns6) {
		var pfo = document.getElementById("scrollpfo");
		if (pfo != null) {
			pfo = pfo.style;
			var pfu = document.getElementById("scrollpfu").style;
			pfo.left = (parseInt(pfo.left)+dX )+ "px";
			pfo.top = (parseInt(pfo.top)+dY )  + "px";
			pfu.left = (parseInt(pfu.left)+dX )+ "px";
			pfu.top = (parseInt(pfu.top)+dY )  + "px";
		}
	}
}

/* einfaches Scrollen */
function scrollControl(erlaubt,tempo,offSetH)
{
	darfScrollen = erlaubt;
	if (darfScrollen) {
		if (scrollTimeout != null) {
			window.clearTimeout(scrollTimeout);
		}
		scrollContent(tempo,offSetH);
	}
}
// +tempo = nach unten  /  -tempo = nach oben */
function scrollContent(tempo,offSetH)
{
	if (darfScrollen) {
		// Begrenzungen
		if ((tempo > 0 && clipWert(divInhalt,"u") < (offSetH-tempo)) ||		// scroll down
			(tempo < 0 && clipWert(divInhalt,"o") > (-tempo))){				// scroll up
			if (ns4) {
				divInhalt.top = (parseInt(divInhalt.top)-tempo);
				clipRelativ(divInhalt,tempo,0,tempo,0);
			} else {
				divInhalt.top = (parseInt(divInhalt.top)-tempo) + "px";
				divInhalt.height = (parseInt(divInhalt.height)+tempo) + "px";
				clipRelativ(divInhalt,tempo,0,tempo,0);
			}
			scrollTimeout=window.setTimeout("scrollContent("+tempo+","+offSetH+")",10);
		}
	}
}


/* clipping */
function clipWert(obj,wert)
{
  if (ns4)
  {
      if (wert=="o") return obj.clip.top;
      if (wert=="r") return obj.clip.right;
      if (wert=="u") return obj.clip.bottom;
      if (wert=="l") return obj.clip.left;
  }
   else if (ns6 || ie4 || ie5)
  {
	var clip_feld= "" + obj.clip;
	clip_feld = clip_feld.replace(/,/g,"");
	clip_feld=clip_feld.split("rect(")[1].split(")")[0].split("px");
      
     if (wert=="o") return Number(clip_feld[0]);
     if (wert=="r") return Number(clip_feld[1]);
     if (wert=="u") return Number(clip_feld[2]);
     if (wert=="l") return Number(clip_feld[3]);
  }
  
  return false;
}

// veraendert den Clip-Wert relativ
function clipRelativ(obj,o,r,u,l)
{
 if (ns4)
  {
        obj.clip.top=clipWert(obj,'o')+o;
        obj.clip.right=clipWert(obj,'r')+r;
        obj.clip.bottom=clipWert(obj,'u')+u;
        obj.clip.left=clipWert(obj,'l')+l;
  }
 if (ns6 || ie4 || ie5)
  {
        n_o=clipWert(obj,"o")+o;
        n_r=clipWert(obj,"r")+r;
        n_u=clipWert(obj,"u")+u;
        n_l=clipWert(obj,"l")+l;
        obj.clip="rect("+n_o+"px "+n_r+"px "+n_u+"px "+n_l+"px)";
  }
}

// setzt den Clip absolut
function clipAbsolut(obj,o,r,u,l)
{
 if (ns4)
  {
        obj.clip.top=o;
        obj.clip.right=r;
        obj.clip.bottom=u;
        obj.clip.left=l;
  }
 if (ns6 || ie4 || ie5)
  {
        obj.clip="rect("+o+"px "+r+"px "+u+"px "+l+"px)";
  }
}

/* Bewegung */
function bewegeZu(was,x,y)
{
   if(ns4) {
      was.left=parseInt(x);
      was.top =parseInt(y);
   } else {
      was.left=parseInt(x) + "px";
      was.top =parseInt(y) + "px";
   }
}

function bewegeUm(was,x,y)
{
   if (ns4) {
      was.left=parseInt(was.left)+x;
      was.top=parseInt(was.top)+y;
   } else {
      was.left=(parseInt(was.left)+x)+"px";
      was.top=(parseInt(was.top)+y) + "px";
   }
}

/* ein- und ausblenden */
function einblenden(was)
{
   if (ns4) {
       was.visibility="show";
   } else if (ns6)
   {
      was.display="";
      was.visibility="visible";
   } else if (ie4 || ie5) {
      was.visibility="visible";
   }
}

function ausblenden(was)
{
   if (ns4) {
       was.visibility="hide";
   } else if (ns6) {
      was.display="none";
      was.visibility="hidden";
   } else if (ie4 || ie5) {
      was.visibility="hidden";
   }
}