﻿document.domain = 'goorm.com';

// title
document.title="구름 속, 또 다른 세상 - 구름닷컴";

// openwindow
function openwindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

// swapImg
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function pop(url,intWidth,intHeight) { 
	window.open(url, "_blank", "width="+intWidth+",height="+intHeight+",resizable=0,scrollbars=0") ;
}
function pop_scroll(url,intWidth,intHeight) { 
	window.open(url, "_blank", "width="+intWidth+",height="+intHeight+",resizable=0,scrollbars=1") ;
}
//검은투명레이어열기
function black(idname) { 
	//layer_black.style.display = "block";
	document.getElementById(idname).style.display="block";
}
function layer_close(idname) { 
	document.getElementById(idname).style.display="none";
}

function flash(url,id,width,height){
document.write('<object width="'+width+'" height="'+height+'" id="'+id+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" type="application/x-shockwave-flash">'
+'<param name="movie" value="'+url+'">'
+'<param name="quality" value="high">'
+'<param name="wmode" value="transparent">'
+'<param name="allowScriptAccess" value="always">'
+'<param name="FlashVars" value="playMode=embeded">'
+'<param name="swliveconnect" value="true" />'
+'<embed src="'+url+'" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash" ></embed>'
+'</object>');
}

function movie(url,id,width,height){
	document.write('<object type="video/x-ms-wmv" data="http://www.sarahsnotecards.com/catalunyalive/fishstore.wmv" width="'+width+'" height="'+height+'">'
	+'<param name="AutoSize" value="0">'
	+'<param name="AutoStart" value="1">'
	+'<param name="AutoRewind" value="1">'
	+'<param name="ClickToPlay" value="1">'
	+'<param name="Enabled" value="1">'
	+'<param name="ShowTracker" value="1">'
	+'<param name="EnableTracker" value="0">'
	+'<param name="EnableContextMenu" value="0">'
	+'<param name="ShowStatusBar" value="0">'
	+'<param name="ShowControls" value="0">'
	+'<param name="ShowAudioControls" value="0">'
	+'<param name="ShowCaptioning" value="0">'
	+'<param name="Mute" value="0">'
	+'<param name="ShowDisplay" value="0">'
	+'<param name="BufferingTime" value="3">'
	+'<param name="PlayCount" value="1">'
	+'<param name="FileName" value='+url+'>'
	+'</object>');
}

function resizeIframe(fr) { 
                fr.setExpression('height',resize_frame.document.body.scrollHeight); 
                fr.setExpression('width',resize_frame.document.body.scrollWidth); 
} 
function goURLbySelect(url,target) {
	if (url) {
		target.document.location.href = url ;
	}
}

/********************************************************************
*  Function Name		: resizeFrame
*  Description			: 아이프레임 자동 사이
*  Input Data			: tagURL
*  Output Data			: None
*  사용되는 Function 		: None
/********************************************************************/
function resizeFrame(){
		var oBody = iframe_event.document.body;
		var oFrame = document.all("iframe_event");
		oFrame.style.height = oBody.scrollHeight + (oBody.offsetHeight - oBody.clientHeight);
		oFrame.style.width = oBody.scrollWidth + (oBody.offsetWidth - oBody.clientWidth);
}

//PNG
/*
function setPNG24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bPNG24\b/i,'');
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
    obj.src='';
    return '';
}
*/


