arr_reviews = Array();
arr_reviews[1] = Array('Pro Dunk Diamond Basketball System', 5, 41, '../basketball_goals/adjustable_in_ground/pro_dunk_diamond.php');
arr_reviews[2] = Array('Pro Dunk Platinum Basketball System', 5, 164, '../basketball_goals/adjustable_in_ground/pro_dunk_platinum.php');
arr_reviews[3] = Array('Pro Dunk Gold Basketball System', 5, 167, '../basketball_goals/adjustable_in_ground/pro_dunk_gold.php');
arr_reviews[4] = Array('Pro Dunk Silver Basketball System', 5, 130, '../basketball_goals/adjustable_in_ground/pro_dunk_silver.php');
arr_reviews[16] = Array('Hercules Diamond Basketball System', 5, 14, '../basketball_goals/fixed_height_in_ground/hercules_diamond.php');
arr_reviews[102] = Array('Hercules Platinum Basketball System', 4.5, 8, '../basketball_goals/fixed_height_in_ground/hercules_platinum.php');
arr_reviews[113] = Array('Hercules Gold Basketball System', 5, 13, '../basketball_goals/fixed_height_in_ground/hercules_gold.php');
arr_reviews[124] = Array('Roof King Platinum Basketball System', 4.5, 7, '../basketball_goals/roof_wall/roof_king_platinum.php');
arr_reviews[129] = Array('Roof King Gold Basketball System', 4.5, 4, '../basketball_goals/roof_wall/roof_king_gold.php');
items_per_page = 2;

function init_reviews_pagination(){
	
	
	
	$('.review_stars').each(function(index){
		
		
		
		el = $(this);
		
		product_id = el.attr('product_id');
		
		
		
		// Get product and review details
		
		if(typeof(arr_reviews[product_id]) != 'undefined'){
			
			
			
			arr_review_summary = arr_reviews[product_id];
			
			title_tag = arr_review_summary[2] + ' customer reviews with an average rating of ' + arr_review_summary[1] + ' out of 5 stars';

			href = arr_review_summary[3];

			src = 'images/design/reviews/' + arr_review_summary[1] + '_star_v1.gif';
			

			
			target = el.attr('target');
			

			
			html = '<a title="' + title_tag + '" href="' + path + href + '" target="' + target + '"><img style="border:0;" src="' + path + src + '"/></a>';
			
			el.after(html);
			
		}
		
		
		
	});
	
	if(typeof(jQuery.PaginationCalculator) == 'function'){
		var num_entries = $('#reviews_all div.review_entry').length;
		
		$(".reviews_pagination").pagination(num_entries, {
			callback: pageselectCallback,
			items_per_page:items_per_page
		});
	}
}

$(document).ready(function(){      
	init_reviews_pagination();
});

function pageselectCallback(page_index, jq){
	
	// Get index based on page
	index = page_index * items_per_page;
	
	// From
	$('#reviews_pagination_from').html(index+1);
	
	// To
	num_entries = $('#reviews_all div.review_entry').length;
	if(index+items_per_page > num_entries) pagination_to = num_entries;
	else pagination_to = index+items_per_page
	$('#reviews_pagination_to').html(pagination_to);
	
	// Update DOM
	$('#reviews_some').empty();
	for(i=index;i<index+items_per_page;i++){
		$('#reviews_some').append($('#reviews_all div.review_entry:eq('+i+')').clone());
	}
	
	return false;
	
}

function reviews_sort(){
	$('#reviews_all').load(path + 'includes/review_by_product.php',{product_id:3, sort_by:$('#reviews_sort').val(), path:path}, init_reviews_pagination);
}

