﻿//-----------------------------------------------------------------------------
// 모든 이미지와 링크에 링크시 포커스를 자동으로 제거 한다.
//-----------------------------------------------------------------------------
function fn_Bluring(){ 
  if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
}
document.onfocusin=fn_Bluring; 

var _SITE_STATUS		= location.protocol +"://"+ document.domain +"/";
window.status		= "";
window.defaultStatus	= _SITE_STATUS;

//-----------------------------------------------------------------------------
// User Agent 검사... 
//-----------------------------------------------------------------------------
function fn_UserAgent() {
	var userAgent	= navigator.userAgent;
	this.win32Ver	= "";
	this.isNS			= navigator.appName == "Netscape";
	this.isNS4		= (document.layers ? true : false);	
	this.isDOM		= (document.getElementById ? true : false); 
	this.isIE4		= ((document.all && !this.isDOM) ? true : false);

    if(userAgent.indexOf("MSIE") != -1){
        this.isIE			= true;
		this.agentVer	= userAgent.charAt(userAgent.indexOf("MSIE") + 5);
		if (this.agentVer == 4) this.isIE4 = true;
		else if (this.agentVer == 5) this.isIE5 = true;
		else if (this.agentVer == 6) this.isIE6 = true;
		else if (this.agentVer == 7) this.isIE7 = true;		
		if (this.isIE6 && navigator.appMinorVersion.indexOf("SP2") != -1) {
			this.isXP2 = true;
		} else {
			this.isXP2 = false;
		}		

		this.bLan		= navigator.browserLanguage;
		this.uLan		= navigator.userLanguage;
		this.sLan	 		= navigator.systemLanguage;
		this.platform	= navigator.platform;		
		this.cpuClass	= navigator.cpuClass;
		this.isOnLine	= navigator.onLine;
		this.isCookie	= navigator.cookieEnabled;
		this.isJava		= navigator.javaEnabled();

    }else if(userAgent.indexOf("Mozilla") != -1 && userAgent.indexOf("compatible") == -1){
        this.isNav = true;
		this.agentVer	= userAgent.charAt(UA.indexOf("Mozilla") + 8);
        if(agentVer == 4 ) this.isNav4 = true;
        else if(agentVer == 5 ) this.isNav5 = true;
        else if(agentVer == 6 ) this.isNav6 = true;
        else if(agentVer == 7 ) this.isNav7 = true;
    }	
}
var oUABc = new fn_UserAgent();

