/**************************************************************************************************/
/*  Bg fader is developed by puredesign(.be)
/**************************************************************************************************/
var bg_amount       = 11;
var fotoFolder      = 'images/';
var photoExt        = 'jpg';
var myFotos         = new Array();
//
Array.prototype.shuffle = function (){
    var i = this.length, j, temp;
    if ( i == 0 ) return;
    while ( --i ) {
        j = Math.floor( Math.random() * ( i + 1 ) );
        temp = this[i];
        this[i] = this[j];
        this[j] = temp;
    }
};
///

for(i=0;i<bg_amount;i++){
    if(i<10){
        myFotos[i] = 'schoenwinkel-'+(i+1)+'.'+photoExt;
    }
    else{
        myFotos[i] = 'schoenwinkel-'+(i+1)+'.'+photoExt;
    }
}
myFotos.shuffle();
var bg_begin        = 0;
var bg_current      = bg_begin;
var bg_next         = 0;
var bg_img          = '';
var fade_seconds    = 4000;  // 1 sec = 1000
$(function() {
    $(".slide-photo").attr("src","images/"+(myFotos[bg_next]));
    var item_interval = setInterval(fadeNext,fade_seconds); 
});
function fadeNext(){
    if(bg_current==(bg_amount-1)){
        bg_next = 0;
    }
    else{
        bg_next = bg_current+1;
    }
    $(".slide-photo").hide()
    $(".slide-photo").attr("src","images/"+(myFotos[bg_next]));
    $(".slide-photo").fadeIn("normal");
    bg_current = bg_next;
}
