var bar_length = 100; // the bar will be this many pixels long
var wait = 1000; // How many milliseconds to wait for other browsers
function progress_bar(new_width,j,loggedin){
	var image_count = 4;
	var bar_part = Math.round((bar_length) / image_count);
	var bar_perc = Math.round(100 / image_count);

	if (!new_width) var new_width = 0; // Will become new width of progress bar
	if (!j) var j = 0;  // count how many images are complete
	var percent = 0; // Add up the percentage
    document.getElementById('wbamaxpercent').innerHTML = image_count;

    jQuery.get('_check.php', { check: 'gam' },function(data){
        percent = percent + bar_perc;
        new_width = new_width + bar_part;
        j = j + 1;

	   document.getElementById('wbarpercent').innerHTML = j;
	   document.getElementById('wbarp').style.width = new_width + '%';
    
    	if (new_width < bar_length && data == '1'){
            jQuery('#wbar').css({'display':""});
    		setTimeout('progress_bar('+new_width+','+j+',"'+loggedin+'");', wait);
            //jQuery('.ui-widget-overlay').css({display:'block'});
            jQuery('.ui-widget-overlay').css({height:jQuery(document).height()});
    	}else {
    		if (data == '2') {
                //close_bar();
                jQuery('#wbar').css({'display':"none"});
            }else {
                jQuery('#msgERROR').css({display : ''});
                jQuery('#msgINFO').css({display : 'none'});
    		}
    	}
    });
}
function close_bar(){
    window.location.reload()
}
