function validEmail(email) {
invalidChars = " /:,;"

if (email == "") {						// cannot be empty
return false
}
for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
badChar = invalidChars.charAt(i)
if (email.indexOf(badChar,0) > -1) {
return false
}
}
atPos = email.indexOf("@",1)			// there must be one "@" symbol
if (atPos == -1) {
return false
}
if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
return false
}
periodPos = email.indexOf(".",atPos)
if (periodPos == -1) {					// and at least one "." after the "@"
return false
}
if (periodPos+3 > email.length)	{		// must be at least 2 characters after the "."
return false
}
return true
}


function submitIt(compForm) {



if (compForm.fname.value=="") {						// cannot be empty
alert("Required field 'First Name' has not been completed.")
compForm.fname.focus()
compForm.fname.select()
return false
}


if (compForm.lname.value=="") {						// cannot be empty
alert("Required field 'Last Name' has not been completed.")
compForm.lname.focus()
compForm.lname.select()
return false
}

if (compForm.co.value=="") {						// cannot be empty
alert("Required field 'Business/Company' has not been completed.")
compForm.co.focus()
compForm.co.select()
return false
}

if (!validEmail(compForm.email.value) ){
alert("Required field 'email' is invalid or has not been completed.")
compForm.email.focus()
compForm.email.select()
return false
}

if (compForm.tel.value=="" ){
alert("Required field 'Tel' is invalid or has not been completed.")
compForm.tel.focus()
compForm.tel.select()
return false
}

if (compForm.street.value=="") {						// cannot be empty
alert("Required field 'Street' has not been completed.")
compForm.street.focus()
compForm.street.select()
return false
}

if (compForm.suburb.value=="") {						// cannot be empty
alert("Required field 'Suburb' has not been completed.")
compForm.suburb.focus()
compForm.suburb.select()
return false
}

if (compForm.state.value=="") {						// cannot be empty
alert("Required field 'State' has not been completed.")
compForm.state.focus()
compForm.state.select()
return false
}

if (compForm.pcode.value=="") {						// cannot be empty
alert("Required field 'Post Code' has not been completed.")
compForm.pcode.focus()
compForm.pcode.select()
return false
}




d_sameOption = -1
for (i=0; i<compForm.d_same.length; i++) {
if (compForm.d_same[i].checked) {
d_sameOption = i
}
}
if (d_sameOption == -1){

if (compForm.d_street.value=="") {						// cannot be empty
alert("Required field 'Delivery Street' has not been completed or 'same as postal' not selected.")
compForm.d_street.focus()
compForm.d_street.select()
return false
}

if (compForm.d_suburb.value=="") {						// cannot be empty
alert("Required field 'Delivery Suburb' has not been completed or 'same as postal' not selected.")
compForm.d_suburb.focus()
compForm.d_suburb.select()
return false
}

if (compForm.d_state.value=="") {						// cannot be empty
alert("Required field 'Delivery State' has not been completed or 'same as postal' not selected.")
compForm.d_state.focus()
compForm.d_state.select()
return false
}

if (compForm.d_pcode.value=="") {						// cannot be empty
alert("Required field 'Delivery Post Code' has not been completed or 'same as postal' not selected.")
compForm.d_pcode.focus()
compForm.d_pcode.select()
return false
}

}

if (compForm.location.value=="non") {						// cannot be empty
alert("Required field 'Location for Freight calculations' not selected.")
compForm.location.focus()
compForm.location.select()
return false
}

return true
}

