var url =			new Array();
var time =		new Array();
var branch =	new Array();
var sub =		new Array();
var service =	new Array();
var dir =			new Array();
var doc =		document.all;
var now =		new Date();

url = {
	base :			'http://',
	host :			getDomain(false),
	domain :		getDomain(true),
	current :		escape(document.location.href),
	referrer :		escape(document.referrer),
	agent :			navigator.userAgent,
	ie :				((document.all && document.getElementById) ? true : false),
	session :		getCookie("PHPSESSID")
}

url.fileServer =		'upload/fileServer.php';					// 파일 핸들링 서버
url.rpcServer =		'device/rcpServer.php';		// XML RPC
url.dataServer =	url.base + 'data.' + url.domain;								// 파일 데이터
url.imgServer =		url.base + 'img.' + url.domain + '/images';	// 이미지	
url.jsServer =		url.base + 'img.' + url.domain + '/js';			// 자바스크립트
url.cssServer =		url.base + 'img.' + url.domain + '/css';			// 스타일시트

time.minute =		60 * 1000;
time.hour =			60 * time.minute;
time.day =			24 * time.hour;
time.week =		7 * time.day;
time.regdate =		now.getYear() + '-' + (now.getMonth()+1) + '-' + now.getDate() + ' ' + now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();

/**
*
* 도메인 서비스
*
*/
server = {
	www :			'메인',
	data :			'데이터',
	img :				'이미지'
}

/*
	기본 디렉토리 정의
	-----------------------------------------------------
	@ 입력 - serv(루트디렉토리), skin(스킨디렉토리)
*/
function setExplorer(root, skin)
{
	// 기본베이스
	dir.root = root.replace('.', '');
	dir.rpc = url.base + 'rpc.' + url.domain + dir.root;
	dir.user = dir.root + '/user';							// user/
	dir.bbs = dir.root + '/bbs';							// bbs/
				// images/
	dir.btn = url.imgServer + '/button';					// images/button/
	dir.skin = skin;											// ../skin/호스트/서비스/스킨/
		
	// 웹에디터
	dir.layer_editor = dir.skin + '/editor';
	dir.img_editor = dir.img + '/editor';				// images/editor/
	dir.btn_editor = url.imgServer + '/editor/button';		// images/editor/button/
	dir.emoticon = url.imgServer + '/editor/emoticon';	// images/editor/emoticon/

	// 탭패널
	dir.img_tabpane = dir.editor + '/tabpane';		// images/editor/tabpane/
	return
}

/*
	도메인 정보
	------------------------------------------------------
	@ 입력 - check( true: 도메인, false: 2차 도메인 )
*/
function getDomain(check)
{
	var sf	 = document.domain.split('.');
	var _domain = "";
	if ( check )
	{
		_domain = sf[sf.length-2] + '.' + sf[sf.length-1];
		return sf[sf.length-1].length == 2 ? sf[sf.length-3] + '.' + _domain : _domain;
	}
	else
	{
		_domain = sf[sf.length-1].length == 2 ? sf[sf.length-4] : sf[sf.length-3];
		return _domain != undefined ? _domain : '';
	}
}

/*
	쿠키 굽기
	------------------------------------------------------
	@ 입력 - name(쿠키이름), value(쿠키값), expires(일자 - 없으면 1일), path(true), domain(true)
*/
function setCookie(name, value, expiredays, domain)
{
	var todayDate = new Date();
	expiredays = expiredays ? expiredays : 1;
	todayDate.setDate( todayDate.getDate() + expiredays );
	domain = domain ? " domain=" + url.domain + ";" : '';
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" + domain;
}

/*
	쿠키 삭제
	@ 입력 - name(쿠키이름), path(true), domain(true)
*/
function delCookie(name)
{
	document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" + ";path=/";
}

/*
	쿠키값 가져오기
*/
function 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 "";
}

var orderItem = Array();
orderItem[0] = '';
orderItem[1] = '';

