﻿// UI개발에서 사용

//이미지 롤오버
 
function imgover(img) {
	var image=img.src;
	
	if (image.indexOf('on.gif') < 0) {
		currentUrl=image.substr(0,image.indexOf('off.gif'));
		img.src=currentUrl + "on.gif";
	}
	else {	    
		currentUrl=image.substr(0,image.indexOf('on.gif'));
		img.src=currentUrl + "off.gif";
	}
} 



//게토골드 기능소개 탭 레이어

function ClickGetoGuideSection( nType )
{
	document.all.GetoGuide1.style.display = 'none';
	document.all.GetoGuide2.style.display = 'none';
	document.all.GetoGuide3.style.display = 'none';
	document.all.GetoGuide4.style.display = 'none';
	
	if ( nType == 1 )
		document.all.GetoGuide1.style.display = '';
	else if ( nType == 2 )
		document.all.GetoGuide2.style.display = '';
	else if ( nType == 3 )
		document.all.GetoGuide3.style.display = '';
	else if ( nType == 4 )
		document.all.GetoGuide4.style.display = '';
}



// faq 사용
function initToggleDefList(listEl) {
        listEl.currentItem = false;
        listEl.dtList = listEl.getElementsByTagName("dt");
        listEl.ddList = listEl.getElementsByTagName("dd");

        for (i=0; i<listEl.getElementsByTagName("dt").length; i++) {
                listEl.dtList.item(i).dlEl = listEl;
                listEl.dtList.item(i).listNum = i;
                listEl.dtList.item(i).onclick = toggleDefinitionList;
        }
}

function toggleDefinitionList() {
        if (this.dlEl.dtList.item(this.dlEl.currentItem) && this.dlEl.ddList.item(this.dlEl.currentItem) && this.dlEl.currentItem != this.listNum) {
                this.dlEl.dtList.item(this.dlEl.currentItem).className = null;
                this.dlEl.ddList.item(this.dlEl.currentItem).className = null;
        }

        if (this.dlEl.ddList.item(this.listNum).className == "on") {
                this.dlEl.dtList.item(this.listNum).className = null;
                this.dlEl.ddList.item(this.listNum).className = null;
        } else {
                this.dlEl.dtList.item(this.listNum).className = "on";
                this.dlEl.ddList.item(this.listNum).className = "on";
        }

        this.dlEl.currentItem = this.listNum;
}


/* Content Paging
------------------------------------------------------------------------------------------------------------------*/
// btnType	: 이전인지 다음인지 {pre | next}
// obj			: 순서에 해당하는 숫자를 제외한 컨트롤 할 해당 아이디
// totalCnt	: obj 전체 카운트
var contentVisibleOrder = 1;
function contentPaging(btnType, obj, totalCnt)
{	
	document.getElementById(obj + contentVisibleOrder).style.display = "none";
	if(btnType == "prev")
	{
		contentVisibleOrder = contentVisibleOrder - 1;
		if (contentVisibleOrder == 0)
		{
				contentVisibleOrder = totalCnt;
		}
	}
	else
	{
		contentVisibleOrder = contentVisibleOrder + 1;
		if (contentVisibleOrder > totalCnt)
		{
				contentVisibleOrder = 1;
		}
	}
	document.getElementById(obj + contentVisibleOrder).style.display = "block";
}



var contentVisibleOrder2 = 1;
function contentPaging2(btnType, obj, totalCnt)
{	
	document.getElementById(obj + contentVisibleOrder2).style.display = "none";
	if(btnType == "prev")
	{
		contentVisibleOrder2 = contentVisibleOrder2 - 1;
		if (contentVisibleOrder2 == 0)
		{
				contentVisibleOrder2 = totalCnt;
		}
	}
	else
	{
		contentVisibleOrder2 = contentVisibleOrder2 + 1;
		if (contentVisibleOrder2 > totalCnt)
		{
				contentVisibleOrder2 = 1;
		}
	}
	document.getElementById(obj + contentVisibleOrder2).style.display = "block";
}


