// title
//document.title="쾌감슈팅! 케로로 팡팡";



// openwindow
function openwindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

// location
function locationUrl(url){
	window.location = url;
}

// 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.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 ) + "; 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 = 'url(http://cache.goorm.com/krpang/images/main02/txt_back.gif)';
		f.id.style.backgroundRepeat = 'no-repeat';
	} 
	else if (type == "pass") {
		f.passwd.style.backgroundImage = 'url(http://cache.goorm.com/krpang/images/main02/txt_back.gif)';
		f.passwd.style.backgroundRepeat = 'no-repeat';
	}
}

//로그인 폼 아이디/비밀번호 표시 나타내기
function loginform_addbg(type) {
	var f = document.login_form;
	
	if (type == "id") {
		f.id.style.backgroundImage = 'url(http://cache.goorm.com/krpang/images/main02/txt_id.gif)';
		f.id.style.backgroundRepeat = 'no-repeat';
	} 
	
	else if (type == "pass") {
		f.passwd.style.backgroundImage = 'url(http://cache.goorm.com/krpang/images/main02/txt_pass.gif)';
		f.passwd.style.backgroundRepeat = 'no-repeat';
	}
}
**/


window.onload = __init;
function __init() {
	var HOST_URL = self.location.host;
	var string_value=/tooniland./;
	if (string_value.test(HOST_URL))
	{
		getform_tooni();
	} else {
		getform();
	}
	
	//로컬에서 에러로 주석처리 20091008
	//updatePopup();
	
}

function idSetCookie (name, value, expires) {
	document.cookie = name + "=" + escape (value) + "; domain=.goorm.com; path=/; expires=" + expires.toGMTString();
}

function idSetCookieTooni (name, value, expires) {
	document.cookie = name + "=" + escape (value) + "; domain=.tooniland.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 {
		//alert(document.cookie);
		//f.save_cnk.checked = ((f.id.value = getCookie("saveid")) != "");
		document.getElementById("save_cnk").checked = ((document.getElementById("id").value = getCookie("saveid")) != "");
		
		//f.save_cnk.checked = ((f.passwd.value = getCookie("savepass")) != "");
	
		loginform_addbg('pass');

		if (document.getElementById("save_cnk").checked) {
			document.getElementById("id").value = getCookie("saveid");
			loginform_clearbg('id');
		}
		else {
			document.getElementById("id").value = '';
			loginform_addbg('id');
		}
	} catch (e) {
		
	}
}
//채널링 투니용~
function saveform_tooni() {
	var expdate = new Date();
	//var f = document.login_form;
	var gc_id = document.getElementById("gc_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);
		}
		idSetCookieTooni("saveid", gc_id, expdate);
		//alert(document.cookie);
		//setCookie("savepass", f.cnj_pass.value, expdate);
	} catch (e) {
		
	}	
}
function getform_tooni() {
	//var f = document.login_form;	
	try {
		//alert(document.cookie);
		//f.save_cnk.checked = ((f.id.value = getCookie("saveid")) != "");
		document.getElementById("save_cnk").checked = ((document.getElementById("gc_id").value = getCookie("saveid")) != "");
		
		//f.save_cnk.checked = ((f.passwd.value = getCookie("savepass")) != "");
	
		//loginform_addbg('pass');

		if (document.getElementById("save_cnk").checked) {
			if (getCookie("saveid") != null)
			{
				document.getElementById("gc_id").value = getCookie("saveid");
				//loginform_clearbg('id');
			} else {
				document.getElementById("gc_id").value = "";
			}		
			
			loginform_clearbg('gc_id');
		}
		else {
			document.getElementById("gc_id").value = '';
			//loginform_addbg('gc_id');
			//투니용에서 자동 저장된 쿠키
			if (getCookie("idSave") != '')
			{
						document.getElementById("save_cnk").checked = ((document.getElementById("gc_id").value = getCookie("idSave")) != "");
						document.getElementById("gc_id").value = getCookie("idSave");
			}
		}
		
	} catch (e) {
		
	}
}

// 뷰 플래시
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 Createflash(w,h,movie,ids){
	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='"+ids+"' align='middle'>"+
	"<param name='allowScriptAccess' value='always' />"+
	"<param name='movie' value='"+movie+"' />"+
	"<param name='wmode' value='transparent' />"+
	"<param name='menu' value='false' />"+
	"<param name='quality' value='high' />"+
	"<embed src='"+movie+"' wmode='transparent' menu='false' quality='high' width='"+w+"' height='"+h+"' name='"+ids+"' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
	"</object>";
	
	 document.write(flashStr);

}

//	링크 클릭시 테두리없애기
function autoblur() {
 if(!document.body){
  return;
 }else if(event.srcElement.tagName == "A" && document.body){
  document.body.focus();
 }
}
document.onfocusin = autoblur;

	function getCookie(Name) {
		var search = Name + "="
		if (document.cookie.length > 0) { // 쿠키가 설정되어 있다면
		offset = document.cookie.indexOf(search)
		if (offset != -1) {
			offset += search.length
			end = document.cookie.indexOf(";", offset)
		
			if (end == -1)
				end = document.cookie.length
				return unescape(document.cookie.substring(offset, end))
			}
		}
		return "";
	}

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 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 GNB_CheckLoginTooni() {
	var search = 'cAI=';
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search)
		if (offset != -1) {
			return true
		}
	}
	return false;
}