function queue(name, value, order)
{
	var im = gd = gb = gv = gs = '';

	if ( order!=undefined )
	{
		orderItem[0] = value;	// 기본정렬이름
		orderItem[1] = order;	// 기본정렬방식
	}
	
	qs = new QueryString;

	gd = qs.getVar('order');	// 현재정렬이름
	gb = qs.getVar('by');		// 현재정렬방식

	qs.setVar('order', value);
	qs.setVar('by', 'DESC');

	if ( gd )
	{
		if ( gd==value)
		{
			gv = gb=='DESC' ? 'DESC' : 'ASC';
			gs = gv=='DESC' ? 'ASC' : 'DESC';
			qs.setVar('by', gs);
		}
	}
	else
	{
		if ( orderItem[0]==value )
		{
			gv = orderItem[1]=='DESC' ? 'DESC' : 'ASC';
			gs = gv=='DESC' ? 'ASC' : 'DESC';
			qs.setVar('order', orderItem[0]);
			qs.setVar('by', gs);
		}
	}

	document.write("<a href='"+qs.getVar()+"'>"+(gs ? "<b>" + name + "</b> <img src='http://img."+url.domain+"/images/icons/queue."+gv+".gif' align='absmiddle' border='0' />" : name)+"</a>");
}

/*
	스크롤
*/
function goTop(orix,oriy,desx,desy) {
		var Timer;
		var winHeight = document.body.scrollTop;
		if(Timer) clearTimeout(Timer);
		startx = 0;
		starty = winHeight;
		if(!orix || orix < 0) orix = 0;
		if(!oriy || oriy < 0) oriy = 0;
		var speed = 7;
		if(!desx) desx = 0 + startx;
		if(!desy) desy = 0 + starty;
		desx += (orix - startx) / speed;
		if (desx < 0) desx = 0;
		desy += (oriy - starty) / speed;
		if (desy < 0) desy = 0;
		var posX = Math.ceil(desx);
		var posY = Math.ceil(desy);
		window.scrollTo(posX, posY);
		if((Math.floor(Math.abs(startx - orix)) < 1) && (Math.floor(Math.abs(starty - oriy)) < 1)){
			clearTimeout(Timer);
			window.scroll(orix,oriy);
		}else if(posX != orix || posY != oriy){
			Timer = setTimeout("goTop("+orix+","+oriy+","+desx+","+desy+")",15);
		}else{
			clearTimeout(Timer);
		}
}

/*
	리로드
*/
function goLoad()
{
	//history.go(0);
	location.reload();
}

function goReload()
{
	location.reload();
}

function centerX()
{
	return document.body && document.body.clientWidth ? document.body.clientWidth/2 : window.innerWidth ? innerWidth/2 : null;
}

function centerY()
{
	return document.body && document.body.clientHeight ? document.body.clientHeight/2 :window.innerHeight? innerHeight/2 : null;
}

/** 화면 스크립의 중앙 **/
function center(id)
{
	var obj = getElement(id);
	if (obj && obj.style) {
		var x = centerX();
		obj.style.left = x - obj.offsetWidth/2 + 'px';
		obj.style.top = document.body.scrollHeight - (document.body.scrollHeight - document.body.scrollTop) - obj.offsetHeight/2 + document.body.clientHeight/2 + 'px';
	}
}

//메세지 체인지
function waitBoxView(msg)
{
//	layerShow('waitBox');
	layerShow('divBg');
//	center('waitBox');
	center('divBg');
	//로딩창 실행
//	document.all['message_box'].SetVariable("LOOP","true");
//	document.all['message_box'].SetVariable("message",msg);
//	document.all['message_box'].TPlay("loadBarMov");
	document.getElementById("divBg").focus();
}

//레이어 하이드
function layerHide(lay)
{
	document.getElementById(lay).style.display = "none";
}

function layerShow(lay)
{
	document.getElementById(lay).style.display = "inline";
}

function _select(n)
{
	var i;
	var l = document.getElementsByName('item[]');

	for (i = 0; i < l.length; i++)
	{
		switch(n)
		{
			case 1:
				l[i].checked = true;
				break;
			case 2:
				l[i].checked = false;
				break;
			case 3:
				l[i].checked = !l[i].checked;
				break;
			default:
		}
	}
}

