//<![CDATA[
// JavaScript Document

// Cookie
function setCookie(c_name, value, expiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie ( cookie_name ) {
	var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
	if ( results ) return ( unescape ( results[2] ) );
	else return null;
}

// Login Cookie 설정
function loginOnLoad() {
	if ( getCookie('FUNFUN_CHECK') == "true") {
		document.fLoginform.secure.checked = true;
		document.fLoginform.user_id.value = getCookie('FUNFUN_LOGID');
		document.fLoginform.action='https://secure.neofun.com/account/process/process_login.asp';
	} else {
		document.fLoginform.secure.checked = false;
		document.fLoginform.action='http://secure.neofun.com/account/process/process_login.asp';
	}
}

function changeSecure(f) {
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + 30 );
	setCookie('FUNFUN_CHECK', f.secure.checked, todayDate);
	setCookie('FUNFUN_LOGID', f.user_id.value, todayDate);
	if (f.secure.checked) {
		document.f.action='https://secure.neofun.com/account/process/process_login.asp';
	} else {
		document.f.action='http://secure.neofun.com/account/process/process_login.asp';
	}
}

// Ranking 정보
function imgChagne(obj) {
	if(obj == 1) {
		document.getElementById('image1').src = "/images/main/RK_tep_btn01.gif";
		document.getElementById('image2').src = "/images/main/RK_tep_btn02_r.gif";
		document.getElementById('bb').style.display = "block";
		document.getElementById('cc').style.display = "none";
	}else {
		document.getElementById('image1').src = "/images/main/RK_tep_btn01_r.gif";
		document.getElementById('image2').src = "/images/main/RK_tep_btn02.gif";
		document.getElementById('bb').style.display = "none";
		document.getElementById('cc').style.display = "block";
	}
}

function playFlash(filename,width,height,id,trans,lock) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="movie" value="'+filename+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="'+trans+'" /><param name="menu" value="'+lock+'" /><embed src="'+filename+'" quality="high" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="'+id+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>')
}
// 받아오는 변수 : 파일명, 폭, 높이, 아이디설정, wmode설정, menu설정

function TopMenuCreate(xObj, xWidth, xHeight, xParam, xEmbed) {
	var xCreateStr = '';
	xCreateStr = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ xWidth +'" height="'+ xHeight+'">';
	xParamArry = xParam.split('||');
	
	var cnt = xParamArry.length;
	xTmp = new Array(cnt);
	
	for(var i = 0; i < cnt; i++) {
		xCreateStr = xCreateStr + xParamArry[i].toString();
	}

	xCreateStr = xCreateStr + xEmbed;
	xCreateStr = xCreateStr + '</object>';
	xObj.innerHTML = xCreateStr.toString();
}

// 회원 로그인시
function goLogin_Submit(f) {
	var s = "";
	if (s = word_filter_check(f.user_id.value)) {
		alert("Invalid ID: Use of word ('"+s+"') is not allowed.");
		f.user_id.focus();
		return;
	}

	if ( chkRegPattern('uid', f.user_id.value) == false ) {
		alert("First letter should be alphabet. Must be a combination of alphabet+number.\nID should contain more than 5 charaters.");
		f.user_id.focus();
		return;
	}

	if (!isValidPassword(f.user_id.value)) {
		alert("Invalid ID.");
		f.user_id.focus();
		return;
	}

	if (s = word_filter_check(f.user_password.value)) {
		alert("Invalid Password: Use of word ('"+s+"') is not allowed.");
		f.user_password.focus();
		return;
	}

	document.getElementById("user_id").style.backgroundImage='';
	
	if ( chkRegPattern('pwd', f.user_password.value) == false ) {
		alert("Password should contain more than 6 characters.");
		f.user_password.focus();
		return;
	}

	if (!isValidPassword(f.user_password.value)) {
		alert("Invalid Password");
		f.user_password.focus();
		return;
	}

	if (f.user_id.value == f.user_password.value) {
		alert("ID and Password should be different.\nPlease refrain from using simple password.");
		f.user_password.focus();
		return;
	}

	if (f.secure.checked) {
		t_action = "https://secure.neofun.com/account/process/process_login.asp";
	} else {
		t_action = "http://secure.neofun.com/account/process/process_login.asp";
	}

	// No.1 CBT OPEN
	f.action = '/account/process/process_login_cbt.asp';
	f.submit();
}

// 회원가입 약관 동의시
function goConsent_Submit(f) {
	if ( !f.agree1.checked ) {
		alert("You must fully read and agree to License Agreement.");
		f.agree1.focus();
		return;
	}

	// No.1 CBT OPEN
	f.action = "/account/?po_type=cbt";
	f.submit();
}

// 회원가입, 수정
function click_select(a){
	var num = "";
	num = document.getElementById("question_list").selectedIndex;
	if ( num == 7 ) {
		//document.getElementById('question_view').style.display = "";
		document.getElementById('question_title').style.display = "";
	} else {
		//document.getElementById('question_view').style.display = "none";
		document.getElementById('question_title').style.display = "none";
	}
}