// Form 문에서 값을 체크하기 위한 함수 모음
	/*--------------------------------------------------------------------------
	* 사용 예 :
	* <FORM name="form1" onSubmit="return chkForm(this)">
	* input tag에 대한 설명
	* <input
	*	type="text" 	//형식
	*	name="id" 		//이름
	*	hname="아이디" 	//한글 이름
	*	pattern="regId" //어떤 정규식으로 처리할지 선언 (pattern="/^[a-zA-Z]+$/")
	*	required 		//필수 항목에 설정
	*   maxlength=10 	//길이 제한(byte)
	* >
	*-------------------------------------------------------------------------*/
	
	// 폼객체의 이름을 가져오기. 나중에 에러메세지 등에 사용할 객체 이름을 적을것.
	function FormGetElementName(obj)
	{
		if (obj.getAttribute("hname") != null) {
			return obj.hname;
		} else {
			return obj.name;
		}
	}
	
	// 패턴하고 비교하여 패턴에 맞지 않는 값일 경우 alert 메세지 띄움.
	function FormCheckPattern(obj,pattern,hname)
	{
		var regNum = /^[0-9]+$/;
		var regPhone =/^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/;
		var regMail =/^[_a-zA-Z0-9-]+@[._a-zA-Z0-9-]+\.[a-zA-Z]+$/;
		var regDomain =/^[.a-zA-Z0-9-]+.[a-zA-Z]+$/;
		var regAlpha =/^[a-zA-Z]+$/;
		var regHost =/^[a-zA-Z-]+$/;
		var regHangul =/[가-힣]/;	
		var regHangulEng =/[가-힣a-zA-Z]/;
		var regHangulEngNum =/[가-힣a-zA-Z0-9]/;
		var regHangulOnly =/^[가-힣]*$/;	
		var regPasswd = /^[a-zA-Z0-9_-]+$/;
		var regPlainPhone = /^[0-9_-]+$/;
		var regDate =/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;
		var regEngNum =/[a-zA-Z0-9]/;
	
		pattern = eval(pattern);
	
		if(!pattern.test(obj.value)){
			alert("" + hname + " 항목의 형식이 올바르지 않습니다.");
			obj.focus();
			return false;
		}
		return true;
	}
	
	// 문자열의 길이를 계산.
	function StringLength(str)
	{
	//	return (str.length + (escape(str) + "/%u").match(/%u/g).length-1);
	    var l = 0;
	    for (var i=0; i<str.length; i++)
	    	l += (str.charCodeAt(i) > 128) ? 2 : 1;
	    return l;
	}
	
	// form 객체의 maxlength를 가져와 길이 비교를 하고 넘어갈 경우 alert 메세지를 띄움.
	function FormGetElementLength(obj,len,hname)
	{
		if(StringLength(obj.value) > len){
			alert("" + hname + " 항목은 " + "최대 " + len + "byte로 입력이 제한되어 있습니다.\n\n(영문숫자1byte,한글2byte로 계산)");
			obj.focus();
			return false;
		}
	
		return true;
	}
	
	function FormMinElementLength(obj,len,hname)
	{
		if(StringLength(obj.value) < len){
			alert("" + hname + " 항목은 " + "최소 " + len + "byte 이상입니다.\n\n(영문숫자1byte,한글2byte로 계산)");
			obj.focus();
			return false;
		}
	
		return true;
	}
	
	// value가 없을 경우 select, text에 따라 적절한 alert 메세지 띄움
	function FormCheckText(obj, hname)
	{
		if(obj.value.length < 1){
			if (obj.tagName.toUpperCase() == "SELECT")
				alert("" + hname + " 항목을 선택하여 주십시요.");
			else
				alert("" + hname + "를 입력해 주세요.");
	
			obj.focus();
			return false;
		}
		return true;
	}
	
	function FormCheckSelect(obj, hname)
	{
		if(obj.value.length < 1){
			alert("" + hname + " 항목을 선택하여 주십시요.");
			obj.focus();
			return false;
		}
		return true;
	}
	
	function FormCheckCheckbox(form, ele, hname)
	{
	
		//obj = eval(form.name+'.'+ele.name);
		obj = document.getElementsByName(ele.name);
		
		//2006-05-02 체크박스가 여러개일경우 추가
		if(obj.length > 1){
			var count = 0;
			for (i = 0; i < obj.length; i++) {
	       		if (obj[i].checked == true ) {
	    			count++;
				}
			}
			
			if (count == 0 ) { 
				alert("" + hname + " 항목을 선택하여 주십시요.");
				return false;
			}
		}
		else{
			
			alert("" + hname + " 항목을 선택하여 주십시요.");
			obj.focus();
			return false;
		}
	
		return true;
		
		/*
		if (!obj.checked){
			alert("" + hname + " 항목을 선택하여 주십시요.");
			obj.focus();
			return false;
		}
		return true;
		*/
	
	}
	
	function FormCheckRadio(form, ele, hname)
	{
		obj = eval(form.name+'.'+ele.name);
		for (i=0;i<obj.length;i++) {
			if (obj[i].checked)
				return true;
		}
		alert("" + hname + " 항목을 선택하여 주십시요.");
		obj.focus();
		return false;
	}
	
	// 실제 Form 객체들의 값들을 체크하는 함수
	function FormValidate(f)
	{
		var i,currEl;
		for(i = 0; i < f.elements.length; i++){
			currEl = f.elements[i];			
			//필수 항목을 체크한다.
			if (currEl.getAttribute("required") != null){
				if(currEl.type.toUpperCase() == "TEXT" || currEl.tagName.toUpperCase() == "SELECT" || currEl.tagName.toUpperCase() == "TEXTAREA" ||currEl.type.toUpperCase() == "PASSWORD" || currEl.type.toUpperCase() == "FILE" || currEl.type.toUpperCase() == "HIDDEN"){
					if(!FormCheckText(currEl,FormGetElementName(currEl)))
						return false;
				}
				else if(currEl.type.toUpperCase() == "CHECKBOX"){
					if(!FormCheckCheckbox(f, currEl,FormGetElementName(currEl)))
						return false;
				}
				else if(currEl.type.toUpperCase() == "RADIO"){
					if(!FormCheckRadio(f, currEl,currEl.hname))
						return false;
				}
			}

			// 길이 제한을 체크한다.
			if( currEl.tagName.toUpperCase() == "INPUT" && ( currEl.type.toUpperCase() == "TEXT" || currEl.tagName.toUpperCase() == "TEXTAREA" ||currEl.type.toUpperCase() == "PASSWORD") ) {
				if(currEl.getAttribute("maxlength") != null && currEl.value.length > 0){
					if(!FormGetElementLength(currEl,currEl.getAttribute("maxlength"),FormGetElementName(currEl))) {
						return false;
					}
				}
				
				if(currEl.getAttribute("minlength") != null && currEl.value.length > 0){
					if(!FormMinElementLength(currEl,currEl.getAttribute("minlength"),FormGetElementName(currEl))) {
						return false;
					}
				}
			}
	
			// 입력 패턴을 체크한다.
			if(currEl.getAttribute("pattern") != null && currEl.value.length > 0){
				if(!FormCheckPattern(currEl,currEl.pattern,FormGetElementName(currEl)))
					return false;
			}
		}
	
		return true;
	}

	/**
	*	파일 사이즈를 용량 표시와 함께 리턴 한다.
	*/
	function getFileSize(nSize) {
		if (nSize <= 1024)
			return parseInt(nSize) + " byte";
		else if (nSize <= 1024 * 1024)
			return parseInt(nSize / 1024 * 100) / 100 + " Kbyte";
		else if (nSize <= 1024 * 1024 * 1024)
			return parseInt(nSize / (1024 * 1024) * 100) / 100 + " Mbyte";

		return parseInt(nSize / (1024 * 1024 * 1024) * 100) / 100 + " Gbyte";
	}
