/***************************************************************
* 로그인 관련 함수
****************************************************************/

document.onkeydown = function(){
	if (event.keyCode == 116){
		event.keyCode = 505;
	}
	if (event.keyCode == 505){
		return false;
	}
}

function bluring() {
        if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin=bluring;



// 자동로그인
function autologin_checked()
{
	var obj = document.forms["login_box"].elements["conf_auto_login"];
	if(obj.checked == true) {
		alert("자동 로그인 기능을 사용하시겠습니까?\n\n자동 로그인 사용시 다음 접속부터는 로그인을 하실필요가 없습니다.\n\n단, 게임방, 학교 등 공공장소에서 이용시 개인정보가 유출될 수 있으니 주의해 주세요.");
	}
}

// 로그인이 안돼요
function not_login()
{
	window.open('../help/login.html', 'HELP', 'width=550,height=500,scrollbars=yes');
}

function member_forget()
{
	window.open("../members/_forget.html", "forget", "width=420,height=400,scrollbars=yes");
}

function member_register(murl)
{
	location.href = "../members/register_1.html?murl=" + murl;
}

function member_logout(murl)
{
	location.href = "/members/logout.html?murl=" + murl;
}

// 로그인 텍스트박스에 배경이미지
function logintxtbox_focus(name, s)
{
	var obj = document.forms["login_box"].elements[name];

	if(s == "on") obj.style.backgroundImage = "url()";
	else if(!obj.value) obj.style.backgroundImage = "url('/img/w_login/bg_"+name+".gif')";
	else  obj.style.backgroundImage = "url()";
}

// 로그인 텍스트박스에 배경이미지
function top_login_focus(name, s)
{
	var obj = document.forms["login_check"].elements[name];

	if(s == "on") obj.style.backgroundImage = "url()";
	else if(!obj.value) obj.style.backgroundImage = "url('/img/w_login/bg_"+name+".gif')";
	else  obj.style.backgroundImage = "url()";
}

// 메인/서브 배경 이미지
function com_login_img(name, s)
{
	var obj = document.forms["chk_login"].elements[name];

	if(s == "on") obj.style.backgroundImage = "url()";
	else if(!obj.value) obj.style.backgroundImage = "url('/img/w_login/bg_"+name+".gif')";
	else  obj.style.backgroundImage = "url()";
}
// 내글박스
function popup_myarticlebox()
{
	window.open("../mypage/myarticlebox.html", "MyArticleBox", "width=640,height=450,scrollbars=yes");
}

// 관심글
function layer_myat()
{
	var obj = document.getElementById("myat");

	if(obj.style.display == "block") {
		obj.style.display = "none";
	} else {
		var obj_pos = document.getElementById("myat_position");
		if(document.all) {
			var rect = obj_pos.getBoundingClientRect();
			obj.style.left = rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft) + 10;
			obj.style.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop) - 83;
		} else {
			var box = document.getBoxObjectFor(obj_pos);
			obj.style.left = box.x + 10;
			obj.style.top = box.y - 83;
		}

		obj.style.display = "block";
		obj.innerHTML = "<div style=\"padding:100px 0px;border:1px solid #9a9a9a;text-align:center;background-color:#ffffff;\"><img src=\"/img/mypage/__myat/loading.gif\" /></div>";
		SendData = "";
		ajaxConnect("POST", "../mypage/__myat.html", "true", SendData, "myat");
	}
}

// 즐겨찾기
function layer_favorite(mode, name, url)
{
	url = encodeURI(url);
	var obj = document.getElementById("myfavorite");
	var obj_pos = document.getElementById("myfavorite_position");
	if(document.all) {
		var rect = obj_pos.getBoundingClientRect();
		obj.style.left = rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft) - 9;
		obj.style.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop) + 19;
	} else {
		var box = document.getBoxObjectFor(obj_pos);
		obj.style.left = box.x - 9;
		obj.style.top = box.y + 19;
	}

	// list모드 두번일경우
	if(mode == "list_close") {
		if(obj.style.display == "block") {
			obj_pos.src = "../img/w_login/btn_favorite_off.gif";
			mode = "close";
		} else {
			obj_pos.src = "../img/w_login/btn_favorite_on.gif";
			mode = "list";
		}
	}

	if(mode == "list" || mode == "add") {
		obj.innerHTML = "<div style=\"padding:30px 0px;text-align:center;\"><img src=\"/img/aj_favorite/loading.gif\" /></div>";
		obj.style.display = "block";
		SendData = "&m="+mode+"&name="+name+"&url="+url;
		ajaxConnect("POST", "../lib/_aj_favorite.html", "true", SendData, "myfavorite");
	} else if(mode == "close") {
		obj.style.display = "none";
		obj.innerHTML = "";
	}
}
function layer_favorite_delete(name, url, no)
{
	url = encodeURI(url);
	document.getElementById("myfavorite").innerHTML = "<div style=\"padding:30px 0px;text-align:center;\"><img src=\"/img/aj_favorite/loading.gif\" /></div>";
	document.getElementById("myfavorite").style.display = "block";
	SendData = "&m=delete_ok&name="+name+"&url="+url+"&no="+no;
	ajaxConnect("POST", "../lib/_aj_favorite.html", "true", SendData, "myfavorite");
}
function favorite_add_submit()
{
	var form = document.forms["ajf_favorite"];

	if(!form.elements["name"].value) {
		alert("빨리가기 이름을 입력해 주세요");
		form.elements["name"].onFocus();
		return false;
	}

	var name = form.elements["name"].value;
	var url = form.elements["url"].value;
	SendData = "&m=add_ok&name="+name+"&url="+url;
	ajaxConnect("POST", "../lib/_aj_favorite.html", "true", SendData, "myfavorite");

	return false;
}