//-----------------------------------------------------------------------------
// Cooki control
//-----------------------------------------------------------------------------
function getCookieVal(offset) {
	var endstr=document.cookie.indexOf(";",offset);
	if (endstr==-1) endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function getCookie( name ) {
	var 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 setCookie( name, value, expiredays ) {
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString()  + ";"
}

//-----------------------------------------------------------------------------
// window.open
//-----------------------------------------------------------------------------
function win_pop(path, win_name, wi, he, scroll) {
	window.open(path,win_name,'width='+wi+',height='+he+',resizable=no,scrollbars='+scroll+', status=no,toolbar=no');
}
function win_pop(p_url, win_name, p_width, p_height, scroll_yn, p_left, p_top) 
{
	window.open(p_url, win_name, 'width=' + p_width + ',height=' + p_height + ',scrollbars=' + scroll_yn + ',left=' + p_left + ',top=' + p_top);
}
function win_pop_cookie(path, win_name, wi, he, scroll, cookie_name) {
	if ( getCookie( cookie_name ) == "" ) {
		window.open(path,win_name,'width='+wi+',height='+he+',resizable=no,scrollbars='+scroll+', status=no,toolbar=no');
	}
}
function win_pop_cookie(p_url, win_name, p_width, p_height, scroll_yn, cookie_name, p_left, p_top)
{
	if ( getCookie( cookie_name ) == "" ) 
	{
		window.open(p_url, win_name, 'width=' + p_width + ',height=' + p_height + ',scrollbars=' + scroll_yn + ',left=' + p_left + ',top=' + p_top);
	}
}

//-----------------------------------------------------------------------------
// String Method
//-----------------------------------------------------------------------------
String.prototype.isEmpty = function() {
  return (this == null || this == "");
}
String.prototype.isAlphaNum = function() {
  if (this.search(/[^A-Za-z0-9_-]/) == -1)
	 return true;
  else 
	 return false;
}
String.prototype.isAlpha = function() {
  if (this.search(/[^A-Za-z]/) == -1)
	 return true;
  else
	 return false;
}
String.prototype.isNumber = function() {
  if (this.search(/[^0-9]/) == -1)
	 return true;
  else
	 return false;
}
String.prototype.isKor = function() {
	return (/^[가-힣]+$/).test(this.remove(arguments[0])) ? true : false;
}
String.prototype.isEmail = function() {
	return (/\w+([-+.]\w+)*@\w+([-.]\w+)*\.[a-zA-Z]{2,4}$/).test(this.trim());
}
String.prototype.int = function() 
{	// 숫자로 변환.
	return isNaN(this) ? null : parseInt(this);
}
String.prototype.num = function() 
{	// 숫자만 반환
	return (this.trim().replace(/[^0-9]/g, ""));
}
String.prototype.money = function() 
{ // 숫자에 3자리마다 , 를 찍어서 반환
	var num = this.trim();
	while((/(-?[0-9]+)([0-9]{3})/).test(num)) {
		num = num.replace((/(-?[0-9]+)([0-9]{3})/), "$1,$2");
	}
	return num;
}
String.prototype.digits = function(cnt) 
{	// 숫자의 자리수(cnt)에 맞도록 반환
	 var digit = "";
	 if (this.length < cnt) {
		for(var i = 0; i < cnt - this.length; i++) {
			 digit += "0";
		}
	}
	return digit + this;
}
String.prototype.bytes = function() 
{	// 바이트 계산.
	var b = 0;
	for (var i=0; i<this.length; i++) b += (this.charCodeAt(i) > 128) ? 2 : 1;
	return b;
}
String.prototype.trim = function() {		// 공백 제거
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.ltrim = function() {	// 좌 공백제거
	return this.replace(/(^\s*)/, "");
}
String.prototype.rtrim = function() {	// 우 공백제거
	return this.replace(/(\s*$)/, "");
}

//-----------------------------------------------------------------------------
// 전화번호 체크 - arguments[0] : 전화번호 구분자
// @return : boolean
//-----------------------------------------------------------------------------
String.prototype.isPhone = function() {
	var arg = arguments[0] ? arguments[0] : "";
	return eval("(/(02|0[3-9]{1}[0-9]{1})" + arg + "[1-9]{1}[0-9]{2,3}" + arg + "[0-9]{4}$/).test(this)");
}

//-----------------------------------------------------------------------------
// 핸드폰번호 체크 - arguments[0] : 핸드폰 구분자
// @return : boolean
//-----------------------------------------------------------------------------
String.prototype.isMobile = function() {
	var arg = arguments[0] ? arguments[0] : "";
	return eval("(/01[016789]" + arg + "[1-9]{1}[0-9]{2,3}" + arg + "[0-9]{4}$/).test(this)");
}

//-----------------------------------------------------------------------------
// 주민번호 체크 - arguments[0] : 주민번호 구분자
// XXXXXX-XXXXXXX
// @return : boolean
//-----------------------------------------------------------------------------
String.prototype.isJumin = function() {
	var arg = arguments[0] ? arguments[0] : "";
	var jumin = eval("this.match(/[0-9]{2}[01]{1}[0-9]{1}[0123]{1}[0-9]{1}" + arg + "[1234]{1}[0-9]{6}$/)");
	if(jumin == null) {
		return false;
	} else {
		jumin = jumin.toString().num().toString();
	}
	
	// 생년월일 체크
	var birthYY = (parseInt(jumin.charAt(6)) == (1 ||2)) ? "19" : "20";
	birthYY += jumin.substr(0, 2);
	var birthMM = jumin.substr(2, 2) - 1;
	var birthDD = jumin.substr(4, 2);
	var birthDay = new Date(birthYY, birthMM, birthDD);
	if(birthDay.getYear() % 100 != jumin.substr(0,2) || birthDay.getMonth() != birthMM || birthDay.getDate() != birthDD) {
		return false;
	}
	var sum = 0;
	var num = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5];
	var last = parseInt(jumin.charAt(12));
	for(var i = 0; i < 12; i++) {
		sum += parseInt(jumin.charAt(i)) * num[i];
	}
	return ((11 - sum % 11) % 10 == last) ? true : false;
}

//-----------------------------------------------------------------------------
// 외국인 등록번호 체크 - arguments[0] : 등록번호 구분자
// XXXXXX-XXXXXXX
// @return : boolean
//-----------------------------------------------------------------------------
String.prototype.isForeign = function() {
	var arg = arguments[0] ? arguments[0] : "";
	var jumin = eval("this.match(/[0-9]{2}[01]{1}[0-9]{1}[0123]{1}[0-9]{1}" + arg + "[5678]{1}[0-9]{1}[02468]{1}[0-9]{2}[6789]{1}[0-9]{1}$/)");
	if(jumin == null) {
		return false;
	} else {
		jumin = jumin.toString().num().toString();
	}
	
	// 생년월일 체크
	var birthYY = (parseInt(jumin.charAt(6)) == (5 || 6)) ? "19" : "20";
	birthYY += jumin.substr(0, 2);
	var birthMM = jumin.substr(2, 2) - 1;
	var birthDD = jumin.substr(4, 2);
	var birthDay = new Date(birthYY, birthMM, birthDD);
	if(birthDay.getYear() % 100 != jumin.substr(0,2) || birthDay.getMonth() != birthMM || birthDay.getDate() != birthDD) {
		return false;
	}
	if((parseInt(jumin.charAt(7)) * 10 + parseInt(jumin.charAt(8))) % 2 != 0) {
		return false;
	}
	var sum = 0;
	var num = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5];
	var last = parseInt(jumin.charAt(12));
	for(var i = 0; i < 12; i++) {
		sum += parseInt(jumin.charAt(i)) * num[i];
	}
	return (((11 - sum % 11) % 10) + 2 == last) ? true : false;
}

//-----------------------------------------------------------------------------
// 사업자번호 체크 - arguments[0] : 등록번호 구분자
// XXX-XX-XXXXX
// @return : boolean
//-----------------------------------------------------------------------------
String.prototype.isBiznum = function() {
	var arg = arguments[0] ? arguments[0] : "";
	var biznum = eval("this.match(/[0-9]{3}" + arg + "[0-9]{2}" + arg + "[0-9]{5}$/)");
	if(biznum == null) {
		return false;
	} else {
		biznum = biznum.toString().num().toString();
	}
	var sum = parseInt(biznum.charAt(0));
	var num = [0, 3, 7, 1, 3, 7, 1, 3];
	for(var i = 1; i < 8; i++) {
		sum += (parseInt(biznum.charAt(i)) * num[i]) % 10;
	}
	sum += Math.floor(parseInt(parseInt(biznum.charAt(8))) * 5 / 10);
	sum += (parseInt(biznum.charAt(8)) * 5) % 10 + parseInt(biznum.charAt(9));
	return (sum % 10 == 0) ? true : false;
}

//-----------------------------------------------------------------------------
// 법인 등록번호 체크 - arguments[0] : 등록번호 구분자
// XXXXXX-XXXXXXX
// @return : boolean
//-----------------------------------------------------------------------------
String.prototype.isCorpnum = function() 
{
	var arg = arguments[0] ? arguments[0] : "";
	var corpnum = eval("this.match(/[0-9]{6}" + arg + "[0-9]{7}$/)");
	if(corpnum == null) {
		return false;
	} else {
		corpnum = corpnum.toString().num().toString();
	}
	var sum = 0;
	var num = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2];
	var last = parseInt(corpnum.charAt(12));
	for(var i = 0; i < 12; i++) {
		sum += parseInt(corpnum.charAt(i)) * num[i];
	}
	return ((10 - sum % 10) % 10 == last) ? true : false;
}