//****************** 퀵메뉴 시작
var stmnLEFT = 910; // 스크롤메뉴의 좌측 위치
var stmnGAP1 = 172; // 페이지 위쪽 여백
var stmnGAP2 = 72; // 스크롤시 브라우저 상단과 약간 띄움. 필요없으면 0으로 세팅
var stmnBASE = 0;   // 스크롤메뉴 초기 시작위치 (아무렇게나 해도 상관은 없지만 stmnGAP1과 약간 차이를 주는게 보기 좋음)
var stmnActivateSpeed = 80; // 움직임을 감지하는 속도 (숫자가 클수록 늦게 알아차림)
var stmnScrollSpeed =10; // 스크롤되는 속도 (클수록 늦게 움직임)

var stmnTimer;


function ReadCookie(name) {
var label = name + "=";
var labelLen = label.length;
var cLen = document.cookie.length;
var i = 0;

while (i < cLen) {
var j = i + labelLen;

if (document.cookie.substring(i, j) == label) {
var cEnd = document.cookie.indexOf(";", j);
if (cEnd == -1) cEnd = document.cookie.length;
return unescape(document.cookie.substring(j, cEnd));
}
i++;
}
return "";
}

function SaveCookie(name, value, expire) {
var eDate = new Date();
eDate.setDate(eDate.getDate() + expire);
document.cookie = name + "=" + value + "; expires=" + eDate.toGMTString()+ "; path=/";
}

function RefreshStaticMenu() {
var stmnStartPoint, stmnEndPoint, stmnRefreshTimer;

stmnStartPoint = parseInt(STATICMENU.style.top, 10);
stmnEndPoint = document.body.scrollTop + stmnGAP2;
if (stmnEndPoint < stmnGAP1) stmnEndPoint = stmnGAP1;

stmnRefreshTimer = stmnActivateSpeed;

if ( stmnStartPoint != stmnEndPoint ) {
stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 15 );
STATICMENU.style.top = parseInt(STATICMENU.style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount );
stmnRefreshTimer = stmnScrollSpeed;
}
stmnTimer = setTimeout ("RefreshStaticMenu();", stmnRefreshTimer);
}

function ToggleAnimate() {
if (!ANIMATE.checked) {
RefreshStaticMenu();
SaveCookie("ANIMATE", "true", 300);
} else {
clearTimeout(stmnTimer);
STATICMENU.style.top = stmnGAP1;
SaveCookie("ANIMATE", "false", 300);
}
}

