<?php
// +------------------------------------------------------------------------+
// | PHP Melody version 1.6.7 ( www.phpsugar.com )
// +------------------------------------------------------------------------+
// | PHP Melody IS NOT FREE SOFTWARE
// | If you have downloaded this software from a website other
// | than www.phpsugar.com or if you have received
// | this software from someone who is not a representative of
// | phpSugar, you are involved in an illegal activity.
// | ---
// | In such case, please contact: support@phpsugar.com.
// +------------------------------------------------------------------------+
// | Developed by: phpSugar (www.phpsugar.com) / support@phpsugar.com
// | Copyright: (c) 2004-2011 PhpSugar.com. All rights reserved.
// +------------------------------------------------------------------------+

require('config.php');
require_once('include/functions.php');

function rating_bar($id) 
{
	global $lang;
	
	$tableName = "pm_ratings";

	$query		= mysql_query("SELECT total_votes, total_value, used_ips FROM $tableName WHERE id = \"$id\" ");
	$numbers	= mysql_fetch_assoc($query);
	$count = $numbers['total_votes'];//how many votes total
	$current_rating = $numbers['total_value'];//total number of rating added together and stored
	$tense = ($count==1) ? "vote" : "votes";//plural form votes/vote
	
	$ip = $_SERVER['REMOTE_ADDR'];
	?>
				<div id="unit_long<?php echo $id ?>">
				<ul class="unit-rating">
				<li class='current-rating' style="width:<?php echo @number_format($current_rating/$count,2)*20; ?>px;">
				<?php 
					echo sprintf($lang['currently'], @number_format($current_rating/$count,2));
				?>
				</li>
					<?php
					for ($ncount = 1; $ncount <= 5; $ncount++) { ?>
						<li><a href="#" title="<?php sprintf($lang['rating_count'], $ncount);?>" class="r<?php echo $ncount ?>-unit" onclick="javascript:sndReq('<?php echo $ncount ?>','<?php echo $id ?>','<?php echo $ip ?>', '<?php echo _URL; ?>')"><?php echo $ncount ?></a></li>
				<?php	}
					$ncount = 0; // resets the count
					?>
				</ul>
	<span style="font-size: 9px;">
	<?php
		if($count == '') $count = 0;
		echo sprintf($lang['show_rating'], @number_format($current_rating/$count,1), $count, $tense); ?>
	</span> 
				</div>
<?php
}
?>