
var interval;
var vorstand_count;
var old_vorstand = 1; //jump to 2nd manager
var current_vorstand = 0;
var flag = 0;
function vorstandRotate(mode) {  
    // Loop for default imgChange
    if ( (mode == "undefined") && (flag != "1") ) {   
        current_vorstand = (old_vorstand + 1) % vorstand_count; 
        var mode = $("#contVorstand div.changeImages:eq(" + old_vorstand + ")").attr("id");
    }
    switch(mode) {
        case 'vorstand_1':
            $("#vorstand_big > a > img").fadeOut(1000, function(){ 
            $("#vorstand_big > a > img").attr({ src: "/graphics/visuals/vis_teyssen300x150.jpg" }).fadeIn(1000);
            $("#vorstand_big > a ").attr({ href: "/en/investors/14270.jsp"});
            $("#vorstand_big > a > img").attr({ alt: "Dr. Johannes Teyssen"});
            $("#vorstand_link > p > a").text("Dr. Johannes Teyssen");
            $("#vorstand_link > p > a").attr({ href: "/en/investors/14270.jsp"});
            $("#vorstand_link > p > a").attr({ title: "Dr. Johannes Teyssen"});
            // kill old border  
            $('#contVorstand div.changeImages').removeClass('borderAktiv');
            $('#contVorstand div.changeImages').addClass('borderInAktiv');
            // border around activeObject
            //$('#vorstand_1').addClass('borderAktiv');
            $('#vorstand_1').addClass('borderAktiv');
            $('#vorstand_1').removeClass('borderInAktiv');
            });
            break;     
        case 'vorstand_2':
            $("#vorstand_big > a > img").fadeOut(1000, function(){ 
            $("#vorstand_big > a > img").attr({ src: "/graphics/visuals/vis_daenzer300x150.jpg" }).fadeIn(1000);
            $("#vorstand_big > a ").attr({ href: "/en/investors/14267.jsp"});
            $("#vorstand_big > a > img").attr({ alt: "Christoph Dänzer-Vanotti"});
            $("#vorstand_link > p > a").text("Christoph Dänzer-Vanotti"); 
            $("#vorstand_link > p > a").attr({ href: "/en/investors/14267.jsp"}); 
            $("#vorstand_link > p > a").attr({ title: "Christoph Dänzer-Vanotti"});
            // kill old border  
            $('#contVorstand div.changeImages').removeClass('borderAktiv');
            $('#contVorstand div.changeImages').addClass('borderInAktiv');
            // border around activeObject
            $('#vorstand_2').addClass('borderAktiv');
            $('#vorstand_2').removeClass('borderInAktiv');
            });
            break;
        case 'vorstand_3':
            $("#vorstand_big > a > img").fadeOut(1000, function(){ 
            $("#vorstand_big > a > img").attr({ src: "/graphics/visuals/vis_feldmann300x150.jpg" }).fadeIn(1000);
            $("#vorstand_big > a ").attr({ href: "/en/investors/14268.jsp"});
            $("#vorstand_big > a > img").attr({ alt: "Lutz Feldmann"});
            $("#vorstand_link > p > a").text("Lutz Feldmann"); 
            $("#vorstand_link > p > a").attr({ href: "/en/investors/14268.jsp"});
            $("#vorstand_link > p > a").attr({ title: "Lutz Feldmann"});
            // kill old border  
            $('#contVorstand div.changeImages').removeClass('borderAktiv');
            $('#contVorstand div.changeImages').addClass('borderInAktiv');
            // border around activeObject
            $('#vorstand_3').addClass('borderAktiv');
            $('#vorstand_3').removeClass('borderInAktiv');        
            });
            break;
        case 'vorstand_4':
            $("#vorstand_big > a > img").fadeOut(1000, function(){ 
            $("#vorstand_big > a > img").attr({ src: "/graphics/visuals/vis_schenk300x150.jpg" }).fadeIn(1000);
            $("#vorstand_big > a ").attr({ href: "/en/investors/14269.jsp"});
            $("#vorstand_big > a > img").attr({ alt: "Dr. Marcus Schenck"});
            $("#vorstand_link > p > a").text("Dr. Marcus Schenck");
            $("#vorstand_link > p > a").attr({ href: "/en/investors/14269.jsp"});
            $("#vorstand_link > p > a").attr({ title: "Dr. Marcus Schenck"});
            // kill old border  
            $('#contVorstand div.changeImages').removeClass('borderAktiv');
            $('#contVorstand div.changeImages').addClass('borderInAktiv');
            // border around activeObject
            $('#vorstand_4').addClass('borderAktiv');
            $('#vorstand_4').removeClass('borderInAktiv');     
            });
            break; 
    }    
    old_vorstand = current_vorstand;
}
 
$(document).ready(function() {
    // do stuff when DOM is ready 
    vorstand_count = $("#contVorstand div.changeImages").size(); 
    vorstand_interval = setInterval("vorstandRotate('undefined')",3500);
    // changeImages onClick 
    $('#contVorstand div.changeImages').click( function() {
        var mode = $(this).attr("id");   
        /*flag = "1";*/
        vorstandRotate(mode);
        return false;
        clearInterval(vorstand_interval);    
    });
    //pause onHover
    $('#contVorstand div.changeImages').hover( function() {
        /*flag = "1";
        $(this).addClass('borderAktiv');
        $(this).removeClass('borderInAktiv');*/
        clearInterval(vorstand_interval);
    },
    function() {
        /*flag = "0";
        $(this).addClass('borderInAktiv');
        $(this).removeClass('borderAktiv'); */
        vorstand_interval = setInterval("vorstandRotate('undefined')",3500);
    }); 
});