// 쿠키관련 모음
	function popup_setcookie( name, value, expiredays )
	{
		var todayDate = new Date(); 
		todayDate.setDate( todayDate.getDate() + expiredays ); 
		document.cookie = name + "=" + escape( value ) + "; domain=.goorm.com; path=/; expires=" + todayDate.toGMTString() + ";" 
	}
	
	
	function popup_getCookie(name)
	{
	        var nameOfCookie = name + "=";
	        var x = 0;
	        while ( x <= document.cookie.length )
	        {
	                var y = (x+nameOfCookie.length);
	                if ( document.cookie.substring( x, y ) == nameOfCookie ) {
	                        if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
	                                endOfCookie = document.cookie.length;
	                       return unescape( document.cookie.substring( y, endOfCookie ) );
	                }
	                x = document.cookie.indexOf( " ", x ) + 1;
	                if ( x == 0 )
	                        break;
	        }
	        return "";
	}



// 로그인 관련 함수 모음
	function  login_check()
	{
		var f = document.login_form;
		
		if(checkFormValue(f) ) {
			
		
			saveform();
			f.id.value = f.id.value.toLowerCase();
			document.getElementById("custInfoExtDto.custId").value=f.id.value;
			document.getElementById("custInfoExtDto.pwd").value=f.passwd.value;
			//f.action = CERT_HOME_URL + "/sso/loginRedirect.do?backURL=" + BACK_URL;
			f.submit();
		}
		
	}

	function checkFormValue(form)
	{
			
		if(FormValidate(form))
		{
			return true;
		}
		else
		{
			return false;
		}
	
	}

	//로그인 폼 아이디/비밀번호 표시 사라지기
