/*
   Version 1
   eNews JS @ Bekalius.com
   --------------------------------------------------------
*/
function ValidateMyForm() {
MessageLength=document.REPLIER.comment.value.length;
errors="";
if (MessageLength < 50) {
errors="Please enter some text, at least 10 chars.";
}
if (errors != "") {
alert(errors);
return false;
} else {
document.REPLIER.submit.disabled = true;
return true;
}
}
function paste(name)
{
document.REPLIER.comment.value+="<strong>"+name+"</strong>\n";
}
function paste2(name)
{
if (name!="") document.REPLIER.comment.value+="<blockquote>"+name+"</blockquote>\n"
}
function paste3(name)
{
if (name!="") document.REPLIER.comment.value+=""+name+"\n"
}
function Insert(text){ 
if (text!="") paste4("<blockquote>"+text+"</blockquote>\n", 0);
}
function paste4(text, flag){ 
if (document.REPLIER) {
if ((document.selection)&&(flag)) {
	document.REPLIER.comment.focus();
	document.REPLIER.document.selection.createRange().text = text;
} else document.REPLIER.comment.value += text;
}
}

function get_selection() {
  if(navigator.userAgent.search(/webkit/i) > -1) {
    selection = window.getSelection();
    } else {
      if (document.getSelection){
           selection = document.getSelection();
	selection = selection.replace(/\r\n\r\n/gi, "_doublecaret_");
	 selection = selection.replace(/\r\n/gi, " ");
	 while (selection.indexOf("  ") !=-1) selection = selection.replace(/  /gi, "");
	 selection = selection.replace(/_doublecaret_/gi, "\r\n\r\n");
	 } else {
 selection = document.selection.createRange().text;
          }
  }
}