String.prototype.substringBytes = function(start, limitBytes) 
{	// 원하는 바이트 까지 잘라서 반환.
	var b = 0;
	var L = 0;
	var s = "";	
	for (var i=0; i<this.length; i++) {
		b = (this.charCodeAt(i) > 128) ? 2 : 1;
		if (i >= start) {
			L += b;
			s += this.charCodeAt(i);
		}
		if (L >= limitBytes)
			break;
	}
	return s;
}
String.prototype.delHtmlTag = function() {
	var objStrip = new RegExp();
	objStrip = /[<][^>]*[>]/gi;
	return this.replace(objStrip, " ");
}
String.prototype.indexesOf = function(ptn) {
	var position = 0;
	var hits = -1;
	var start = -1;

	while( position != -1 ) {
		position = this.indexOf(ptn, start+1);
		hits += 1;
		start = position;
	}
	return hits;
}
String.prototype.replaceAll = function(source, target) {
	source = source.replace(new RegExp("(\\W)", "g"), "\\$1");
	target = target.replace(new RegExp("\\$", "g"), "$$$$");
	return this.replace(new RegExp(source, "gm"), target);
}
String.prototype.toLower = function() {
	return this.toLowerCase();
}
String.prototype.toUpper = function() {
	return this.toUpperCase();
}
String.prototype.getFileName = function() {
	if (this.indexOf("/") > 0)
		return this.split('/')[this.split('/').length-1].toLower();
	else
		return this.split('\\')[this.split('\\').length-1].toLower();
}
String.prototype.getFileExpName = function() {
	return this.split('.')[this.split('.').length-1].toLower();
}
String.prototype.toDateString = function() {	
	if (this.indexOf("-") > 0) 
	{	// 2008-04-23
		s = this.split("-");
		return s[0] +"년 "+ s[1] +"월 "+ s[2] +"일"
	} 
	else if (this.indexOf("/") > 0) 
	{	// 2008/04/23
		s = this.split("/");
		return s[0] +"년 "+ s[1] +"월 "+ s[2] +"일"
	}
	else if (this.length == 8) 
	{
		return this.substring(0,4) +"년 "+ this.substring(4,2) +"월 "+ this.substring(6,2) +"일"
	}
}
String.prototype.Left = function(intLEN) {
//Left 함수 기능
	if (intLEN > String(this).length) {
		return this;
	} else {
		return String(this).substring(0, intLEN);
	}
}
String.prototype.Right = function(intLEN) {
//Right 함수 기능
	if (intLEN > String(this).length) {
		return this;
	} else {
		var intTEMP = String(this).length;
		return String(this).substring(intTEMP, intTEMP - intLEN);
	}
}

