
/*
Submit Once form validation- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}

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) // and at least 2 characters after the "."
 return false

		return true
	}
	
	function submitIt(mailForm) {

		// They had to enter a name
		if (mailForm.realname.value == "") {
 alert("Please enter your name.")
 mailForm.realname.focus()
 mailForm.realname.select()
 return false
		}
		
		// check to see if the email's valid
		if (mailForm.email.value == "") {
alert("Please enter your e-mail address.")
 mailForm.email.focus()
 mailForm.email.select()
 return false}
		else	{
		if (!validEmail(mailForm.email.value)) {
 alert("The e-mail address that you have\nentered does not appear to be valid.")
 mailForm.email.focus()
 mailForm.email.select()
 return false
			}
		}
		
		// They had to enter a subject
		if (mailForm.subject.value == "") {
 alert("Please enter a subject.")
 mailForm.subject.focus()
 mailForm.subject.select()
 return false
		}
		
		// They had to enter a message
		if (mailForm.message.value == "") {
 alert("Please enter a message.")
 mailForm.message.focus()
 mailForm.message.select()
 return false
		}

submitonce(mailForm);
		
		// If we made it to here, everything's valid, so return true
		return true
	}



function verifySubscribe(mailForm) {

		// They had to enter a name
		if (mailForm.realname.value == "") {
 alert("Please enter a name.")
 mailForm.realname.focus()
 mailForm.realname.select()
 return false
		}
		
		// check to see if the email's valid
		if (!validEmail(mailForm.email.value)) {
 alert("The e-mail address that you have\nentered does not appear to be valid.")
 mailForm.email.focus()
 mailForm.email.select()
 return false
		}
		
submitonce(mailForm);
		
		// If we made it to here, everything's valid, so return true
		return true
	}



function checkMLmessage(mailForm) {
	
		// They had to enter a subject
		if (mailForm.subject.value == "") {
 alert("Please enter a subject.")
 mailForm.subject.focus()
 mailForm.subject.select()
 return false
}
		
		// They had to enter a message
		if (mailForm.message.value == "") {
 alert("Please enter a message.")
 mailForm.message.focus()
 mailForm.message.select()
 return false
}

submitonce(mailForm);
		
		// If we made it to here, everything's valid, so return true
		return true
}

function open_window(url,winName,width,height) {
var details = ("toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+ width + ",height=" + height);
send = open(url,winName,details);
if (send.opener == null) send.opener = self;


//<a href="javascript:open_window('theurl.html','windowname',width,height)">
}