// 공지사항
function w_notice_close()
{
	document.getElementById("w_notice").style.display = "none";
}

/***************************************************************
* GG & PG = Tab
****************************************************************/
function globaltab_change(id, w)
{
	if(id == "gg") document.getElementById("tabbox").style.backgroundImage = "url('../img/submenu/nrpg/mbox_tbg.gif')";
	else if(id == "pg") document.getElementById("tabbox").style.backgroundImage = "url('../img/submenu/playground/mbox_tbg.gif')";

	document.getElementById("listbox_gg").style.display = "none";
	document.getElementById("listbox_pg").style.display = "none";
	document.getElementById("listbox_"+id).style.display = "block";

	document.images["tab_pg"].src = "../img/submenu/"+w+"/tab_pg_off.gif";
	document.images["tab_gg"].src = "../img/submenu/"+w+"/tab_gg_off.gif";
	document.images["tab_"+id].src = "../img/submenu/"+w+"/tab_"+id+"_on.gif";
}

function help_gptab(onf)
{
	var obj = document.getElementById("help_gptab");

	if(onf == "none") {
		obj.style.display = "none";
	} else {
		var obj_pos = document.getElementById("tabbox");
		if(document.all) {
			var rect = obj_pos.getBoundingClientRect();
			obj.style.left = rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft) - 20;
			obj.style.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop) - 70;
		} else {
			var box = document.getBoxObjectFor(obj_pos);
			obj.style.left = box.x - 20;
			obj.style.top = box.y + 70;
		}

		obj.style.display = "block";
	}
}

/***************************************************************
* GG & PG = Thumnail
****************************************************************/
function listthum_view(url, pos)
{
	var obj = document.getElementById("list_thumnail");

	var obj_pos = document.getElementById(pos);
	if(document.all) {
		var rect = obj_pos.getBoundingClientRect();
		obj.style.left = rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft) + 100;
		obj.style.top = rect.top + (document.documentElement.scrollTop || document.body.scrollTop) + 18;
	} else {
		var box = document.getBoxObjectFor(obj_pos);
		obj.style.left = box.x + 100;
		obj.style.top = box.y + 18;
	}

	obj.style.display = "block";
	document.images["list_thumnail"].src = url;
}
function listthum_close()
{
	var obj = document.getElementById("list_thumnail");
	obj.style.display = "none";
	document.images["list_thumnail"].src = "../img/public/tspace.gif";
}

/****************************************************************/

function view_maps()
{
	var obj = document.getElementById("link_map");
	obj.style.left = document.documentElement.scrollLeft + window.event.clientX + 10 + "px";
	obj.style.top = document.documentElement.scrollTop + window.event.clientY - 300 + "px";
	obj.style.display = "block";
}
function close_maps()
{
	document.getElementById("link_map").style.display = "none";
}
function linkmap_listc(id)
{
	document.getElementById("gl_1").src = "../img/submenu/nrpg/gl_1_off.gif";
	document.getElementById("gl_2").src = "../img/submenu/nrpg/gl_2_off.gif";
	document.getElementById("gl_3").src = "../img/submenu/nrpg/gl_3_off.gif";
	document.getElementById("gl_4").src = "../img/submenu/nrpg/gl_4_off.gif";
	document.getElementById("gl_5").src = "../img/submenu/nrpg/gl_5_off.gif";
	document.getElementById("gl_1_list").style.display = "none";
	document.getElementById("gl_2_list").style.display = "none";
	document.getElementById("gl_3_list").style.display = "none";
	document.getElementById("gl_4_list").style.display = "none";
	document.getElementById("gl_5_list").style.display = "none";

	document.getElementById(id).src = "../img/submenu/nrpg/"+id+"_on.gif";
	document.getElementById(id+"_list").style.display = "block";
}
/****************************************************************/

// 클립보드로html저장
function copy_clipboard(code)
{
	//body전체를 선택범위로 지정
	var  text = document.body.createTextRange();
	//code 객체만 지정하겠다는 의미
	text.moveToElementText(code);
	text.execCommand("Copy");
	alert("클립보드로 내용이 복사되었습니다. Ctrl+V를 사용하시면 붙여넣을 수 있습니다.");
}

// 검색시 추천검색어
function view_goodword(word)
{
	if(word) {
		var searchkey = document.forms["frm_search"].elements["searchkey"].value;
		SendData = "&searchkey="+searchkey+"&word=" + word;
		ajaxConnect("POST", "../search/__goodword.html", "true", SendData, "view_goodword");
		document.getElementById("goodword").style.display = "block";
	} else {
		document.getElementById("goodword").style.display = "none";
	}
}

function close_goodword()
{
	document.getElementById("goodword").style.display = "none";
	document.getElementById("goodword").innerHTML = "";
}

// 글로벌 네비
function navi_over(no)
{
	var no_p = parseInt(no) - 1;
	//if(no == 4) no_p = parseInt(no) - 2;
	var no_n = parseInt(no);
	document.images["global_"+no].src = "../img/lib/navi/global_on_"+no+".gif";
	//if(no_p > 0) document.getElementById("navi_global_line_"+no_p).style.backgroundImage = "url('')";
	//if(no_p < 7) document.getElementById("navi_global_line_"+no_n).style.backgroundImage = "url('')";
}
function navi_out(no)
{
	var no_p = parseInt(no) - 1;
	//if(no == 4) no_p = parseInt(no) - 2;
	var no_n = parseInt(no);
	document.images["global_"+no].src = "../img/lib/navi/global_off_"+no+".gif";
	//if(no_p > 0) document.getElementById("navi_global_line_"+no_p).style.backgroundImage = "url('../img/lib/navi/btn_top_line.gif')";
	//if(no_p < 7) document.getElementById("navi_global_line_"+no_n).style.backgroundImage = "url('../img/lib/navi/btn_top_line.gif')";
}