function InitializeStaticMenu() {
STATICMENU.style.left = stmnLEFT;
if (ReadCookie("ANIMATE") == "false") {
ANIMATE.checked = true;
STATICMENU.style.top = document.body.scrollTop + stmnGAP1;
} else {
//ANIMATE.checked = false;
STATICMENU.style.top = document.body.scrollTop + stmnBASE;
RefreshStaticMenu();
}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//****************** 퀵메뉴 끝


// 총판 레이어
function showSalelayer() {
    var status = document.getElementById('wrap_salelayer');
    if(status.style.display=="none") {
        status.style.display = "block";
    }
    else {
        status.style.display = "none";
    }    
}


/* */

function openGames() {
    var status = document.getElementById('wrap_games');
    if(status.style.display=="none") {
        status.style.display = "block";
    }
    else {
        status.style.display = "none";
    }    
}



/* GameInfo */
function screenChg(img, game) {
	var image = img.src;
	var mainImg = document.getElementById('screenshot');
	var gameid = "s_" + game;
	
	thisUrl = image.substr(0,image.indexOf(gameid+'.gif'));
	mainImg.src = thisUrl + "_" + game + ".jpg";
} 

var vodVisibleOrder = 1;
function vodChg(obj, cnt) {	
	document.getElementById(obj + vodVisibleOrder).style.display = "none";
	vodVisibleOrder = cnt;
    
	document.getElementById(obj + vodVisibleOrder).style.display = "block";
}

function popnone(pop,width,height)
{
	var url = pop;  
	var wd = width;
	var he = height;
	
	window.open(url,"","status=0,toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + wd +",height=" + he + ";")
}

function changeBG(){
    var num = Math.round(Math.random()*3)+1;
    var ImageServerURL = "";

    if(location.href.substring(0,5) == "https") 
        ImageServerURL="http://wstatic.plaync.co.kr";
    else 
        ImageServerURL="http://static.ncsoft.net";
    bgImage = "url('"+ ImageServerURL + "/PCCafeWeb/main/bg_top" + num + ".jpg')";	
	document.getElementById("mtopsec").style.backgroundImage = bgImage;
}



/* Flash Banner Link
------------------------------------------------------------------------------------------------------------------*/
function open_popup(url, wid, hei, scroll, winName)
{
	var url = url;
	var posi = "width="+ wid +",height="+hei+",toolbar=no,location=no,status=no,menubar=no,top=10,left=50,scrollbars=" + scroll +",resizable=no" ;
	if (winName == "")
	{
		winName = popup;
	}
	window.open(url,winName,posi);
}

function lolgamebanner(myurl, mywidth, myheight, isscroll) {
	//alert("mywidth="+mywidth+"- myheight="+myheight+"- isscroll="+isscroll+"- myurl="+myurl);
	if(mywidth == "0" && myheight == "0") {
		if(isscroll == "0" ) {
			document.location.href= myurl;
		} else {
			window.open(myurl,"_blank");
		}
	} else {
		open_popup(myurl,mywidth,myheight,isscroll,"lolgamebanner" );
	}
}


/* Flash Banner & XML
------------------------------------------------------------------------------------------------------------------*/
/*
objID			: 플래시 아이디
objSource		: 플래시 파일 이름 및 경로
objXML			: 플래시에 입력될 xml 파일 이름
objWidth		: 플래시 가로 사이즈
objHeight		: 플래시 세로 사이즈
objQuality	: 플래시 무비 퀄러티
objWmode	: 플래시 Wmode
objBgcolor	: 플래시 배경색
*/
function flashBannerObject(objID, objSource, objXML, objWidth, objHeight, objQuality, objWmode, objBgcolor)
{
	var cntT;
	var xmlDoc;
	var bannerPriorityCnstT = 0;
	
	try
	{
		var xmlHttp = false;
		if (window.XMLHttpRequest)
		{
			xmlHttp = new XMLHttpRequest();
		}
		else
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}

		xmlHttp.open("get", objXML, false);
		xmlHttp.send(null);

		if (xmlHttp.readyState == 4)
		{			
			if (xmlHttp.status == 200)
			{	
				xmlDoc = xmlHttp.responseXML;

				if (window.ActiveXObject)
				{
					cntT = xmlDoc.getElementsByTagName("dataInfo")[0].childNodes.length;
				}
				else
				{
					var cntW = xmlDoc.getElementsByTagName("dataInfo")[0].childNodes.length;
					cntT = (cntW-1) / 2;
				}

				for (i=0; i<cntT; i++)
				{
					bannerPriorityCnstT = eval(bannerPriorityCnstT) + eval(xmlDoc.getElementsByTagName("thumNum")[i].childNodes[0].nodeValue);
				}

				var focusItemCnst = Math.random();
				focusItemCnst = parseInt(focusItemCnst * bannerPriorityCnstT);

				bannerPriorityCnstT = 0;
				var chkMovie =  0;
				for (i=0; i<cntT; i++)
				{
					bannerPriorityCnstT = eval(bannerPriorityCnstT) + eval(xmlDoc.getElementsByTagName("thumNum")[i].childNodes[0].nodeValue);
					if (focusItemCnst < bannerPriorityCnstT)
					{
						chkMovie = i;
						break;
					}
				}
			}
			else
			{
				chkMovie =  0;
			}
		}
		else
		{
			chkMovie =  0;
		}
	}
	catch (e)
	{
		chkMovie =  0;
	}

	//page url
	var pageUrl=self.window.location.href;
	if(pageUrl.substring(0,5)=="https") swfUrl="https";
	else swfUrl="http";
	//default value setting
	if (objID=="") objID="ShockwaveFlash1";
	if (objWidth=="") objWidth="0";
	if (objHeight=="") objHeight="0";
	if (objQuality=="") objQuality="high";
	if(objWmode=="") objWmode="transparent";

	objSource = objSource + "?server=" +  objXML + "&chkMovie=" + chkMovie;

	document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+swfUrl+'://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" width="'+objWidth+'" height="'+objHeight+'" id="'+objID+'" align="middle">');
	document.writeln('<param name="movie" value="'+objSource+'" />');
	document.writeln('<param name="allowScriptAccess" value="always" />');
	document.writeln('<param name="menu" value="false" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="bgcolor" value="'+objBgcolor+'" />');
	document.writeln('<param name="wmode" value="'+objWmode+'" />');
	document.writeln('<embed src="'+objSource+'" allowScriptAccess="always" menu="false" quality="high" bgcolor="'+objBgcolor+'" wmode="'+objWmode+'" width="'+objWidth+'" height="'+objHeight+'" name="'+objID+'" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.writeln('</object>');
}


// 문자열 왼쪽공백 제거
function ltrim(str){ 
	var s = new String(str); 

	if (s.substr(0,1) == " ") 
			return ltrim(s.substr(1)); 
	else 
			return s; 
} 
// 문자열 오른쪽공백 제거
function rtrim(str){ 
	var s = new String(str); 
	if(s.substr(s.length-1,1) == " ") 
			return rtrim(s.substring(0, s.length-1)) 
	else 
			return s; 
} 


function trim(str){
	return str.replace(/(^\s*)|(\s*$)/g,"");
}

// 문자열내 앞뒤공백제거
//function trim(str) { 
//	return ltrim(rtrim(str));
//}
// 문자열 길이 return
function strlen(str) { 
	var j = 0;
	for(var i=0; i<str.length; i++) {
		if(escape(str.charAt(i)).length == 6) j++;
		j++;
	}
	return (j);
}
// 문자열내 공백제거
function deleteSpace (val) {
	var old_val = val;
	var new_val = "";

	var n = old_val.length;

	for(var i=0; i<n; i++) {
		if(old_val.charAt(i) == " ")
			continue;
		else
			new_val += old_val.charAt(i);
	}

	return new_val;
}
// `name` or `id`값으로 object찾아서 return
function getObject (sID){
	if (typeof(sID) == "object")
		return (sID);
	else if (typeof (window.document.all [sID]) == "object")
		return (window.document.all [sID]);
	else
		return (null);
}
// 새창열기
function F_Open_Win (sURL, oTarget, nWidth, nHeight, bScrollbar, bResizable) {
	if (!bScrollbar)	bScrollbar = "no";
	if (!bResizable)	bResizable = "no";
	var nLeft = parseInt ((window.screen.availWidth - nWidth) / 2);
	var nTop = parseInt ((window.screen.availHeight - nHeight) / 2);
	var oWindow = window.open (sURL, oTarget, "status=yes, left=" + nLeft + ", top=" + nTop + ", width=" + nWidth+", height=" + nHeight + ", menubar=no, scrollbars=" + bScrollbar + ",resizable=" + bResizable);
	if (oWindow){
		oWindow.focus ();
		return (oWindow);
	}
	else	
		return (null);
}


function openwin( winurl, winname, winwidth, winheight, adjust, resizable, scrollbar ) {
    var width  = winwidth;
    var height = winheight;
    var left, top;

    switch( adjust ) {
	case 1: //top left aligned
		left = top = 0;
		break;
	case 2: //top RIGHT aligned
		left = window.screen.availWidth - width - 10;
		top = 0;
		break;
	case 3: //centered
		left = (window.screen.availWidth - width) / 2;
		top = (window.screen.availHeight - height) / 2;
		break;
	case 4: //bottom left aligned
		left = 0;
		top = window.screen.availHeight - height - 25 - 10;
		break;
	case 5: //bottom RIGHT aligned
		left = window.screen.availWidth - width - 10;
		top = window.screen.availHeight - height - 25 - 10;
		break;
    }
   
    var dynamic = "";
    if( adjust > 0 ) dynamic = "left=" + left + ",top=" + top;
    dynamic = dynamic + ",width=" + width + ",height=" + height;
    if( resizable ) dynamic = dynamic + ",resizable=yes";
    else dynamic = dynamic + ",resizable=no";
    if( scrollbar ) dynamic = dynamic + ",scrollbars=yes";
    else dynamic = dynamic = dynamic + ",scrollbars=no";
    remotecontrol = window.open( winurl, winname, "toolbar=no," + dynamic + ",directories=no,status=no,menubar=no");
}

function openargwin( winurl, argv, winname, winwidth, winheight, adjust, resizable ) {

    var width  = winwidth;
    var height = winheight;
    var left, top;
    switch( adjust ) {
	case 1: //top left aligned
		left = top = 0;
		break;
	case 2: //top RIGHT aligned
		left = window.screen.availWidth - width - 10;
		top = 0;
		break;
	case 3: //centered
		left = (window.screen.availWidth - width) / 2;
		top = (window.screen.availHeight - height) / 2;
		break;
	case 4: //bottom left aligned
		left = 0;
		top = window.screen.availHeight - height - 25 - 10;
		break;
	case 5: //bottom RIGHT aligned
		left = window.screen.availWidth - width - 10;
		top = window.screen.availHeight - height - 25 - 10;
		break;
    }
    var dynamic = "";
    if( adjust > 0 ) dynamic = "left=" + left + ",top=" + top;
    dynamic = dynamic + ",width=" + width + ",height=" + height;
    if( resizable ) dynamic = dynamic + ",resizable=yes,scrollbars=auto";
    else dynamic = dynamic + ",resizable=no,scrollbars=auto";    
    winurl = winurl + argv;
   
    remotecontrol = window.open(winurl, winname, "toolbar=no," + dynamic + ",directories=no,status=no,scrollbars=no,menubar=no");
}

function get_exact_count( ctrlnm, specialset ) {
    var thisvalue = ctrlnm.value;
    var byte1count = 0, byte2count = 0;
    for( var i = 0; i < thisvalue.length; i++ ) {
        thischar = thisvalue.charAt( i );
        if( ((thischar >= '0') && (thischar <= '9')) ||
            ((thischar >= 'A') && (thischar <= 'Z')) ||
            ((thischar >= 'a') && (thischar <= 'z')) ||
            ((thischar == '-') || (thischar == '_')) )
            byte1count++;
        else if( thischar == '(' || thischar == ')' ) {
        	byte1count++;
        	//byte1count++;
        }
        else if( specialset.indexOf(thischar) != -1 )
            byte1count++;
        else
            byte2count++;
    }
    return( byte1count + byte2count * 2 );
}

function is_nothing( ctrlnm ) {
    var thisvalue = ctrlnm.value;
    if( thisvalue.length == 0 ) {
        alert( "빈칸을 모두 입력해주세요." );
        if( FOCUSABLE ){ 
                if( ctrlnm.style.visibility == "hidden" || ctrlnm.styledisplay == "none" ){
                }else{
                                  ctrlnm.focus();
                }
        }
        
        return( true ); 
    }
    spacecount = 0;
    for( var i = 0; i < thisvalue.length; i++ ) {
        thischar = thisvalue.charAt( i );
        if( thischar == ' ' ) spacecount++;
    }
    if( spacecount == thisvalue.length ) {
	    alert( "빈칸을 모두 입력해주세요." );
	    
        if( FOCUSABLE ){ 
                if( ctrlnm.style.visibility == "hidden" || ctrlnm.styledisplay == "none" ){
                }else{
                                  ctrlnm.focus();
                }
        }

	    return( true ); 
	}
	return( false );
}

function valid_text( ctrlnm, minimum, maximum, incspecial ) {
    var thisvalue = ctrlnm.value;
    var exactcount = 0;
    var specialset = " `~!@#$%^&*()_+|\\=-[]{};':\",./<>?";
    
	if( (minimum > -1)&& (is_nothing(ctrlnm)) ) 
	    return( false );	
    if( incspecial == false ) {
	    for( var i = 0; i < thisvalue.length; i++ ) {
	        thischar = thisvalue.charAt( i );
	        //if( specialset.indexOf(thischar) != -1 ) {
		    //    alert( "특수한 문자는 허용되지 않습니다.\r\n" + 
		    //           "Special character is NOT available, Enter another one!" );
		    //    if( FOCUSABLE ) ctrlnm.focus();
		    //    return( false ); 
	        //    }
	    }
	}
    exactcount = get_exact_count( ctrlnm, specialset );    
    if( (minimum > -1) && (exactcount < minimum) ) {
        alert( "본 항목은 최소 (" + minimum + ")자 이상이어야 합니다. 현재 (" + exactcount + ")자 입니다." );
/*
        if( FOCUSABLE ){                  ctrlnm.focus();

        }
*/
        ctrlnm.focus();
        return( false );
    }
    if( (maximum > -1) && (exactcount > maximum) ) {
        alert( "본 항목은 최대 (" + maximum + ")자 이하이어야 합니다. 현재 (" + exactcount + ")자 입니다." );
/*
        if( FOCUSABLE ){ 
                if( ctrlnm.style.visibility == "hidden" || ctrlnm.styledisplay == "none" ){
                }else{
                                  ctrlnm.focus();
                }
        }
*/
        ctrlnm.focus();
        return( false );
    }
    return( true );
}



function valid_text_unlimit( ctrlnm, minimum, incspecial ) {
    var thisvalue = ctrlnm.value;    
    var exactcount = 0;
    var specialset = " `~!@#$%^&*()_+|\\=-[]{};':\",./<>?";
    
	if( (minimum > -1)&& (is_nothing(ctrlnm)) ) 
	    return( false );	
    if( incspecial == false ) {
	    for( var i = 0; i < thisvalue.length; i++ ) {
	        thischar = thisvalue.charAt( i );
	        //if( specialset.indexOf(thischar) != -1 ) {
		    //    alert( "특수한 문자는 허용되지 않습니다.\r\n" + 
		    //           "Special character is NOT available, Enter another one!" );
		    //    if( FOCUSABLE ) ctrlnm.focus();
		    //    return( false ); 
	        //    }
	    }
	}
    exactcount = get_exact_count( ctrlnm, specialset );    
    if( (minimum > -1) && (exactcount < minimum) ) {
        alert( "본 항목은 최소 (" + minimum + ")자 이상이어야 합니다. 현재 (" + exactcount + ")자 입니다." );

        if( FOCUSABLE ){                  
        	ctrlnm.focus();
        }
        return( false );
    }
    return( true );
}

function is_zero( ctrlnm ) { 
    if( ctrlnm.value.length == 0 || parseInt(ctrlnm.value, 10) == 0 ) { 
        alert( "빈칸을 모두 입력해주세요.");
        if( FOCUSABLE ) ctrlnm.focus();
        return( true ); 
    } else {
        return( false ); 
    }
}

function is_numeric( ctrlnm ) {
    var charDetected = 0, markDetected = 0, dotCount = 0;
    var numeric = ctrlnm.value;
    if( numeric == null || numeric == "" || numeric.length == 0 ) {        
        return( false );
    }
    for( var i = 0; i < numeric.length; i++ ) {
      thischar = numeric.charAt( i );
      if( !((thischar >= '0') && (thischar <= '9')) ) {        
        return( false );
        }
    } //end of for
    return( true );
}

function valid_number( ctrlnm, minimum, maximum ) {
    var numeric = ctrlnm.value;
    if( is_numeric( ctrlnm ) == false ) {
        	alert( "값이 비어 있거나 숫자가 아닙니다." );
        //if( FOCUSABLE ) ctrlnm.focus();
        ctrlnm.focus();
        return( false );
    }
    var quantity = parseInt( numeric, 10 );
    if( (minimum > -1) && (quantity < minimum) ) {
        alert( "본 항목은 최소 (" + minimum + ") 이상이어야 합니다." );
        //if( FOCUSABLE ) ctrlnm.focus();
        ctrlnm.focus();
        return( false );
    }
    if( (maximum > -1) && (quantity > maximum) ) {
        alert( "본 항목은 최대 (" + maximum + ") 이하이어야 합니다." );
        //if( FOCUSABLE ) ctrlnm.focus();
        ctrlnm.focus();
        return( false );
    }
    return( true );
}

function valid_numberChk( ctrlnm ) {
    var numeric = ctrlnm.value;
    if( is_numeric( ctrlnm ) == false ) {
        	alert( "값이 비어 있거나 숫자가 아닙니다." );
        //if( FOCUSABLE ) ctrlnm.focus();
        ctrlnm.focus();
        return( false );
    }
    return (true);
}

function has_string( ctrlnm, minimum, maximum, incspecial, fmtstr ) {
	if( !valid_text( ctrlnm, minimum, maximum, incspecial ) ) return( false );
    var thisvalue = ctrlnm.value;
    index = thisvalue.indexOf( fmtstr );
    if( index < 0 ) {
        alert( "본 항목에는 반드시 (" + fmtstr + ") 가 포함되어야 합니다." );
        if( FOCUSABLE ) ctrlnm.focus();
        return( false );
    }
    return( true );
}
function selectAll( form, btnset,countLs ) {
	var singlecheck = 0;
	if(countLs!=1){
	    for( i = 0; i < btnset.length; i++ ) {
	        thisset = btnset[i];
	        thisset.checked = true;
	        singlecheck++;
	    }
	    if( singlecheck == 0 ) { //if there is nothing checked, we should check through the form
			for( i = 0; i < form.length; i++ ) {
				if( form[i].type == "checkbox" )
					form[i].checked = true;
			}
		}
	}else{
		btnset.checked = true;
	}
}

function deselectAll( form, btnset,countLs  ) {
	var singlecheck = 0;
	if(countLs!=1){
	    for( i = 0; i < btnset.length; i++ ) {
	        thisset = btnset[i];
	        thisset.checked = false;
	        singlecheck++;
	    }
	    if( singlecheck == 0 ) { //if there is nothing checked, we should check through the form
			for( i = 0; i < form.length; i++ ) {
				if( form[i].type == "checkbox" )
					form[i].checked = false;
			}
		}
	}else{
		btnset.checked = false;
	}
}

function reverseAll( form, btnset ) {
	var singlecheck = 0;
    for( i = 0; i < btnset.length; i++ ) {
        thisset = btnset[i];
        if( thisset.checked ) thisset.checked = false;
        else thisset.checked = true;
        singlecheck++;
    }
    if( singlecheck == 0 ) { //if there is nothing checked, we should check through the form
		for( i = 0; i < form.length; i++ ) {
			if( form[i].type == "checkbox" )
				form[i].checked = !form[i].checked;
		}
	}
}

function get_checked_count( form, btnset ) {
    var checkedcount = 0, singlecheck = 0;
    for( i = 0; i < btnset.length; i++ ) {
        thisset = btnset[i];
        if( thisset.checked ) checkedcount++;
        singlecheck++;
    }
    if( singlecheck == 0 ) { //if there is nothing checked, we should check through the form
		for( i = 0; i < form.length; i++ ) {
			if( form[i].type == "checkbox" && form[i].checked == true )
				checkedcount++;
		}
	}
    return( checkedcount );
}

function something_checked( form, btnset ) {
	if( get_checked_count(form, btnset) == 0 ) {
        alert( "선택된 항목이 없습니다. 항목을 하나 또는 하나 이상 선택하신 뒤 다시 시도하시기 바랍니다.");
        return( false );
    }
    return( true );
}

		
function getSingleSelectValue( select ) {
    if( !select.options )
        return( select.value );
    for( i = 0; i < select.options.length; i++ ) {
        thisset = select.options[i];
        if( thisset.selected ) {
            return( thisset.value );
        }
    }
    return( "" );
}

function multi_delete( form, btnctrl, action ) {
    if( !something_checked( form, btnctrl ) ) return( false );
    var response = confirm( "선택된 항목들을 정말 삭제하시겠습니까?" );
    if( response == false ) return(false);
    form.action = action;
    form.submit();
    return( true ); 
}

function confirm_delete( form, action ) { 
    var response = confirm( "본 자료를 정말 삭제하시겠습니까?" );
    if( response == false ) return( false );
    form.action = action;
    form.submit();
    return( true )
}


// 빈 공백 문자열 CHECK
function isempty(P) {
	if (P != null) {
      P = ReplaceChar(P,"\n","");
      P = ReplaceChar(P,"\r","");
   }
   return ((P == null) || (P.replace(/ /gi,"").length == 0));
}

// 숫자형 자료 CHECK
function isdigit (P) {
   var len = P.length;

   for (i=0; i<len; i++) {
      if ( (P.charAt(i) >= "0") && (P.charAt(i) <= "9") ) {
      }
      else {
         return false;
      }
   }
   return true;
}

// 단일문자 대체 (원본문자열, 대체대상 문자, 대체할 문자)
function ReplaceChar(str, tarCh, repCh) {
   var nowCh  = "";
   var sumStr = "";
   var len    = str.length;

   for (i=0; i<len; i++) {
      if (str.charAt(i) == tarCh) {
         nowCh = repCh;
      }
      else {
         nowCh = str.charAt(i);
      }
      sumStr = sumStr + nowCh;
   }
   return sumStr;
}

//입력시 체크 예제
function frm_insertChk(form) {
		
	if( !valid_text( form.subject,1,255,false ) ) return( false );
	if( !valid_text( form.content,1,24,false ) ) return( false );
	if(login==0){//비로그인 일때.
		if( !valid_text(form.password,1,12,false) ) return( false );	
	}	
	return (true);

}


//팝업창 스크립트 - 스크롤바 없는 것
function popnone(pop,width,height)
{
	var url = pop;  
	var wd = width;
	var he = height;
	
	window.open(url,"","status=0,toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + wd +",height=" + he + ";")
}

//팝업창 스크립트 - 스크롤바 있는 것
function popscroll(pop,width,height)
{
	var url = pop;  
	var wd = width;
	var he = height;
	
	window.open(url,"","status=0,toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=" + wd +",height=" + he + ";")
}


// Next Focus
function doNextForm(input,len, e) {
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var keyCode = (isNN) ? e.which : e.keyCode;
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode))
	{
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}

function containsElement(arr, ele) {
	var found = false, index = 0;
	while(!found && index < arr.length)
	if(arr[index] == ele)
		found = true;
	else
		index++;
	return found;
}

function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
		if (input.form[i] == input)
			index = i;
		else
			i++;
		return index;
	}
	return true;
}

