


	function CSR_star_over(obj, star_number)
	{
		if(/MSIE (5|6)/.test(navigator.userAgent)) obj.style.cursor ="hand";
		var csr=obj.parentNode;
		var as=csr.getElementsByTagName('label');
		for (i=0;i<star_number;++i)
		{
			as[i].lastClass = as[i].className;
			as[i].className = 'CSR_full_star';
		}
		for (;i<as.length;++i) as[i].lastClass = as[i].className;
	}



	function CSR_star_out(obj)
	{
		if(/MSIE (5|6)/.test(navigator.userAgent)) obj.style.cursor ="default";
		var as=obj.getElementsByTagName('label');
		for (i=0;i<as.length;++i)
		{
			if (as[i].lastClass) as[i].className = as[i].lastClass;
		}
	}



	function CSR_getHTTPObject()
	{
		try
		{
			return(new XMLHttpRequest());
		}
		catch(e)
		{
			var la_activex = ['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'];
			for (var i=0; i < la_activex.length; i++)
			{
				try
				{
					return(new ActiveXObject(la_activex[i]));
				}
				catch(e) { }
			}
		}		
		return(false);
	}



	function CSR_save_vote(post, comment, points)
	{
		if (CSR_http !== false)
		{
			if (!CSR_isWorking)
			{
				var lu_options = document.getElementById('CSR_options_' + comment);
				var lu_options_wait = document.getElementById('CSR_options_wait_' + comment);
				if (lu_options && lu_options_wait)
				{
					lu_options.style.display = 'none';
					lu_options_wait.style.display = 'block';
				}

				CSR_current_post = post;
				CSR_current_comment = comment;
				CSR_http.open('GET', CSR_url + 'csr-ajax-stars.php?p=' + CSR_current_post + '&c=' + CSR_current_comment + '&csr_stars=' + points, true);
				CSR_http.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
				CSR_http.setRequestHeader("charset", "utf-8");
				CSR_http.onreadystatechange = CSR_save_vote_response; 
				CSR_isWorking = true;
				CSR_http.send(null);
			}
		}
	}



	function CSR_save_vote_response()
	{
		if (CSR_http.readyState == 4)
		{
			CSR_isWorking = false;
			var cont = document.getElementById('CSR_form_' + CSR_current_post + '_' + CSR_current_comment).parentNode;
			cont.innerHTML=CSR_http.responseText;
		}
	}



	function CSR_show_most(post)
	{
		if (CSR_http !== false)
		{
			if (!CSR_isWorking)
			{
				if (CSR_most_loaded) CSR_most_loaded = false;
				CSR_current_post = post;
				CSR_http.open('GET', CSR_url + 'csr-ajax-most.php?p=' + CSR_current_post);
				CSR_http.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
				CSR_http.setRequestHeader("charset", "utf-8");
				CSR_http.onreadystatechange = CSR_show_most_response; 
				CSR_isWorking = true;
				CSR_http.send(null);
			}
		}
	}



	function CSR_show_most_response()
	{
		if (CSR_http.readyState == 4)
		{
			CSR_isWorking = false;
			CSR_most_loaded = true;

			var la_obj = CSR_get_switch_objects();
			if (la_obj === false) return;
			
			var ls_html = CSR_http.responseText;			
			la_obj['comments_rated_wait'].style.display = 'none';
			la_obj['comments_rated_content'].innerHTML = ls_html;

			if (ls_html != '') la_obj['comments_rated_content'].style.display = 'block';
			else la_obj['comments_rated_empty'].style.display = 'block';
		}
	}



	function CSR_switch(vb_list, vi_post, vs_classname)
	{
		var la_obj = CSR_get_switch_objects();
		if (la_obj === false) return;

		la_obj['link_list'].className = 			(vb_list)? vs_classname : '';
		la_obj['comments_list'].style.display = 	(vb_list)? 'block' : 'none';

		la_obj['link_rated'].className = 			(vb_list)? '' : vs_classname;
		la_obj['comments_rated'].style.display = 	(vb_list)? 'none' : 'block';

		if (!vb_list)
		{
			la_obj['comments_rated_empty'].style.display = 'none';
			la_obj['comments_rated_wait'].style.display = 'block';
			la_obj['comments_rated_content'].innerHTML = '';
			la_obj['comments_rated_content'].style.display = 'none';

			if (CSR_timer !== null) clearTimeout(CSR_timer);
			CSR_timer = setTimeout('CSR_show_most(' + vi_post + ')', 100)
		}
	}



	function CSR_get_switch_objects()
	{
		if (CSR_switch_objects !== null) return(CSR_switch_objects);
		
		var la_obj = [];
		var la_div = ['link_list', 'link_rated', 'comments_list', 'comments_rated', 'comments_rated_wait', 'comments_rated_content', 'comments_rated_empty'];
		
		for (var i = 0; i< la_div.length; i++)
		{
			var lu_obj = document.getElementById('CSR_' + la_div[i]);
			if (lu_obj) la_obj[la_div[i]] = lu_obj;
			else return(false);
		}
		
		CSR_switch_objects = la_obj;
		return(la_obj);
	}



	CSR_current_post = null;
	CSR_current_comment = null;
	CSR_http = CSR_getHTTPObject();
	CSR_isWorking = false;
	CSR_most_loaded = false;
	CSR_timer = null;
	CSR_switch_objects = null;
