
//Begin DoubleClick Error Checking

function CheckVals(appType){

var mesg = "";
var appType = appType;


//PrefCtr Error Check ------------------------------------------------------------

if (appType == "PrefCtr"){

	//Check email address presence
	if(document.DCForm.EmailAddr.value == ""){
	alert("Please fill in your e-mail 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"){
       alert("The email address you entered does not have a valid\n" +
       "syntax.  Please re-enter the address and try again.");
	   document.DCForm.EmailAddr.focus();
       return false;
    }
	//Check DOB was entered
	//Check Month
	if (document.DCForm.month.selectedIndex == "0") {
			mesg = mesg + "\nPlease select a Month";
			}
	//Check Day
	if (document.DCForm.day.selectedIndex == "0") {
			mesg = mesg + "\nPlease select a Day";
			}
	//Check Year
	if (document.DCForm.year.selectedIndex == "0") {
			mesg = mesg + "\nPlease select a Year";
			}
}

//MiniForm Error Check -------------------------------------------------------------
if (appType == "Miniform"){
	mesg = mesg; 
	//Check email address presence
	if(document.DCForm.EmailAddr.value == ""){
	alert("Please fill in your e-mail 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"){
	   alert("The email address you entered does not have a valid\n" +
	   "syntax.  Please re-enter the address and try again.");
	   document.DCForm.EmailAddr.focus();
	   return false;
	}
	//Check DOB was entered
	//Check Month
	if (document.DCForm.month.selectedIndex == "0") {
			mesg = mesg + "\nPlease select a Month";
			}
	//Check Day
	if (document.DCForm.day.selectedIndex == "0") {
			mesg = mesg + "\nPlease select a Day";
			}
	//Check Year
	if (document.DCForm.year.selectedIndex == "0") {
			mesg = mesg + "\nPlease select a Year";
			}

	//V1 MF: list subscription check
	if (document.DCForm.Opt){
			if (document.DCForm.Opt.checked){
				mesg = mesg; 
			}
			else {
			mesg = mesg + "\nPlease select a check box to subscribe.\n";
			}
	}
	//V2 MF: List Subscription check
	else{
		if (!checkThisMF()){
			return false;
			}
	}

//If good, go ---------------------------------------------------------
	if (!mesg == "") {
			//mesg = "Please enter\n" + mesg
			alert(mesg);
			return false;
			}	
	return true;
}

//--------- PrefCtr Login -------------------------
if (appType == "login"){
	//Check email address presence
	if(document.DCForm.EmailAddr.value == ""){
	alert("Please fill in your e-mail 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"){
	alert("The email address you entered does not have a valid\n" +
	"syntax.  Please re-enter the address and try again.");
	document.DCForm.EmailAddr.focus();
	return false;
	}
	//Check DOB was entered
	//Check Month
	if (document.DCForm.month.selectedIndex == "0") {
			mesg = mesg + "\nMonth";
			}
	//Check Day
	if (document.DCForm.day.selectedIndex == "0") {
			mesg = mesg + "\nDay";
			}
	//Check Year
	if (document.DCForm.year.selectedIndex == "0") {
			mesg = mesg + "\nYear";
			}
}

//-- 13 to 17 Parent Notification ------------------------------------

if (appType == "13to16"){
	//Check Parent email address presence
	if(document.DCForm.Parent_Email.value == ""){
	alert("Please fill in your Parent's e-mail address!"); 
	document.DCForm.Parent_Email.focus()
	return false; 
	}
	//Check for valid Parent email address
	if (document.DCForm.Parent_Email.value.indexOf("@") + "" == "-1" || document.DCForm.Parent_Email.value.indexOf(".") + "" == "-1"){
	alert("The email address you entered does not have a valid\n" +
	"syntax.  Please re-enter the address and try again.");
	document.DCForm.Parent_Email.focus();
	return false;
	}
	//Check that Parent Email is not the same as Child Email
	if(document.DCForm.Parent_Email.value == document.DCForm.EmailAddr.value){
	alert("Please make sure you enter your parent's email address and not your own.");
	return false;
	}
}

//If good, go ---------------------------------------------------------
	if (!mesg == "") {
			//mesg = "Please enter\n" + mesg
			alert(mesg);
			return false;
		}	
	return true;
}



//***************************** DOB Functionality 
Months = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];
// Non-Leap year Month days..
DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// Leap year Month days..
lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function dayofmon(monthNo, p_year) {
	/* 
	Check for leap year ..
	1.Years evenly divisible by four are normally leap years, except for... 
	2.Years also evenly divisible by 100 are not leap years, except for... 
	3.Years also evenly divisible by 400 are leap years. 
	*/
	if (p_year == "") return DOMonth[monthNo];
	if ((p_year % 4) == 0) {
		if ((p_year % 100) == 0 && (p_year % 400) != 0)
			return DOMonth[monthNo];
	
		return lDOMonth[monthNo];
	} else
		return DOMonth[monthNo];
}

function setDays() {		
	// delete every day first
	for (var i = document.DCForm.day.options.length; i > 0; i--){
		document.DCForm.day.options[i] = null;
	}
	// rebuild days for this month
	var ttldays = dayofmon(document.DCForm.month.selectedIndex - 1, document.DCForm.year.options[document.DCForm.year.selectedIndex].value);
	for (i = 1; i <= ttldays; i++) {
		document.DCForm.day.options[document.DCForm.day.options.length] = new Option(i,i);
	}
}

//**************************** /DOB Functionality 


//----------------------------------------------- PC profile logic
function AllSiteUnsub(){
	if(confirm("By hitting Ok to submit this request, you will be unsubscribed from ALL EA Emails.\n\nYou may unsubscribe from individual emails by simply hitting Cancel and \ndeselecting specific check boxes.\n\n")){
		/*
			This function sets the Master Unsub Flag used by the PC
			unsubscribe from all sites and lists to ON.  It will also
			remove anything else that is currently checked on the page.

			For this to stay current, ANY additional checkboxes or 
			removal of checkboxes MUST be updated in this list.  Please
			merely comment out any removals so that a record is kept.

			Parent List - Definition:  
			Any list that must be subbed/unsubbed in conjunction
			with it's site.  Usually a hidden form element.
		*/
		//set Master Unsub Flag on
		document.DCForm.AllSiteNListUnsub.value = "1"
		/*
			Set Site Subriptions to Unsubscribe.  All elements are hidden. 
		*/
		document.DCForm.S_EA_Games.value = "1"					//Site: EA_Games
		document.DCForm.S_EA_Sports.value = "1"					//Site: EA_Sports
		document.DCForm.S_EA_SportsBIG.value = "1"				//Site: EA_SportsBIG
		document.DCForm.S_EA_SportsNation.value = "1"					//Site: EA_SportsNation
		document.DCForm.S_Earth_Beyond.value = "1"				//Site: Earth_Beyond		
		document.DCForm.S_Maxis.value = "1"							//Site: Maxis
		document.DCForm.S_Pogo.value = "1"							//Site: Pogo
		document.DCForm.S_Pogo_ToGo.value = "1"					//Site: Pogo_ToGo
		document.DCForm.S_TheSimsOnline.value = "1"	 			//Site: TheSimsOnline
		document.DCForm.S_UltimaOnline.value = "1"					//Site: UltimaOnline
		document.DCForm.S_Westwood.value = "1"					//Site: Westwood
		/*
			==== Site Level/List info categorized by Site: =====
		*/
		//Site: EA_Games
		//Lists
		document.DCForm.L_EA_Games_EA_Games_Main.checked = false; //Parent List 
		document.DCForm.L_EA_Games_Bond_List.checked = false;
		document.DCForm.L_EA_Games_LordOfTheRings_List.checked = false;
		document.DCForm.L_EA_Games_MedalofHonor_List.checked = false;
		document.DCForm.L_EA_Games_Battlefield_List.checked = false;
		document.DCForm.L_EA_Games_NeedForSpeed_List.checked = false;
		document.DCForm.L_EA_Games_Burnout_HouseList.checked = false;
		//Site: EA_Sports
			//Lists
		document.DCForm.L_EA_Sports_EA_Sports_Main.checked = false; //Parent List 
		document.DCForm.L_EA_Sports_Madden_List.checked = false;
		document.DCForm.L_EA_Sports_NBA_Live_List.checked = false;

		//Site: EA_SportsBIG
			//Profile Fields
			//Lists
		document.DCForm.L_EA_SportsBIG_EA_SportsBIG_Main.checked = false; //Parent List 
		//Site: EA_SportsNation
			//Profile Fields
			//Lists		
		//document.DCForm.L_EA_SportsNation_EA_SportsNation_HouseList.checked = false;//Parent List 
		//Site: Earth_Beyond
			//Profile Fields
			//Lists
		//document.DCForm.L_Earth_Beyond_EB_HouseList.checked = false; //Parent List 
		//Site: Maxis
			//Profile Fields
			//Lists
		document.DCForm.L_Maxis_Maxis_HouseList.checked = false; //Parent List 
		document.DCForm.L_Maxis_Sims2_List.checked = false;
		//Site: Pogo
			//Profile Fields
		document.DCForm.Pogo_Pogo_All.checked = false;
			//document.DCForm.Pogo_Pogo_All.value = "";
			//alert("Pogo_Pogo_All value is: " + document.DCForm.Pogo_Pogo_All.value)
		document.DCForm.Pogo_Pogo_Arcade.checked = false;
			//document.DCForm.Pogo_Pogo_Arcade.value = "";
			//alert("Pogo_Pogo_Arcade value is: " + document.DCForm.Pogo_Pogo_Arcade.value)
		document.DCForm.Pogo_Pogo_Casino.checked = false;
			//document.DCForm.Pogo_Pogo_Casino.value = "";
			//alert("Pogo_Pogo_Casino value is: " + document.DCForm.Pogo_Pogo_Casino.value)
		document.DCForm.Pogo_Pogo_Puzzle.checked = false;
			//document.DCForm.Pogo_Pogo_Puzzle.value = "";
			//alert("Pogo_Pogo_Puzzle value is: " + document.DCForm.Pogo_Pogo_Puzzle.value)
		document.DCForm.Pogo_Pogo_Sports.checked = false;	
			//document.DCForm.Pogo_Pogo_Sports.value = "";
			//alert("Pogo_Pogo_Sports value is: " + document.DCForm.Pogo_Pogo_Sports.value)
			//Lists
		document.DCForm.L_Pogo_Pogo_HouseList.checked = false; //Parent List 
		//Site: Pogo_ToGo
			//Profile Fields	
			//Lists
		document.DCForm.L_Pogo_ToGo_PogoToGo_List.checked = false; //Parent List 
		//Site: TheSimsOnline
			//Profile Fields
			//Lists
		//document.DCForm.L_TheSimsOnline_TSO_HouseList.checked = false; //Parent List 		
		//Site: UltimaOnline
			//Profile Fields
			//Lists			
		document.DCForm.L_UltimaOnline_UO_HouseList.checked = false;//Parent List 		
		//Site: Westwood
			//Profile Fields
			//Lists
		document.DCForm.L_Westwood_Westwood_HouseList.checked = false; //Parent List 

		document.DCForm.submit();
	}
}


		/*
			These functions keep checkboxes categorized by their DM Site so that check/unchecking
			them will check/uncheck all necessary corresponding checkboxes and reset any 
			hidden Site Sub/Unsub values
		*/

//----- Site: EA_Games
function Chk_EA_Games(Box){
	//If user selects a Games site level box, automatically check Site/List subscription box
	if (Box.checked){
		//set Master Unsub Flag off
		document.DCForm.AllSiteNListUnsub.value = "0"
		document.DCForm.L_EA_Games_EA_Games_Main.checked = true;
		//Set Site Subscribe Back on
		document.DCForm.S_EA_Games.value = "0"
	}
	
	else {
		if (	
			//Lists
			document.DCForm.L_EA_Games_Bond_List.checked == false &&
			document.DCForm.L_EA_Games_LordOfTheRings_List.checked == false &&
			document.DCForm.L_EA_Games_MedalofHonor_List.checked == false &&
			document.DCForm.L_EA_Games_Battlefield_List.checked == false &&
			document.DCForm.L_EA_Games_NeedForSpeed_List.checked == false &&
			document.DCForm.L_EA_Games_Burnout_HouseList == false){
			//Set Site Subscribe Off
			document.DCForm.L_EA_Games_EA_Games_Main.checked = false;
			document.DCForm.S_EA_Games.value = "1"
		}
	}
}

//If user clicks this suite subscribe off, uncheck all associated site level fields
function EA_GamesOff(){
	//Check to reset Client Unsub off if user clicked on a site subscribe
	//SiteOff()

	if (document.DCForm.L_EA_Games_EA_Games_Main.checked == false){
		//Lists
		document.DCForm.L_EA_Games_Bond_List.checked = false;
		document.DCForm.L_EA_Games_LordOfTheRings_List.checked = false;
		document.DCForm.L_EA_Games_MedalofHonor_List.checked = false;
		document.DCForm.L_EA_Games_Battlefield_List.checked = false;
		document.DCForm.L_EA_Games_NeedForSpeed_List.checked = false;
		//Set Site Subscribe Off
		document.DCForm.S_EA_Games.value = "1";
	}
}

//----- Site: EA_Sports
function Chk_EA_Sports(Box){
	if (Box.checked){
			//set Master Unsub Flag off
			document.DCForm.AllSiteNListUnsub.value = "0"
			document.DCForm.L_EA_Sports_EA_Sports_Main.checked = true;
			//Set Site Subscribe Back on
			document.DCForm.S_EA_Sports.value = "0"
	}
	else {
		if (document.DCForm.L_EA_Sports_Madden_List.checked == false &&
			document.DCForm.L_EA_SportsEspanol_EA_SportsEspanol_HouseList.checked == false &&
			document.DCForm.L_EA_Sports_NBA_Live_List.checked == false){
		//Set Site Subscribe Off
		document.DCForm.S_EA_Sports.value = "1";
		document.DCForm.L_EA_Sports_EA_Sports_Main.checked = false;
		}
	}
}
//If user clicks this suite subscribe off, uncheck all associated site level fields
function EA_SportsOff(){
	//Check to reset Client Unsub off if user clicked on a site subscribe
	//SiteOff()

	if (document.DCForm.L_EA_Sports_EA_Sports_Main.checked == false){
		//Site Profile Fields
		//Lists
		//Set Site Subscribe Off
		document.DCForm.L_EA_Sports_Madden_List.checked = false;
		document.DCForm.L_EA_SportsEspanol_EA_SportsEspanol_HouseList.checked = false;
		document.DCForm.L_EA_Sports_NBA_Live_List.checked = false;
		
		document.DCForm.S_EA_Sports.value = "1";
	}
}

//----- Site: Maxis
function Chk_EA_SportsEspanol(Box){
	if (Box.checked){
		//set Master Unsub Flag off
		document.DCForm.AllSiteNListUnsub.value = "0"
		//Set Site Subscribe Back on
		document.DCForm.S_EA_SportsEspanol.value = "0"
	}
	else {
		if (document.DCForm.L_EA_SportsEspanol_EA_SportsEspanol_HouseList.checked == false){
			//Set Site Subscribe Off
			document.DCForm.S_EA_SportsEspanol.value = "1"	
		}
	}
}


//----- Site: EA_SportsBIG: Single List Site
function Chk_EA_SportsBIG(Box){
	if (Box.checked){
		//set Master Unsub Flag off
		document.DCForm.AllSiteNListUnsub.value = "0"
		//Set Site Subscribe Back on
		document.DCForm.S_EA_SportsBIG.value = "0"
	}
	else {
		//Set Site Subscribe Off
		document.DCForm.S_EA_SportsBIG.value = "1"	
	}
}

//----- Site: EA_SportsNation: Single List Site
function Chk_EA_SportsNation(Box){
	if (Box.checked){
		//set Master Unsub Flag off
		document.DCForm.AllSiteNListUnsub.value = "0"
		//Set Site Subscribe Back on
		document.DCForm.S_EA_SportsNation.value = "0"
	}
	else {
		//Set Site Subscribe Off
		document.DCForm.S_EA_SportsNation.value = "1"	
	}
}

//----- Site: Earth_Beyond: Single List Site
function Chk_Earth_Beyond(Box){
	if (Box.checked){
		//set Master Unsub Flag off
		document.DCForm.AllSiteNListUnsub.value = "0"
		//Set Site Subscribe Back on
		document.DCForm.S_Earth_Beyond.value = "0"
	}
	else {
		//Set Site Subscribe Off
		document.DCForm.S_Earth_Beyond.value = "1"	
	}
}

//----- Site: Maxis
function Chk_Maxis(Box){
	if (Box.checked){
		//set Master Unsub Flag off
		document.DCForm.AllSiteNListUnsub.value = "0"
		//Set Site Subscribe Back on
		document.DCForm.S_Maxis.value = "0"
	}
	else {
		if (document.DCForm.L_Maxis_Maxis_HouseList.checked == false &&
			document.DCForm.L_Maxis_Sims2_List.checked == false){
			//Set Site Subscribe Off
			document.DCForm.S_Maxis.value = "1"	
		}
	}
}


//----- Site: Pogo
function Chk_Pogo(Box){
	if (Box.checked){
			document.DCForm.L_Pogo_Pogo_HouseList.checked = true;
			//set Master Unsub Flag off
			document.DCForm.AllSiteNListUnsub.value = "0"
			//Set Site Subscribe Back on
			document.DCForm.S_Pogo.value = "0"
			document.DCForm.PogoPC_SubDateTime.value = "1"

	}
	else {
		if (	document.DCForm.Pogo_Pogo_All.checked == false &&
			document.DCForm.Pogo_Pogo_Arcade.checked == false &&
			document.DCForm.Pogo_Pogo_Sports.checked == false &&
			document.DCForm.Pogo_Pogo_Casino.checked == false &&
			document.DCForm.Pogo_Pogo_Puzzle.checked == false){
			//Set Site Subscribe Off
			document.DCForm.L_Pogo_Pogo_HouseList.checked = false;
			document.DCForm.S_Pogo.value = "1"	
			document.DCForm.PogoPC_SubDateTime.value = "0"
		}
	}
}
//If user clicks this suite subscribe off, uncheck all associated site level fields	
function PogoOff(){
	//Check to reset Client Unsub off if user clicked on a site subscribe
	//SiteOff()
	if (document.DCForm.L_Pogo_Pogo_HouseList.checked == false){
		document.DCForm.Pogo_Pogo_All.checked = false;
		document.DCForm.Pogo_Pogo_Arcade.checked = false;
		document.DCForm.Pogo_Pogo_Sports.checked = false;
		document.DCForm.Pogo_Pogo_Casino.checked = false;
		document.DCForm.Pogo_Pogo_Puzzle.checked = false;
		//Set Site Subscribe Off
		document.DCForm.S_Pogo.value = "1"
		document.DCForm.PogoPC_SubDateTime.value = "0"
	}
}


//----- Site: Pogo_ToGo: Single List Site
function Chk_Pogo_ToGo(Box){
	if (Box.checked){
		//set Master Unsub Flag off
		document.DCForm.AllSiteNListUnsub.value = "0"
		//Set Site Subscribe Back on
		document.DCForm.S_Pogo_ToGo.value = "0"
	}
	else {
		//Set Site Subscribe Off
		document.DCForm.S_Pogo_ToGo.value = "1"	
	}
}


//----- Site: TheSimsOnline: Single List Site
function Chk_TheSimsOnline(Box){
	if (Box.checked){
		//set Master Unsub Flag off
		document.DCForm.AllSiteNListUnsub.value = "0"
		//Set Site Subscribe Back on
		document.DCForm.S_TheSimsOnline.value = "0"
	}
	else {
		//Set Site Subscribe Off
		document.DCForm.S_TheSimsOnline.value = "1"	
	}
}


//----- Site: UltimaOnline: Single List Site
function Chk_UltimaOnline(Box){
	if (Box.checked){
		//set Master Unsub Flag off
		document.DCForm.AllSiteNListUnsub.value = "0"
		//Set Site Subscribe Back on
		document.DCForm.S_UltimaOnline.value = "0"
	}
	else {
		//Set Site Subscribe Off
		document.DCForm.S_UltimaOnline.value = "1"	
	}
}

//----- Site: Westwood: Single List Site
function Chk_Westwood(Box){
	if (Box.checked){
		//set Master Unsub Flag off
		document.DCForm.AllSiteNListUnsub.value = "0"
		//Set Site Subscribe Back on
		document.DCForm.S_Westwood.value = "0"
	}
	else {
		//Set Site Subscribe Off
		document.DCForm.S_Westwood.value = "1"	
	}
}


//Sets client Unsub back off if after user sets it on, they check a Site subscribe field 
function SiteOff(){

	//BP: 03/26/2003 - Re-wrote this check to explicit names to support removal/addition of sites
	if (document.DCForm.site1.checked == true ||
		document.DCForm.site2.checked == true ||
	//BP: site3 was previously removed and causing error in old JS
	//	document.DCForm.site3.checked == true ||
		document.DCForm.site4.checked == true ||
		document.DCForm.site5.checked == true ||
		document.DCForm.site6.checked == true ||
		document.DCForm.site7.checked == true ||
		document.DCForm.site8.checked == true ||
		document.DCForm.site9.checked == true ||
		document.DCForm.site10.checked == true ||
		document.DCForm.site11.checked == true){
//BP: Removed per CRD: 2003-18044
//		document.DCForm.site12.checked == true
		
		document.DCForm.AllSiteNListUnsub.value = "0";
	}
}

//End DoubleClick Error Checking
