//cn start
function cnsOnFocus(obj) {
	obj.style.backgroundColor="";
	document.getElementById("cnEX").innerHTML = "Please enter your Account ID.";
}

function cnsValidate(obj) {
	document.getElementById("cnEX").innerHTML = "";
	obj.style.backgroundColor = "";
	var cn = obj.value;
	var reg = /^[a-zA-Z0-9]{1}[-._a-zA-Z0-9]{4,15}$/;

	if (!reg.test(cn)) {
		obj.style.backgroundColor = 'pink';
		document.getElementById("cnEX").innerHTML = "<font color='red'>Invalid Account ID format.</font>";
        return false;
	}

	obj.style.backgroundColor = "ccff99";
	return true;
}
//cn end

//password start
function passwordsOnFocus(obj) {
	obj.style.backgroundColor="";
	document.getElementById("passwordEX").innerHTML = "Please enter your Password.";	
}

function passwordsValidate(obj) {
	document.getElementById("passwordEX").innerHTML = "";
	obj.style.backgroundColor = "";
	var password = obj.value;
	var cn = document.getElementById("cn").value;
	var reg = /^[~`!@#$%\^&*()_+=\-{}\]\[:;',.<>\/?"a-zA-Z0-9]{4,16}$/;
	//without space,'"
	if (!reg.test(password)) {
		obj.style.backgroundColor = 'pink';
		document.getElementById("passwordEX").innerHTML = "<font color='red'>Incorrect Password.</font>";
        return false;
	}
	if (password == cn) {
		obj.style.backgroundColor = 'pink';
		document.getElementById("passwordEX").innerHTML = "<font color='red'>Account ID and Password cannot be the same. Please change your Password.</font>";
        return false;
	}
	obj.style.backgroundColor = "ccff99";
	return true;
}
//password end

//superPassword start
function superPasswordsOnFocus(obj) {
	obj.style.backgroundColor="";
	document.getElementById("superPasswordEX").innerHTML = "Please enter your Super Password.";	
}

function superPasswordsValidate(obj) {
	document.getElementById("superPasswordEX").innerHTML = "";
	obj.style.backgroundColor = "";
	var superPassword = obj.value;
	var reg = /^[^\s,\u0027\u0022]{8,16}$/;
	//without space,'"
	if (!reg.test(superPassword)) {
		obj.style.backgroundColor = 'pink';
		document.getElementById("superPasswordEX").innerHTML = "<font color='red'>Incorrect Super Password.</font>";
        return false;
	}
	obj.style.backgroundColor = "ccff99";
	return true;
}
//superPassword end

//email start
function emailsOnFocus(obj) {
	obj.style.backgroundColor="";
	document.getElementById("emailEX").innerHTML = "Please enter your Security E-mail.";
}

function emailsValidate(obj) {
	document.getElementById("emailEX").innerHTML = "";
	obj.style.backgroundColor = "";
	var email = obj.value;
	if (email.length == 0) {
		obj.style.backgroundColor = 'pink';
		document.getElementById("emailEX").innerHTML = "<font color='red'>Please enter your Security E-mail.</font>";
        return false;
	}
	if (email.length > 50) {
		obj.style.backgroundColor = 'pink';
		document.getElementById("emailEX").innerHTML = "<font color='red'>There is a 50 characters limit.</font>";
        return false;
	}
	var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if (!reg.test(email)) {
		obj.style.backgroundColor = 'pink';
		document.getElementById("emailEX").innerHTML = "<font color='red'>Invalid E-mail address format.</font>";
        return false;
	}
	
	obj.style.backgroundColor="ccff99";
	return true;
}
//email end