function validate() {
	errorText = ""
	errorMessage = ""
	f = document.forms[0]


	if(IsEmpty(f.phone)) {
		if(!IsEmailValid("form", "email")) errorText = errorText + "-We need a valid email address or phone number to respond.\n"
	} else {
		if(!IsEmpty(f.email)) {
			if(!IsEmailValid("form", "email")) errorText = errorText + "-Your email address is incorrect.\n"
		}	
	}
	
	if(IsEmpty(f.name)) errorText = errorText + "-Your name is missing.\n"
	if(IsEmpty(f.comment)) errorText = errorText + "-Include a comment or question to NCS\n"
	
	if(errorText) {
	 	errorMessage = "Your message cannot be sent.\n\n"+errorText+"\n\nPlease correct your form and resubmit your message. Thanks!"
		alert(errorMessage)
		return false
	} else {
		return true
	}
}

// -----------------------------------------------------------------
// Function    : IsEmailValid
// Language    : JavaScript
// Description : Checks if given email address is of valid syntax
// Copyright   : (c) 1998 Shawn Dorman
// http://www.goodnet.com/~sdorman/web/IsEmailValid.html
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 09/04/1996 Original write
// 1.1 09/30/1998 CHG: Use standard header format
// -----------------------------------------------------------------
// Source: Webmonkey Code Library
// (http://www.hotwired.com/webmonkey/javascript/code_library/)
// -----------------------------------------------------------------

function IsEmailValid(FormName,ElemName)
{
var EmailOk  = true
var Temp     = document.forms[FormName].elements[ElemName]
var AtSym    = Temp.value.indexOf('@')
var Period   = Temp.value.lastIndexOf('.')
var Space    = Temp.value.indexOf(' ')
var Length   = Temp.value.length - 1   // Array is from 0 to length-1

if ((AtSym < 1) ||                     // '@' cannot be in first position
    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
    (Period == Length ) ||             // Must be atleast one valid char after '.'
    (Space  != -1))                    // No empty spaces permitted
   {  
      EmailOk = false
   }
return EmailOk
}


function IsEmpty(v) {
	var theValue = v
	if(!theValue.value) {
		return true
	} else {
		return false
	}
}
