﻿function generateLoopBackground(images,delay) {

    window.setInterval(function () {
            var randomValue = $.randomBetween(0, (images.length - 1));
            var path = images[randomValue];
            loadBackgroundBodyImage(path)
        }, delay);

};
function loadBackgroundBodyImage(Path) {
    var img = new Image();
    $(img).load(function () {
        //$('#bck').id = 'toberemoved';
        //hide the loaded image
        $(this).hide();
        img.ID = 'bck';
        var url = 'url("' + Path + '")'
        $('body').css('background-image', url)
        //.append(this);
        //$('body').hide();
        //$(this).fadeIn(3000);
        //$('#toberemoved').remove();
    }).attr('src', Path);
}