// 도움말풍선
function helpball(str)
{
	var obj = document.getElementById("helpball");
	var obj_txt = document.getElementById("helpball_txt");
	if(str) {
		obj.style.left = document.documentElement.scrollLeft + window.event.clientX - 23 + "px";
		obj.style.top = document.documentElement.scrollTop + window.event.clientY + 10 + "px";
		obj_txt.innerHTML = str;
		obj.style.display = "block";
	} else {
		obj.style.display = "none";
	}
}

// WDD 오픈
function wdd_open(t, m, g, w)
{
	if(t == "ktfbigi")	window.open("../wdd/index.html?t=ktf&m="+m+"&g="+g+"&w="+w+"&bigi=1", "WDD", "width=430,height=430");
	else window.open("../wdd/index.html?t="+t+"&m="+m+"&g="+g+"&w="+w, "WDD", "width=430,height=430");
}
function wdd_open_ktf(m, p, w)
{
	window.open("../shop/ktf_wdd.html?m="+m+"&p="+p+"&w="+w, "WDD", "width=430,height=430");
}

function wdd_center()
{
	var x,y;
	if (self.innerHeight) { // IE 외 모든 브라우저
		x = (screen.availWidth - self.innerWidth) / 2;
		y = (screen.availHeight - self.innerHeight) / 2;
	}else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict 모드
		x = (screen.availWidth - document.documentElement.clientWidth) / 2;
		y = (screen.availHeight - document.documentElement.clientHeight) / 2;
	}else if (document.body) { // 다른 IE 브라우저( IE < 6)
		x = (screen.availWidth - document.body.clientWidth) / 2;
		y = (screen.availHeight - document.body.clientHeight) / 2;
	}
	self.window.moveTo(x,y);
}

// 플래시나 임베디드
function openflash(width,height,src){
    return "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width="+width+" height="+height+"><param name=\"wmode\" value=\"transparent\" /><param name=movie value="+src+"><param name=quality value=high ><embed src="+src+" quality=high  pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width="+width+" height="+height+"></embed></object>";
}
function writeflash(src){
    document.write(src);
}

// 로그인 박스 체크 스크립트
function submit_login(form)
{
	if(!form.id.value) {
		alert('아이디를 입력해 주세요');
		return false;
	}

	if(!form.password.value) {
		alert('비밀번호를 입력해 주세요');
		return false;
	}

	return true;
}

function go_register()
{
	location.href = "../members/register_1.html";
}

function go_regsterno(murl)
{
	if(murl) {
		location.href = murl;
	} else {
		location.href = "../index.html";
	}
}



function back_register(murl)
{
	location.href = murl;
}





// 서치박스 클릭
function searchbox_click(obj)
{
	obj.style.backgroundImage = "url('')";
}



// 메뉴설명 보이기
function view_menubox(no)
{

	document.getElementById("menubox").innerHTML = "";
	if(no == 0) document.getElementById("menubox").style.display = "none";
	else  document.getElementById("menubox").style.display = "block";

	if(no == 1) {

		document.getElementById("menubox").style.left = "130px";
		document.getElementById("menubox").innerHTML = "<img src=\"../img/lib/navi/help_dot.gif\" align=\"absmiddle\" /> 게임뉴스와 신규게임소개 및 다양한 이벤트와 공동구매~! 그리고 가장 재밌는 내가 만드는 게임 랭킹까지!";

	} else if(no == 2) {

		document.getElementById("menubox").style.left = "228px";
		document.getElementById("menubox").innerHTML = "<img src=\"../img/lib/navi/help_dot.gif\" align=\"absmiddle\" /> 모바일에 대한 모든 질문과 답변이 있습니다. <br />무엇이든 물어 보세요. 모바일 지식서비스 지식M";

	} else if(no == 3) {

		document.getElementById("menubox").style.left = "297px";
		document.getElementById("menubox").innerHTML = "<img src=\"../img/lib/navi/help_dot.gif\" align=\"absmiddle\" /> 온라인/모바일게임 거래는 안전한 톨거래로 거래해 보세요.<br />신속한 아이템거래!!";

	} else if(no == 4) {

		document.getElementById("menubox").style.left = "395px";
		document.getElementById("menubox").innerHTML = "<img src=\"../img/lib/navi/help_dot.gif\" align=\"absmiddle\" /> 지금 제일 뜨는 게임은? 제일 재밌는 게임은?<br />각 게임의 단독 게시판 공간으로 공략과 커뮤니티를 마음껏 즐기 실 수 있습니다.";

	} else if(no == 5) {

		document.getElementById("menubox").style.left = "543px";
		document.getElementById("menubox").innerHTML = "<img src=\"../img/lib/navi/help_dot.gif\" align=\"absmiddle\" /> 미니게임? 리듬게임? 짧게 굵게! 그리고 간편하게 즐기는 게임 중 재밌는건 뭘까?<br />공략과 커뮤니티 그리고 이벤트를 마음껏 즐기실 수 있습니다.";

	} else if(no == 6) {

		document.getElementById("menubox").style.left = "640px";
		document.getElementById("menubox").innerHTML = "<img src=\"../img/lib/navi/help_dot.gif\" align=\"absmiddle\" /> 내가 주는 게임 점수! 내가 만드는 게임 랭킹!<br />직접 게임에 점수를 줘보세요~";

	} else if(no == 7) {

		document.getElementById("menubox").style.left = "764px";
		document.getElementById("menubox").innerHTML = "<img src=\"../img/lib/navi/help_dot.gif\" align=\"absmiddle\" /> 수다와 친분을 쌓아 볼까요?";

	}

}

