<!--- hiding
function validateConsumer( TheForm ) 
{
	validateOptIn( TheForm );
	
var blnRetVal = true;
	var consumer = new UnileverConsumer( TheForm );
	
	consumer.unMark();
	if( !consumer.isFormBlank() )
	{
		alert("E-Mail address and First name are required. Please fill in.");
		return !blnRetVal;
	}
	consumer.fixDataFields( TheForm );
	if( !consumer.validateFields() )
	{
		return !blnRetVal;
	}
	if ( Trim( eval('document.' + TheForm + '.fname').value ) != '' )		
		eval('document.' + TheForm + '.firstname').value = eval('document.' + TheForm + '.fname').value;
	if ( Trim( eval('document.' + TheForm + '.lname').value ) != '' )		
		eval('document.' + TheForm + '.lastname').value = eval('document.' + TheForm + '.lname').value;
}
function UnileverConsumer(frmName)
{	
	this.defaultFontWeight = 'normal'; 
	this.defaultColor = '#2B8EBC'; 
	this.errorFontWeight = 'bold';
	this.errorColor = '#F2170C';
	
	this.email = eval('document.' + frmName + '.email');
	this.fname = eval('document.' + frmName + '.fname');
	this.lname = eval('document.' + frmName + '.lname');
	this.address = eval('document.' + frmName + '.address');
	this.addr2 = eval('document.' + frmName + '.address2');
	this.city = eval('document.' + frmName + '.city');
	this.state = eval('document.' + frmName + '.state');
	this.zip = eval('document.' + frmName + '.zip');
	this.blnFormBlank = false;
	this.isFormBlank = isFormBlank;
	this.fixDataFields = fixDataFields;
	this.validateFields = validateFields;
	this.checkTextField = checkTextField;
	this.unMark = unMark;
	this.mark = mark;
}
function unMark()
{
	document.getElementById('divemail').style.fontWeight = this.defaultFontWeight
	document.getElementById('divemail').style.color = this.defaultColor
	document.getElementById('divfirstname').style.fontWeight = this.defaultFontWeight
	document.getElementById('divfirstname').style.color = this.defaultColor
	document.getElementById('lname').style.fontWeight = this.defaultFontWeight
	document.getElementById('lname').style.color = this.defaultColor
	document.getElementById('city').style.fontWeight = this.defaultFontWeight
	document.getElementById('city').style.color = this.defaultColor
	document.getElementById('address').style.fontWeight = this.defaultFontWeight
	document.getElementById('address').style.color = this.defaultColor
	document.getElementById('address2').style.fontWeight = this.defaultFontWeight
	document.getElementById('address2').style.color = this.defaultColor
	document.getElementById('zip').style.fontWeight = this.defaultFontWeight
	document.getElementById('zip').style.color = this.defaultColor

}

function mark(elementName)
{
	document.getElementById(elementName).style.fontWeight = this.errorFontWeight;
	document.getElementById(elementName).style.color = this.errorColor;
}
function mark(elementName)
{
	document.getElementById(elementName).style.fontWeight = this.errorFontWeight;
	document.getElementById(elementName).style.color = this.errorColor;
}
function validateFields()
{	
	//validate the email address
	if( !validateEmail( this.email.value ) )
	{
		return this.checkTextField('divemail', 'Enter a valid Email Address', 'email');
    }
	//validate the firstname
	if( Trim(this.fname.value) != '' )
	if( !validateAlpha( this.fname.value ) )
		return this.checkTextField('divfirstname', 'Enter First Name with only alpha characters', 'fname');
		
	//validate the lastname
	if( Trim(this.lname.value) != '' )
	if( !validateAlpha( this.lname.value ) )
		return this.checkTextField('lname', 'Enter Last Name with only alpha characters', 'lname');
	
	//validate the city
	if( Trim(this.city.value) != '' )
	if( !validateAlpha( this.city.value ) )
		return this.checkTextField('city', 'Enter City with only alpha characters', 'city');

	//validate the address
	if( Trim(this.address.value) != '' )
	if( !isValid( this.address.value ) )
		return this.checkTextField('address', 'Enter Address with only alpha and numeric characters', 'address');
	
	if( Trim(this.addr2.value) != '' )
	if( !isValid( this.addr2.value ) )
		return this.checkTextField('address2', 'Enter Address2 with only alpha and numeric characters', 'addr2');
	  
	//validate the zip code
	if( Trim(this.zip.value) != '' )
	if( !validateZip( this.zip.value ) )
		return this.checkTextField('zip', 'Enter Zipcode with only numerics \nand either 5 or 9 digits', 'zip');

	return true;
}


