function validateEmail(emailAddresses, statusLabel) {
//validate the email address before we head to the server.

	// Clear prior status messages in case there are any for add email.
	if(document.getElementById('statusAdded') != null) {
		document.getElementById('statusAdded').innerHTML='';
	}
	if(document.getElementById('statusNotAdded') != null) {
		document.getElementById('statusNotAdded').innerHTML='';
	}

	//remove all the spaces
	emailAddresses = emailAddresses.replace(/^\s+/g, '').replace(/\s+/g, '')

	if (emailAddresses == '') {
		statusLabel.innerHTML = '<br><span class="red">' + invalidEmailError + '</span>';
		return false;
	}

  	if (emailAddresses.match(/^([_a-zA-Z0-9][_a-zA-Z0-9'\.\-\+\&\/]*@[a-zA-Z_0-9][a-zA-Z0-9\-]*([\.]+[a-zA-Z0-9\-]+)*)+$/gi) == null) {
		// ensure we have atleast one valid character before the @, atleast one between @ and . and atleast 3 characters after the .
		statusLabel.innerHTML = '<br><span class="red">'  + invalidEmailError + '</span>';
		return false;
	} else {
		return true;
	} // end else
} // end function validateEmail

var invalidEmailError = "Please enter an e-mail address.";
var blankEmailError = "It appears that you did not enter an e-mail address - please try again!";

function validateProfileForm(statusLabel) {
	if (document.getElementById("txtEmail").value == '') {
		document.getElementById("lblEmailStatus").innerHTML = blankEmailError;
		document.getElementById("lblEmailStatus").style.visibility = 'visible';
		return false;
	}
	else if (validateEmail(document.getElementById("txtEmail").value, document.getElementById("lblEmailStatus"))) {
		document.getElementById("lblEmailStatus").innerHTML = '';
		document.getElementById("lblEmailStatus").style.visibility = 'hidden';
		return true;
	} else {
		document.getElementById("lblEmailStatus").innerHTML = document.getElementById("lblEmailStatus").innerHTML;
		document.getElementById("lblEmailStatus").style.visibility = 'visible';
		return false;
	} //end if
} //end validateForm

//Hide/Show postcode dropdown list on Signin/Singup pages
function HidePostalCodeDD(countryCode){
    if(document.getElementById('NewSubscriptionModule_CountryList').value!=countryCode){
        if (document.getElementById('NewSubscriptionModule_PostCode')){
            document.getElementById('NewSubscriptionModule_PostCode').style.visibility='hidden';
        }
        if(document.getElementById('NewSubscriptionModule_lblPostCode')){
            document.getElementById('NewSubscriptionModule_lblPostCode').style.visibility='hidden';
        }
        if(document.getElementById('NewSubscriptionModule_lblPostCodeStatus')){
            document.getElementById('NewSubscriptionModule_lblPostCodeStatus').style.visibility='hidden';
        }
        if(document.getElementById('NewSubscriptionModule_PostCode')){
            document.getElementById('NewSubscriptionModule_PostCode').value='';
        }
    }else{
	    if(document.getElementById('NewSubscriptionModule_PostCode')){
	        document.getElementById('NewSubscriptionModule_PostCode').style.visibility='visible';
	    }
	    if(document.getElementById('NewSubscriptionModule_lblPostCode')){
            document.getElementById('NewSubscriptionModule_lblPostCode').style.visibility='visible';
	    }
	    if(document.getElementById('NewSubscriptionModule_lblPostCodeStatus')){
	        document.getElementById('NewSubscriptionModule_lblPostCodeStatus').style.visibility='visible';
	    }
	}
}