// 글 신고하기
function article_report(program, pid, pno)
{
	window.open("../report/report.html?program="+program+"&pid="+pid+"&pno="+pno, "REPORT", "width=347,height=420,scrollbars=yes");
}
// 코멘트 신고하기
function comment_report(program, pid, pno, pcno)
{
	window.open("../report/report.html?program="+program+"&pid="+pid+"&pno="+pno+"&pcno="+pcno, "REPORT", "width=347,height=420,scrollbars=yes");
}



// 페이지 이동
function readyaction(url)
{
	location.href = url;
}






/* 글로벌 온오프사라짐
// 글로벌메뉴 오버
function global_over(name)
{
	document.images["global_"+name].src = "../img/navi/global_on_" + name + ".gif";
}
function global_out(name)
{
	document.images["global_"+name].src = "../img/navi/global_off_" + name + ".gif";
}
*/

// 되확인 링크
function confirm_check(msg, url)
{

	if(confirm(msg)) {
		location.href = url;
	}

}

// 숫자만 입력 받기, 같이 ime모드도 같이 사용해야 함
function num_only(Ev)
{
	var evCode = ( window.netscape ) ? Ev.which : event.keyCode ;
	/* FF일 경우 Ev.which 값을,
		IE을 경우 event.keyCode 값을 evCode에 대입 */
	if ( ! ( evCode == 0 || evCode == 8 || ( evCode > 47 && evCode < 58 ) ) ) {
	/* 눌러진 키 코드가 숫자가 아닌 경우
		( '0'은 FF에서 Tab 키,
		  '8'은 FF에서 BackSpace가 먹히지 않아 삽입)    */
		if ( window.netscape ) {        // FF일 경우
			Ev.preventDefault() ;        // 이벤트 무효화
		} else {                                // IE일 경우
			event.returnValue=false;    // 이벤트 무효화
		}
	}
}



/****************************************************************
* 미니박스 [2009.07.08.신정훈]
*****************************************************************/
function minibox_view(id)
{

	var obj = document.getElementById("minibox");

	obj.style.left = document.documentElement.scrollLeft + window.event.clientX + 10 + "px";
    obj.style.top = document.documentElement.scrollTop + window.event.clientY - 15 + "px";
	obj.style.display = "block";
	obj.style.width = "200px";
	obj.style.height = "220px";
	obj.innerHTML = "<img src=\"/img/w_minibox/loading.gif\" />";

	SendData = "&id=" + id;
	ajaxConnect("POST", "/lib/_widget_minibox.html", "true", SendData, "minibox");

}

function minibox_close()
{
	document.getElementById("minibox").innerHTML = "";
	document.getElementById("minibox").style.display = "none";
}


function send_memo(id)
{
	window.open("/memo/write.html?m=write&id="+id, "memo", "width=510,height=520,scrollbars=yes");
}

function mileage_gift(id)
{
	window.open("/mileage/gift.html?id="+id, "tol", "width=420,height=400,scrollbars=no");
}


function memos_view()
{
	window.open("/memo/memos.html", "memo", "width=510,height=520,scrollbars=yes");
}


// rolling
var rolling_banner = function(ta){
	this.ta = ta;
//	this.ta.className = 'rolling_banner';
	this.ta_id = 'roll_'+(this.ta.id||this.ta.name);
	this.gap = 5;					//움직이는 픽셀단위
	this.gap_count=0;			//카운팅용:건들지 마세요
	this.gap_time = '5000';		//움직이는 단위시간
	this.gap_sleep = '5000';	//화면이 멈춰있을 단위시간
	this.over_stop = true;  //마우스를 올렸을 때 멈출 것인가?
	this.timer = null;
	eval(this.ta_id+'=this');
	var temp = eval(this.ta_id);
	this.init_div();
}
rolling_banner.prototype.start = function(){	//롤링 시작
	this.ta.readonly =false;
	this.stop =false;
	if(!this.timer){ this.rolling();	 }
}
rolling_banner.prototype.stop = function(){	//롤링 시작
	this.stop =true;
}
rolling_banner.prototype.init_div = function(){	//<div> 빼고 전부 제거 , 스타일 초기화
	this.ta.style.position="relative";
	this.ta.style.overflow="hidden";
  	this.ta.onmouseover=function(){ eval("this.readOnly=true;"); }
  	this.ta.onmouseout=function(){ eval("this.readOnly=false;"); }

	var child = this.ta.childNodes;
	var ch = this.ta.firstChild;
	var ch2 = null;
	while(ch){
		ch2 = ch.nextSibling;
		if(ch.nodeName.toLowerCase() !='div'){
		this.ta.removeChild(ch);
		}else{
		ch.style.position = "relative";
		ch.style.borderStyle='none';
		ch.style.top='0px';
		}
		ch=ch2;
	}
}
rolling_banner.prototype.strtonum = function(str){
	var num = parseInt(str);
	if(isNaN(num)) num = '0';
	return num
}
rolling_banner.prototype.strtopx = function(str){
	var num = this.strtonum(str);
	return num+'px';
}
rolling_banner.prototype.rolling = function(){
	if(this.gap_count==0){
		this.sleep();
		this.gap_count+=1;
		return;
	}
	if(!this.ta.readOnly && !this.stop){
		this.rolling_top();
	}
	this.timer = null;
	var re = this.ta_id+'.rolling()';
	this.timer = setTimeout(re,this.gap_time);
}
rolling_banner.prototype.rolling_top = function(){
	this.gap_count+=parseInt(this.gap);
	var ch1 = this.ta.firstChild;
	var child = this.ta.childNodes;
	var ta_ch = null;
	var	top_ori = this.strtonum(child[0].style.top);
	var top = this.strtopx(top_ori-parseInt(this.gap));
	for(var i=0,m=child.length;i<m;i++){
		child[i].style.top=top;
	}
	if(this.gap_count >= this.strtonum(ch1.style.height)){
		var temp =ch1.cloneNode(true);
		this.ta.removeChild(ch1);
		this.ta.appendChild(temp);
		for(var i=0,m=child.length;i<m;i++){
			child[i].style.top='0px';
		}
	this.gap_count = 0
	}
}
rolling_banner.prototype.sleep = function(){
	this.timer = null;
	var re = this.ta_id+'.rolling()';
	this.timer = setTimeout(re,this.gap_sleep);
}


