
var bad;

function testtwo()
	{
	bad=0;
	noUsername();
	}

function noUsername(){
//not used with ipnstock
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) || isat(c) || isperiod(c)) )
	na = 1;
    }

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


function emailCheck() {
//not used in ipnstock
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 {
		submitCheck();
		}
return true;
}

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

function clearIt(){
document.isn.username.value = "";
document.isn.email.value = "";
}


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

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

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

function isperiod(c){
        return(c== ".");
}

// 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))
}
 



