//////////////  Begin Contact Page ////////////////// 
//email address vaildation
function isValidEmail(theField) {
        if((getFront(theField.value,"@") != null) && (getEnd(theField.value,"@") != "") && (getEnd(theField.value,".") != "") && (getEnd(theField.value,".") != "")) {

            return true; 
        } else {
            return false; 
        }
    }
    
    
    function getFront(mainStr,searchStr){
        foundOffset = mainStr.indexOf(searchStr)
        if (foundOffset <= 0) {
            return null                        
        } 
        else {
            return mainStr.substring(0,foundOffset)
        }
    }
    
    
    function getEnd(mainStr,searchStr) {
        foundOffset = mainStr.indexOf(searchStr)
        if (foundOffset <= 0) {
            return ""   
        }
        else {
            return mainStr.substring(foundOffset+searchStr.length,mainStr.length)                       
        }
    }

	
//vaildate Contact Form
function submit_contact(form) {
    
        foundError = false;  
		nameError = ""
        emailError = ""
		msgError = ""

        if(form.name.value == "") {
            nameError = " - NAME.\r";
            foundError = true;
        }

        if(form.email.value == "") {
            emailError = " - EMAIL ADDRESS.\r";
            foundError = true;
        } 
        
        if((emailError == "") && (isValidEmail(form.email) == false)) { 
            emailError = " - VALID email address.\r";
            foundError = true;
        }
	
        if(form.message.value == "") {
            msgError = " - COMMENT.\r";
            foundError = true;
        }
	
      
        if(foundError == false) {
             return true;

        }else{ 
            errorMessage = "Please review the following information:\r\r" + nameError + emailError + msgError;
            alert (errorMessage)

            if (nameError != "") {
                form.name.focus()
                form.name.select()  
				emailError = "" 
				msgError = ""
            }
            if (emailError != "") {
                form.email.focus()
                form.email.select()
				msgError = ""

            }
            if (msgError != "") {
                form.message.focus()
                form.message.select() 
            }
            return false;                       
        }   
    }

//////////////  End Contact Page //////////////////
