var errorcolor = "#e7d6ab"; //this is the error hightlight color of fields
var normalcolor = "#ffffff";  // this is the normal background of fields

function validateNewsletterForm()
{   var alertMessage = "Please enter your: \n";
    var isAlert = false;

    // Makes sure the Date of Birth Fields arent empty
    if( !validateNotEmpty( document.contest.birthMonth.value ) )
    {   alertMessage += "Birth date: Month \n";
        document.contest.birthMonth.style.background = errorcolor;
        isAlert = true;
    }
    if( !validateNotEmpty( document.contest.birthDay.value ) )
    {   alertMessage += "Birth date: Day \n";
        document.contest.birthDay.style.background = errorcolor;
        isAlert = true;
    }
    if( !validateNotEmpty( document.contest.birthYear.value ) )
    {   alertMessage += "Birth date: Year \n";
        document.contest.birthYear.style.background = errorcolor;
        isAlert = true;
    }

    // The following Validates Emails are in correct Syntax
    if( !validateEmail( document.contest.email.value ) )
    {   alertMessage += "Email \n";
        document.contest.email.style.background = errorcolor;
        isAlert = true;
    }

    if( isAlert )
    {   alert( alertMessage );
    }
    else
    {   // *** This takes the THREE DOB fields (MONTH,DAY,YEAR) and puts them into one field (DOB) for Coppa validation
        var dob = document.contest.birthMonth.value + "/" + document.contest.birthDay.value + "/" + document.contest.birthYear.value;
        document.contest.dob.value = dob;
        IsUnderage( document.contest );
    }

}

function validateContestForm()
{   var alertMessage = "Please enter your: \n";
	var alertMessage2 = "\n";
	var alertMessage3 = "\n";
    var isAlert = false;
	var isAlert2 = false;
	var isAlert3 = false;
	
    if( !validateNotEmpty( document.command.optionalText1.value ) )
    {   alertMessage2 += "Watch episodes of PRIVATE for the codes you need to register for your chance to win prizes! \n";
        document.command.optionalText1.style.background = errorcolor;
        isAlert2 = true;
    }
	else{
	
		if(!document.command.optionalCheckbox1.checked)
		{
			alertMessage3 += "      Do you agree to the terms and policy? \n";
        	document.command.optionalCheckbox1.style.background = errorcolor;
        	isAlert3 = true;
		}
		else{
	
    	// The following makes sure a field is NOT EMPTY  (validateNotEmpty) Repeat As necessary
    	if( !validateNotEmpty( document.command.firstName.value ) )
    	{ 
			alertMessage += "First Name \n";
        	document.command.firstName.style.background = errorcolor;
        	isAlert = true;
    	}

    	if( !validateNotEmpty( document.command.lastName.value ) )
    	{   alertMessage += "Last Name \n";
        	document.command.lastName.style.background = errorcolor;
        	isAlert = true;
    	}

    	// Makes sure the Date of Birth Fields arent empty
    	if( !validateNotEmpty( document.command.birthMonth.value ) )
    	{   alertMessage += "Birth date: Month \n";
        	document.command.birthMonth.style.background = errorcolor;
        	isAlert = true;
    	}
    	if( !validateNotEmpty( document.command.birthDay.value ) )
    	{   alertMessage += "Birth date: Day \n";
        	document.command.birthDay.style.background = errorcolor;
        	isAlert = true;
    	}
    	if( !validateNotEmpty( document.command.birthYear.value ) )
    	{   alertMessage += "Birth date: Year \n";
        	document.command.birthYear.style.background = errorcolor;
        	isAlert = true;
    	}

    	// The following Validates Emails are in correct Syntax
    	if( !validateEmail( document.command.email.value ) )
    	{   alertMessage += "Email \n";
        	document.command.email.style.background = errorcolor;
        	isAlert = true;
    	}

    	if( !validateNotEmpty( document.command.address1.value ) )
    	{   alertMessage += "Address \n";
        	document.command.address1.style.background = errorcolor;
        	isAlert = true;
    	}

    	if( !validateNotEmpty( document.command.city.value ) )
    	{   alertMessage += "City \n";
        	document.command.city.style.background = errorcolor;
        	isAlert = true;
    	}

    	if( !validateNotEmpty( document.command.state.value ) )
    	{   alertMessage += "State \n";
        	document.command.state.style.background = errorcolor;
        	isAlert = true;
    	}

    	if( !validateNotEmpty( document.command.zip.value ) )
    	{   alertMessage += "Zip \n";
        	document.command.zip.style.background = errorcolor;
        	isAlert = true;
    	}

    	if( !validateNotEmpty( document.command.phone.value ) )
    	{   alertMessage += "Phone \n";
        	document.command.phone.style.background = errorcolor;
        	isAlert = true;
    	}

    	if( !validateNotEmpty( document.command.gender.value ) )
    	{   alertMessage += "Gender \n";
        	document.command.gender.style.background = errorcolor;
        	isAlert = true;
    	}
		}
	
	}

    if( isAlert || isAlert2 || isAlert3)
    {   
		if(isAlert)
		{
		alert( alertMessage );
		}
		if(isAlert2)
		{
		alert( alertMessage2 );
		}
		if(isAlert3)
		{
		alert( alertMessage3 );
		}
		
    }
    else
    {   // *** This takes the THREE DOB fields (MONTH,DAY,YEAR) and puts them into one field (DOB) for Coppa validation
        var dob = document.command.birthMonth.value + "/" + document.command.birthDay.value + "/" + document.command.birthYear.value;
        document.command.dob.value = dob;
        IsUnderage( document.command );
    }
}