/*
	설명 : 윈도우창 열기
	--------------------------------------------------------
	@ 입력 - check(modal, modaless, layer, default), page(URL 또는 레이어 내용), name(창이름), w(가로크기), h(세로크기), scroll(스크롤형태), top(세로위치), left(가로위치)

	- 일반창 작성
	- 모달 및 모달리스 추가
	- 레이어 방식 추가
*/
function open_(check, page, name, w, h, scroll, wintop, winleft)
{
	var _win = null;
	var _set = '';
	if (wintop == '') wintop=0;
	if (winleft == '') winleft=0;
	scroll = scroll=='yes' ? 'yes' : 'no';
	_winl = winleft;
	_wint = wintop;

	switch (check)
	{
		// 레퍼런스 : http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/showmodelessdialog.asp
		case 'modal' : // 모달 ( 윈도우창 바깥에 포커스 불가능 )
		case 'modaless' : // 모달리스 ( 윈도우창 바깥에 포커스 가능 )
			_set += 'dialogHeight: ' + h + 'px;'
				+ 'dialogWidth: ' + w + 'px;'
				+ 'dialogTop: ' + _wint + 'px;'
				+ 'dialogLeft: ' + _winl + 'px;'
				+ 'scroll: ' + scroll + ';'		// scroll:{ yes | no | 1 | 0 | on | off }
				+ 'resizable: no;'				// resizable:{ yes | no | 1 | 0 | on | off }
				+ 'status: off;'						// status:{ yes | no | 1 | 0 | on | off }
				+ 'edge: raised;'					// edge:{ sunken | raised }
				+ 'unadorned: yes;'				// unadorned:{ yes | no | 1 | 0 | on | off }
				+ 'dialogHide: no;'				// dialogHide:{ yes | no | 1 | 0 | on | off }
//				+ 'center: yes;'					// center:{ yes | no | 1 | 0 | on | off }
				+ 'help: no;';						// help:{ yes | no | 1 | 0 | on | off }
			if( check == 'modal' )
				showModalDialog(page, name, _set);
			else
				showModelessDialog(page, window, _set);
			break;
		// 레퍼런스 : http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/div.asp
		case 'layer' : // 레이어 ( id : 창이름 -> 아이디, page : 윈도우창 URL -> 레이어 내용, scroll : 스크롤 -> 쿠키일자 )
			 // 상단바 높이, 하단바 높이, 전체 레이어 높이

		// now를 Date 객체로 선언, getMonth는 0~11의 값을 가져오기 때문에 +1, getDay를 getDate로 수정 - 080212 다메
		// 드래그 기능 추가 - 080215 다메
			var _b = 28;
			var m = (now.getMonth()+1) + "";
			var d = now.getDate() + '';
			var fd = now.getYear()+"-"+((m.length==1 ? "0":"")+m)+"-"+((d.length==1 ? "0":"")+d);

str =  "<div id='"+name+"' style='border-width:0px;Z-INDEX: 99;WIDTH: " + w + "px;LEFT: " + _winl + "px;TOP: " + _wint + "px;POSITION: absolute;' onmousedown=\"ddInit('', '"+name+"');\"><layer onMouseover=\"isHot=true;if (isN4) ddN4(theLayer)\" onMouseout=\"isHot=false\" z-index=\"1\"><table id=\"titleBar\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=" + w + "><tr><td bgcolor='white' valign='top' height='"+h+"'>"+page+"</td></tr><tr>   <td><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr bgcolor=\"#000000\" valign='middle'><td style='cursor:move;FONT-FAMILY: Arial;FONT-SIZE: 10px;color:#FFFFFF;'><input type='checkbox' name='popup' value='"+name+"|"+fd+"' class='none' onMouseOver=\"this.style.cursor='default';\" onClick=\"closePopup('"+name+"', 'layer', this.value, 1)\" /><img src='skin/www/images/main/today.gif'></td><td align='center' width='20'><input type=\"image\" src='skin/www/images/main/x.gif' onclick=\"document.getElementById("+name+").style.visibility='hidden'\" style=\"cursor:hand; border-width:0; border-style:none;\" valign=\"bottom\"></td></tr></table></td></tr></table></layer></div>";

			document.write(str);
			break;
		// 레퍼런스 : http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/open_0.asp
		default : // 일반창
			_set += 'height=' + h + ','
				+ 'width=' + w + ','
				+ 'top=' + _wint + ','
				+ 'left=' + _winl + ','
				+ 'scrollbars=' + scroll + ','
				+ 'channelmode=no,'
				+ 'directories=no,'
				+ 'fullscreen=no,'
				+ 'location=no,'
				+ 'menubar=no,'
				+ 'titlebar=no,'
				+ 'toolbar=no,'
				+ 'resizable=no,'
				+ 'status=no';
			_win = window.open(page, name, _set);
			_win.window.focus();
	}
}

