/* Rating for Pages */

var rating_msg = ['Rate Me:','Poor','Not bad','OK','Good','Awesome!'];
var rating_show_msg = true;
var rating_inline = false;

function rating_init_nomsg() {
	rating_show_msg = false;
	rating_inline = true;
	rating_init();
}

function rating_init() {
	$('static_rating').style.display = "none";
	$('static_rating').style.width= "100px";
	if(rating_inline) {
		$('dynamic_rating').style.display = "inline";
	} else {
		$('dynamic_rating').style.display = "block";
	}
	//alert('star'+i);
	$('star1').onmouseover = function() { rating_change(1,0); }
	$('star1').onmouseout = function() { rating_change(1,1); }
	$('star2').onmouseover = function() { rating_change(2,0); }
	$('star2').onmouseout = function() { rating_change(2,1); }
	$('star3').onmouseover = function() { rating_change(3,0); }
	$('star3').onmouseout = function() { rating_change(3,1); }
	$('star4').onmouseover = function() { rating_change(4,0); }
	$('star4').onmouseout = function() { rating_change(4,1); }
	$('star5').onmouseover = function() { rating_change(5,0); }
	$('star5').onmouseout = function() { rating_change(5,1); }	
}

function rating_change(pos,action) {
	//Mouse out
	if(action == 1) {
		if(rating_show_msg) {
			$('rating_text').innerHTML = rating_msg[0];
		}
		for(var i=1; i<=5; i++) {
			$('star'+i).className = 'star';
		}			
	} else {	
		if(rating_show_msg) {
			$('rating_text').innerHTML = rating_msg[pos];
		}
		for(var i=1; i<=pos; i++) {
			$('star'+i).className = 'star over';
		}
	}
}

function story_rating_init() {
	$('dynamicStoryRating').style.display = "inline";
	$('staticStoryRating').style.display = "none";
		
	$('star1').onmouseover = function() { story_rating_change(1,0); }
	$('star1').onmouseout = function() { story_rating_change(1,1); }
	$('star2').onmouseover = function() { story_rating_change(2,0); }
	$('star2').onmouseout = function() { story_rating_change(2,1); }
	$('star3').onmouseover = function() { story_rating_change(3,0); }
	$('star3').onmouseout = function() { story_rating_change(3,1); }
	$('star4').onmouseover = function() { story_rating_change(4,0); }
	$('star4').onmouseout = function() { story_rating_change(4,1); }
	$('star5').onmouseover = function() { story_rating_change(5,0); }
	$('star5').onmouseout = function() { story_rating_change(5,1); }	
}



function story_rating_change(pos,action) {
	//Mouse out
	if(action == 1) {
		for(var i=1; i<=5; i++) {
			$('star'+i).src = story_rating_img_off;
		}			
	} else {
		for(var i=1; i<=pos; i++) {
			$('star'+i).src = story_rating_img_on;
		}
	}
}
