
    function isValidEmail(str) {
        return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
     }
    
    function check() {
        
        //var re = '';
        //var vpass = '';
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
        var vpass = /^([0-9a-zA-Z.\s']{1,50})$/;

        /*
        if(document.tform.title.value=='na') {
            alert("Please select your title");
            document.tform.title.focus();
               //document.tform.title.select();
            return false;
        }
        */
        
        if(document.tform.first_name.value=='') {
            alert("Please enter your First Name");
            document.tform.first_name.focus();
            //document.tform.first_name.style.border-color = '#cc0000';
            return false;
        }
        
        if(document.tform.last_name.value=='') {
            alert("Please enter your Last Name");
            document.tform.last_name.focus();
               //document.tform.last_name.select();
            return false;
        }
        
        if(document.tform.new_email.value=='') {
            alert("Please enter your email address");
            return false;
        }
        
        /*
        if (isValidEmail(document.tform.email.value) == false){
            alert("Please enter a vaild email address");
            return false;
        }
        */
        
        if (! document.tform.new_email.value.match(re)) {
               alert("Invalid email address. Please enter a vaild email address");
               document.tform.new_email.focus();
               document.tform.new_email.select();
               return false;
           }
        
        if(document.tform.school.value=='') {
            alert("Please enter your School Name");
            document.tform.school.focus();
               //document.tform.school.select();
            return false;
        }
        
        
        if(document.tform.sc_address.value=='') {
            alert("Please enter your School's Address");
            document.tform.sc_address.focus();
               //document.tform.sc_address.select();
            return false;
        }
        
        if(document.tform.sc_city.value=='') {
            alert("Please enter your School's city");
            document.tform.sc_city.focus();
               //document.tform.sc_address.select();
            return false;
        }
        
        if(document.tform.sc_state.value=='') {
            alert("Please enter your School's state");
            document.tform.sc_state.focus();
               //document.tform.sc_address.select();
            return false;
        }
        /*
        if(document.tform.sc_phone.value=='') {
            alert("Please enter your School's Phone Number");
            document.tform.sc_phone.focus();
               //document.tform.sc_phone.select();
            return false;
        }
        */
        /*
        if(document.tform.affiliation.value=='na') {
            alert("Please select your School's Affiliation status");
            document.tform.affiliation.focus();
               //document.tform.affiliation.select();
            return false;
        }
        */
        /*
        if(document.tform.sc_type.value=='na') {
            alert("Please select your School Type");
            document.tform.sc_type.focus();
               //document.tform.sc_type.select();
            return false;
        }
        */
        
        if(document.tform.sc_grade.value=='na') {
            alert("Please select at least one grade taking part in living-museum");
            document.tform.sc_grade.focus();
               //document.tform.sc_grade.select();
            return false;
        }
        /*
        if(document.tform.sc_subject_a.value=='') {
            alert("Please enter the name of one subject you teach");
            document.tform.sc_subject_a.focus();
            return false;
        }
        */
        if(document.tform.userid.value=='') {
            alert("Please enter a user id for your account");
            document.tform.userid.focus();
               //document.tform.userid.select();
            return false;
        }
        
        var usertr = document.tform.userid.value;
        
        if (! usertr.match(vpass) || usertr.length < 6 || usertr.length > 12) {
               alert("Login must be numbers and letters only and should be more than 6 characters and less than 12 characters");
               //login_error
               //document.getElementById("login_error").style.display = "block";               
               //document.tform.password.focus();
               //document.tform.email.select();
               return false;
           }  else {
                 //document.getElementById("login_error").style.display = "none";
           }
           
           
           
           
           var uemail = document.tform.new_email.value;
        
        if (!uemail.match(re)) {
               alert("Please enter a valid email address");
               //login_error
               //document.getElementById("login_error").style.display = "block";               
               //document.tform.password.focus();
               //document.tform.email.select();
               return false;
           }  else {
                 //document.getElementById("login_error").style.display = "none";
           }
           
        
        if(document.tform.password.value=='') {
            alert("Please enter a password for your account");
            document.tform.password.focus();
               //document.tform.password.select();
            return false;
        }
        
        
        
        //////////////////////////////////////////////////////////////
        
        if(document.tform.sc_country.value=='') {
            alert("Please enter your country");
            document.tform.password.focus();
               //document.tform.password.select();
            return false;
        }
        
        if(document.tform.sc_zip.value=='') {
            alert("Please enter a zip");
            document.tform.password.focus();
               //document.tform.password.select();
            return false;
        }
        
        ////////////////////////////////////////////////////////////////
        
        
        if(document.tform.password.value != document.tform.con_pass.value) {
            alert("Please check your password. Your password does not match.");
            return false;
        }
        
        /*
        
        if(document.tform.position.value == 'Other') {
            if(document.tform.apply_reason.value == '') {
                alert("Please select your position, or enter why you want to register as a teacher");
                document.tform.position.focus();
                   //document.tform.position.select();
                return false;
            }
        } 
        
        */
         /*
        if(document.tform.position.value == 'na') {
            alert("Please select your position");
            document.tform.position.focus();
               //document.tform.position.select();
            return false;
        }
        
        */
        var passstr = document.tform.password.value;
        
        if(document.tform.password.value == '') {
            alert("Please enter a password for your account");
            //document.tform.position.focus();
            //document.tform.position.select();
            return false;   
        }
            
        if (! document.tform.password.value.match(vpass) || passstr.length < 6 || passstr.length > 12) {
               alert("Invalid password format only 0-9,a-z and A-Z are allowed. Password should be of 6 to 12 letters");
               //alert("Password must be numbers and letters only and should be more than 6 words and less than 12 words");
               
               return false;
           } else {
                 //document.getElementById("login_error").style.display = "none";
           }
                     
       //con_pass
       
       if(document.tform.password.value != document.tform.con_pass.value) {
            alert("Your password do not match. Please check your password and try again");
            return false; 
       }              
           
        
        
    }
    
     function showhidefield(){
         if(document.getElementById("porition_input").style.display == "none") {
              document.getElementById("porition_select").style.display = "block";
              //document.tform.position.value = "na";
              //document.getElementById("porition_select").style.position = 'static';
              document.getElementById("porition_input").style.display = "none";
              //document.getElementById("porition_input").style.position = "absolute";
         } else {
             if(document.tform.position.value == 'Other') {
                 document.getElementById("porition_select").style.display = "none";
                 //document.getElementById("porition_select").style.position = "absolute";
                  document.getElementById("porition_input").style.display = "block";
                  //document.getElementById("porition_input").style.position = 'static';
             }
         }
         return false;        
       }
    