<div class="topgames widget">
	
    <div class="title-caption">
		
        <h3><?php echo $instance['title'] ?></h3>
		
    </div><!--/ .title-captin -->
	
    <div class="entry-holder">

        <?php
		
        $rated_users = Thememakers_Entity_Rating::get_users_rating();
        $user_ids = array_keys($rated_users);
        $user_ids = implode(",", $user_ids);
        global $wpdb;
        $users = $wpdb->get_results("SELECT ID,display_name FROM $wpdb->users WHERE ID IN($user_ids)");
        $max_rating = Thememakers_Entity_Rating::get_max_rating_number();
		
		?>
		
				
        <ul>
			
            <?php foreach ($users as $key => $user) : ?>
			
                <?php if ($key >= $instance['count']) break; ?>
			
                <li>
					
                    <?php $unique_id = uniqid(); ?>
					
                    <a class="vtop" href="<?php echo ThemeMakersUser::get_profile_url($user->ID) ?>">
						<?php echo $user->display_name ?>
					</a>
					
					&nbsp;<span class="star rating_<?php echo $unique_id ?>"></span>

                    <script type="text/javascript">
						
                        jQuery(function(){
                            jQuery('.rating_<?php echo $unique_id ?>').raty({
                                half:  true,
                                readOnly: true,
                                number:<?php echo $max_rating ?>,
                                score: parseFloat(<?php echo $rated_users[$user->ID] ?>)
                            });
                        });
						
                    </script>

                </li>
				
            <?php endforeach; ?>
				
        </ul>

    </div><!--/ .entry-holder-->
	
</div><!--/ .topgames-->


