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("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail IAddressD")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

 		 return true					
	}


function validateSignupForm()
{
	var user,pword,pword2,fname,mname,lname,country,sec;
	var emailID=document.getElementById('email');
	
	user = document.getElementById('username');
	pword = document.getElementById('password');
	pword2 = document.getElementById('password2');
	fname = document.getElementById('firstname');
	lname = document.getElementById('lastname');
	country = document.getElementById('country');
	sec = document.getElementById('security_code');
	agree = document.getElementById('agree');

	if(user.value == "")
	{
		alert("Please enter your desired username");
		user.focus();
		
		return false;
	}
	else if(pword.value == "")
	{
		alert("Please enter your desired password");
		pword.focus();
		
		return false;
	}
	else if(pword.value != pword2.value)
	{
		alert("Passwords do not match");	
		pword.focus();
		
		return false;
	}
	else if(fname.value == "")
	{
		alert("Please fill in your first name");
		fname.focus();
		
		return false;
	}
	else if(lname.value == "")
	{
		alert("Please fill in you last name");
		lname.focus();
		
		return false;
	}
	else if(country.value == "")
	{
		alert("Please choose a country");
		country.focus();
		
		return false;
	}
	else if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address");
		emailID.focus();
		
		return false;
	}
	else if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		
		return false;
	}
	else if(sec.value == "")
	{
		alert("Please type the security code");
		sec.focus();
		
		return false;
	}
	
	else if(agree.checked == false)
	{
		alert("You must agree with the Terms and Conditions of ADEC Technical Solutions to proceed.");
		agree.focus();
		
		return false;
	}
	
	return true;
		
}