/************************************************************************************** import start */
/*
스크롤링 소스 - 공대여자는 예쁘다
수정 2007-08-11 | 첨부 2009-01-09
만든이 공대여자(mins01.com) | 첨부자 엔젠드(nzend.com)
*/
var js_rolling = function(this_s){
	// 시간단위는 ms로 1000이 1초
	if(this_s.nodeType==1){
		this.this_s = this_s;
	}else{
		this.this_s = document.getElementById(this_s);
	}
	this.is_rolling = false;
	this.direction = 1; //1:top, 2:right, 3:bottom, 4:left (시계방향) // 1번과 4번만 됨
	this.children =	null;
	this.move_gap = 1;	//움직이는 픽셀단위
	this.time_dealy = 100; //움직이는 타임딜레이
	this.time_dealy_pause = 1000;//하나의 대상이 새로 시작할 때 멈추는 시간, 0 이면 적용 안함
	this.time_timer=null;
	this.time_timer_pause=null;
	this.mouseover=false;
	this.init();
	this.set_direction(this.direction);
}
js_rolling.prototype.init = function(){
	this.this_s.style.position='relative';
	this.this_s.style.overflow='hidden';
	var children = this.this_s.childNodes;
	for(var i=(children.length-1);0<=i;i--){
		if(children[i].nodeType==1){
			children[i].style.position='relative';
		}else{
			this.this_s.removeChild(children[i]);
		}
	}
	var this_s=this;
	this.this_s.onmouseover=function(){
		this_s.mouseover=true;
		if(!this_s.time_timer_pause){
			this_s.pause();
		}
	}
	this.this_s.onmouseout=function(){
		this_s.mouseover=false;
		if(!this_s.time_timer_pause){
			this_s.resume();
		}
	}
}
js_rolling.prototype.set_direction = function(direction){
	this.direction=direction;
	if(this.direction==2 ||this.direction==4){
		this.this_s.style.whiteSpace='nowrap';
	}else{
		this.this_s.style.whiteSpace='normal';
	}
	var children = this.this_s.childNodes;
	for(var i=(children.length-1);0<=i;i--){
			if(this.direction==1){
				children[i].style.display='block';
			}else if(this.direction==2){
				children[i].style.textlign='right';
				children[i].style.display='inline';
			}else if(this.direction==3){
				children[i].style.display='block';
			}else if(this.direction==4){
				children[i].style.display='inline';
			}
	}
	this.init_element_children();
}
js_rolling.prototype.init_element_children = function(){
	var children = this.this_s.childNodes;
	this.children = children;
	for(var i=(children.length-1);0<=i;i--){
			if(this.direction==1){
				children[i].style.top='0px';
			}else if(this.direction==2){
				children[i].style.left='-'+this.this_s.firstChild.offsetWidth+'px';
			}else if(this.direction==3){
				children[i].style.top='-'+this.this_s.firstChild.offsetHeight+'px';
			}else if(this.direction==4){
				children[i].style.left='0px';
			}
	}
}
js_rolling.prototype.act_move_up = function(){
	for(var i = 0,m=this.children.length;i<m;i++){
		var child = this.children[i];
		child.style.top=(parseInt(child.style.top)-this.move_gap)+'px';
	}
	if((this.children[0].offsetHeight+parseInt(this.children[0].style.top))<=0){
		this.this_s.appendChild(this.children[0]);
		this.init_element_children();
		this.pause_act();
	}
}
js_rolling.prototype.move_up = function(){
	if(this.direction!=1&&this.direction!=3){return false;}
	this.this_s.appendChild(this.children[0]);
	this.init_element_children();
	this.pause_act();
}
js_rolling.prototype.act_move_down = function(){
	for(var i = 0,m=this.children.length;i<m;i++){
		var child = this.children[i];
		child.style.top=(parseInt(child.style.top)+this.move_gap)+'px';
	}
	if(parseInt(this.children[0].style.top)>=0){
		this.this_s.insertBefore(this.this_s.lastChild,this.this_s.firstChild);
		this.init_element_children();
		this.pause_act();
	}
}
js_rolling.prototype.move_down = function(){
	if(this.direction!=1&&this.direction!=3){return false;}
	this.this_s.insertBefore(this.this_s.lastChild,this.this_s.firstChild);
	this.init_element_children();
	this.pause_act();
}
js_rolling.prototype.act_move_left = function(){
	for(var i = 0,m=this.children.length;i<m;i++){
		var child = this.children[i];
		child.style.left=(parseInt(child.style.left)-this.move_gap)+'px';
	}
	if((this.children[0].offsetWidth+parseInt(this.children[0].style.left))<=0){
		this.this_s.appendChild(this.this_s.firstChild);
		this.init_element_children();
		this.pause_act();
	}
}
js_rolling.prototype.move_left = function(){
	if(this.direction!=2&&this.direction!=4){return false;}
	this.this_s.appendChild(this.this_s.firstChild);
	this.init_element_children();
	this.pause_act();
}
js_rolling.prototype.act_move_right = function(){
	for(var i = 0,m=this.children.length;i<m;i++){
		var child = this.children[i];
		child.style.left=(parseInt(child.style.left)+this.move_gap)+'px';
	}

	if(parseInt(this.this_s.lastChild.style.left)>=0){
		this.this_s.insertBefore(this.this_s.lastChild,this.this_s.firstChild);
		this.init_element_children();
		this.pause_act();
	}
}
js_rolling.prototype.move_right = function(){
	if(this.direction!=2&&this.direction!=4){return false;}
	this.this_s.insertBefore(this.this_s.lastChild,this.this_s.firstChild);
	this.init_element_children();
	this.pause_act();
}
js_rolling.prototype.start = function(){ //롤링 시작
	var this_s = this;
	this.stop();
	this.is_rolling = true;
	var act = function(){
		if(this_s.is_rolling){
			if(this_s.direction==1){this_s.act_move_up();}
			else if(this_s.direction==2){this_s.act_move_right();}
			else if(this_s.direction==3){this_s.act_move_down();}
			else if(this_s.direction==4){this_s.act_move_left();}
		}
	}
	this.time_timer = setInterval(act,this.time_dealy);
}
js_rolling.prototype.pause_act = function(){ //일시 동작
	if(this.time_dealy_pause){
		var this_s = this;
		var act = function(){this_s.resume();this_s.time_timer_pause=null;}
		if(this.time_timer_pause){clearTimeout(this.time_timer_pause);}
		this.time_timer_pause = setTimeout(act,this.time_dealy_pause);
		this.pause();
	}
}
js_rolling.prototype.pause = function(){ //일시 멈춤
	this.is_rolling = false;
}
js_rolling.prototype.resume = function(){ //일시 멈춤 해제
	if(!this.mouseover){
		this.is_rolling = true;
	}
}
js_rolling.prototype.stop = function(){ //롤링을 끝냄
	this.is_rolling = false;
	if(!this.time_timer){
		clearInterval(this.time_timer);
	}
	this.time_timer = null
}

