// Diese Routinen und Algorithmen sind urheberlich geschützt (c) von Reinhard Doberstein, Mannheim; info@doberstein.com !
// This funktions are copyright (c) by Reinhard Doberstein, info@doberstein.com !

abstand_oben = 1;
abstand_links = 1;
Bildbreite = 186;
window_offset_leftNS = 10;
window_offset_topNS = 0;
window_offset_leftIE = -2;
window_offset_topIE = 2;
window_breite = 1;
max_abstand_alt = 1;
max_abstand2 = 1;
letztes_auge_links = "";
letztes_auge_rechts = "";

aug_l_x = 48;
aug_l_y = 21;
aug_r_x = 144;
aug_r_y = 35;
grenze1= 0.01;
grenze2 = 0.2
grenze3 = 0.8;

ns =0;
ie =0;

function do_scroll()
{
do_weiter = true;
sub_speed = 1;
        if (scroll_status == 0 ) {
                scroll_status++;
        } else if (scroll_status == 3){
                if ( scroll_sub_status <= scroll_anzahl) {
                        if (scroll_sub_status < scroll_anzahl) {
//                                if (scroll_sub_status %2 == 0 ) {
//                                        eval( "document.p_" +scroll_sub_status+ ".src = 'pm1.gif'" )
//                                } else {
                                        eval( "document.p_" +scroll_sub_status+ ".src = 'pm2.gif'" )
//                                }
//                                eval( "document.p_" +scroll_sub_status+ ".src = 'sm_le.gif'" )
                        }
                        if ( (scroll_sub_status -1 )  >= 0) {
                                eval( "document.p_" + (scroll_sub_status -1 ) + ".src = 'space.gif'" )
                        }
                } else {
                        scroll_status++;
                }
                scroll_sub_status++;
        } else if (scroll_status == 5){
                for ( i = 0 ; i < scroll_liste.length ; i++ ) {
                        scroll_liste[i] = text_2[i];
                }
                scroll_status++;
        } else if (scroll_status == 7){
                sub_speed = 2;
                if ( scroll_sub_status <= text_2.length ) {
                        for ( i = 0; i < scroll_anzahl ; i++ ) {
                                bild = get_gif(scroll_sub_status + i, text_2);
//                                bild = "punkt.gif";
                                eval( "document.p_" + i + ".src = '"+ bild + "'");
                        }
                } else {
                        scroll_status++;
                }
                scroll_sub_status++;
        } else if (scroll_status == 20){
                for ( i = 0; i < scroll_anzahl ; i++ ) {
                        bild = get_gif(scroll_sub_status + i, text_1);
                        eval( "document.p_" + i + ".src = '"+ bild + "'");
                }
                scroll_status++;
        } else if (scroll_status == 30){
//                alert ("ready");
                scroll_status = 0;
        } else if (scroll_status == 100){
                do_weiter = false;
        } else {
                scroll_status++;
                scroll_sub_status=0;
        }
        if ( do_weiter == true) {
                setTimeout('do_scroll();', ((1000/scroll_speed)/sub_speed));
        }
};        // function do_scroll()

function Mauskontrolle_ie() {
        // abstand_links = Math.floor((top.mitte.document.body.clientWidth - Bildbreite)/2 - window_offset_leftIE );
        abstand_links = Math.floor((document.body.clientWidth - Bildbreite)/2 - window_offset_leftIE );
        set_auge(window.event.x, window.event.y);
//        txt = "IE: " + window.event.x +"/"+ window.event.y + " Breite : " + abstand_links +"/"+ abstand_oben ;
//        window.defaultStatus = txt;
        return true;
  }

