var photo_mouse_tm = new Array();
var rating_mouse_tm = 0;
var rating_texts = {1:"никак","2":"так себе",3:"хорошо",4:"отлично",5:"потрясающе!"};

function photo_mouse_out(nm,nm2,ii)
{
	if (photo_mouse_tm[ii]) return false;
	var d = document.getElementById(nm);
	if (d) photo_mouse_tm[ii] = setTimeout("document.getElementById('"+nm+"').style.display=\"none\";document.getElementById('"+nm2+"').style.display=\"none\";",10);
	return false;
}
function photo_mouse_over(nm,nm2,ii)
{
	if (photo_mouse_tm[ii]) clearTimeout(photo_mouse_tm[ii]);
	photo_mouse_tm[ii] = null;
	var d = document.getElementById(nm);
	if (d) d.style.display="block";
	d = document.getElementById(nm2);
	if (d) d.style.display="block";

}


function set_overlap_rating(rating)
{
	if (rating_mouse_tm != null)
			clearTimeout(rating_mouse_tm);
	rating_mouse_tm = null;

	for (var i = 1; i <= 5; i++)
	{
		if (i <= rating)
			document.getElementById("star_overlap_"+i).src='/im/star2.png';
		else
			document.getElementById("star_overlap_"+i).src='/im/star1.png';
	}

	if (rating > 0)
		document.getElementById("rating_text").innerHTML = rating_texts[rating];
	else
		document.getElementById("rating_text").innerHTML = document.getElementById("rating_default_text").innerHTML;
}


function clear_overlap_rating()
{
	rating_mouse_tm = setTimeout(function() { set_overlap_rating(0); },100);
}


function send_overlap_rating(photo_id,rating)
{
	var str = "";
	var new_votes = parseInt(document.getElementById("rating_votes").innerHTML)+1;
	var new_rating = Math.round(100*(parseInt(document.getElementById("rating_score").innerHTML)+rating)/new_votes)/100;
	document.getElementById("stars").innerHTML = "Ваша оценка <strong>" + rating + "</strong>, общий рейтинг <strong>" + new_rating + "</strong>, проголосовало <strong>" + new_votes + "</strong>";

	var iframe = document.createElement("iframe");
	iframe.src = "http://www.photovision.ru/rate.php?photo_id=" + photo_id + "&rate=" + rating;
	iframe.style.display = "none";
	document.body.appendChild(iframe);
}

