/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function getRandomNum(lbound, ubound) {
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}

function getRandomChar() {
var numberChars = "0123456789";
var lowerChars = "abcdefghijklmnopqrstuvwxyz";
var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var otherChars = "";

charSet="";
charSet += numberChars;
charSet += lowerChars;
charSet += upperChars;


return charSet.charAt(getRandomNum(0, charSet.length));
}


function initParallax(){
    
  



    // Declare parallax on layers
    jQuery('#backgroundhelper>div.bhbg').parallax(
    {'xparallax':'10%','yparallax':'2%','decay':0}
    );
       

    
}


$j(document).ready(function() {
  
  
  
  
jQuery('#backgroundhelper .layer2').append('<div class="bubbles" style="position:absolute;left:'+getRandomNum(0,20)+'%;top:'+getRandomNum(30,60)+'%;">'+getRandomChar()+'</div>');
jQuery('#backgroundhelper .layer3').append('<div class="bubbles" style="position:absolute;left:'+getRandomNum(0,30)+'%;top:'+getRandomNum(30,70)+'%;">'+getRandomChar()+'</div>');
jQuery('#backgroundhelper .layer2').append('<div class="bubbles" style="position:absolute;left:'+getRandomNum(50,88)+'%;top:'+getRandomNum(20,60)+'%;">'+getRandomChar()+'</div>');
jQuery('#backgroundhelper .layer3').append('<div class="bubbles" style="position:absolute;left:'+getRandomNum(60,90)+'%;top:'+getRandomNum(20,70)+'%;">'+getRandomChar()+'</div>');
jQuery('#backgroundhelper .layer2').append('<div class="bubbles" style="position:absolute;left:'+getRandomNum(0,100)+'%;top:'+getRandomNum(60,100)+'%;">'+getRandomChar()+'</div>');
jQuery('#backgroundhelper .layer3').append('<div class="bubbles" style="position:absolute;left:'+getRandomNum(0,100)+'%;top:'+getRandomNum(60,100)+'%;">'+getRandomChar()+'</div>');


  
  
       initParallax();
       
       $j(window).resize(function(){initParallax();});
       
    $j("div.image_container a").not("div.mod_gallerylist div.image_container a").colorbox();   

	$j('a[rel="lightbox"]').colorbox();
        
       
        
        $j('img[alt="youtube"]', 'a.newslinkinvisible').colorbox({ html: function(){
    var url = $j(this).parent().parent().attr('href');
    return '<iframe width="600" height="437" frameborder="0" src="'+url+'" class="polaroid"></iframe>';
}});
$j('a.youtube').colorbox({ html: function(){
    var url = $j(this).attr('href');
    return '<iframe width="600" height="437" frameborder="0" src="'+url+'" class="polaroid"></iframe>';
}});


        
   /*
   $j(".homenewsimage").each(function(){
       var altebreite=$j("img",this).width();
       $j("img",this).width('100');
       
       $j("img",this).height(100/altebreite *$j("img",this).height());
       
       
   });*/
   
   
      
   $j(".ausdersicht").each(function(){
       $j(this).mouseenter(function(){
           $j(this).fadeTo('fast',1);
       });
       $j(this).mouseleave(function(){
           $j(this).fadeTo('fast',0.7);
       });
       
   });
   
   
   
   
   
    $j('#slider').nivoSlider({
        effect: 'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices: 15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed: 500, // Slide transition speed
        pauseTime: 4000, // How long each slide will show
        startSlide: 0, // Set starting Slide (0 index)
        directionNav: false, // Next & Prev navigation
        directionNavHide: true, // Only show on hover
        controlNav: true, // 1,2,3... navigation
        controlNavThumbs: false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel: false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav: true, // Use left & right arrows
        pauseOnHover: false, // Stop animation while hovering
        manualAdvance: false, // Force manual transitions
        captionOpacity: 0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
    
    
    
    $j(".slider-wrapper").mousemove(function(event) {
        var os=0;
        os=event.pageY-$j(".slider-wrapper").offset().top-20;


        if(os<=0&&os>-56){$j("#slideroverlay").css("top","0px");}

        if(os>=596&&os<652){$j("#slideroverlay").css("top","596px");}

        if(os>0&&os<596){
        //$j("#slideroverlay").stop(true,false);
        //$j("#slideroverlay").animate({top:event.pageY-$j(".slider-wrapper").offset().top-20}, 300);

        $j("#slideroverlay").css("top",os+"px");

        }

    });


    var choehe=500;
    
    if($j(".fullhighlight").height()+$j("#main").height()>choehe){choehe=$j(".fullhighlight").height()+$j("#main").height();}
    if($j(".fullhighlight").height()+$j("#right").height()>choehe){choehe=$j(".fullhighlight").height()+$j("#right").height();}
    
    
    
    $j("#container").css("min-height",choehe+"px");
    
    var whoehe=800;
    
    if($j("#header").height()+$j("#container").height()+$j("#footer").height()>whoehe){whoehe=$j("#header").height()+$j("#container").height()+$j("#footer").height();}
   
    
    
    $j("#wrapper").css("min-height",whoehe+"px");
   
  
});


