﻿function validatesmallv5(Name,Terms,EmailAccept,PleaseFill,TooShort,EmailInvalid,EmailIllegal)
{
  var result;
  result = false;
  
  if (checkWord(PleaseFill,TooShort,document.aspnetForm.ctl00_CPH_Name.value, Name))
  {
  	result = false;	
  }
  else if (checkEmail(EmailInvalid,EmailIllegal,document.aspnetForm.ctl00_CPH_Email.value,''))
  {
  	result = false;
  }
  else if (document.aspnetForm.ctl00_CPH_Terms.checked == false)
  {
  	alert(Terms);
	result = false;
  }
  else if (document.aspnetForm.ctl00_CPH_emailaccept.checked == false)
  {
  	alert(EmailAccept);
	result = false;
  }
  else
  {
	result = true;
  }  
  
  return result;
}

function checkWord(PleaseFill,TooShort,strng, txt) 
{
	if (strng == "") 
	{
	    alert(PleaseFill + " " + txt);
		return true;
	}	
	if ((strng.length < 2)) 
	{
	   alert(txt + " " + TooShort + "\n");
	   return true;
	}
}

function checkEmail(EmailInvalid,EmailIllegal,strng,txt)
{
	var emailFilter=/^.+@.+\..{2,4}$/;
	if (!(emailFilter.test(strng))) 
	{ 
       alert (txt + EmailInvalid);
	   return true;
	}
	
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
	if (strng.match(illegalChars)) 
	{
   		alert(txt + EmailIllegal);
		return true;
	}
}
