//written by Gregory R. Jones
//copyright 2000 Aurora and Photos Productions

var bad;

function testAll()
	{
	noUsername();
	}

function noUsername(){
bad=0;
mt=document.isn.username.value;
if (mt.length<4){
	alert("Please enter a username.  (at least 4 letters)");
	bad++;
	return false;
	} 

else {
     isAlphanumeric();
     }

return true;
}

function isAlphanumeric(mt)
{   
var i;
na=0;
s=document.isn.username.value;

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number or letter.
        var c = s.charAt(i);

        if (! (isLetter(c) || isDigit(c) ) )
	na = 1;
    }

   if (na > 0){
	alert("Usernames must be alphanumeric. (letters and numbers, no spaces)");
	bad++;
        return false;
    }
    else {
    passwordV();
    }
    return true;
}



function passwordV(){
bone="";
btwo="";
ps=document.isn.password.value;
cps=document.isn.cpassword.value;
if (ps.length<1) {
	alert("You need to enter a password please.");
	bad++;
	return false;
	}
if (ps != cps) {
	alert("The password and confirm password are not the same. Please re-enter the passwords.");
	document.isn.password.value=bone
	document.isn.cpassword.value=btwo;
	bad++;
	return false;
	} else {
		emailCheck();
		}
return true;
}

function emailCheck() {
txt=document.isn.email.value;
if (txt.indexOf("@")<2){
	alert("I'm sorry. This email address seems invalid. Please"
	+" check the prefix and '@' sign.");
	bad++;
	return false;
	} else {
		firstname();
		}
return true;
}

function firstname() {
fname=document.isn.firstname.value;
if (fname.length<1){
	alert("Please enter your first name.");
	bad++;
	return false;
	} else {
		lastname();
		}
return true;
}

function lastname() {
lname=document.isn.lastname.value;
if (lname.length<1){
	alert("Please enter your last name.");
	bad++;
	return false;
	} else {
		checkStreet();
		}
return true;
}

function checkStreet() {
street=document.isn.street.value;
if (street.length<1){
	alert("Please enter your street address.");
	bad++;
	return false;
	} else {
		checkCity();
		}
return true;
}

function checkCity() {
city=document.isn.city.value;
if (city.length<1){
	alert("Please enter your city.");
	bad++;
	return false;
	} else {
		checkState();
		}
return true;
}

function checkState() {
state=document.isn.state.selectedIndex;
if (state<1){
        alert("Please enter your state / province. You can select none if it does not apply to your country.");
        document.isn.state.focus();
        bad++;
        return false;
        } else {
                checkZip();
                }
return true;
}

function checkZip() {
zip=document.isn.zip.value;
if (zip.length<1){
	alert("Please enter your zip / postal code.");
	bad++;
	return false;
	} else {
		checkCountry();
		}
return true;
}

function checkCountry() {
country=document.isn.country.value;
if (country.length<1){
	alert("Please enter your country.");
	bad++;
	return false;
	} else {
		termsBox();
		}
return true;
}

function termsBox(){
if (document.isn.iagree.checked){
	submitCheck();
	} else {
		alert("Please sign the Terms and Conditions agreement by checking the I Agree box.");
		}
}

function submitCheck(){
if (bad==0){
	document.isn.submit();
	}
}

function clearIt(){
document.isn.password.value = "";
document.isn.cpassword.value = "";
document.isn.username.value = "";
document.isn.email.value = "";
document.isn.firstname.value = "";
document.isn.lastname.value = "";
}


function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}
       

    
// Returns true if character c is a digit
// (0 .. 9).

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}
  


// Returns true if character c is a letter or digit.
     
function isLetterOrDigit (c)
{   return (isLetter(c) || isDigit(c))
}
 
function isEmpty(mt)
{   return ((mt == null) || (mt.length == 0))
}
 