function isValid(strValue) {
	var blnRetVal = true;
	var strTest = new String(strValue);
	var pattern = new RegExp(/[^a-zA-Z0-9^\-^^ ^.\^'\^#]/);
	var result = strTest.match(pattern);
	if (result)
		var blnRetVal = false;

	return blnRetVal;
}
function validateZip(strValue) {
	var blnRetVal = true;
				
	var strTest = new String(strValue);
	var pattern = new RegExp(/[^0-9^\-]/);
	var result = strTest.match(pattern)
	if (result) 
		blnRetVal = false;
					
	//Check the length of the zip code
	if (blnRetVal == true) {
		if (strTest.length != 0 && strTest.length !=5 && strTest.length !=9) 
		   	blnRetVal = false;
	}
						
	return blnRetVal;
						
}
function validateEmail(strValue)
{
	var oRegExp = new RegExp(/^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/);
	if (oRegExp.test(strValue))
	{	//proper email address
	return true;
	}
	else
	{	//improper email address
	return false;
	}
}
	
function checkTextField(sMarkField, sAlert, sField)
{
	this.mark( sMarkField )
	alert( sAlert );
	eval('this.' + sField + '.focus()');
	eval('this.' + sField + '.select()');
	return false;
}

function isFormBlank()
{
	var blnFlag = false;
	var oRegExp = new RegExp(/\S/);
	if( !oRegExp.test(this.email.value) )
	{	
		this.blnFormBlank = true;
		this.mark('divemail')
	}
	if( !oRegExp.test(this.fname.value) )
	{	
		this.blnFormBlank = true;
		this.mark('divfirstname')
	}
	return !this.blnFormBlank
}

function fixDataFields(frmName)
{
	if( Trim(this.addr2.value) == '' )
		 eval('document.' + frmName + '.address2').value = ""
	else
		eval('document.' + frmName + '.address2').value = Trim(this.addr2.value)
		
	if( this.state.selectedIndex == 0 )
		 eval('document.' + frmName + '.state').value = ""  
	else
		eval('document.' + frmName + '.state').value = Trim(this.state.value)
	}
function validateOptIn(frmName)
{	
	eval( 'document.' + frmName + '.optin' ).value = ""
	if( eval( 'document.' + frmName + '.optinallBrands' ).checked )
		eval( 'document.' + frmName + '.optin' ).value = "allBrands ,"
	if( eval( 'document.' + frmName + '.optinbrandonly' ).checked )
		eval( 'document.' + frmName + '.optin' ).value += "SuaveOnly"
	if( eval( 'document.' + frmName + '.optin' ).value.charAt( eval( 'document.' + frmName + '.optin' ).value.length - 1 ) == "," )
		eval( 'document.' + frmName + '.optin' ).value = eval( 'document.' + frmName + '.optin' ).value.substr( 0, ( eval( 'document.' + frmName + '.optin' ).value.length - 1 ) )
	if( eval( 'document.' + frmName + '.optin' ).value == "" )
		eval( 'document.' + frmName + '.optin' ).value = "NONE"
		
	
}

function mark(elementName)
{
    document.getElementById(elementName).style.fontweight = this.errorFontWeight;
	document.getElementById(elementName).style.color = this.errorColor;
}

function Trim(strText)
{
	while(strText.length != 0 && strText.charAt(0) == " ")
	{
		strText=strText.substring(1,strText.length)
	}
	while(strText.length != 0 && strText.charAt(strText.length-1) == " ")
	{
		strText=strText.substring(0,strText.length-1)
	}
	return(strText)
}
function validateAlpha(strValue) {
	var blnRetVal = true;
	var strTest = new String(strValue);
	var pattern = new RegExp(/[^a-zA-Z^\-^`^ ^'^_]/);
	var result = strTest.match(pattern)
	if (result)
		blnRetVal = false;
						
	return blnRetVal;
						
}
// end hiding --->