// validate send messages
function Validar(form)
{     
   if (form.mensaje_torrents_comment.value == "")
   { alert("write comment"); form.mensaje_torrents_comment.focus(); return; }
   
   if (form.mensaje_torrents_comment.value.length > 200)
   { alert("max 200 characters"); form.mensaje_torrents_comment.focus(); return; }
			
    form.submit();

}

function noshit(e) {
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla==8) return true;
    patron =/[A-Za-z0-9\s]/;
    te = String.fromCharCode(tecla);
    return patron.test(te);
} 


// validate send messages soon
function ValidarSoon(form)
{     
   if (form.mensaje_soon_comment.value == "")
   { alert("write comment"); form.mensaje_soon_comment.focus(); return; }
   
   if (form.mensaje_soon_comment.value.length > 200)
   { alert("max 200 characters"); form.mensaje_soon_comment.focus(); return; }
			
    form.submit();

}

// validate chat messages
function chat(form)
{     
   if (form.chatbox_mensaje.value == "")
   { alert("write message"); form.chatbox_mensaje.focus(); return; }
   
   if (form.chatbox_mensaje.value.length > 200)
   { alert("max 200 characters"); form.chatbox_mensaje.focus(); return; }
			
    form.submit();

}

// validate canalmail
function submit_page(form)
{   
   if (form.username.value == "")
   { alert("Please input your username"); form.username.focus(); return; }
   
   if (form.username.value.length < 5)
   { alert("Username min 5 characters"); form.username.focus(); return; }
   
   if (form.username.value.length > 10)
   { alert("Username max 10 characters"); form.username.focus(); return; }
   
   if (form.password1.value == "")
   { alert("Please input your password"); form.password1.focus(); return; }
   
   if (form.password2.value == "")
   { alert("Insert your password again"); form.password2.focus(); return; } 
   
   if (form.password1.value != form.password2.value)
   { alert("The Passwords Don't Match! Try Again"); form.password1.focus(); return; }
   
   if (form.email.value == "")
   { alert("Invalid e-mail"); form.email.focus(); return; }
   
   if (form.email.value.indexOf('@', 0) == -1 ||
      form.email.value.indexOf('.', 0) == -1)
   { alert("Invalid e-mail"); form.email.focus(); return; }
			
    form.submit();

}

// validate change password
function changepass(form)
{     
   if (form.newpass.value == "")
   { alert("Insert Your New Password"); form.newpass.focus(); return; }
   
   if (form.newpass2.value == "")
   { alert("Insert The Repeat of Your New Password"); form.newpass2.focus(); return; } 
   
   if (form.newpass.value != form.newpass2.value)
   { alert("The Passwords Don't Match! Try Again"); form.newpass.focus(); return; }
			
    form.submit();

}