// FUNZIONE VERIFICA CAMPI VUOTI:
function validate_required(field){
with (field){
if (value.toLowerCase()==null||value.toLowerCase()==""){return false}
// if (value.length() < 3){return false}
else {return true}
}}


// FUNZIONE VERIFICA CAMPI VUOTI CON ALERT:
// function validate_required(field,alerttxt){
// with (field){
// if (value.toLowerCase()==null||value.toLowerCase()=="")
// {alert(alerttxt); return false;}
// else {return true;}
// }}



// FUNZIONE VERIFICA MAIL:
// the input data must contain at least an @ sign and a dot (.).
// Also, the @ must not be the first character of the email address,
// and the last dot must at least be one character after the @ sign.
function validate_email(field){
with (field){
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2)
{return false}
else {return true}
}}



// FUNZIONE VERIFICA CONTENUTO:
var bad_words_array=new Array("cigaret","xxx","orgy","orgasm",".txt","[","link=","eiac","ejac","tp:",".exe",".pdf","porca madon","porco dio","puttana","sex","fuck","interracial","cock","culo","cazzo","bocchin","blow jo","blowjo","pussy","lesb"," tits","masturb","sesso","&#",";&","porn ","hardcore");
function badwords(txt)
{var alert_arr=new Array;
var alert_count=0;
var compare_text=txt;
for(var i=0; i<bad_words_array.length; i++)
{for(var j=0; j<(compare_text.length); j++)
{if(bad_words_array[i]==compare_text. 
substring(j,(j+bad_words_array[i].length)).toLowerCase())
{alert_count++;}}}
return alert_count;}

function validate_content(field)
{
bwords=badwords(field.value);
if(bwords>0)
{return false}
else {return true}
}



// FUNZIONI PRINCIPALI:

function convalida_ebook(thisform){
with (thisform){
  if (validate_required(nome)==false)
  {nome.style.backgroundColor='#FFCCCC'; nome.focus(); return false}
  	if (validate_email(nome)==false)
  	{nome.style.backgroundColor='#FFCCCC'; nome.focus(); return false}
}}


function convalida_reply(thisform){
with (thisform){
  if (validate_required(nome)==false)
  {nome.style.backgroundColor='#FFCCCC'; nome.focus(); return false}
  	if (validate_content(nome)==false)
  	{nome.style.backgroundColor='#FFCCCC'; nome.focus(); return false}

  if (validate_required(testo)==false)
  {testo.style.backgroundColor='#FFCCCC'; testo.focus(); return false}
  	if (validate_content(testo)==false)
  	{testo.style.backgroundColor='#FFCCCC'; testo.focus(); return false}
}}


function convalida_newmsg(thisform){
with (thisform){
  if (validate_required(nome)==false)
  {nome.style.backgroundColor='#FFCCCC'; nome.focus(); return false}
  	if (validate_content(nome)==false)
  	{nome.style.backgroundColor='#FFCCCC'; nome.focus(); return false}

  if (validate_required(titolo)==false)
  {titolo.style.backgroundColor='#FFCCCC'; titolo.focus(); return false}
  	if (validate_content(titolo)==false)
  	{titolo.style.backgroundColor='#FFCCCC'; titolo.focus(); return false}

  if (validate_required(testo)==false)
  {testo.style.backgroundColor='#FFCCCC'; testo.focus(); return false}
  	if (validate_content(testo)==false)
  	{testo.style.backgroundColor='#FFCCCC'; testo.focus(); return false}
}}


function convalida_nlet(thisform){
with (thisform){
  if (validate_required(email)==false)
  {email.style.backgroundColor='#FFCCCC'; email.focus(); return false}
}}


// SCRIVE CONTENUTO FORM SU ALERT
// {alert("Welcome " + document.forms["formnum1"]["testo"].value + "!")}

