var saved = new Array();
function ratingRollovers($id) {
	saveSrcs();
	var imgs = document.getElementById($id);
	results = imgs.id.match(/rating\-(\d+)/i);
	if(results.length >= 2 )
	{
		x = parseInt(results[1]);
		document.getElementById('rating-'+x).src = mainurl_rating +'html/star2.jpg';
		while(x > 0) {
			realid = "rating-"+x;
			document.getElementById(realid).src = mainurl_rating + 'html/star2.jpg';
			x--;
		}
		document.getElementById('rating-'+results[1]).onmouseout = function()
		{
			setSrcs();
		}
	}
}
function saveSrcs() {
	var images = 5;
	for(x=1;x<images+1;x++) {
		saved[x] = document.getElementById('rating-'+x).src;
	}	
}
function setSrcs() {
	for(x in saved) {
		if( document.getElementById('rating-'+x) ) {
			document.getElementById('rating-'+x).src = saved[x];
		}
	}
}
function rateEpiside(eid,rating) {
	rating = rating.match(/rating-(\d+)/i);
	if(rating.length < 2) {
		alert("Error: NO ID Present");
		return;
	}
	rating = rating[1];
	$.post(mainurl_rating + 'index.php?action=rating', {rating: rating, id: eid}, function(data) {
		if(data.match(/error:/i)) {
			alert(data);
		} else {
			hash="#new";
			window.location.href=(window.location.href.match("#bottom"))?window.location.href.split("#bottom")[0]+hash:window.location.href+hash;
		}
	});
}