// Digit Only
function doDigitOnly()
{
    if( ( ( event.keyCode < 48 ) || ( event.keyCode > 57 ) ) && ( event.keyCode != 46 ) )
        event.returnValue   = false;
}

function doDigitEng()
{
    if( ( ( event.keyCode < 48 ) || ( event.keyCode > 122 ) ) && ( event.keyCode != 46 ) )
        event.returnValue   = false;
}

// ei7.0 patch
function showFlashObject(objID, objSource, objWidth, objHeight, objQuality, objWmode, objBgcolor)
{
	//page url
	var pageUrl = self.window.location.href;
	if(pageUrl.substring(0,5) == 'https') {
		swfUrl = "https";
	} else {
		swfUrl = "http";
	}
	/* Default Value Setting */
	if (objID == "") objID = 'ShockwaveFlash1';
	if (objWidth == "") objWidth = '0';
	if (objHeight == "") objHeight = '0';
	if (objQuality == "") objQuality = 'best';
	if (objWmode == "") {
		objWmode = 'transparent';
	} else {
		objWmode = '';
	}


	/* Flash 8.0 version */
	document.write('<OBJECT id="' + objID + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
	document.write('type="application/x-shockwave-flash" ');
	document.write('data="' + objSource + '" ');
	document.write('codebase="' + swfUrl +'://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" ');
	document.write('WIDTH="' + objWidth + '" HEIGHT="' + objHeight + '">');
	document.write('<PARAM NAME=menu value=false>');
	document.write('<PARAM NAME=allowScriptAccess value=always>');
	document.write('<PARAM NAME=wmode value="'+ objWmode +'">');
	document.write('<PARAM NAME=movie VALUE="'+ objSource +'">');
	document.write('<PARAM NAME=quality VALUE="'+ objQuality +'">');
	document.write('<PARAM NAME=bgcolor VALUE="'+ objBgcolor +'">');
	document.write('<embed allowScriptAccess="always" swLiveConnect="true" src="' + objSource + '" menu="false" quality="' + objQuality + '" wmode="' + objWmode + '" bgcolor="' + objBgcolor + '" width="' + objWidth + '" height="' + objHeight + '" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer">');
	document.write('</OBJECT>');
}