//-- 키보드 보안 체크여부
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();
}




// IE6 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='http://cache.goorm.com/we/comn/trans.gif';
	return '';
}

/* 로그인 박스 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.backgroundPosition  = "left top";
		}
		passwd.onkeypress = function() {
			passwd.style.backgroundPosition  = "left top";
		}
		userid.onclick = function() {
			userid.style.backgroundPosition  = "left top";
		}
		passwd.onclick = function() {
			passwd.style.backgroundPosition  = "left top";
		}
		
		if (passwd.value != "") {
			passwd.style.backgroundPosition  = "left top";
		}
		if (userid.value != "") {
			userid.style.backgroundPosition  = "left top";
		}
	}
}
function loginControlBg01(objId) {
	objId.style.backgroundPosition  = "left top";
}

/* GNB height 늘리기 */
function gnbOverSide() {
	
}

function gnbOutSide() {
	
}

// menuOver
function menuOver() {
	this.src = this.src.replace("off.gif", "on.gif");
}
function menuOut() {
	this.src = this.src.replace("on.gif", "off.gif");
}

// Tab  //

function initTabMenu(menuElId) {
	var tabMenu = document.getElementById(menuElId).getElementsByTagName("a");
	for(i=0; i<tabMenu.length; i++) {
		thismenu = tabMenu.item(i);
		thismenu.menuContainer = document.getElementById(menuElId) ? document.getElementById(menuElId) : null;
		thismenu.targetEl = document.getElementById(tabMenu.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.getElementsByTagName("img").item(0).onmouseover = menuOver;
		thismenu.getElementsByTagName("img").item(0).onmouseout = menuOut;
		thismenu.onclick = tabMenuClick;
	}
	var initmenu = tabMenu.item(0);
	initmenu.targetEl.style.display = "block";
	initmenu.getElementsByTagName("img").item(0).onmouseover();
	initmenu.getElementsByTagName("img").item(0).onmouseover = null;
	initmenu.getElementsByTagName("img").item(0).onmouseout = null;
	initmenu.menuContainer.current = initmenu;
}

function tabMenuClick() {
	var currentmenu = this.menuContainer.current;
	if (currentmenu != this) {
		currentmenu.targetEl.style.display = "none";
		currentmenu.getElementsByTagName("img").item(0).onmouseover = menuOver;
		currentmenu.getElementsByTagName("img").item(0).onmouseout = menuOut;
		currentmenu.getElementsByTagName("img").item(0).onmouseout();

		this.targetEl.style.display = "block";
		this.getElementsByTagName("img").item(0).onmouseover = null;
		this.getElementsByTagName("img").item(0).onmouseout = null;
		this.menuContainer.current = this;

//more check
		var moreChk = document.getElementById(currentmenu.targetEl.id + "_more") ?  document.getElementById(currentmenu.targetEl.id + "_more") : null;
		if (moreChk != null) {
			var currentMoreBtn = document.getElementById(currentmenu.targetEl.id + "_more");
			var thisMoreBtn = document.getElementById(this.targetEl.id + "_more");

			currentMoreBtn.style.display = "none";
			thisMoreBtn.style.display = "block";
		}
	}
	return false;
}

var itemflag=false, itembzAw=0, itemtemp=0, itemamount=0, itembzHchk=0, _targetItem=null, slideSize=0;
//itemflag:롤링 여부, itembzAw:현재위치
//itemtemp:롤링 속도,배너 사이즈 체크, itemamount:배너하나당 width값, itembzHchk:화면에 보여지는 width
//itembzAw:현재위치 , _targetItem:objectID

function slideLR(obj,chk,atom,list) { //obj:objectID, chk:Left Right, atom:배너하나당 width값, list:화면에 보여지는 갯수

	if (!itemflag){
		_targetItem	= document.getElementById(obj);


		var objs = _targetItem.getElementsByTagName("td");
		var i = objs.length;
		var itemTotalWidth = i * atom;
		var itemChkAllow = (itembzAw + itemTotalWidth) - (atom * list);
		itemamount = atom * list;

		itembzHchk = (atom * i) - (atom * list);
		itemflag=true;

		if ((itemChkAllow < (atom * list)) && (chk == "R")) {
			itemamount = (atom * itemChkAllow) / atom;
		}

		for (var intI = 0; intI <= 25; intI++) { //한번에 이동할 슬라이딩 크기 지정
			if (atom % intI == 0) {
				slideSize = intI;
			}
		}

		if(obj != "indexBest") itemamount = atom; //한칸씩 이동할 크기 지정


		if (!isNaN(_targetItem.style.left)){
			itembzAw = 0;
			return scroll(chk);
		}
		else {
			itembzAw = parseInt(_targetItem.style.left);
			return scroll(chk);
		}
	}
}

function scroll(chkPos) {
    if (itemflag) {
    	if((itembzAw == 0 && chkPos == "L") || ((itembzAw <= (-itembzHchk)) && chkPos == "R")){
    		itemtemp = 0;
    		itemflag = false;
    	} else{
			itemtemp += slideSize;
            if(chkPos=='L') {
				_targetItem.style.left = (itembzAw + itemtemp) +"px";
				if ((itembzAw + itemtemp) == 0) {
					itembzAw = 0;
				}
            } else if(chkPos=='R') {
				_targetItem.style.left = (itembzAw - itemtemp) +"px";
           }
	        if(itemamount<=itemtemp) {
	        	itemflag = false;
	        	itemtemp = 0;
	        	itembzAw = parseInt(_targetItem.style.left);

	        }
	        window.setTimeout("scroll('"+chkPos+"')", 20);			
        }
    }
	
}


function selectForm(wrapEl,frm){
  var hiddenForms = document.getElementById(wrapEl);

  theForm = hiddenForms.getElementsByTagName("div");

  for(x=0; x<theForm.length; x++){
    theForm[x].style.display = "none";
  }

  if (theForm[frm-1]){
    theForm[frm-1].style.display = "block";
  }

  var rtype = 0;	

  if(frm == "15"){	
	  rtype ="1";  
  } else if(frm == "2"){
	  rtype ="2";    
  } else if(frm == "12"){
	  rtype ="3";    
  } else if(frm == "4"){
	  rtype ="4";    
  } else if(frm == "14"){
	  rtype ="5";    
  } else if(frm == "16"){
	  rtype ="6";    
  } else if(frm == "1"){
	  rtype ="7";    
  } else if(frm == "17"){
	  rtype ="8";    
  } else if(frm == "7"){
	  rtype ="9";    
  } else if(frm == "6"){
	  rtype ="10";    
  } else if(frm == "8"){
	  rtype ="11";    
  } else if(frm == "10"){
	  rtype ="12";    
  } else if(frm == "18"){
	  rtype ="13";    
  } else if(frm == "5"){
	  rtype ="14";    
  } else if(frm == "9"){
	  rtype ="15";    
  } else if(frm == "13"){
	  rtype ="16";    
  } else if(frm == "3"){
	  rtype ="17";    
  }


  document.getElementById('rankListObj2_more').href = "/ranking/crank0.gm?type="+rtype;
}


var agent = navigator.userAgent.toLowerCase();
var ver = agent.split(';');
if(agent.indexOf('msie') != -1)
var version = parseFloat(ver[1].slice(6, ver[1].length));

function layerPopSelectHidden() {
//IE6 셀렉트 박스 이외 처리
	if (version == 6) {
		var chkSel = document.body.getElementsByTagName('select');
		for (var i = 0; i < chkSel.length; i++) {
			chkSel[i].style.visibility = "hidden";
		}
	}	
}
function layerPopSelectShow() {
//IE6 셀렉트 박스 이외 처리
	if (version == 6) {
		var chkSel = document.body.getElementsByTagName('select');
		for (var i = 0; i < chkSel.length; i++) {
			chkSel[i].style.visibility = "visible";
		}
	}	
}

//Layer Popup Open
function layerPopOpen(imgPath, objId){
	var layerTop = getYScroll() + (getWindowHeight() / 40);
	
	var objId = document.getElementById(objId);
	objId.style.display = "block";
	
	objId.style.left = "50%";
	objId.style.top = layerTop;
	
	var objW = objId.offsetWidth / 2;
	var objH = objId.offsetHeight / 3;
	objId.style.margin ="-"+objH+"px 0 0 -"+objW+"px";

	var imgId = document.getElementById(objId.id+"Img") ? document.getElementById(objId.id+"Img") : null;

	if (imgId != null) {
		imgId.src = imgPath;
	}
	
	layerPopSelectHidden();
}


function getYScroll() {

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	return yScroll;
}

function getWindowHeight() {

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	 
	return windowHeight;
}

//-- 이미지 원본보기
function popupImg(img_view) {
	htmlz = "<html><head><title>이미지크게보기</title><style>body{margin:0;cursor:hand;}</style></head><body scroll=auto onload='width1=document.all.Timage.width;height1=document.all.Timage.height;top.window.resizeTo(width1+30,height1+54);' onclick='top.window.close();'><img src='"+img_view+"'  title='클릭하시면 닫힙니다.' name='Timage' id='Timage'></body></html>"
	imagez = window.open('', "image", "width="+ 100 +", height="+ 100 +", top=0,left=0,scrollbars=auto,resizable=1,toolbar=0,menubar=0,location=0,directories=0,status=1");
	imagez.document.open();
	imagez.document.write(htmlz)
	imagez.document.close();
}


//쿠폰 입력
function coupon_pop() {
	if (!GNB_CheckLogin())
	{
		alert("로그인 이후 가능 합니다.");
		
	}
	else {
		window.open('/coupon/pop_coupon.html','coupon_win','width=454,height=465'); 		
	}
}	 