/* http://najackal.com.ne.kr/s-hompage/s-java/sturdy16.html */
function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {	//while open
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
   }	//while close
   return null;
}

function SetCookie (name, value) {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (2 < argc) ? argv[2] : null;
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
      ((expires == null) ? "" :
         ("; expires=" + expires.toGMTString())) +
      ((path == null) ? "" : ("; path=" + path)) +
      ((domain == null) ? "" : ("; domain=" + domain)) +
      ((secure == true) ? "; secure" : "");
}
/************************************************************************************** import end */

/**************************************************
 * AJAX
 **************************************************/

// 생성 변수
var sendData;
var incUrl;

// XMLHttpRequest 생성
function ajaxStart()
{

	var ajaxProtocol;

	if(window.ActiveXObject) {

		try {

			ajaxProtocol = new ActiveXObject("Xsxml2.XMLHTTP");

		} catch(e) {

			try {

				ajaxProtocol = new ActiveXObject("Microsoft.XMLHTTP");

			} catch(e1) {

				ajaxProtocol = null;

			}

		}

	} else if(window.XMLHttpRequest) {

		try {

			ajaxProtocol = new XMLHttpRequest();

		} catch(e) {

			ajaxProtocol = null;

		}

	}

	if(ajaxProtocol == null) {

		errorMessage("AJAX 초기화 오류 입니다");

	} else {

		return ajaxProtocol;

	}

}

// AJAX 연결 메소드, 연결파일, 동기옵션, 전송데이터, 실행 명령어
function ajaxConnect(method, url, async, send, what) {

	var ajaxProtocol = ajaxStart();

	ajaxProtocol.open(method, url, async);
	ajaxProtocol.onreadystatechange = function() {
		if(ajaxProtocol.readyState == 4) {

			if(ajaxProtocol.status == 200) {

				ajaxAction(ajaxProtocol, what);

			} else if(ajaxProtocol.status == 403) {
				alert("접근거부 에러");
			} else if(ajaxProtocol.status == 404) {
				alert("페이지를 찾을 수 없는 에러");
			} else if(ajaxProtocol.status == 500) {
				alert("서버 오류");
			}

		}
	}

	ajaxProtocol.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajaxProtocol.send(send);

}

/**************************************************
 * AJAX ACTION
 **************************************************/