// ///////////////////////////////////////////////////////////////////////////////////////////////////
// DateTime Method...
Date.prototype.addDay = function(day) {
	return new Date(this.getYear(), this.getMonth(), this.getDate() + day);
}
Date.prototype.addMonth = function(month) {
	return new Date(this.getYear(), this.getMonth() + month, this.getDate());
}
Date.prototype.addYear = function(year) {
	return new Date(this.getYear() + year, this.getMonth(), this.getDate());
}
Date.prototype.now = function() {
	return new Date();
}
Date.prototype.compare = function(date) 
{	// 현재 날짜가 date보다 이전이면 2, 같으면 0, 이후이면 1이다.
	var cDate = this.calculator(date);
	if (this.getYear() == date.getYear() && this.getMonth() == date.getMonth() && this.getDate() == date.getDate())
		return 0;
	else if (cDate.getYear() > 0 || cDate.getMonth() > 0 || cDate.getDate() > 0)
		return 1;
	else	
		return 2;
}
Date.prototype.calculator = function(date) 
{	// 지정된 날자에서 date 만큼을 빼준다.
	var day		= this.getDate() - date.getDate();
	var month	= this.getMonth() - date.getMonth();
	var year		= this.getYear() - date.getYear();

	if (day < 0) {
		month--;
		day		= 1;
	}
	if (month < 0) {
		year--;
		month	= 0;
	}
	if (year < 0) {
		return new Date(0, 0, 0);
	} else {
		return new Date(year, month, day);
	}
}
Date.prototype.getLastDay = function() 
{	// 해당월의 마지막 일을 반환.
	var days = "31,28,31,30,31,30,31,31,30,31,30,31";
	if (this.getMonth() == 1 && this.isLeapYear())	// 윤년 2월달이면 일수가 다르다.
		return 29;
	else
		return days.split(',')[this.getMonth()];
}
Date.prototype.isLeapYear = function() 
{	// 윤년인지 검사.
	var year = (this.getYear() < 1900) ? this.getYear() + 1900 : this.getYear();
	return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
}
Date.prototype.toString = function()
{
	var type = typeof(arguments[0]) == "number" ? arguments[0] : 0;
	return this.toDateString(type) +" "+ this.toDateTimeString(type);
}
Date.prototype.toDateString = function()
{
	var type = typeof(arguments[0]) == "number" ? arguments[0] : 0;
	if (type == 1)
		return this.getYear() +"-"+ getDigitThisLength((this.getMonth()+1),2) +"-"+ getDigitThisLength(this.getDate(),2);
	else if (type == 2)
		return this.getYear() +"/"+ getDigitThisLength((this.getMonth()+1),2) +"/"+ getDigitThisLength(this.getDate(),2);
	else if (type == 10)
		return this.getYear() +"년 "+ getDigitThisLength((this.getMonth()+1),2) +"월 "+ getDigitThisLength(this.getDate(),2) +"일 "+ this.toWeekString(2);
	else if (type == 11)
		return this.getYear() +"-"+ getDigitThisLength((this.getMonth()+1),2) +"-"+ getDigitThisLength(this.getDate(),2) +" "+ this.toWeekString(1);
	else if (type == 12)
		return this.getYear() +"/"+ getDigitThisLength((this.getMonth()+1),2) +"/"+ getDigitThisLength(this.getDate(),2) +" "+ this.toWeekString(0);
	else
		return this.getYear() +"년 "+ getDigitThisLength((this.getMonth()+1),2) +"월 "+ getDigitThisLength(this.getDate(),2) +"일";

}
Date.prototype.toDateTimeString = function()
{
	var type = typeof(arguments[0]) == "number" ? arguments[0] : 0;
	if (type == 1)
		return getDigitThisLength(this.getHours(),2) +":"+ getDigitThisLength(this.getMinutes(),2) +":"+ getDigitThisLength(this.getSeconds(),2);
	else if (type == 2)
		return getDigitThisLength(this.getHours(),2) +":"+ getDigitThisLength(this.getMinutes(),2) +":"+ getDigitThisLength(this.getSeconds(),2);
	else if (type == 10)
		return getDigitThisLength(this.getHours(),2) +"시 "+ getDigitThisLength(this.getMinutes(),2) +"분 "+ getDigitThisLength(this.getSeconds(),2) +"초";
	else if (type == 11)
		return getDigitThisLength(this.getHours(),2) +":"+ getDigitThisLength(this.getMinutes(),2) +":"+ getDigitThisLength(this.getSeconds(),2);
	else if (type == 12)
		return getDigitThisLength(this.getHours(),2) +":"+ getDigitThisLength(this.getMinutes(),2) +":"+ getDigitThisLength(this.getSeconds(),2);	
	else
		return getDigitThisLength(this.getHours(),2) +"시 "+ getDigitThisLength(this.getMinutes(),2) +"분 "+ getDigitThisLength(this.getSeconds(),2) +"초";
}
Date.prototype.toWeekString = function()
{
	var type = typeof(arguments[0]) == "number" ? arguments[0] : 0;
	var weeks = "";
	if (type == 1)
		weeks = "일,월,화,수,목,금,토".split(",");
	else if (type == 2)
		weeks = "일요일,월요일,화요일,수요일,목요일,금요일,토요일".split(",");
	else
		weeks = "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(",");

	return weeks[this.getDay()];
}
function $D() {
	return new Date();
}


// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Dictionary object
function Dictionary(id, value) {
	this.id		= id;
	this.value	= value;
}
// Size object
function Size(x, y) {
	this.x	= parseInt(x);
	this.y	= parseInt(y);
}
Size.prototype.Balance = function(maxLimit) 
{	// 최대 Size에 비례하는 Size를 계산하여 반환.
	var balance = new Size(0,0);
	if ((this.x != 0 && this.y != 0) && (maxLimit.x != 0 || maxLimit.y != 0) && (this.x > maxLimit.x || this.y > maxLimit.y)) {
		
		var aW	= (maxLimit.x  > 0) ? (maxLimit.x / this.x) : 1;
		var aH	= (maxLimit.y  > 0) ? (maxLimit.y / this.y) : 1;

		if (aW <= aH) {
			balance.x	= parseInt(this.x * aW);
			balance.y	= parseInt(this.y * aW);
		} else {
			balance.x	= parseInt(this.x * aH);
			balance.y	= parseInt(this.y * aH);
		}
	} else {
		balance.x	= orignal.x;
		balance.y	= orignal.y;
	}
	return balance;
}
Size.prototype.Compare = function(size) 
{	// 두개의 Size가 같으면 true, 다르면 false
	return ((this.x == size.x) && (this.y == size.y));
}

