var $indi = jQuery.noConflict();
var sliderPostition = 0;
var activeLinks = 1;
var ani = 1;

var anzahlBilder = 4;
var sliderMaxPos = (anzahlBilder -1) * (-728);

$indi(document).ready(function(){
  setInterval(function() {
  	if(ani== 1){
        if(sliderPostition >  sliderMaxPos ){
            moveRight();
        }
        else{
            sliderPostition = 728;
            moveRight();
        }
     }
   }, 5000);
 
    $indi('#links a').mouseenter(function(){
        $indi('#'+ $indi(this).attr('id')).animate({
            'top' : '-5px'
        }, 200, function() {
          
            });
    }).mouseleave(function(){
        $indi('#'+ $indi(this).attr('id')).animate({
           
            'top':'0px'
        }, 200, function() {
            
            });
    });
    
    $indi('#banner .item').mouseenter(function(){
       ani = 0;
     
    }).mouseleave(function(){
         ani = 1;    
    });


    $indi('.topitem').mouseenter(function(){
        $indi(this).animate({
            'margin-top' : '-4px'
        }, 200, function() {
            // Animation complete.
        });
    }).mouseleave(function(){
        $indi(this).animate({
            'margin-top':'0px'
        }, 200, function() {
            // Animation complete.
        });
    });

    switchLinks();
    
    $indi('#move_left').click(function(){
        if(sliderPostition < 0){
            moveLeft(); 
            ani = 0;
        }
 
    });

    $indi('#move_right').click(function(){
        if(sliderPostition > sliderMaxPos){
            moveRight();
        //switchLinks();
        }
        else{
            sliderPostition = 728;
            moveRight();

        }
        ani = 0;
    });
    
    $indi("#moreInfos").click(function(){
        showMoreInfos();
        return false;
    });
    
    
     $indi("#closeText").click(function(){
        closeMoreInfos();
        return false;
    });
  
 
});

function showMoreInfos(){
    $indi("#mask").addClass("on");
    $indi("#moreText").fadeIn("slow");
   
}

function closeMoreInfos(){
    $indi("#mask").fadeOut("slow");
    $indi("#mask").removeClass("on");
    
     $indi("#mask").show("slow");
    $indi("#moreText").fadeOut("slow");
   
}

function switchLinks(){

    $indi('#linkcon1').animate({
        top: '-140px'
    }, 400, function() {
        // Animation complete.
        });
    $indi('#linkcon2').animate({
        top: '-140px'
    }, 400, function() {
        // Animation complete.
        });
    $indi('#linkcon3').animate({
        top: '-140px'
    }, 400, function() {
        // Animation complete.
        });

    $indi('#linkcon' + GetRandom(1,1)).animate({
        top: '5px'
    }, 500, function() {
        // Animation complete.
        });
}

function moveLeft(){

    sliderPostition += 728;
    $indi('#bannerSlider').animate({
        left: sliderPostition
    }, 700, function() {
        animation = true;
    });
 
}

function moveRight(){
  
    sliderPostition -= 728;
    $indi('#bannerSlider').animate({
        left: sliderPostition
    }, 700, function() {
        animation = true;
    });

}

function GetRandom( min, max ) {
    if( min > max ) {
        return( -1 );
    }
    if( min == max ) {
        return( min );
    }

    return(min + parseInt( Math.random() * ( max-min+1 )));
}

 