function reloadDialog()
{
	dialogArguments.goReload();
}

/*
	설명 : 팝업 윈도우창 닫기
	-------------------------------------------------------------
	@ 입력 - name(창이름), check(창형태), day(쿠키일자), href(부모창 URL)
*/
function closePopup(name, check, data, day, href)
{
	if ( day && data )
	{
		var coo = getCookie('popup');
		if( coo )								// 팝업 쿠키값이 존재할 경우
		{
			var on = data.split('|');	// 데이터값분리
			var sp = coo.split('^');		// 쿠키값 1차 분리
			var db = "";						// 쿠키로 구울 데이터
			var da = Array();
			var chk = false;				// 업데이트/신규 구분 플래그
			for(var i in sp)
			{
				if(sp[i])							// 1차 분리된 데이터가 존재할경우
				{
					da = sp[i].split('|');	// 쿠키값 2차 분리
					if( sp[i] == data )		// 고유번호와 일자가 일치할경우
					{
						db = "";					// 데이터를 초기화 시킴
						break;
					}
					else if( on[0]==da[0] && on[1]!=da[1] ) // 고유번호는 일치하지만 쿠키생성일이 맞지않을 경우
					{
						db += data + "^";
						chk = true;
					}
					else
						db += sp[i] + "^";
				}
			}
			if( chk == false )
				db += data + "^";
			if( db )							// 데이터가 있으면 쿠키로 굽는다.
				setCookie('popup', db, day);
		}
		else									// 팝업 쿠키값이 존재하지 않을 최초 쿠키값생성
			setCookie('popup', data+"^", day);
	}

	if ( href &&  check == 'layer' )
		location.href = href;
	else if ( href )
		window.parent.location.href = href;

	if ( check == 'layer' )
		document.getElementById(name).style.display = 'none';
	else
		window.close();
}

/*
	설명 : 자동포커스
	--------------------------------------------------------------
	@ 입력 - frm(폼객체), obj(현제객체), next(포커스받을 객체), len(길이)
*/
function autoFocus(frm, obj, nxt, len)
{
	if ( obj.value.length >= len )
		eval("frm." + nxt + ".focus();");
}

/*
	설명 : 자동생일입력
	--------------------------------------------------------------
	@ 입력 - frm(폼객체)
	@ 출력 - birthday (생일)
*/
function autoBirth(frm, load)
{
	if ( frm.numtwo.value.length == 1 || load==true)
	{
		sex = frm.numtwo.value.substring(0,1);
		year = frm.numone.value.substring(0,2);
		month = frm.numone.value.substring(2,4);
		day = frm.numone.value.substring(4);
		year = ( sex == 1 || sex == 2 ) ? '19' + year : '20' + year;
		frm.birthday.value = year + '-' + month + '-' + day;
	}
}

/*
	설명 : 자동로그인
	--------------------------------------------------------------
	@ 입력 - obj(체크박스객체)
*/
function autoLogin(obj)
{
	if ( obj.autoSave.checked == true )
	{
		if ( confirm("자동 아이디 저장 기능을 사용하시겠습니까?\n\n보안을 위해 3일 동안(로그인시 갱신됨)만 저장됩니다.") == false )
			obj.autoSave.checked = false;
	}
}

/*
	설명 : <TR> 테그라인 색상변경
	---------------------------------------------------------------
	@ 입력 - obj(객체), color(색상)
*/
function changeTrColor(obj, color)
{
	color = color ? color : '';
	for(i = 0; i < obj.childNodes.length; i ++)
	{
		if(obj.childNodes[i].nodeName.toUpperCase == 'TD') continue;
		obj.childNodes[i].style.backgroundColor = color;
//		obj.childNodes[i].style.color = color ? "" : "#FFFFFF";
	}
	return true;
}

