	var msnrr_rated = true;
	function UCI(section, imgId)
	{
		var elmImg = document.getElementById(imgId);
		if (elmImg.disabled)
			return;
		elmImg.src = section.attributes["i"].value;
	}
	
	function URI(imgId)
	{
		var elmImg = document.getElementById(imgId);
		if (elmImg.disabled)
			return;
		var originalImg = elmImg.attributes["originalImg"].value;
		elmImg.src = originalImg;
	}		
	
	function UR(imgPath, imgId, value, cv, area)
	{
		var map = document.getElementsByName(imgId + "Map")[0];
		if (map)
		{
			var hp = map.attributes["hp"].value;
			var ct = map.attributes["ct"].value;
			var ii = map.attributes["ii"].value;
			var it = map.attributes["it"].value;
			var ai = map.attributes["ai"].value;
			var key = map.attributes["key"].value;
			var hc = map.attributes["hc"].value;
			var rtxt = (map.attributes["rtxt"]?map.attributes["rtxt"].value.replace(/%userrating%/gi, area.attributes["v"].value):null);

			var elmImg = document.getElementById(imgId);
			var usrKey = key.replace(/ /g, '_');
			if (!elmImg.disabled)
			{
				if (document.cookie.indexOf(key + "=") < 0)
				{
					var attr, usr = 0;
					var usrrat = document.getElementById("rrur_" + imgId);
					if(usrrat.expires == '')
					{
						try
						{
							usrrat.load(ct);
							attr = usrrat.getAttribute('r' + hc);
							if (attr)
								usr = attr.indexOf(' ' + usrKey + ' ') + 1;
							else
								attr = '';
						}
						catch(e)
						{ }
					}
					var img = document.getElementById("rrir_" + imgId);
					img.src = hp + "?ct=" + ct + "&ii=" + ii + "&it=" + it + "&ai=" + ai + "&r=" + value + "&c=" + cv + "&u=" + usr;
					if(usrrat.expires == '' && usr < 1)
					{
						try
						{
							usrrat.setAttribute('r' + hc, attr + ' ' + usrKey + ' ');
							usrrat.save(ct);
						}
						catch(e)
						{ }
					}
					if (elmImg)
					{
						elmImg.attributes["originalImg"].value = imgPath;
						elmImg.src = imgPath;
					}
				}
				var div = document.getElementById("divUCnt" + imgId);
				if (div)
					div.style.display = "none";
				div = document.getElementById("rrdivthanks" + imgId);
				if (div)
					div.style.display = "";
				if (div)
				{
				div.innerHTML = "&#160;&#160;&#160;Current&#160;rating:&#160;<b>" + usrRating + "</b>&#160;by&#160;<b>" + totalUsers +"</b>&#160;users"
					div.style.display = "";
				}

				Disable(imgId, rtxt, null);
				
				return false;
			}
		}
	}
	
	function Disable(imgId, rtxt, dval)
	{
		var elmImg = document.getElementById(imgId);
		if (elmImg)
		{
			elmImg.disabled = true;
			elmImg.style.cursor = "default";
			var map = document.getElementsByName(imgId + "Map")[0];
			if (map)
			{
				for(i = 0; i < map.childNodes.length; i++)
				{
					var area = map.childNodes[i];
					if (area.nodeName == "AREA")
					{
						if(rtxt != null)
							area.setAttribute("alt", rtxt.replace(/%userrating%/gi, dval));
						area.removeAttribute("href");
					}
				}
			}
		}
	}
	
	function UGR(imgId)
	{
		var map = document.getElementsByName(imgId + "Map")[0];
		if (map)
		{
			var key = map.attributes["key"].value;
			var rtxt = (map.attributes["rtxt"]?map.attributes["rtxt"].value:null);
			var dc = document.cookie;
			var search = key + "=";
			var pos = dc.indexOf("; " + search);
			if (pos == -1) 
			{
				pos = dc.indexOf(search);
				if (pos == -1) return;
			} 
			else
			{
				pos += 2;
			}
			var pos2 = dc.indexOf(";", pos);
			if (pos2 == -1)
				pos2 = dc.length;
			var val = unescape(dc.substring(pos + search.length, pos2));
			
			var elmImg = document.getElementById(imgId);
			if (elmImg && val)
			{
				var div = document.getElementById("divUCnt" + imgId);
				if (div)
				{
					div.innerHTML = "&#160;&#160;&#160;Current&#160;rating:&#160;<b>" + usrRating + "</b>&#160;by&#160;<b>" + totalUsers +"</b>&#160;users"
					div.style.display = "none";
				}
				
				var a = GetMapArea(imgId, val);
				if (a)
				{
					elmImg.attributes["originalImg"].value = a.attributes["i"].value;
					elmImg.src = a.attributes["i"].value;
					Disable(imgId, rtxt, a.attributes["v"].value);
				}
			}
		}
	}
	
	function GetMapArea(imgId, idx)
	{
		var map = document.getElementsByName(imgId + "Map")[0];
		if (map)
		{
			var a = 0;
			for(i = 0; i < map.childNodes.length; i++)
			{
				var area = map.childNodes[i];
				if (area.nodeName == "AREA" && a++==idx)
					return area;
			}
		}
	}
	
	function WriteRatings()
	{
		if (msnrr_rated)
		{
			var div = document.getElementById("userRatingTotal");
			if (div)
			{
				div.innerHTML = "&#160;&#160;&#160;Current&#160;rating:&#160;<b>" + usrRating + "</b>&#160;by&#160;<b>" + totalUsers +"</b>&#160;users"
				div.style.display = "";
			}
		}			
	}