// ///////////////////////////////////////////////////////////////////////////////////////////////////
// String Builder..
var StringBuilder = function()
{ 
	this.buffer = new Array(); 
}
StringBuilder.prototype.append=function(str)
{ 
	this.buffer[this.buffer.length] = str; 
}
StringBuilder.prototype.toString = function()
{ 
	return this.buffer.join(""); 
}

// ///////////////////////////////////////////////////////////////////////////////////////////////////
// ex) onkeydown="onlyNumber();"
function onlyNumber() {
	if(((event.keyCode > 64)&&(event.keyCode < 91)) ||((event.keyCode > 106)&&(event.keyCode < 123)))
		event.returnValue=false;		
}

function getDigitThisLength(intValue, intLength) {
	var strValue;
	var strtmp	= String(intValue);
	if (strtmp.length < intLength) {
		strValue = getDigitThisLength(String("0"+strtmp), intLength);
	} else {
		strValue = strtmp;
	}
	return strValue;
}
function gatNumber(timeString, index) {
	if (isNaN(timeString))
		return 0;
	else
	{
		if (typeof(index)!="number")
			return gatNumber(timeString, 0);
		else
		{
			if (timeString.length <= index)
				return parseInt(timeString.substring(index, timeString.length-(index-1)));
			else
				return (timeString.substring(index, index+1) == 0) ? gatNumber(timeString, index+1) : parseInt(timeString.substring(index, timeString.length-(index-1)));
		}
	}
}
// Querystring에서 값을 검색해 반환.
function getQueryData (name, query) {
	var n, u, s, q;
	if (typeof(query) == "string" && query != "")
		q = query;
	else
		q = document.URL;
	
	n = name.trim()+"=";
	u = q.trim();	
	s = q.search(n);
	if (s > 0) {
		u	= u.substring(parseInt(s + n.length), u.length);
		s	= u.search("&");
		if (s > 0)	
			return u.substring(0,s).trim();
		else
			return u.trim();
	} else {
		return "";
	}
}

// 해당 년,월,일이 날자 형식이 올바른지를 검사한다.
function isDateValidation(strYear, strMonth, strDate) {
	var isDateValid = true;
	try {
		var startDate = new Date(strYear, strMonth-1, strDate);
		if (typeof(startDate.getYear()) == "number" && typeof(startDate.getMonth()) == "number" && typeof(startDate.getDate()) == "number"){
			if (
				getDigitThisLength(startDate.getYear(),4) != strYear || 
				getDigitThisLength(startDate.getMonth()+1,2) != strMonth || 
				getDigitThisLength(startDate.getDate(),2) != strDate
			){
				isDateValid = false;	
			}
		} else {
			isDateValid = false;
		}
	} catch (e) {
		isDateValid = false;
	}
	return isDateValid;
}