/*
	설명 : <TD> 테그라인 색상변경
	---------------------------------------------------------------
	@ 입력 - obj(객체), color(색상)
*/
function changeTdColor(obj, color)
{
	prt = obj.parentNode;
	color = color ? color : '';
	for(i = 0; i < prt.childNodes.length; i ++) if(prt.childNodes[i] == obj) break;
	prtprt = prt.parentNode;
	for(j = 0; j < prtprt.childNodes.length; j ++)
	{
		if(prtprt.childNodes[j].nodeName.toUpperCase == "TR") continue;
		prtprt.childNodes[j].childNodes[i].style.backgroundColor = color;
	}
	return true;
}

function searchValue(Ary, val) {
       var len = Ary.length;
       
       for (var i=0; i < len; i++) {
              if (Ary[i] == val) return i;
       }
       
       return -1;
}

/*
	설명 : GET 값가져오기
	---------------------------------------------------------------
	@ 입력 - name(가져올 GET 변수)
*/
function getQuery(name)
{
	return location.search.match(RegExp('&?'+name+'=([^&]*)')) ? RegExp.$1 : '';
}

QueryString = function(str)
{
	var str = str ? str : document.location.href;
	this.argv = new Array();
	this.baseName = str.split('?')[0];
	this.queryString = str.replace(/^[^\?]+\?/, '').replace(/#(.*)$/, '');
	if (!this.queryString)
		this.queryString = '';
	var _argv = this.queryString.split('&');
	for(var i=0; i<_argv.length; i++)
	{
		var _key = _argv[i].substring(0, _argv[i].indexOf('='));
		var _val = _argv[i].substring(_argv[i].indexOf('=')+1);
		if(!_key || _argv[i].indexOf('=') == -1) continue;
		this.argv[_key] = _val;
	}
}

QueryString.prototype.setVar = function(key,val)
{
	if (typeof key == 'object')
		for (var item in key)
			this.argv[item] = key[item];
	else
		this.argv[key] = val;
	return this.getVar();
}

QueryString.prototype.getVar = function(key)
{
	if (key)
		return this.argv[key] ? this.argv[key] : '';
	else 
	{
		var _item = new Array();
		for (var x in this.argv)
		{
			if (this.argv[x]) _item[_item.length] = x + '=' + this.argv[x];
			else continue;
		}
		return this.baseName + '?' + _item.join('&');
	}
}

Paging = function(total)
{
	this.config = {
		pageVariable: 'start',
		numberFormat: ' %n ',
		showFirstLast: true,	// 맨처음, 맨 마지막으로 가는 링크를 만들것인가.
		thisPageStyle: 'color:red; font-weight: bold;',
		otherPageStyle: 'color: navy; text-decoration: none;',
		itemPerPage: 15,	// 리스트 목록수
		pagePerView: 10,	// 페이지당 네비게이션 항목수
		prevIcon: null,	// 이전페이지 아이콘
		nextIcon: null,	// 다음페이지 아이콘
		firstIcon: null,	// 첫페이지로 아이콘
		lastIcon: null	// 마지막페이지 아이콘
	}

	this.totalItem = total;
	this.qs = new QueryString;

	this.calculate = function() {
		this.totalPage = Math.ceil(this.totalItem / this.config.itemPerPage);
		this.currentPage = this.qs.getVar(this.config.pageVariable);
		if (!this.currentPage)
			this.currentPage = 1;
		if (this.currentPage > this.totalPage)
			this.currentPage = this.totalPage;
		this.lastPageItems = this.totalPage % this.config.itemPerPage;
		this.prevPage = this.currentPage-1;
		this.nextPage = this.currentPage+1;
		this.seek = this.prevPage * this.config.itemPerPage;
		this.currentScale = parseInt(this.currentPage / this.config.pagePerView);
		if (this.currentPage % this.config.pagePerView < 1)
			this.currentScale--;
		this.totalScale = parseInt(this.totalPage / this.config.pagePerView);
		this.lastScalePages = this.totalPage % this.config.pagePerView;
		if (this.lastScalePages == 0)
			this.totalScale--;
		this.prevPage = this.currentScale * this.config.pagePerView;
		this.nextPage = this.prevPage + this.config.pagePerView + 1;
	}

	this.toString = function() {
		var ss, se;
		var firstBtn = '';
		var lastBtn = '';
		var prevBtn = '';
		var nextBtn = '';

		this.calculate();

		if (this.config.showFirstLast)
		{
			if (this.config.firstIcon) firstBtn = '<img src="'+this.config.firstIcon+'" border="0" align="absmiddle">';
			else firstBtn = '<span style=\'font-size:8pt\'>◀◀</span>'; //'☜';
			firstBtn = firstBtn.link(this.qs.setVar(this.config.pageVariable,1));

			if (this.config.lastIcon) lastBtn = '<img src="'+this.config.lastIcon+'" border="0" align="absmiddle">';
			else lastBtn = '<span style=\'font-size:8pt\'>▶▶</span>'; //'☞';
			lastBtn = lastBtn.link(this.qs.setVar(this.config.pageVariable,this.totalPage));
		}
		else
			firstBtn = lastBtn = '';

		if (this.config.prevIcon) prevBtn ='<img src="'+this.config.prevIcon+'" border="0" align="absmiddle">';
		else prevBtn = '◀';
		if (this.currentPage > this.config.pagePerView)
			prevBtn = prevBtn.link(this.qs.setVar(this.config.pageVariable,this.prevPage));

		ss = this.prevPage + 1;
		if ((this.currentScale >= this.totalScale) && (this.lastScalePages != 0)) se = ss + this.lastScalePages;
		else if (this.currentScale <= -1) se = ss;
		else se = ss + this.config.pagePerView;

		var navBtn = '';
		for(var i = ss; i<se; i++)
		{
			var pageText = this.config.numberFormat.replace(/%n/g,i);
			if (i == this.currentPage)
				_btn = '<span style="'+this.config.thisPageStyle+'">'+pageText+'</span>';
			else
				_btn = '<a href="'+this.qs.setVar(this.config.pageVariable,i)+'" style="'+this.config.otherPageStyle+'">'+pageText+'</a>';		navBtn+=_btn;
		}
		if (this.config.prevIcon) nextBtn ='<img src="'+this.config.nextIcon+'" border="0" align="absmiddle">';
		else nextBtn = '▶';
		if (this.totalPage > this.nextPage)
			nextBtn = nextBtn.link(this.qs.setVar(this.config.pageVariable,this.nextPage));
		return firstBtn+' '+prevBtn+navBtn+nextBtn+' '+lastBtn;
	}
}

function shref(page, check, sn)
{
	if(page.indexOf('/')!=0 && page.indexOf('http://')!=0)
		page = (page=='' || page=='www:main:default') ? '/' : '/?page=' + page;
	if ( check )
	{
		if ( check==true && confirm("정말로 실행하시겠습니까?") == false )
			return;
		else if (confirm(check) == false )
			return;
	}
	if (sn)
		return page;
	else
		document.location.href = page;
}

/*
@ 객체, 변수, 메세지(필요시), 경고창형태(true: 일반경고창, false: 레이어창)
*/
function frmCheck(obj, val, msg, type)
{
	type = type == undefined ? false : true;
	if ( validate(obj, type) == false )
		return false;
	if ( msg )
		if ( confirm(msg) == false)
			return false;

	try{
		document.getElementById('submitButton').style.display = "none";
	}
	catch(e)
	{	}

	postForm(obj, val);

	return false;
}

function triggerXML()
{
	try{
		document.getElementById('submitButton').style.display = "inline";
	}
	catch(e)
	{	}
}

function uniCheck(obj, name, val, space, type)
{
	var syc = '';
	if ( obj.value )
	{
		if ( type )
		{
			switch( type )
			{
				case 'uid':
					var pattern = /^[a-zA-Z]{1}[a-zA-Z0-9_-]{4,11}$/;
					if (pattern.test(obj.value) == false)
				{
						alert("아이디(ID) 는 5자이상 12자 이하, 영문, 숫자, -, _ 문자만 사용할 수 있습니다");
						obj.select();
						return false;
					}
					break;
				case 'email':
					break;
				case 'numone':
					    var pattern = /^([0-9]{6})-?([0-9]{7})$/;
						var num = obj.value + '-' + document.register.numtwo.value;
						syc = num;
						if (!pattern.test(num))
						{
							alert("주민등록번호가 정확하지 않습니다.");
							obj.select();
							return false;
						}
						num = RegExp.$1 + RegExp.$2;

					var sum = 0;
						var last = num.charCodeAt(12) - 0x30;
						var bases = "234567892345";
						for (var i=0; i<12; i++) {
							if (isNaN(num.substring(i,i+1)))
							{
								alert("주민등록번호의 번호가 정확하지 않습니다.");
								obj.select();
								return false;
							}
							sum += (num.charCodeAt(i) - 0x30) * (bases.charCodeAt(i) - 0x30);
						}
						var mod = sum % 11;
						if ((11 - mod) % 10 != last)
						{
							alert("입력된 주민등록번호를 다시 한번 확인하세요.");
							obj.select();
							return false;
						}
					break;
			}
		}
		syc = syc ? syc : obj.value;
		postXml(Array('value', 'nameEng', 'nameKor', 'space'), Array(syc, obj.name, name, space), val);
	}
	else
	{
		alert(name +' 을 입력 하세요');
		obj.focus();
	}
	return false;
}

function checklen(obj, len)
{
	var msgtext, msglen;
	len = len ? len : 500;

	msgtext = obj.messageBox.value;
	msglen = obj.curByte.value;
	
	var i=0,l=0;
	var temp,lastl;
	
	//길이를 구한다.
	while(i < msgtext.length)
	{
		temp = msgtext.charAt(i);
		
		if (escape(temp).length > 4)
			l+=2;
		else if (temp!='\r')
			l++;
		// OverFlow
		if(l>len)
		{
			alert_('글자수체크', "<b>허용 길이 이상의 글을 쓰셨습니다.</b><br /><br /> 한글 " + len/2 + "자, 영문 " + len + "자까지만 쓰실 수 있습니다.");
			temp = obj.messageBox.value.substr(0,i);
			obj.messageBox.value = temp;
			l = lastl;
			break;
		}
		lastl = l;
	i++;
	}
	obj.curByte.value=l;
}

// 전역 GET 변수중 url 과 dbno 는 사용금지( directGo 함수참고 )
function directGo(name, check, msg)
{
	if(name!='logout' && check)
	{
		if(name=='login')
			msg = msg ? msg : "회원전용 페이지를 선택하셨습니다. 로그인하시겠습니까?";
		else
			msg = check;
		if(confirm(msg)==false)
			return;
	}
	switch(name)	// 변수제어
	{
		case('agreement'):		// 회원가입
		case('findUid'):			// 아이디찾기
		case('findPass'):		// 비밀번호찾기
		case('setUser'):			// 아이디생성(관리자가 정보입력시 아이디와 비밀번호 생성하지 않았을 경우)
		case('login'):				// 로그인
		case('checkName'):	// 성인인증
		case('provision'):		// 이용약관
		case('policy'):			// 개인정보보호정책
		case('modify'):			// 회원정보변경
		case('point'):				// 회원포인트
		case('qna'):				// 질문과답변
		case('online'):			// 상담내역
		case('retire'):				// 탈퇴
		case('logout'):			// 로그아웃
			break;
		default:
//			name = 'login';
	}
	var redirect = getQuery('url') ? getQuery('url') : url.redirect;
	if(name!='logout')
	{
		var dbno = getQuery('dbno') ? getQuery('dbno') : (sub[url.host] ? sub[url.host] : 0);
		location.href = "https://www."+url.domain+"/?page=www:user:"+name+"&dbno="+dbno+"&url="+redirect;
	}
	else
		postXml(Array('url', 'check'), Array(redirect, check), 'www::user::logout');	// check 값이 존재 할경우 리다이렉트함
}
