
function submitSignup() {
	postinterfaceSubmit('subform', 'email,firstname,birthyear,birthmonth,birthday', 
		'emailerror,firstnameerror,birthyearerror,birthmontherror,birthdayerror', null, null, customValidation);
}

function customValidation() {
	if (null != document.getElementById('subscribe_failed'))
		document.getElementById('subscribe_failed').style.display = 'none';
	if (null != document.getElementById('email_not_match'))
		document.getElementById('email_not_match').style.display = 'none';
	if (null != document.getElementById('sendme_error'))
		document.getElementById('sendme_error').style.display = 'none';
	var error = false;
	if (!document.getElementById('sendme').checked) {
		document.getElementById('sendme_error').style.display = '';
		error = true;
	}
	if (document.getElementById('emailerror').style.display == 'none') {
		// if email is valid
		if (document.getElementById('email').value.toLowerCase() != document.getElementById('confirmmail').value.toLowerCase()) {
			document.getElementById('email_not_match').style.display = '';
			error = true;
		}
	}
	return error;
}

function submitRightboxSignup(type) {
	if (null != document.getElementById('signup_error_' + type))
		document.getElementById('signup_error_' + type).style.display = 'none';
	
	_customtype = type;
	postinterfaceSubmit('subform_' + type, 'email_' + type + ',firstname_' + type + ',birthyear_' + type + ',birthmonth_' + type + ',birthday_' + type + '', 
		'signup_error_' + type + ',signup_error_' + type + ',signup_error_' + type + ',signup_error_' + type + ',signup_error_' + type + '', null, null, customRightboxValidation);
}

var _customtype = 1;
function customRightboxValidation() {
	var error = false;
	if (!document.getElementById('sendme_' + _customtype).checked) {
		document.getElementById('signup_error_' + _customtype).style.display = '';
		error = true;
	}
	return error;
}

function checkEnter(e) {
	var characterCode;
	if(e && e.which) {
		characterCode = e.which;
	} else {
		e = event
		characterCode = e.keyCode;
	}

	if(characterCode == 13) {
		submitSignup();
		return false;
	} else {
		return true;
	}
}