function getCheckedBoxValues(obj) {
	var Value = "";
	if(typeof(obj.length)=="number")	{		// 배열로 이루어짐.
		for(i=0;i<obj.length;i++) {
			if(obj[i].checked==true) {
				Value += obj[i].value +",";
			}
		}
	} else {	// 단일개체로 이루어짐
		if(obj.checked)
			Value = obj.value +",";
	}

	if (Value.length > 0) {
		Value = Value.substring(0, Value.length-1);
	}
	return Value;
}
function setCheckedBoxValue(obj, strValue) {
	if (typeof(obj) == "object" && strValue != "") {
		if (strValue.indexOf(",") > 0) {
			var sp = strValue.split(",");
			for (x=0;x<sp.length;x++) {
				setRadioValue(obj, sp[x]);
			}
		} else {
			if(typeof(obj.length)=="number")
				for(i=0;i<obj.length;i++) {
					if (obj[i].value == strValue)
						obj[i].checked = true;
				}
			else 
				obj.checked = (obj.value == strValue);
		}
	}
}

//-----------------------------------------------------------------------------
// 문자열 길이제한
//-----------------------------------------------------------------------------
function strLength(field) {
	var Length = 0;
	var Nav = navigator.appName;
	var Ver = navigator.appVersion;
	var IsExplorer = false;
	var ch;
	
	if ( (Nav == 'Microsoft Internet Explorer') && (Ver.charAt(0) >= 4) ) {
		IsExplorer = true;
	}
	
	if(IsExplorer) {
		for(var i = 0 ; i < field.value.length; i++) {
			ch = field.value.charAt(i);
	
			if ((ch == "\n") || ((ch >= "ㅏ") && (ch <= "히")) || ((ch >="ㄱ") && (ch <="ㅎ"))) {
				Length += 2;
			} else {
				Length += 1;
			}
		}
	} else {
		Length = field.value.length ;
	}
	return Length;
}
function isOutOfRange(field, min, max, error_msg)
{
	if(strLength(field) < min || strLength(field) > max)
	{
		alert(error_msg);
		field.focus();
		field.select();
		return true;
	}
	return false;
}
function isNotExactLength(field, len, error_msg) {
	if(strLength(field) != len) {
		alert(error_msg);
		field.focus();
		field.select();
		return true;
	}
	return false;
}
function isOutOfNumericRange(field, min, max, error_msg) {
	if(field.value < min || field.value > max) {
		alert(error_msg);
		field.focus();
		field.select();
		return true;
	}
	return false;
}

//-----------------------------------------------------------------------------
// SELECT, CHECK BOX 관련 함수
//-----------------------------------------------------------------------------
function isNotSelected(field, error_msg) {
	//Select Box 선택여부 검사
	if(field.selectedIndex == 0) {
		alert(error_msg);
		field.focus() ;
		return true;
	} else {
		return false;
	}
}
function isNotCheckedRadio(field, error_msg) {
	//Radio Button Check
	if ( field == null ) {
		alert(error_msg);
		return true;
	}

	if ( field.length == null ) {
		if ( field.checked == true ) {
			return false;
		} else {
			alert(error_msg);
			return true;
		}
	}

	for(i = 0; i < field.length; i++) {
		if(field[i].checked == true) {
			return false;
		}
	}
	alert(error_msg);
	return true;
}
function uncheckRadio(field) {
	//Radio Button을 선택해제
	for(i = 0; i < field.length; i++) {
		field[i].checked = false;
	}
}
function getRadioVal(field) {
	//Radio Button의 선택된 값을 가져온다
	if (field.length == undefined) {
		if (field != null)	{
			return field.value;
		} else {
			return "";
		}
	} else {
		for(i = 0; i < field.length; i++) {
			if(field[i].checked == true)
				return field[i].value;
		}
	}
}

