var max_up,max_down,make_scroll,texttext,tr_h,sc_h,scf_h,hoch,text_oben,div_on,foto_on,stop=hold_m=xxx=tf_oben=0,pi=1,pfeil_h=16,scf_min=5,start=0;

function MM_preloadimages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadimages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function init()
{
 texttext = document.getElementById("textfeld");
 tr_h = parseInt(document.getElementById("textrahmen").style.height);
 sc_h = scf_min;
 scf_h = tr_h-(2*pfeil_h);
 tf_unten = parseInt(texttext.style.height);
 text_oben = parseInt(texttext.style.top);
 texttext.style.clip = "rect(0px, 350px, 260px, 0px)";
 if(tf_unten > tr_h)
 {
  if((tf_unten-tr_h) > (scf_h - sc_h))
   pi = Math.floor((tf_unten-tr_h)/(scf_h - sc_h));
  else
   sc_h = scf_h-(tf_unten - tr_h);
  write_scroller();
  scroll_balk = document.getElementById("scroller");
  max_up = parseInt(scroll_balk.style.top);
  hoch = (parseInt(scroll_balk.style.height)+(2*pfeil_h));
  max_down = (max_up+(tr_h-hoch));
 }
 else
  if(start == 0)
   write_noscroll();
}

function write_scroller()
{
 document.write('<div id="scroller" style="position:absolute; visibility:visible; z-Index:5; width:16px; height:'+sc_h+'px; top:328px; left:721px; border:solid 1px #CC0033"><table style="width:16px; height:'+sc_h+'px; background-color:#CC0033"  border="0" cellspacing="0" cellpadding="0"><tr><td style="width:16px; height:'+sc_h+'px;" align="center" valign="middle" class="imgcell"><a onmousedown="beginDrag('+"'scroller'"+',event);return false" href="#"><img border="0" width="16" height="'+sc_h+'" src="but/pix0.gif"></a></td></tr></table></div>');
 document.write('<div style="position:absolute; visibility:visible; z-Index:3; width:16px; height:260px; top:312px; left:721px; border:solid 1px #CC0033"><table style="width:16px; height:260px;" border="0" cellspacing="0" cellpadding="0"><tr><td style="width:16px; height:16px; border-bottom:solid 1px #CC0033" align="center" valign="center" class="imgcell"><a onmousedown="pf_scroll(4);return false" onmouseout="stop_scrolling()" onmouseup="stop_scrolling()" href="#"><img src="but/pfd.gif" border="0" alt="Pfeil nach unten"></a></td></tr><tr><td style="width:16px; height:226px;" align="center" valign="center" class="imgcell"><img src="but/pix0.gif" width="16" height="226" border="0" alt="Scrollfläche"></td></tr><tr><td style="width:16px; height:16px; border-top:solid 1px #CC0033" align="center" valign="center" class="imgcell"><a onmousedown="pf_scroll(-4);return false" onmouseout="stop_scrolling()" onmouseup="stop_scrolling()" href="#"><img src="but/pfu.gif" border="0" alt="Pfeil nach oben"></a></td></tr></table></div>');
}

function write_noscroll()
{
 document.write('<div style="position:absolute; visibility:visible; z-Index:3; width:16px; height:260px; top:312px; left:721px; border:solid 1px #CC0033"><table style="width:16px; height:260px;" border="0" cellspacing="0" cellpadding="0"><tr><td style="width:16px; height:16px; border-bottom:solid 1px #CC0033" align="center" valign="center" class="imgcell"><img src="but/pix0.gif" border="0" alt="Leerbild statt Pfeil nach unten"></td></tr><tr><td style="width:16px; height:226px;" align="center" valign="center" class="imgcell"><img src="but/pix0.gif" width="16" height="226" border="0" alt="Leerbild statt Scrollfläche"></td></tr><tr><td style="width:16px; height:16px; border-top:solid 1px #CC0033" align="center" valign="center" class="imgcell"><img src="but/pix0.gif" border="0" alt="Leerbild statt Pfeil nach oben"></td></tr></table></div>');
}

function divover(what)
{
 if(what)
 {
  document.getElementById(what).style.visibility = "visible";
  if(div_on)
   document.getElementById(div_on).style.visibility = "hidden";
 }
}

function divout(what)
{
 if(what)
 {
  document.getElementById(what).style.visibility = "hidden";
  if(div_on)
   document.getElementById(div_on).style.visibility = "visible";
 }
}


function imgover(src,name)
{
 document.images[name].src = "but/"+src+"o.gif";
}

function imgout(src,name)
{
 document.images[name].src = "but/"+src+".gif";
}

function show_foto(src)
{
 document.images[foto_on+"foto"].src = "fotos/"+foto_on+src+".jpg";
}

function popit(es,weite,hoehe)
{
 var w0=(screen.width-hoehe)/2,w1=(screen.height-weite)/2;
 Ent = window.open("4_entspannung/foto.html?"+es+"","entspannung","width="+weite+",height="+hoehe+",left="+w0+",top="+w1+"","menubar=no,scrollbars=no,toolbar=no");
 Ent.focus();
}

function scrollen(x)
{
 x = x*(-1);
 xxx += (x*pi);
 var on = "rect("+(tf_oben+xxx)+"px, 350px, "+(tr_h+xxx)+"px, 0px)";
 texttext.style.clip = on;
 texttext.style.top = (text_oben-xxx)+"px";
}

function pf_scroll(x)
{
 var sb = parseInt(scroll_balk.style.top)
 var sbb = (sb-x);
 if((sbb >= max_up) &&  (sbb <= max_down))
 {
  scroll_balk.style.top = sb-x+"px";
  scrollen(x);
  stop = 0;
  make_scroll = setTimeout("pf_scroll("+x+")",100);
 }
}

function stop_scrolling()
{
 if(stop == 0)
 {
 stop = 1;
 if(make_scroll)
  clearTimeout(make_scroll);
 var sb = parseInt(scroll_balk.style.top);
 hold_m = sb;
 }
}

function beginDrag(etd,event)
{
  if (!etd) etd = this;
  if (!event) event = window.event;
  etd = document.getElementById(etd);
  etd.style.zIndex = 5;
  var y = parseInt(etd.style.top);
  var dy = event.clientY - y;
  if (document.addEventListener)
  {
    document.addEventListener("mousemove",moveHandler, true);
    document.addEventListener("mouseup",upHandler, true);
  }
  else if (document.attachEvent)
  {
    document.attachEvent("onmousemove", moveHandler);
    document.attachEvent("onmouseup", upHandler);
  }
  if (event.stopPropagation)
   event.stopPropagation();
  else event.cancelBubble = true;
  if (event.preventDefault)
   event.preventDefault();
  else
   event.returnValue = false;

  function moveHandler(event)
  {
    if (!event) event=window.event;
    var m = (event.clientY - dy);
    if(!hold_m)
     hold_m = m;
    if((m >= max_up) && (m < max_down))
    {
     etd.style.top = m + "px";
     var st = hold_m - m;
     if(st != 0)
      scrollen(st);
     hold_m = m;
    }
    if (event.preventDefault) event.preventDefault();
    else event.returnValue = false;
  }
  function upHandler(event)
  {
    if (!event) event=window.event;
    if (document.removeEventListener)
    {
     document.removeEventListener("mouseup", upHandler, true);
     document.removeEventListener("mousemove", moveHandler, true);
    }
    else
    {
     document.detachEvent("onmouseup", upHandler);
     document.detachEvent("onmousemove", moveHandler);
    }
    if (event.stopPropagation) event.stopPropagation();
    else event.cancelBubble = true;
  }
}