window.addEvent('domready', function() {

    // ******************** Scriptabschnitt fuer Bildergalerie **********************

    var bgBalken = new Fx.Tween('bg_balken');
    
    x_bg_balken = 0;

    if(document.getElementById("bg_forwards")){
        $('bg_forwards').addEvent('click', function(e){
            e.stop();
        
            if(-(bg_width-483) <= (x_bg_balken-img_width)){
                x_bg_balken = x_bg_balken - img_width;
                bgBalken.start('left', x_bg_balken+img_width, x_bg_balken);
                document.getElementById("bg_back").style.display = "inline-block";
            }
            
            if(-(bg_width-483) >= x_bg_balken){
                document.getElementById("bg_forwards").style.display = "none";
            }
        }); 
    }
    
    if(document.getElementById("bg_back")){
        $('bg_back').addEvent('click', function(e){
            e.stop();
            if(x_bg_balken < 0){
                x_bg_balken = x_bg_balken + img_width;
                bgBalken.start('left', x_bg_balken-img_width, x_bg_balken);
               document.getElementById("bg_forwards").style.display = "inline-block";
            }
        
            if(x_bg_balken >= 0){
                document.getElementById("bg_back").style.display = "none";
            }
        }); 
    }
    
    
    
    // ****************** Scriptabschnitt fuer Infobox auf Startseite ********************
    
    var hgInfobox = new Fx.Tween('infobox_start_img');
    
    x_infobox = 0;

    if(document.getElementById("infobox_button_links")){
        $('infobox_button_links').addEvent('click', function(e){
            e.stop();
        
            if(-(hg_width_inf-240) <= (x_infobox-img_width_inf)){
                x_infobox = x_infobox - img_width_inf;
                hgInfobox.start('left', x_infobox+img_width_inf, x_infobox);
                document.getElementById("infobox_button_rechts").style.display = "inline-block";
            }
            
            if(-(hg_width_inf-240) >= x_infobox){
                document.getElementById("infobox_button_links").style.display = "none";
            }
        }); 
    }
    
    if(document.getElementById("infobox_button_rechts")){
        $('infobox_button_rechts').addEvent('click', function(e){
            e.stop();
            if(x_infobox < 0){
               x_infobox = x_infobox + img_width_inf;
               hgInfobox.start('left', x_infobox-img_width_inf, x_infobox);
               document.getElementById("infobox_button_links").style.display = "inline-block";
            }
        
            if(x_infobox >= 0){
                document.getElementById("infobox_button_rechts").style.display = "none";
            }
        }); 
    }
    
    

});

function emailDecode(wert1,wert2,wert3){
    var mail = wert3+"@"+wert2+wert1;
    location.href = "mailto:"+mail;
}

function addBookmark(title,url) {
 
    var bookmarkurl="http://www.foerderverein-nuthe-nieplitz.de"
    var bookmarktitle="Naturpark Nuthe Nieplitz"
    
    if (window.sidebar)
    { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(bookmarktitle, bookmarkurl,"");
    }
    else if(window.external)
    { // IE Favorite
        window.external.AddFavorite(bookmarkurl, bookmarktitle);
    }
    else if(window.opera && window.print)
    { // Opera Hotlist
        alert("Bitte die Tastenkombination STRG + D drücken");
        return true;
    }
    else
    {
       alert("Bitte die Tastenkombination STRG + D drücken");
       return true;
    }

}



var x_BG = 0;
var z = 1;
var bg_forwards = 0;
var bg_back = 0;
    
function bgInit(){
    z = 1;
    while (eval('document.getElementById("image'+z+'")')) {
        z++;
    }
}

function bgForwards(){
    
    bgInit();

    if(document.getElementById("bg_balken")){
                    
        if(z >= (bg_forwards+4)){
            x_BG = x_BG - 161;
            document.getElementById("bg_balken").style.left = x_BG + "px";
        }
        
        if(z >= (bg_forwards+4)){
            bg_forwards++;
        }
    }
}

function bgBack(){

    bgInit();
    
    if(document.getElementById("bg_balken")){
    
        if(z <= (bg_forwards+4)){
            bg_forwards--;
        }
        
        if(document.getElementById("bg_balken").style.left < "0px" && document.getElementById("bg_balken").style.left != ""){
            x_BG = x_BG + 161;
            document.getElementById("bg_balken").style.left = x_BG + "px";
        }
    }
}

var routeSum = 0;
var start_value;
var end_value; 

function changeRoute(wert){

    if(routeSum == 0){
        start_value = document.routenplaner.start.value;
        end_value = document.routenplaner.end.value; 
        routeSum++;
    }

    if(wert == 0){
        document.getElementById("calendar_events_route_from").style.color = "rgb(106, 117, 84)";
        document.getElementById("calendar_events_route_from").style.textDecoration = "underline";
        document.getElementById("calendar_events_route_to").style.color = "rgb(0, 0, 0)";
        document.getElementById("calendar_events_route_to").style.textDecoration = "none";

        document.routenplaner.start.value = end_value;
        document.routenplaner.end.value = start_value;
    }
    
    if(wert == 1){
        document.getElementById("calendar_events_route_from").style.color = "rgb(0, 0, 0)";
        document.getElementById("calendar_events_route_from").style.textDecoration = "none";
        document.getElementById("calendar_events_route_to").style.color = "rgb(106, 117, 84)";
        document.getElementById("calendar_events_route_to").style.textDecoration = "underline";

        document.routenplaner.start.value = start_value;
        document.routenplaner.end.value = end_value;
    }
}


