// JavaScript Document
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid email address.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter a valid email address.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter a valid email address.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter a valid email address.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter a valid email address.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter a valid email address.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter a valid email address.")
		    return false
		 }

 		 return true					
	}

function aolchecktwo(str)
{
var mystrings=new Array("@spamcorptastic","@mailinator","@temporaryinbox.com","@lycos.co.uk")
//var myalerts=new Array("We cannot currently accept \"spamcorptastic\" email addresses. Please enter another email address.","Ah ha, you are from a \"@whichbingo.co.uk\" email addresses! Please enter another email address.")
for (var i = 0; i <= 4; i++ ) {
if (str.indexOf(mystrings[i])!=-1){
alertstring = "We cannot currently accept \""+mystrings[i]+"\" email addresses. Please enter another email address."
alert(alertstring)
//		   alert(myalerts[i])
		   return false
		}
	}
}

function aolcheck(str)
{
var ataol="@aol"
		if (str.indexOf(ataol)!=-1){
		   alert("We cannot currently accept aol email addresses. Please enter another email address.")
		   return false
		}
}

function validateThis(theForm)
{

  if (theForm.regusername.value == "")
  {
    alert("Please enter a value for the \"Username\" field.");
    theForm.regusername.focus();
    return (false);
  }

  if (theForm.regusername.value.length < 4)
  {
    alert("Your username must be at least 4 letters long");
    theForm.regusername.focus();
    return (false);
  }

  if (theForm.regusername.value.length > 20)
  {
    alert("Your username cannot be bigger than 20 letters long");
    theForm.regusername.focus();
    return (false);
  }

  if (theForm.regemail.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theForm.regemail.focus();
    return (false);
  }

  if (theForm.regemail.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Email Address\" field.");
    theForm.regemail.focus();
    return (false);
  }

  if (theForm.regemail.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Email Address\" field.");
    theForm.regemail.focus();
    return (false);
  }
  
 if (echeck(theForm.regemail.value)==false){
		theForm.regemail.value="";
		theForm.regemail.focus();
		return (false);
	} 
	
 if (aolchecktwo(theForm.regemail.value)==false){
		theForm.regemail.value="";
		theForm.regemail.focus();
		return (false);
	} 
	
    if (theForm.regemail.value != theForm.regemail2.value)
  {
    alert("Both \"Email Address\" fields must contain the same address.");
    theForm.regemail2.focus();
    return (false);
  }

  return (true);
}

function validatePanel(theForm)
{


  if (theForm.panelregusername.value == "")
  {
    alert("Please choose a \"Username\"");
    theForm.panelregusername.focus();
    return (false);
  }

  if (theForm.panelregusername.value.length < 4)
  {
    alert("Your username must be at least 4 letters long");
    theForm.panelregusername.focus();
    return (false);
  }

  if (theForm.panelregusername.value.length > 20)
  {
    alert("Your username cannot be bigger than 20 letters long.");
    theForm.panelregusername.focus();
    return (false);
  }

  if (theForm.panelregemail.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theForm.panelregemail.focus();
    return (false);
  }

  if (theForm.panelregemail.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Email Address\" field.");
    theForm.panelregemail.focus();
    return (false);
  }

  if (theForm.panelregemail.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Email Address\" field.");
    theForm.panelregemail.focus();
    return (false);
  }
  
 if (echeck(theForm.panelregemail.value)==false){
		theForm.panelregemail.value="";
		theForm.panelregemail.focus();
		return (false);
	} 
	
 if (aolchecktwo(theForm.panelregemail.value)==false){
		theForm.panelregemail.value="";
		theForm.panelregemail.focus();
		return (false);
	} 
	
    if (theForm.panelregemail.value != theForm.panelregemailtwo.value)
  {
    alert("Both \"Email Address\" fields must contain the same address.");
    theForm.panelregemailtwo.focus();
    return (false);
  }

  return (true);
}