//-----------------------------------------------------------------------------
// 허용 문자 체크
//-----------------------------------------------------------------------------
function isNotValidChar(field,error_msg) {
	var Count;
	var PermitChar = "0123456789-";  // 허용가능한 문자들을 모두 기록한다.
	
	for (var i = 0; i < field.value.length; i++) {
		Count = 0;
		
		for (var j = 0; j < PermitChar.length; j++) {
			if(field.value.charAt(i) == PermitChar.charAt(j)) {
				Count++;
				break;
			}
		}
	
		if (Count == 0) {
			alert(error_msg);
			field.focus();
			field.select();
			return true;
			break;
		}
	}
	return false;
}
function isNotValidChar2(field,error_msg) {
	var NotPermitChar = "\"";  //허용되어서는 안되는 문자들을 모두 기록한다.
	//   var NotPermitChar = "<>\"^&|'\\ ";  //허용되어서는 안되는 문자들을 모두 기록한다.
	
	if(field.value == "") return false;
	
	for (var i = 0; i < field.value.length; i++) {
		for (var j = 0; j < NotPermitChar.length; j++) {
			if(field.value.charAt(i) == NotPermitChar.charAt(j)) {
				ans = confirm(error_msg);
				
				if(ans == true) {
					return false;
				} else {
					field.focus();
					field.select();
					return true;
				}
			}
		}
	}
	return false;
}

//-----------------------------------------------------------------------------
// AJXA 개체 생성
//-----------------------------------------------------------------------------
function createRequest() {	
	var xmlHttp = null;
	try {
		xmlHttp = new XMLHttpRequest();
	} catch (trymicrosoft) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
				xmlHttp = null;
			}
		}
	}
	
	if (xmlHttp == null) {
		alert("Error creating xmlHttp object!");
	} else {
		return xmlHttp;
	}
}

//-----------------------------------------------------------------------------
// FRAME 리사이즈
//-----------------------------------------------------------------------------
function autoResize(name) {
	var frameName  = document.getElementById(name);
	
	if(document.all) {
		var iframeHeight = frames[name].document.body.scrollHeight;
	} else {
		var iframeHeight=  frameName.contentWindow.document.body.offsetHeight;
	}
	frameName.height=iframeHeight;
}


function parentAutoResize(name) {
	var frameName  = parent.document.getElementById(name);
	
	if(document.all) {
		var iframeHeight = parent.frames[name].document.body.scrollHeight;
	} else {
		var iframeHeight=  frameName.contentWindow.document.body.offsetHeight;
	}
	frameName.height=iframeHeight;
}

//-----------------------------------------------------------------------------
// 슬라이드메뉴
//-----------------------------------------------------------------------------
var stmnGAP1	= 230;	//초기 상단간격
var stmnGAP2	= 50;	//스크롤 후 상단간격
var stmnGAP3	= 300;	//초기 상단간격
var stmnGAP4	= 50;	//스크롤 후 상단간격
var stmnBASE	= 400;
var stmnActivateSpeed	= 300; 
var stmnScrollSpeed	= 10; 

        function RefreshStaticMenu()
        {
                var stmnStartPoint, stmnEndPoint, stmnRefreshTimer;

                stmnStartPoint	= parseInt(STATICMENU.style.top, 10);
                stmnEndPoint	= document.body.scrollTop + stmnGAP2;
                if (stmnEndPoint < stmnGAP1) stmnEndPoint = stmnGAP1;

                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;
                } else {
                        stmnRefreshTimer = stmnActivateSpeed;
                }

                setTimeout ("RefreshStaticMenu();", stmnRefreshTimer);
        }




        function InitializeStaticMenu()
        {
                STATICMENU.style.top = document.body.scrollTop + stmnBASE;
                RefreshStaticMenu();
        }


/*
슬라이드메뉴 : html 에 삽입부분
<div id="STATICMENU" style="width:81px; height:294px; position:absolute; left:878px; top:231px; z-index:100;" >
<table cellpadding="0" cellspacing="0">
    <table align="center" cellpadding="0" cellspacing="0" width="140" height="20">
        <tr>
            <td>
            </td>
        </tr>
    </table>
</div>     
<script language="javascript">InitializeStaticMenu();</script> 
*/