function Mauskontrolle_ns(Ereignis) {
//        abstand_links = Math.floor((top.innerWidth - Bildbreite)/2 - window_offset_leftNS );
        // abstand_links = Math.floor((top.mitte.innerWidth - Bildbreite)/2 - window_offset_leftNS );
        // abstand_links = Math.floor((document.innerWidth - Bildbreite)/2 - window_offset_leftNS );
        abstand_links = Math.floor((window.innerWidth - Bildbreite)/2 - window_offset_leftNS );
        set_auge(Ereignis.layerX , Ereignis.layerY);
//        txt = "NS: " + Ereignis.layerX +"/"+ Ereignis.layerY + " Breite : " + abstand_links +"/"+ abstand_oben ;
//        window.defaultStatus = txt;
        return true;
  }

function set_auge(mouseX, mouseY)
{
        // Berechnung für linkes Auge
        mouse_left = mouseX - (abstand_links + aug_l_x );
        mouse_top = mouseY - (abstand_oben + aug_l_y );
        abstand2 = mouse_left*mouse_left + mouse_top*mouse_top ;
        abstand = Math.sqrt(abstand2);

        u = mouse_left / abstand;
        v = mouse_top / abstand;
        if (mouse_top  >= 0) {
                erg =  (Math.acos (u) / Math.PI ) *180;
        } else{
                erg =  (-Math.acos (u) / Math.PI ) *180+360;
        };
        erg = erg +90+22.5;
        if (erg < 0 ) {
                erg = erg + 360;
        }
        if (erg > 360 ) {
                erg = erg - 360;
        }
        Aug_Richtung = Math.floor(erg /45)+1;
        // alert (" abstand_links = " + abstand_links);
        // alert (" aug_l_x = " + aug_l_x);

        // abstand_links = Math.floor((document.innerWidth - Bildbreite)/2 - window_offset_leftNS );
        // alert (" document.innerWidth = " + document.innerWidth);
        // alert (" window.innerWidth = " + window.innerWidth);
        // alert (" Bildbreite = " + Bildbreite);
        // alert (" window_offset_leftNS = " + window_offset_leftNS);

        // alert (" mouseX = " + mouseX);
        // alert (" mouse_left = " + mouse_left);
        // alert (" abstand2 = " + abstand2);
        // alert (" abstand = " + abstand);
        // alert (" u = " + u);
        // alert (" erg = " + erg);
        //  alert (" Aug_Richtung = " + Aug_Richtung);

        max_abstand_alt = 0.99 *max_abstand_alt;
        if (abstand > max_abstand_alt) {
                max_abstand_alt = abstand;
        }
        entf = abstand / max_abstand_alt;
        if ( entf < grenze1) {
                suffix = "";
        } else if ( entf < grenze2) {
                suffix = "a"+ Aug_Richtung ;
        } else if ( entf < grenze3) {
                suffix = "b"+ Aug_Richtung ;
        } else {
                suffix = "c"+ Aug_Richtung ;
        }
//        txt = "erg =" + erg + " enf =" + entf + " Bild = " + "augen_links/aug_l" + suffix +" .GIF";
//        document.aug_l.src = 'augen_links/aug_la1.GIF';
        if ( suffix != letztes_auge_links ) {
                letztes_auge_links = suffix;
                if (ns == 1) {
                        // alert ("document =" + document);
                        // alert ("document.augenNS_layer =" + document.augenNS_layer);
                        // alert ("document.augenNS_layer.document =" + document.augenNS_layer.document);
                        // alert ("document.augenNS_layer.document.aug_l =" + document.augenNS_layer.document.aug_l);
                        // alert( "document.augenNS_layer.document.aug_l.src = 'augen_links/aug_l" + suffix + ".gif'" );
                        eval( "document.augenNS_layer.document.aug_l.src = 'augen_links/aug_l" + suffix + ".gif'" );
                }
                if ( ie == 1) {
                        // eval( "top.mitte.augenIE.document.aug_l.src = 'augen_links/aug_l" + suffix + ".gif'" );
                        // eval( "document.augenIE.document.aug_l.src = 'augen_links/aug_l" + suffix + ".gif'" );
                  // alert ("document.all.augenIE=" + document.all.augenIE);
                        // alert ("document=" + document);
                        // alert ("document.all.augenIE=" + document.all.augenIE);
                        // alert ("document.all.aug_l=" + document.all.aug_l);
                        // alert ("document.all.augenIE.aug_l=" + document.all.augenIE.aug_l);
                        // alert ("document.all.aug_l.src=" + document.all.aug_l.src);
                  if ( document && document.all.augenIE && document.all.aug_l ) {
                        eval( "document.all.aug_l.src = 'augen_links/aug_l" + suffix + ".gif'" );
                  }
                }
        }

//        window.defaultStatus = txt;


        // Berechnung für rechte Auge
        mouse_left = mouseX - (abstand_links + aug_r_x );
        mouse_top = mouseY - (abstand_oben + aug_r_y );
        abstand2 = mouse_left*mouse_left + mouse_top*mouse_top ;
        abstand = Math.sqrt(abstand2);

        u = mouse_left / abstand;
        v = mouse_top / abstand;
        if (mouse_top  >= 0) {
                erg =  (Math.acos (u) / Math.PI ) *180;
        } else{
                erg =  (-Math.acos (u) / Math.PI ) *180+360;
        };
        erg = erg +90+22.5;
        if (erg < 0 ) {
                erg = erg + 360;
        }
        if (erg > 360 ) {
                erg = erg - 360;
        }
        Aug_Richtung = Math.floor(erg /45)+1;

        max_abstand_alt = 0.99 *max_abstand_alt;
        if (abstand > max_abstand_alt) {
                max_abstand_alt = abstand;
        }
        entf = abstand / max_abstand_alt;
        if ( entf < grenze1) {
                suffix = "";
        } else if ( entf < grenze2) {
                suffix = "a"+ Aug_Richtung ;
        } else if ( entf < grenze3) {
                suffix = "b"+ Aug_Richtung ;
        } else {
                suffix = "c"+ Aug_Richtung ;
        }
//        txt = "erg =" + erg + " enf =" + entf + " Bild = " + "augen_rechts/aug_r" + suffix +" .GIF";
//        document.aug_l.src = 'augen_links/aug_la1.GIF';
        if ( suffix != letztes_auge_rechts ) {
                letztes_auge_rechts = suffix;
                if (ns == 1) {
                        eval( "document.augenNS_layer.document.aug_r.src = 'augen_rechts/aug_r" + suffix + ".gif'" );
                }
                if ( ie == 1) {
                        // eval( "top.mitte.augenIE.document.aug_r.src = 'augen_rechts/aug_r" + suffix + ".gif'" );
                        // eval( "document.augenIE.document.aug_r.src = 'augen_rechts/aug_r" + suffix + ".gif'" );
                  if ( document && document.all.augenIE && document.all.aug_l ) {
                        // alert ("document=" + document);
                        // alert ("document.augenIE=" + document.augenIE);
                        // alert ("document.augenIE.aug_l=" + document.augenIE.aug_l);
                        // alert ("document.augenIE.aug_l.src=" + document.augenIE.aug_l.src);
                        // eval( "document.augenIE.aug_r.src = 'augen_rechts/aug_r" + suffix + ".gif'" );
                        eval( "document.all.aug_r.src = 'augen_rechts/aug_r" + suffix + ".gif'" );
                  }
                }
        }

//        window.defaultStatus = txt;

}


