document.domain = "joymax.com";

function isField(keyword) {
	var st_num,key_len;
	st_num = keyword.indexOf(" ");
	while (st_num != -1){
		keyword = keyword.replace(" ", "");
		st_num  = keyword.indexOf(" ");
	}
	key_len=keyword.length;
	return key_len;
}

function CheckChar(str) {
	strarr = new Array(str.length);
	var flag = true;
	for (i=0; i<str.length; i++) {
		strarr[i] = str.charAt(i)
		if (i==0) {
			if (!((strarr[i]>='a')&&(strarr[i]<='z'))) {
				flag = false;
			}
		}
		else if (i==1) {
			if (!((strarr[i]>='a')&&(strarr[i]<='z'))) {
				flag = false;
			}
		}
		else if (i==2) {
			if (!((strarr[i]>='a')&&(strarr[i]<='z'))) {
				flag = false;
			}
		}
		else {
			if (!((strarr[i]>='a')&&(strarr[i]<='z')||(strarr[i]>='0')&&(strarr[i]<='9'))) {
				flag = false;
			}
		}
	}
	if (flag) {
		return true;
	} else {
		return false;
	}
}

function CheckChar2(str) {
	strarr = new Array(str.length);
	var flag = true;
	for (i=0; i<str.length; i++) {
		strarr[i] = str.charAt(i)
		if (!((strarr[i]>='a')&&(strarr[i]<='z')||(strarr[i]>='0')&&(strarr[i]<='9'))) {
			flag = false;
		}
	}
	if (flag) {
		return true;
	} else {
		return false;
	}
}

function check_submit(frm){

	if (isField(frm.userId.value) < 6) {
		alert("Type ID with more than 6 digits.");
		frm.userId.focus();
		return false;
	}

	if (isField(frm.userId.value) > 12) {
		alert("ID can not be exceeded 12 digits.");
		frm.userId.focus();
		return false;
	}

	if (isField(frm.userId.value) != "") {
		thisfilednum1 = CheckChar(frm.userId.value);
		if (!thisfilednum1)
		{
			alert("ID can be made by small English letter and number.\n\nFirst 3 letters must be small English letter.");
			frm.userId.focus();
			frm.userId.select();
			return false;
		}
	}

	if (frm.userPwd.value == "") {
		alert("Type your Password");
		frm.userPwd.focus();
		return false;
	}

	if (isField(frm.userPwd.value) < 6) {
		alert("Type Password with more than 6 digits.");
		frm.userPwd.focus();
		frm.userPwd.select();
		return false;
	}

	if (isField(frm.userPwd.value) > 12) {
		alert("Password can not be exceeded 12 digits.");
		frm.userPwd.focus();
		frm.userPwd.select();
		return false;
	}
	
	frm.target = "_top";
	frm.workURL.value = "https://portalcp.joymax.com/member/login_Pcs.jmx";
	frm.action = "https://www.joymax.com/portal/Joymax_Front.jmx";

	return true;

}