    function checkData(){
        //array of elements to check        
        var elem = new Array(3);
        elem[0] = "firstname";
        elem[1] = "lastname";
        elem[2] = "email";
        
        var blnSubmit = true //default is true, assume no errors
        
        for (i=0;i<elem.length;i++){
            //get the element to test
            elemInput = document.getElementById(elem[i]);
            //get the associated error message div 
            elemErrorMessageName = elem[i] + "ErrorMessage";
            elemDivErrorMessage = document.getElementById(elemErrorMessageName);
            
            var elemValue = elemInput.value
            var HMTLErrorMessage = "" 
            
            if (elem[i]=="email"){
                HMTLErrorMessage = checkEmail(elemValue);
            }else{
                
                HMTLErrorMessage = checkText(elemValue);
                
                //if there is an error, use the error message that is already in the div
                if(HMTLErrorMessage!=""){
                    HMTLErrorMessage = elemDivErrorMessage.innerHTML;
                }    
            }
           
            if (HMTLErrorMessage!=""){
                elemDivErrorMessage.innerHTML = HMTLErrorMessage;
                elemDivErrorMessage.className = "ErrorMessageDisplay";              
                //retun false to the calling error check
                blnSubmit = false
            }else{
                //just make sure the div is still hidden; could be a second submit
                elemDivErrorMessage.className = "ErrorMessage";
            }
            
            
        }
        
        //change the css to display the General Error Message at the top of the page, if there were errors 
        if(!blnSubmit){
            document.getElementById("alertErrorMessage").className = "ErrorMessageDisplay";
        }
        
        return blnSubmit;
    }
    
    function checkEmail (strng) {
        var error="";
        
        if (strng == "") {
           error = "Please enter a valid email address.";
        }

        var emailFilter=/^.+@.+\..{2,3}$/;
        
        if (!(emailFilter.test(strng))) { 
           error = "Please enter a valid email address.";
        }
        else {
        //test email for illegal characters
           var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
           
           if (strng.match(illegalChars)) {
              error = "The email address contains illegal characters.";
           }
        }
        
        return error;    
    }
    
    function checkText (strng) {
         var error = "";
         
         if (strng == "") {
            error = "Please enter value";
         }
         
         return error;
    }
    
    function ShowHideCommunitySelected(nameOfSelectBox){
        elemInput = document.getElementById(nameOfSelectBox);
        
        var CommunitySelectBoxID = elemInput.value + "CommunitySelected";
        
        elemCommunitySelectBox = document.getElementById(CommunitySelectBoxID);
        
        //CurrentSelectedCommunityBox is set initially in the xslt
        document.getElementById(CurrentSelectedCommunityBox).className="HideSelectBox";
        document.getElementById(CurrentSelectedCommunityBox).className="HideSelectBox";
        
        elemCommunitySelectBox.className = "ShowSelectBox";
        CurrentSelectedCommunityBox = CommunitySelectBoxID;
    }
    
    
