
/**
 * validate a newsletter sign-up form
 *
 * @author mmathews@oxygen.com
 * @author kfrank@oxygen.com
 * @version 1.2 Feb 2002
 * @form		 A form object
 */
      
function newsletterValidate(form) {

	// emfield is a string representation of the DOM path to the field in the
	// form named "email", EmailField uses a string rep instead of an actual
	// object so that it can be constructed before the document is actually loaded.
	var emfield = new EmailField("document.forms."+form.name+".email")
	
	// check if there is an error, this method will only work after the document loads.
	if (!emfield.isValid()) {
		alert("Please reenter your e-mail address.\n\n(Sample: yourname@email.com)")
		form.email.focus()
		form.email.select()
		return false
	}
		
	// possible error so ask user to confirm: user chose HTML but used an .aol address
    //dont do the check if its text only and there was no choice of format
	if(typeof form.listname[0] != "undefined"){
        if (form.listname[0].checked && (emfield.getHost()== "aol.com")) {
    		if (!confirm("Quick tip: AOL 5.0 and 4.0 users may select text format.\n\nAOL 6.0 users select hmtl for graphic newsletters\n\nClick 'cancel' to select text format or 'ok' to continue.")) {
    			form.listname[1].focus()
    			return false;
    		}
    	}
    }
    
    // must be ok
	return true;

}

//create a confirmation window for the form to target its results to
function newsletterPopThanks(formName,newsletterWindow){
	newsletterWindow.open('', 'newsletterConfirmWindow')
	setTimeout("document."+formName+".reset()", 1000)
}
