<!-- The following code was generated by Exacttarget.com. Please do not edit. //--> 

// isEmail (STRING s [, BOOLEAN emptyOK])

// whitespace characters

var whitespace = " \t\n\r";


// Email address must be of form a@b.c ... in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required

function isValidEmail(s) {   
	if (isEmpty(s)) return false;

// is s whitespace?
	if (isWhitespace(s)) return false;

// there must be >= 1 character before @, so we start looking at character position 1  (i.e. second character)
	var i = 1;
	var sLength = s.length;

// look for @
	while ((i < sLength) && (s.charAt(i) != "@")) {
		i++
	}

	if ((i >= sLength) || (s.charAt(i) != "@")) return false;
	else i += 2;

	// look for .

	while ((i < sLength) && (s.charAt(i) != ".")) {
		i++
	}

// there must be at least one character after the .

	if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
	else return true;
}



// Check whether string s is empty.
function isEmpty(s) {   
	return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or whitespace characters only.

function isWhitespace(s) {   
	var i;
// Is s empty?
    if (isEmpty(s)) return true;
// Search through string's characters one by one until we find a non-whitespace character.
// When we do, return false; if we don't, return true.
	for (i = 0; i < s.length; i++) {   
// Check that current character isn't whitespace.
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
    }

// All characters are whitespace.
    return true;
}

function usa() {
	var myCountry = document.subscribeForm.elements['Country'].value.toUpperCase();
	if ((myCountry == "USA") || (myCountry == "US") || (myCountry == "U.S.A.") || (myCountry == "U.S.") || (myCountry == "US") || (myCountry == "AMERICA")) {
		document.subscribeForm.elements['Country'].value = "United States";
	}
}

function checkOther() {
	if (document.subscribeForm.elements['Hear'].value == "Other") {
		document.getElementById('Other').style.display = "block";
	} else {
		document.getElementById('Other').style.display = "none";
		document.getElementById('Other').style.value = "";
	}
}

function checkForm() { 
	var alertArray = new Array;
	var errorCount = 0;
	if (document.subscribeForm.elements['First Name'].value==null||document.subscribeForm.elements['First Name'].value=="") {
		document.subscribeForm.elements['First Name'].style.backgroundColor='yellow';
		alertArray[errorCount] = "First Name must be filled out.";
		errorCount++;
	}
	if (document.subscribeForm.elements['Last Name'].value==null||document.subscribeForm.elements['Last Name'].value=="") {
		document.subscribeForm.elements['Last Name'].style.backgroundColor='yellow';
		alertArray[errorCount] = "Last Name must be filled out.";
		errorCount++;
	}
	if (document.subscribeForm.elements['Address1'].value==null||document.subscribeForm.elements['Address1'].value=="") {
		document.subscribeForm.elements['Address1'].style.backgroundColor='yellow';
		alertArray[errorCount] = "Address 1 must be filled out.";
		errorCount++;
	}
	if (document.subscribeForm.elements['City'].value==null||document.subscribeForm.elements['City'].value=="") {
		document.subscribeForm.elements['City'].style.backgroundColor='yellow';
		alertArray[errorCount] = "City must be filled out.";
		errorCount++;
	}
	if (document.subscribeForm.elements['State or Province'].value==null||document.subscribeForm.elements['State or Province'].value=="") {
		document.subscribeForm.elements['State or Province'].style.backgroundColor='yellow';
		alertArray[errorCount] = "State/Province must be filled out.";
		errorCount++;
	}
	if (document.subscribeForm.elements['Postal Code'].value==null||document.subscribeForm.elements['Postal Code'].value=="") {
		document.subscribeForm.elements['Postal Code'].style.backgroundColor='yellow';
		alertArray[errorCount] = "Zip/Postal Code must be filled out.";
		errorCount++;
	}
	if (document.subscribeForm.elements['Country'].value==null||document.subscribeForm.elements['Country'].value=="") {
		document.subscribeForm.elements['Country'].style.backgroundColor='yellow';
		alertArray[errorCount] = "Country must be filled out.";
		errorCount++;
	}
	if (!isValidEmail(document.subscribeForm.elements['Email Address'].value)) {
		document.subscribeForm.elements['Email Address'].style.backgroundColor='yellow';
		alertArray[errorCount] = "Please enter a valid Email Address.";
		errorCount++;
	}
	if (document.subscribeForm.elements['Market'].checked) {
		document.subscribeForm.elements['Market'].value = "Professional";
	} else {
		document.subscribeForm.elements['Market'].value = "Consumer";
	}
	if (document.subscribeForm.elements['Receive Email'].checked) {
		document.subscribeForm.elements['_subscribe'].value = "yes";
	} else {
		document.subscribeForm.elements['_subscribe'].value = "no";
	}
	if (document.subscribeForm.elements['Hear'].value == "Other") {
		document.subscribeForm.elements['Hear'].options[5].value = document.subscribeForm.elements['Other'].value;
	}

// WHO SHOULD THIS BE MAILED TO?
	if (document.subscribeForm.elements['Country'].value == "United States") {
		if (document.subscribeForm.elements['Market'].checked) {
			document.subscribeForm.elements['_recipients'].value = "shannon.walker@alconlabs.com";
		} else {
			document.subscribeForm.elements['_recipients'].value = "shannon.walker@alconlabs.com";
		}
	} else if (document.subscribeForm.elements['Market'].checked) {
			document.subscribeForm.elements['_recipients'].value = "shannon.walker@alconlabs.com";
	} else {
			document.subscribeForm.elements['_recipients'].value = "shannon.walker@alconlabs.com";
	}



	if (errorCount >= 1) {
		var alertMessage = "";
		i=0;
		while (i < errorCount) {
			alertMessage = alertMessage + "\n" + alertArray[i];
			i++;
		}
		alert (alertMessage);
		return false;
	} else {
		return true;
	}
}