function ajaxAction(ajaxProtocol, what)
{
	//************************************** publick
	if(what == "yongjabox") {
		if(ajaxProtocol.responseText == "#NOMEMBERS#") {
			alert("없는 회원 입니다");
			document.getElementById("yongjabox").innerHTML = "";
		} else if(ajaxProtocol.responseText == "#LEAVEMEMBERS#") {
			alert("탈퇴한 회원 입니다");
			document.getElementById("yongjabox").innerHTML = "";
		} else {
			document.getElementById("yongjabox").innerHTML = ajaxProtocol.responseText;
		}
	}

	//************************************** publick
	if(what == "minibox") {
		if(ajaxProtocol.responseText == "#NOMEMBERS#") {
			alert("없는 회원 입니다");
			document.getElementById("minibox").innerHTML = "";
		} else if(ajaxProtocol.responseText == "#LEAVEMEMBERS#") {
			alert("탈퇴한 회원 입니다");
			document.getElementById("minibox").innerHTML = "";
		} else {
			document.getElementById("minibox").innerHTML = ajaxProtocol.responseText;
		}
	}


	//************************************** member
	// 아이디 중복검사
	if(what == "id_check") {

		sendText = ajaxProtocol.responseText;
		if(sendText == "TRUE") {
			alert("사용하실 수 있는 아이디 입니다");
			document.getElementsByName("checkok_id")[0].value = "1";
		} else if(sendText == "FALSE") {
			alert("이미 다른 사람이 사용중인 아이디 입니다");
			document.forms["frm_member_register"].id.focus();
		} else {
			alert(sendText);
		}

	// 이메일 중복검사
	} else if(what == "nickname_check") {

		sendText = ajaxProtocol.responseText;
		if(sendText == "TRUE") {
			alert("사용하실 수 있는 닉네임 입니다");
			document.getElementsByName("checkok_nickname")[0].value = "1";
		} else if(sendText == "FALSE") {
			alert("이미 다른 사람이 사용중인 닉네임 입니다");
			document.forms["frm_member_register"].nickname.focus();
		} else {
			alert(sendText);
		}

	// 이메일 중복검사
	} else if(what == "email_check") {

		sendText = ajaxProtocol.responseText;
		if(sendText == "TRUE") {
			alert("사용하실 수 있는 이메일 입니다");
			document.getElementsByName("checkok_email")[0].value = "1";
		} else if(sendText == "FALSE") {
			alert("이미 다른 사람이 사용중인 이메일 입니다");
			document.forms["frm_member_register"].email.focus();
		} else {
			alert(sendText);
		}

	// 주민등록번호 중복검사
	} else if(what == "pcode_check") {
		sendText = ajaxProtocol.responseText;
		document.getElementsByName("checkok_protector")[0].value = ""; // 부모동의 초기화
		if(sendText == "TRUE_UP14") {
			alert("가입하실 수 있는 주민등록번호 입니다");
			document.getElementsByName("checkok_pcode")[0].value = "1";
		} else if(sendText == "TRUE_UN14") {
			alert("가입하실 수 있는 주민등록번호 입니다. 만14세 미만 어린이는 부모님이나 보호자와 함께 가입해주세요");
			document.getElementsByName("checkok_pcode")[0].value = "1";
			document.getElementsByName("checkok_protector")[0].value = "1";
			document.getElementById("check_protector").style.display = "block";
		} else if(sendText == "FALSE") {
			alert("이미 가입된 주민등록번호 입니다");
			document.forms["frm_member_register"].elements["pcode[0]"].focus();
		} else {
			alert(sendText);
		}

	}

	//************************************** credit
	if(what == "add_credit") {

		sendText = ajaxProtocol.responseText;
		if(sendText == "TRUE") {

			alert("감사합니다. \n\n평점이 등록되었습니다. \n\n오늘도 좋은 하루 되세요."); // 안내

			point_click(0); // 초기화
			document.forms["add_credit"].elements["comment"].value = "";
			credit_view_layer(document.forms["add_credit"].elements["t"].value, 'all', 1, 10);

		} else if(sendText == "FALSE") {
			alert("오류입니다");
		} else {
			alert(sendText);
		}

	} else if(what == "credit_list") {
		document.getElementById("creditlist").innerHTML = ajaxProtocol.responseText;
	}

	//************************************* gameinfo
	if(what == "game_select") {
		document.getElementById("game_list").innerHTML = ajaxProtocol.responseText;
	}

	//************************************* search
	if(what == "ajview_gameinfo") {
		document.getElementById("ajview_gameinfo").innerHTML = ajaxProtocol.responseText;
	}

	if(what == "ajview_mobilegame") {
		document.getElementById("ajview_mobilegame").innerHTML = ajaxProtocol.responseText;
	}

	if(what == "ajview_km") {
		document.getElementById("ajview_km").innerHTML = ajaxProtocol.responseText;
	}

	if(what == "ajview_itemtrade") {
		document.getElementById("ajview_itemtrade").innerHTML = ajaxProtocol.responseText;
	}

	if(what == "ajview_fandb") {
		document.getElementById("ajview_fandb").innerHTML = ajaxProtocol.responseText;
	}

	if(what == "ajview_review") {
		document.getElementById("ajview_review").innerHTML = ajaxProtocol.responseText;
	}

	//************************************* event
	if(what == "use_event_gamegift") {
		document.getElementById("gamesendok").innerHTML = ajaxProtocol.responseText;
	}

	//************************************* board manager
	if(what == "board_manager_select") {
		document.getElementById("lay_category_id").innerHTML = ajaxProtocol.responseText;
	}

	//************************************* 별점평가 부분
	if(what == "credit_view_layer") {
		document.getElementById("credit_layer").innerHTML = ajaxProtocol.responseText;
	}

	// 출시평가 -> 보기 -> 서브프레임
	if(what == "gameview_subframe") document.getElementById("subframe_body").innerHTML = ajaxProtocol.responseText;

	// 추천검색어
	if(what == "view_goodword") document.getElementById("goodword").innerHTML = ajaxProtocol.responseText;

	// 내관심글
	if(what == "myat") document.getElementById("myat").innerHTML = ajaxProtocol.responseText;

	// 즐겨찾기
	if(what == "myfavorite") document.getElementById("myfavorite").innerHTML = ajaxProtocol.responseText;

	// 게임샵skt플레이어구동여부
	if(what == "skyshop_playrequest") {
		if(ajaxProtocol.responseText == "ERROR") alert("실행시 오류가 발생했습니다. 관리자에게 문의해 주세요");
	}

	//*********************************** 기타부분
	if(what == "bbs_admin_category") document.getElementById("ajax_category_list").innerHTML = ajaxProtocol.responseText;

}


