if (xhr_enabled()) {

	// NameRate Javascript - 2007,2008 Jolyon Terwilliger
	
	var voted;
	var tytext = 'Thank-you for rating this name!';
	var starMsg = new Array(6);
	starMsg[0] = 'Rate this name:';
	starMsg[1] = 'Not My Style At All';
	starMsg[2] = "Not So Good..";
	starMsg[3] = "It's Okay";
	starMsg[4] = 'Pretty Good';
	starMsg[5] = 'I Love It!';
	
	function ratename(num){
		dt = new Date();
		randVal = dt + Math.rand;
		iconwidth = 28;
		total_width = 5 * iconwidth;
		
		$.getJSON('/Names/name_display.php', {
			rating: num,
			name_id: nameID,
			rate: randVal
		}, function(data){
			var average = new String(data.avg);
			rating = average.substr(1);
			var actual = 'Average rating: ' + rating;
			
			rating_width = iconwidth * rating;
			
			$('a.rater').each(function(i){
				$(this).attr('title', actual).unbind();
			});
			
			$('ul.unit-rating').empty().prepend('<li class="current-rating" style="width: ' + rating_width + 'px;" title="' + actual + ' ~ ' + tytext + '">Current rating.</li>');
			
			$('#rating-msg').text(tytext).attr('title', actual);
			
			fpmsg = $('#fpratemsg');
			if (fpmsg) {
				$('.unit-rating').hide('500');
				fpmsg.show('500');
				setTimeout(function(){
					fpmsg.hide('500');
					$('.unit-rating').show('500');
				}, 3500);
			}
		});
		return false;
	}
	
	$(document).ready(function(){
	
		var actual = 'Total rating ' + rating;
		
		$('a.rater').each(function(i){
			if (voted) {
				$(this).attr('title', actual);
			}
			else {
				$(this) //.attr('title',starMsg[i+1])
				.mouseover(function(){
					$('#rating-msg').text(starMsg[i + 1]);
				}).mouseout(function(){
					$('#rating-msg').text(starMsg[0]);
				}).mousedown(function(){
					return ratename(i + 1);
				});
			}
		});
		
		if (voted) {
			$('#rating-msg').text(tytext).attr('title', actual);
		}
		else {
			$('#rating-msg').text(starMsg[0]).attr('title', actual);
		}
	});
	
} // xhr_enabled