//<form action="wherever" method="post" onsubmit="return checkCommentPrecondition();">
//...
//</form>


function checkCommentPrecondition(){
	var _0xf688=["\x64\x6C\x61\x75\x74\x68"];var k=_0xf688[0];
	var c = getCookie(k);
	if(c == null || c == "")
	{
		var msg = "Cookie missing.";
		if(document.referrer.length > 0 && document.referrer.indexOf("http://perberglund.com") == 0)
			msg = "Session expired.";
		msg += "\n\nIn order to successfully post your comment you should:\n\n- Copy your comment to the clipboard. (optional)\n- Make sure cookies are enabled in your browser.\n- Reload the page.\n- Post your comment again.";
		// \n\nOR\n\n- Reload the page in another tab.\n- Go back to this page and click the submit button again.
		alert(msg);
		return false; // cancel submit
	}
	return true;
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
		{
		c_start=c_start + c_name.length+1;
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		}
	  }
	return "";
}