function loginform_clearbg(type) {
	var f = document.login_form;
	
	if (type == "id") {
		f.id.style.backgroundImage = '';
	} 
	else if (type == "pass") {
		f.passwd.style.backgroundImage = '';
	}
}

//로그인 폼 아이디/비밀번호 표시 나타내기
function loginform_addbg(type) {
	var f = document.login_form;
	
	if (type == "id") {
		//f.id.style.backgroundImage = 'url(http://goorm.ktsystemhosting.com/www/images/main/txt_input_id.gif)';
		//f.id.style.backgroundRepeat = 'no-repeat';
	} 
	
	else if (type == "pass") {
		//f.passwd.style.backgroundImage = 'url(http://goorm.ktsystemhosting.com/www/images/main/txt_input_pw.gif)';
		//f.passwd.style.backgroundRepeat = 'no-repeat';
	}
}


window.onload = __init;
function __init() {
	getform();
	loginControlBg();
}



function idSetCookie (name, value, expires) {
	document.cookie = name + "=" + escape (value) + "; domain=.goorm.com; path=/; expires=" + expires.toGMTString();
} 

function saveform() {
	var expdate = new Date();
	//var f = document.login_form;
	var id = document.getElementById("id").value;
	
	try {
		//if (f.save_cnk.checked) {
		if (document.getElementById("save_cnk").checked) {
			//alert(document.getElementById("id").value);
			//alert('아이디 정보를 저장할 경우 다음접속시\n\n'+
			//'아이디를 입력하지 않으셔도 됩니다.\n\n')
			expdate.setTime(expdate.getTime() + 1000 * 3600 * 24 * 7); // 7일 ==> 7일동안 보전
		} else {
			expdate.setTime(expdate.getTime() - 1);
		}
		idSetCookie("saveid", id, expdate);
		//alert(document.cookie);
		//setCookie("savepass", f.cnj_pass.value, expdate);
	} catch (e) {
		
	}	
}

function getform() {
	
	//var f = document.login_form;
	try {

		//f.save_cnk.checked = ((f.id.value = getCookie("saveid")) != "");
		document.getElementById("save_cnk").checked = ((document.getElementById("id").value = getCookie("saveid")) != "");
		//alert(document.cookie);
		//f.save_cnk.checked = ((f.passwd.value = getCookie("savepass")) != "");
	
		loginform_addbg('pass');
		
		if (document.getElementById("save_cnk").checked) {
			
			document.getElementById("id").value = getCookie("saveid");
			document.getElementById("id").style.backgroundImage  = "none";
			//loginform_clearbg('id');			
		}
		else {
			document.getElementById("id").value = '';
			loginform_addbg('id');
		}
	} catch (e) {
		
	}
}

function getCookie(Name) { 
  var search = Name + "=" 
  if (document.cookie.length > 0) { // 쿠키가 설정되어 있다면 
    offset = document.cookie.indexOf(search) 
    if (offset != -1) { // 쿠키가 존재하면 
      offset += search.length 
      // set index of beginning of value 
      end = document.cookie.indexOf(";", offset) 
      // 쿠키 값의 마지막 위치 인덱스 번호 설정 
      if (end == -1) 
        end = document.cookie.length 
      return unescape(document.cookie.substring(offset, end)) 
    } 
  } 
  return ""; 
} 

	function setHomePage()
	{
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage('http://www.goorm.com/');
	}


// 뷰 플래시
function flashWrite(url,w,h,id,bg,vars,win){

	var flashStr=
	"<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='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
	"<param name='allowScriptAccess' value='always' />"+
	"<param name='movie' value='"+url+"' />"+
	"<param name='FlashVars' value='"+vars+"' />"+
	"<param name='wmode' value='"+win+"' />"+
	"<param name='menu' value='false' />"+
	"<param name='quality' value='high' />"+
	"<param name='bgcolor' value='"+bg+"' />"+
	"<embed src='"+url+"' FlashVars='"+vars+"' wmode='"+win+"' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
	"</object>";

	document.write(flashStr);
}

function GNB_CheckLogin() {
	var search = 'AUTH_TICKET_KEY=';
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search)
		if (offset != -1) {
			return true
		}
	}
	return false;
}
		