function do_pos_testen()
{
}

function tst_pos_augenNS(Ereignis)
{
        txt = "tst_pos_NS: " + Ereignis.layerX +"/"+ Ereignis.layerY;
        txt = "tst_pos_NS: " + Ereignis.PageX +"/"+ Ereignis.PageY;
//        window.defaultStatus = txt;
//        alert (txt);
        return true;

//   alert("Sie haben die Taste mit dem Wert " + Ereignis.which + " gedrueckt");
//   window.captureEvents(Event.KEYPRESS);
//   window.onkeypress = Ausgabe;
}

function start_scroll()
{
// alert (navigator.appName);

  do_src = 0;
  ns = 0;
  ie = 0;
  if ((navigator.appName == "Netscape") && ( parseFloat(navigator.appVersion) >= 3.0 )  ) {
        do_src = 1;
        ns = 1;
        window.captureEvents(Event.LOAD);
        window.load = tst_pos_augenNS;

        document.layers["augenNS_layer"].captureEvents(Event.RESIZE);
        document.layers["augenNS_layer"].onresize = tst_pos_augenNS;

        document.augenNS_layer.captureEvents(Event.MOUSEMOVE);
        document.augenNS_layer.onmousemove = tst_pos_augenNS;

        window.captureEvents(Event.MOUSEMOVE);
        window.onmousemove = Mauskontrolle_ns;

//             ***********************************************

//        alert ("LayerX(1): " + document.layers["augenNS_layer"].left);
//        alert ("LayerX(2): " + document.layers["augenNS_layer"].pageX);
//        alert ("LayerX(3): " + document.augenNS_layer.left);
//        alert ("LayerX(4): " + document.augenNS_layer.pageX);
//        alert ("LayerY(1): " + document.layers["augenNS_layer"].top);
//        alert ("LayerY(2): " + document.layers["augenNS_layer"].pageY);
//        alert ("LayerY(3): " + document.augenNS_layer.top);
//        alert ("LayerY(4): " + document.augenNS_layer.pageY);
        abstand_oben = document.augenNS_layer.pageY ;
/*
        alert ("LayerY(1): " + document.layers["augenNS_layer"].top);
        alert ("LayerX: " + document.layers["augenNS_layer"].layerX);
        alert ("LayerY: " + document.layers["augenNS_layer"].layerY);
        alert ("offsetLeft: " + document.layers["augenNS_layer"].offsetLeft);
        alert ("offsetTop: " + document.layers["augenNS_layer"].offsetTop);
        alert ("right: " + document.layers["augenNS_layer"].clip.right);
//        alert ("all: " + document.layers["augenNS_layer"].clip["right"] );
        alert ("left: " + document.layers["augenNS_layer"].clip.left );
//        alert ("top: " + document.layers["augenNS_layer"].clip["top"] );
        alert ("top: " + document.layers["augenNS_layer"].clip.top );
//        alert ("top2: " + document.layers["augenNS_layer"].top );
        alert ("top3: " + document.layers.augenNS_layer.top );
        alert ("bottom: " + document.layers["augenNS_layer"].clip["bottom"] );
//        alert ("top: " + document.layers["augenNS_layer"].clip.top);
//        alert ("Left: " + Augen.Left);
//        alert (Augen.top);
//        alert (document.augen_ns.pageY);
*/

//                aug_l_x = 0; aug_l_y = 0; aug_r_x = 0; aug_r_y = 0;

  }        // if ((navigator.appName == "Netscape") && ( parseFloat(navigator.appVersion) >= 3.0 ))
  if ( (navigator.appName == "Microsoft Internet Explorer") && ( parseFloat(navigator.appVersion) >= 4.0 )  ) {
        do_src = 1;
        ie = 1;
//        alert (document.all.augenIE.offsetLeft);
//        alert (document.all.augenIE.offsetTop);
//        alert ("Window Breite: = " + top.document.body.clientWidth);
//        alert ("Window Höhe: = " + top.document.body.clientHeight);
        abstand_oben = document.all.augenIE.offsetTop + window_offset_topIE ;

  }        // if ((navigator.appName == "Netscape") && ( parseFloat(navigator.appVersion) >= 3.0 ))
/*
  if ( do_src == 1) {
//    eval( "document.all.aug_l.src = 'augen_links/aug_lc8.gif'" );
    eval( "top.augenIE.document.aug_l.src = 'augen_links/aug_lc7.gif'" );
//    eval( "document.augenNS_layer.document.aug_l.src = 'augen_links/aug_lc7.gif'" );
//    eval( "document.augenNS_layer.augenIE.aug_l.src = 'augen_links/aug_lc6.gif'" );
//    eval( "document.augenIE.aug_l.src = 'augen_links/aug_lc5.gif'" );
  }
*/
}        // function start_scroll()
