// function to open a window with the rejection survey
// Added 9/9/03 by MCG
function openSurvey() {
	// if formSubmit was not set to something, then they didn't submit the form
	if (document.DCForm.formSubmit.value == "")
		window.open("emailRejection.cfm?", "surveyWindow", "height=460,width=550,toolbar=no,menubar=no,location=no,scrollbars=yes");
	return;
}


function checkVals(appType){
	var mesg = "";
	var appType = appType;
	var username
	username = document.DCForm.EmailAddr.value.split("@")[0]
	username = username.toUpperCase()
	SpamEmails = ["INFO","MARKETING","SALES","SUPPORT","ABUSE","NOC","SECURITY","POSTMASTER","HOSTMASTER","USENET","NEWS","WEBMASTER","WWW","UUCP","FTP"];

	//PrefCtr Error Check -----------------------------

	if (appType == "PrefCtr"){
		emailRE = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
		fieldValue = document.DCForm.EmailAddr.value;
		if (document.DCForm.EmailAddr.value == "") {
			alert("Please enter your Email Address.");
			document.DCForm.EmailAddr.focus();
			return false;
		}
		else if (fieldValue.search(emailRE) == -1) {
			alert("Please enter a Valid Email Address.");
			document.DCForm.EmailAddr.focus();
			return false;
		}
		else if (document.DCForm.EmailAddr.value != document.DCForm.ConfEmailAddr.value) {
			alert("Your Email Address and Confirm Email Address do not match.");
			document.DCForm.ConfEmailAddr.focus();
			return false;
		}
		if (document.DCForm.HtmlCapable[0].checked == false && document.DCForm.HtmlCapable[1].checked == false ) {
			alert("Please select the Format you wish to receive.");
			document.DCForm.HtmlCapable[0].focus();
			return false;
		}
		if (document.DCForm.FirstName.value == "") {
			alert("Please enter your First Name.");
			document.DCForm.FirstName.focus();
			return false;
		}
		if (document.DCForm.LastName.value == "") {
			alert("Please enter your Last Name.");
			document.DCForm.LastName.focus();
			return false;
		}

		fieldValue = document.DCForm.Address1.value;
		if (fieldValue.length > 500) {
			alert("Your address may not exceed 500 characters. It is currently " + fieldValue.length + ".");
			document.DCForm.Address1.focus();
			return false;
		}

/*		if (document.DCForm.Zip_Postal.value == "") {
			alert("Please enter your Zip/Post Code.");
			document.DCForm.Zip_Postal.focus();
			return false;
		} */

		if (document.DCForm.Country.selectedIndex == 0) {
			alert("Please select your Country.");
			//document.DCForm.Country[0].focus();
			document.DCForm.Country.focus();
			return false;
		}

		if (document.DCForm.O_APAC.checked || document.DCForm.O_USCanMex.checked || document.DCForm.O_LatAmer.checked || document.DCForm.O_MidEast.checked || document.DCForm.O_Europe.checked || document.DCForm.O_Worldwide.checked)
		{
		}
		else
		{
			alert("Please tick at least one Geographical Region.");
			return false;
		}

		if (document.DCForm.PCYN.selectedIndex == 0) {
			alert("Please specify if you are a PCR Member.");
			document.DCForm.PCYN.focus();
			return false;
		}

		//Check For Non Allowed EmailAddr		
		for (i=0; i<SpamEmails.length; i++) {
			if (username == SpamEmails[i]){
			alert("???,??????????????????????????????????");
			document.DCForm.EmailAddr.focus();
			return false;
			}
		}
		return true;
	}

	//Unsub MiniForm Error Check ----------------------
	if (appType == "Unsub"){
		//Check email address presence
		if(document.DCForm.EmailAddr.value == ""){
		alert("Please enter a valid email address."); 
		document.DCForm.EmailAddr.focus();
		return false; 
		}
		//Check for valid email address
		if (document.DCForm.EmailAddr.value.indexOf("@") + "" == "-1" || document.DCForm.EmailAddr.value.indexOf(".") + "" == "-1" || username.length == 0){
		   alert("Please enter a valid email address.");
		   document.DCForm.EmailAddr.focus();
		   return false;
		}

		//Check for EmailAddr match with ConfEmailAddr 
		if (document.DCForm.EmailAddr.value != document.DCForm.ConfEmailAddr.value) {
			alert("Your Email Address and Confirm Email Address do not match.");
			document.DCForm.ConfEmailAddr.focus();
			return false;
		}

		//Check For Non Allowed EmailAddr		
		for (i=0; i<SpamEmails.length; i++) {
			if (username == SpamEmails[i]){
			alert("???,??????????????????????????????????");
			document.DCForm.EmailAddr.focus();
			return false;
			}
		}
	}

	//--------- PrefCtr Login -------------------------
	if (appType == "Login"){

/*		//Check email address presence
		if(document.DCForm.EmailAddr.value == ""){
		alert("Please enter an Email Address"); 
		document.DCForm.EmailAddr.focus();
		return false; 
		}

		//Check for valid email address
		if (document.DCForm.EmailAddr.value.indexOf("@") + "" == "-1" || document.DCForm.EmailAddr.value.indexOf(".") + "" == "-1" || username.length == 0){
		alert("Please Enter a valid Email Address");
		document.DCForm.EmailAddr.focus();
		return false;
		} */

		// check email
		regEx = /^\w(?:\w|-|\.(?!\.|\@))*\@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/;
		emailValue = document.DCForm.EmailAddr.value;
		if (emailValue.length == 0 || !regEx.test(document.DCForm.EmailAddr.value)) {
			document.DCForm.EmailAddr.focus();
			alert("Please fill in a valid email address.");
			return false;
		}

		//Check For Non Allowed EmailAddr		
		for (i=0; i<SpamEmails.length; i++) {
			if (username == SpamEmails[i]){
			alert("???,??????????????????????????????????");
			document.DCForm.EmailAddr.focus();
			return false;
			}
		}
	}
return true;
}

//End DoubleClick Error Checking
