<?php
 if ($prgdone > $prgtotal) {
	$prgdone = $prgtotal;
 }
 //calculate the fill width of the progress bar
 $fill_width = round((($prgwidth- imagesx($bg_cap)) * $prgdone) / $prgtotal) - imagesx($fill_cap);

 //calculate the percent for the users use
 $rankpercent = round(($prgdone / $prgtotal) * 100, $prg_decimal)."%";
 
 //create bar
 $progressbar = imagecreatetruecolor($prgwidth, imagesy($bg));
 imagecopy($progressbar, $bg, 0, 0, 0, 0, imagesx($bg), $prgwidth- imagesx($bg_cap));
 imagecopy($progressbar, $bg_cap, $prgwidth- imagesx($bg_cap), 0, 0, 0, imagesx($bg_cap), imagesy($bg_cap));
 imagecopy($progressbar, $fill, 0, 0, 0, 0, $fill_width, imagesy($fill));
 imagecopy($progressbar, $fill_cap, $fill_width, 0, 0, 0, imagesx($fill_cap), imagesy($fill_cap));

?>