
// Avoid showing progress bar when the page already loaded
// sow it only after a small delay
setTimeout("showProgressBar()", 600);

function showProgressBar() {
    $("#progressBarRoot").css("display", 'block');
}

/*______________________________________________________________________________________________________________________*/
function setPercentage(percent) {
    if (percent >= 100) {
        
        $("#progressBar").animate({ width: "800px" }, 50,
            function () {document.getElementById("progressText").innerHTML = "100 %";
                          $("#carWhite").css("display", 'none');
                          $("#carBlue").css("display", 'block'); 
                          setTimeout("hideProgressBar()", 50); });               
    }
    else {
        var pixels = 800 * (percent / 90);
        $("#progressBar").animate({ width: pixels + 'px' }, 50);
        document.getElementById("progressText").innerHTML = percent + " %";
    }
}

var last = 0;
var countLoaded = 0;
function percentage(imageCount, imgId) {
    // on some browsers we get called twice on the same image
    if (last == imgId) return;
    
    last = imgId;

    countLoaded++;

    if (imageCount > 0) {
        setPercentage(Math.ceil(countLoaded * 100 / imageCount));
    }
  }
/*______________________________________________________________________________________________________________________*/

function hide_div(id_div) {
    $("#" + id_div).hide();
}
/*______________________________________________________________________________________________________________________*/

function hideProgressBar() {
    hide_div('intro_loading');
    $("#content").css("display", 'block');
    $("#container").css("display", 'block');
}


