	var ajaxRequest = function(s,i) {
		// Send off our score to the DB
		$.ajax({
			url: '../include/scoring.php?s=' + s + '&i=' + i,
			success: function(data) {
				var result = data.split('|');
				$('#confirmation div p').remove();
				if(result[0] == 1) {
					$('#confirmation div').prepend('<p>Your rating of <span>' + result[1] + '</span> out of <span>5</span> for this contender was successful.</p><p class="buttons"><a href="#">Close</a></p>');
				} else if(result[0] == 2) {
					$('#confirmation div').prepend('<p>You have already voted for this contender today.</p><p class="buttons"><a href="#">Close</a></p>');
				} else {
					$('#confirmation div').prepend('<p>There was a problem, please try rating this contender again.</p><p class="buttons"><a href="#">Close</a></p>');
				}
				$('#confirmation a').click(function() { window.location.reload(); });
			}
		});

	}
	
	var RatingConfimation = function(t,e,s,id) {
		$('body').prepend('<div id="confirmation"><p class="upper"></p><div><p>Please confirm that you want the rate this contender <span>' + s + '</span> out of <span>5</span>.</p><p class="buttons"><a class="yes" href="yes">Yes</a><a class="no" href="no">No</a></p></div><p class="lower"></p></div>');
		var ePos = $(t).offset();
		var newLeft = (ePos.left + ($(t).width() / 2)) - ($('#confirmation').width() / 2);
		var newTop = ePos.top - ($('#confirmation').height() + 5);
		$('#confirmation').css( { left: newLeft +"px", top: newTop + "px"} );
		$('#confirmation .yes').click(function() { ajaxRequest(s,id); return false; } );
		$('#confirmation .no').click(function() { $('#confirmation').remove(); return false; });
	}
	
	var RatingPanelMouseEnter = function(e) {
		// Get element position
		var ePos = $(this).offset();
		
		// Get mouse position
		var mPos = { left: e.pageX, top: e.pageY };
		
		// Get slider position
		var newWidth = Math.ceil(mPos.left - ePos.left);
		
		// Set slider position
		$(this).children('span.active').css( { width: newWidth + 'px' } );
	}
	
	var RatingPanelMouseClick = function(e) {
		// Get width of rating image (multiply it by 100 so it's easier for me to visualise... yeah, yeah. I'm not good a maths...)
		var iWidth = ($(this).children('img').width()) * 100;
		
		// Get 1/4 of a star with our funky image width
		var fractionScore = iWidth / 20;
		
		// Get our scaled with of our "active / hover" star panel
		var sWidth = ($(this).children('span.active').width()) * 100;
		
		// Get how many "quarters" (1/4th) of a star is show
		var fractionAmount = Math.round(sWidth / fractionScore);
		
		// Conver our "quarters" (1/4th) of a star into "whole" stars...
		var score = fractionAmount / 4;
		
		// DO THIS TO FIX 0.25 ISSUE -- This is cause by the small space between the stars... need to investigate a better fix
		/*var text = score.toString().split('.');
		if(text.length == 2) {
			score = (text[1] == "25") ? parseFloat(text[0]) : parseFloat(text[0] + ".5");
		} else {
			score = parseFloat(text[0]);
		}*/
		
		if(score > 5) {
			score = 5;
		} else {
			score = Math.round(score);
		}
		
		// Now covert our score (that we will soon send to the DB) to pixels
		
		var percentRating = (score / 5) * 100;
		
		var pixels = (($(this).children('img').width() / 100) * percentRating) + 1;
		
		$(this).children('span.active').css( { width: pixels + 'px' } );
	
		RatingConfimation(this,e,score,$(this).attr('id'));
	}