/**********************************************************************
* 집중공략존 서브메뉴 [2009.03.13.신정훈]
***********************************************************************/
function submenutab_nrpg_change(id)
{
	if(id == "rank") document.getElementById("tabbox").style.backgroundImage = "url('../img/submenu/nrpg/mbox_tbg.gif')";
	else if(id == "make") document.getElementById("tabbox").style.backgroundImage = "url('../img/submenu/nrpg/mbox_tbg.gif')";

	document.getElementById("listbox_gg_rank").style.display = "none";
	document.getElementById("listbox_gg_make").style.display = "none";
	document.getElementById("listbox_gg_"+id).style.display = "block";

	document.images["tab_gg_rank"].src = "../img/submenu/nrpg/tab_gg_rank_off.gif";
	document.images["tab_gg_make"].src = "../img/submenu/nrpg/tab_gg_make_off.gif";
	document.images["tab_gg_"+id].src = "../img/submenu/nrpg/tab_gg_"+id+"_on.gif";

	if(id == "rank") setCookie("monawa_check_nrpgmnrank", 1, 60*60*24*365);
	else if(id == "make") deleteCookie("monawa_check_nrpgmnrank");
}

function getCookie(cookieName)
{
	var search = cookieName + "=";
	var cookie = document.cookie;
	if( cookie.length > 0 ) {
		startIndex = cookie.indexOf( cookieName );
		if( startIndex != -1 ) {
			startIndex += cookieName.length;
			endIndex = cookie.indexOf( ";", startIndex );
			if( endIndex == -1) endIndex = cookie.length;
			return unescape( cookie.substring( startIndex + 1, endIndex ) );
		} else {
			return false;
		}
	} else {
		return false;
	}
}

function setCookie(cookieName, cookieValue, expireDate)
{
	var today = new Date();
	today.setDate( today.getDate() + parseInt( expireDate ) );
	document.cookie = cookieName + "=" + escape( cookieValue ) + "; path=/; expires=" + today.toGMTString() + ";"
}


function deleteCookie(cookieName)
{
	var expireDate = new Date();
	expireDate.setDate( expireDate.getDate() - 1 );
	document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString() + "; path=/";
}

/**********************************************************************
* 공통적용 [2009.05.11.신정훈]
***********************************************************************/
// SKT샵
function SKTPlayerStart(PPID)
{
	window.open('../shop/_skt_playerstart.html?ppid='+PPID, 'SKTPlayer', 'width=430,height=250,scrollbars=yes');
}
// 모나와서치
function monawa_search()
{
	var form = document.forms["frm_search"];
	//if(form.searchkey.value == "w") form.cof.value = "FORID:11";
	//if(!form.searchword.value) form.searchword.value = "미스터똥";
	if(!form.searchword.value) {
		alert('검색어를 입력해 주세요.');
		return false;
	}
	form.q.value = form.searchword.value;
	return true;
}
function monawa_search_tab(searchkey)
{
	var form = document.forms["frm_search"];
	//if(searchkey == "w") form.cof.value = "FORID:11";
	form.searchkey.value = searchkey;
	form.q.value = form.searchword.value;
	form.submit();
}
// 글신고
function stapo_article(program, pid, pno)
{
	window.open("../report/stapo.html?stype=article&program="+program+"&pid="+pid+"&pno="+pno, "REPORT", "width=347,height=420,scrollbars=no");
}
// 리플신고
function stapo_reply(program, pid, pno, prno)
{
	window.open("../report/stapo.html?stype=reply&program="+program+"&pid="+pid+"&pno="+pno+"&prno="+prno, "REPORT", "width=347,height=420,scrollbars=no");
}

// 글로벌메뉴
function global_roll_over(id)
{
	//document.getElementById(id).style.display = "block";
}
function global_roll_out(id)
{
	//document.getElementById(id).style.display = "none";
}

// 글로벌메뉴2
function global_over(left,width,img,href)
{
	var t_menu_img = document.getElementById('t_menu_img');
	t_menu_img.style.position = "absolute";
	t_menu_img.style.top = "4px";
	t_menu_img.style.left = left;
	t_menu_img.style.width = width;
	t_menu_img.style.height = "41px";
	t_mon4 = "/bbs/view.html?bid=ot_nom4&ano=5151";
	if(href == 'ot_nom4') t_menu_img.innerHTML = "<a href='"+t_mon4+"' onfocus='blur()' target='_blank'><img src='"+img+"' class='img'/></a>";
	else t_menu_img.innerHTML = "<a href='"+href+"' onfocus='blur()'><img src='"+img+"' class='img'/></a>";
}
function global_out(id)
{
	t_menu_img.innerHTML = "";
}

// 글로벌세컨드메뉴-20100205신정훈
function changeImage(obj, img)
{
	obj.src = img;
}

/***************************************************************
* skt샵 [2009.02.24.신정훈]
****************************************************************/
function genre_action(c, s)
{
	document.getElementById("genremenu_"+c).src = "../img/shop/skt_list_genre/genre_"+c+"_"+s+".gif";
}


/***************************************************************
* 쪽지 시스템 [2009.07.08.신정훈]
****************************************************************/
function delete_memos()
{

	if(confirm("정말 쪽지를 삭제하시겠습니까?")) {
		document.frm_memos.submit();
	}

}

// 목록 전체선택
function checklist_check()
{
	var obj = document.forms["frm_memos"];

	if(obj.elements["list_no_all"].checked == true) {

		for(i = 0; i < obj.elements["list_no[]"].length; i++)
		{

			if(obj.elements["list_no[]"][i].checked == true) {
				obj.elements["list_no[]"][i].checked = false;
			} else {
				obj.elements["list_no[]"][i].checked = true;
			}

		}

	} else {

		for(i = 0; i < obj.elements["list_no[]"].length; i++)
		{
			obj.elements["list_no[]"][i].checked = false;
		}

	}

}

//추가적용
document.execCommand("BackgroundImageCache",false,true);