function getNickNameCookie(Name) { 
  var search = Name + "=" 
  if (document.cookie.length > 0) { // 쿠키가 설정되어 있다면 
    offset = document.cookie.indexOf(search) 
    if (offset != -1) { // 쿠키가 존재하면 
      offset += search.length 
      // set index of beginning of value 
      end = document.cookie.indexOf(";", offset) 
      // 쿠키 값의 마지막 위치 인덱스 번호 설정 
      if (end == -1) 
        end = document.cookie.length 
      return decodeURI((document.cookie.substring(offset, end)))
    } 
  } 
  return ""; 
} 
 
function location_check(objId) {
	if (objId.value == 1 || objId == 1) {
		window.open("http://www.tooniland.com/");
	}
	else if (objId.value == 2 || objId == 2) {
		window.open("http://www.tooniland.com/KeroroWorld/intro.aspx");
	}
}

/* 로그인 박스 BG삭제 onfocus 정상 동작 안함; */

function loginControlBg() {
	var userid = document.getElementById("userid") ? document.getElementById("userid") : null;
	var passwd = document.getElementById("passwd") ? document.getElementById("passwd") : null;
	
	if (userid != null) {
	
		userid.onkeypress = function() {
			userid.style.backgroundImage  = "none";
		}
		passwd.onkeypress = function() {
			passwd.style.backgroundImage  = "none";
		}
		userid.onclick = function() {
			userid.style.backgroundImage  = "none";
		}
		passwd.onclick = function() {
			passwd.style.backgroundImage  = "none";
		}
	}
}
function loginControlBg01(objId) {	
	objId.style.backgroundImage  = "none";
}


function newItemListShow() {
	var objID0 = document.getElementById("hotGameItem0");
	var objID1 = document.getElementById("hotGameItem1");
	
	if (objID0.style.display == "block") {
		objID0.style.display = "none";
		objID1.style.display = "block";
	} else {
		objID0.style.display = "block";
		objID1.style.display = "none";
	}
	setTimeout("newItemListShow();", 5000);
}

//-- 키보드 보안 체크여부
function secuKeyCheckCookie() {
	if (popup_getCookie("SECU_KEY").length == 0) {
		return "checked"
	} else {
		return "";
	}
}

//-- 키보드 보안 체크 클릭
function keyboardSecurityCheck() {
	var secuKey = "SECU_KEY";
	var secuKeyCheck = document.getElementById("secuKeyCheck");
	if(secuKeyCheck != undefined) {
		if(secuKeyCheck.checked) {
			popup_setcookie( secuKey, "none", -1 )
		} else {
			popup_setcookie( secuKey, "none", 1 )
		}
	}
	document.location.reload();
}

	//-- 팝업창 화면 가운데 정렬, Scroll No
	function popWinCenterNoScroll(url, target, intwidth, intheight) {
		var top = 0;
		var left = 0;
		var w_width = intwidth; 	//창 넓이
		var w_height = intheight; 	//창 높이
		if(left == 0){
			var x= screen.width/2 - w_width/2; //화면중앙으로위치
			left = x;
		}
		if(top == 0){
			var y= screen.height/2 - w_height/2;
			top = y;
		}
		window.open(url, target, "top="+top+",left="+left+",width="+intwidth+",height="+intheight+",resizable=0,scrollbars=0");
	}



	function hotMovie(num){
		for(j=1; j<=3; j ++){ 
			if(j==num){ 
				document.getElementById('movieList0'+j) .style.display = 'block';
				document.getElementById('btn0'+j) .className = 'hotBtn0'+j+'ov';
			}else{ 
				document.getElementById('movieList0'+j) .style.display = 'none';
				document.getElementById('btn0'+j) .className = 'hotBtn0'+j;
			} 
		} 
	} 

function HotService() {
	var objID1 = document.getElementById("HotService01");
	var objID2 = document.getElementById("HotService02");
	
	if (objID1.style.display == "block") {
		objID1.style.display = "none";
		objID2.style.display = "block";
	} else {
		objID1.style.display = "block";
		objID2.style.display = "none";
	}
		setTimeout("HotService();", 5000);
}

function UpdateList() {
	var objID1 = document.getElementById("Update01");
	var objID2 = document.getElementById("Update02");
	
	if (objID1.style.display == "block") {
		objID1.style.display = "none";
		objID2.style.display = "block";
	} else {
		objID1.style.display = "block";
		objID2.style.display = "none";
	}
}



