function tcookie()
{
	var o = $i("ta_message");
	if(o == null) return true;

	var v = o.value;
	v = v.replace(/^\s+|\s+$/g, "");
	v = v.replace(/\r\n/, "\\r\\n")

	if(v.length > 0)
		document.cookie = "tm=m=" + escape(v) + ",; path=/;";
}

function _cpost()
{
	var o = $i("ta_message");
	var b = $i("sub_b");

	if(o == null || b == null) return;

	var v = o.value;
	v = v.replace(/^\s+|\s+$/g, "");
	if(v.length < 3)
	{
		disableButton(b);
	
		return;
	}
	
	enableButton(b);

}

function post_rte(isLoggedIn)
{
	//var o = $i("ta_message");
	var o = $i("rte_text");
	var b = $i("sub_b");
	var f = $i("felm");
	if(b == null || f == null) return;
	
	if($i("rte_html").value.length > 10000)
	{
		alert('The post body is too long, \n\rPlease remove some text.');
		return false;
	}
	/*
	if(!isLoggedIn)
	{
		if(_check_sp(o.value))
		{
			//b.disabled = true;
			return false;
		}
	}
	*/
	var so = o.value;
	so = so.replace(/^\s+|\s+$/g, "");
	o.value = so;

	if(so.length < 3)
	{
		alert("No text entered.");
		return false;
	}	
	
	//b.disabled = true;
	
	return true;
}
function post_notrte(isLoggedIn)
{
	//var o = $i("ta_message");
	var o = $i("rte_text");
	var b = $i("sub_b");
	var f = $i("felm");
	if(b == null || f == null) return;
	

	var so = o.value;
	so = so.replace(/^\s+|\s+$/g, "");
	o.value = so;

	if(so.length < 3)
	{
		alert("No text entered.");
		return false;
	}	

	
	return true;
}

function post()
{
	var o = $i("ta_message");
	var b = $i("sub_b");
	var f = $i("felm");
	if(b == null || f == null) return;
	
	if(_check_sp(o.value))
	{
		b.disabled = true;
		return false;
	}

	b.disabled = true;
	
	return true;
}

function _cpost_id(id)
{
	var o = $i("ta_message" + id);
	var b = $i("sub_b" + id);

	if(o == null || b == null) return;

	var v = o.value;
	v = v.replace(/^\s+|\s+$/g, "");
	if(v.length < 3)
	{
		b.disabled = true;	
		if(b.className == "g_button")
			b.className = "g_buttondis";
		return;
	}
	
	b.disabled = false;
	if(b.className == "g_buttondis")
		b.className = "g_button";
}

function post_id(id)
{
	var o = $i("ta_message" + id);
	var b = $i("sub_b" + id);
	var f = $i("felm" + id);
	if(b == null || f == null) return;
	
	if(_check_sp(o.value))
	{
		b.disabled = true;
		if(b.className == "g_button")
			b.className = "g_buttondis";		
		return false;
	}
	b.disabled = true;
	if(b.className == "g_button")
			b.className = "g_buttondis";	
	f.submit();
	return true;
}

function tcookie_id(id)
{
	var o = $i("ta_message" + id);
	if(o == null) return true;

	var v = o.value;
	v = v.replace(/^\s+|\s+$/g, "");
	v = v.replace(/\r\n/, "\\r\\n")

	if(v.length > 0)
		document.cookie = "tm=m=" + escape(v) + ",; path=/;";
}

function reply(id)
{
	var o = $i("ocs" + id);
	if(o != null)
	{
		o.style.display = "block";
	}
	
}

function confirmVote(thisLink)
{
	var yesLink = $i('vote_confirmed');
	
	if(typeof thisLink.href == 'undefined' || yesLink == null)
		return false;
		
	doModal();
	yesLink.href = thisLink.href;
	
	ShowCenteredAlertDIV('confirm_vote');
}

function submitGSAccept(url, msgid)
{
	var myAjax = new Ajax.Request(
        url,
        {
	        method: 'get',
	        onSuccess: function(oHttp)
	        {
				$('frmRate' + msgid).submit();		
	        }
        }
	);
}