function chooseEmailDomain(tarObj, obj) {
	if (obj.selectedIndex > 0) {
		tarObj.value = obj.options[obj.selectedIndex].value;
	}
}

function fregisterform_submit(f) {
	var s = "";
	var email_data = f.reg_first_email.value +'@'+ f.reg_last_email.value;
	// 회원아이디 검사
	if (s = word_filter_check(f.reg_mb_id.value)) {
		alert("Invalid ID: Use of word ('"+s+"') is not allowed.");
		f.reg_mb_id.focus();
		return;
	}

	if ( chkRegPattern('uid', f.reg_mb_id.value) == false ) {
		alert("First letter should be alphabet. Must be a combination of alphabet+number.");
		f.reg_mb_id.focus();
		return;
	}

	if (!isValidPassword(f.reg_mb_id.value)) {
		alert("Invalid ID");
		f.reg_mb_id.focus();
		return;
	}

	if (f.mb_id_enabled.value != '000') {
		sendData(f, 'msg_mb_id');
		alert("ID Error: No entry or invalid");
		f.reg_mb_id.focus();
		return;
	}

	// 회원닉네임 검사
	if (s = word_filter_check(f.mb_nick_enabled.value)) {
		alert("Invalid Nickname: Use of word ('"+s+"') is not allowed");
		f.reg_mb_nick.focus();
		return;
	}

	if ( chkRegPattern('nick', f.reg_mb_nick.value) == false ) {
		alert("First letter should be alphabet. Must be a combination of alphabet+number.");
		f.reg_mb_nick.focus();
		return;
	}

	if (f.mb_nick_enabled.value != '000') {
		sendData(f, 'msg_mb_nick');
		alert('Nickname Error: No entry or invalid');
		f.reg_mb_nick.focus();
		return;
	}

	// 회원이메일 검사
	if (s = word_filter_check(email_data)) {
		alert("Invalid Email: Use of word ('"+s+"') is not allowed.");
		f.reg_first_email.focus();
		return;
	}

	if (!isValidEmail(email_data)) {
		alert("Invalid Email");
		f.reg_first_email.focus();
		return;
	}
		
	if ( chkRegPattern('mail', email_data) == false ) {
		alert("Invalid Email");
		f.reg_first_email.focus();
		return;
	}

	if (f.mb_email_enabled.value != '000') {
		sendData(f, 'msg_mb_email');
		alert('Email Error: No entry or invalid');
		f.reg_first_email.focus();
		return;
	}

	// 회원비밀번호 검사
	if (s = word_filter_check(f.reg_mb_pass1.value)) {
		alert("Invalid Password: Use of word ('"+s+"') is not allowed.");
		f.reg_mb_pass1.focus();
		return;
	}

	if ( chkRegPattern('pwd', f.reg_mb_pass1.value) == false ) {
		alert("Password should contain more than 6 characters.");
		f.reg_mb_pass1.focus();
		return;
	}

	if (!isValidPassword(f.reg_mb_pass1.value)) {
		alert("Invalid Password");
		f.reg_mb_pass1.focus();
		return;
	}

	if (f.reg_mb_id.value == f.reg_mb_pass1.value) {
		alert("ID and Password should be different.\nPlease refrain from using simple password.");
		f.reg_mb_pass1.focus();
		return;
	}

	if (!f.reg_mb_pass2.value) {
		alert("Please enter the Password.");
		f.reg_mb_pass2.focus();
		return;
	}

	if (f.reg_mb_pass1.value != f.reg_mb_pass2.value) {
		alert("Password does not match.");
		f.reg_mb_pass2.focus();
		return;
	}

	// CBT Key
	if (s = word_filter_check(f.reg_cbt_key.value)) {
		alert("Invalid CBT Key: Use of word ('"+s+"') is not allowed.");
		f.reg_cbt_key.focus();
		return;
	}

	if (!f.spamkey.value) {
		alert("Please enter the Verfication Code.");
		f.spamkey.focus();
		return;
	}

	if (f.spamkey.value != f.in_spam.value) {
		alert("Wrong Verification Code.");
		f.spamkey.focus();
		return;
	}

	// No.1 CBT OPEN
	f.action = '/account/process/process_member_cbt.asp';
	f.submit();
}

function guide_start() {
	window.location.replace("/character/?po_type=guide");
}

function coin_start() {
	alert("Coming Soon...");
}

function game_download() {
	alert("Client will be available starting August 4 for download.");
	//alert("Please Login.");
	//window.location.replace("/account/login.asp");
}

function FindFormSearch(f) {
	var s = "";
	var email_data = f.find_email.value;
	f = document.free_search

	if (s = word_filter_check(email_data)) {
		alert("Invalid Email: Use of word ('"+s+"') is not allowed.");
		f.find_email.focus();
		return;
	}

	if (!isValidEmail(email_data)) {
		alert("Invalid Email");
		f.find_email.focus();
		return;
	}
		
	if ( chkRegPattern('mail', email_data) == false ) {
		alert("Invalid Email");
		f.find_email.focus();
		return;
	}

	f.action = '/account/process/process_email.asp';
	f.submit();
}

//]]>