function validateForm(formObj)
{
        if (emptyField(formObj.firstname))
                alert("Please input your first name.");
        else if(emptyField(formObj.lastname))
                alert("Please input your last name.");
        else if(emptyField(formObj.email))
                alert("Please input your email address.");
        else if(verifyEmail(formObj.email))
                alert("Invalid E-mail Address! Please re-enter.");
        else return true;

        return false;
}



function emptyField(textObj)
{
        if (textObj.value.length == 0) return true;
                for (var i = 0; i<textObj.value.length; ++i) {
                        var ch = textObj.value.charAt(i);
                        if (ch != ' ' && ch != '\t') return false;
                }
        return true;
}



function check_passes(txtObj1,txtObj2)
{
        var pass = txtObj1.value;
        var con_pass = txtObj2.value;

        if (pass == con_pass)
        {
                return false;
        }

        return true;
}



function verifyEmail(email)
{
        if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email.value))
        {
                return false;
        }


        //alert("Invalid E-mail Address! Please re-enter.");
        //email.focus();
        return true;
}



function stripBadchs(id,status)
{
        var bad = 0

        for (i = 0; i < id.value.length; i++)
        {
                ch = id.value.substring(i, i + 1);
                if ( status == "letters or numbers" ) { if ( (ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch) && (ch < "0" || "9" <
ch) ) { bad = 1; } }
                if ( status == "letters" ) { if ( (ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch) ) { bad = 1; } }
                if ( status == "dollar value" ) { if ((ch == "$") || (ch == ",")) { bad = 1 } }
                if ( status == "numbers" ) { if (ch < "0" || "9" < ch) { bad = 1 } }
                if ( bad == 1 )
                {
                        id.value = id.value.substring(0,i)+id.value.substring(i+1,id.value.length)
                        i=(i-1);
                        bad = 0;
                }
        }
}



function formatPhone(id)
{
        if (id.value != "") {
                stripBadchs(id,'numbers')
                id.value = "(" + id.value.substring(0,3) + ") " + id.value.substring(3,6) + "-" + id.value.substring(6,10)
        }
}