//파이어폭스에서 구동 안됨
function GJF_object(str) {
	return eval("document.getElementById('" + str + "')");
	
//	return eval("document.all." + str);
}

function GJF_goURL(URL) {
	location.href=URL;
}

function GJF_ImgError(obj, Url) {
	obj.src=Url;
}

function GJF_keyControl(){
	if(event.ctrlKey || event.altKey ){ alert("특수문자 또는 공백을 입력할 수 없습니다."); event.returnValue=false;}
}


function GJF_ChartCheck(strValue) {
	if (strValue.value.search(/\W|\s/g) > -1) { alert("特殊文字、空白は入力できません。"); }
}

function GJF_isFieldChk(obj, text) {
	if (obj.value.trim()=="") { alert(text + "을(를) 입력하세요!"); obj.focus(); return false; }
}

function GJF_isLengthChk(obj, Num1, Num2) {
	var str = obj.value.trim();
	var len = str.length;
	
	if (len < 4 || len > 12 ) { alert("입력값이 길이가" + Num1 + "작거나 " + Num2 + "보다 큽니다."); obj.focus(); return false; }
}

function GJF_isRadioChk(obj, text) {
	var cnt = 0;

	for (var i = 0; i < obj.length; i++ ) { 
		if (obj[i].checked) { cnt++; }
	}

	if (cnt == 0) { alert(text + "을(를) 선택하세요!"); obj[0].focus(); return false; }
}

function GJF_EnterKeyDownCheck(onFunction) {
	if (event.keyCode == 13) {
		eval(onFunction());
	}
}

function GJF_isValueChk(obj, obj1, text) {
	if (obj.value != obj1.value) { alert(text + "가 일치하지 않습니다."); obj1.focus(); obj1.select(); return false; }
}

function GJF_isEmail(strEmail) { 
    var regx = RegExp(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/);
    return regx.test(strEmail); 
}

function GJF_MyRound(Num, Pos) {
	if (!Pos) {
		return Math.round(Num);
	} else {
		var PosV = Math.pow(10,2)
		return Math.round(Num*PosV)/PosV
	}
}

function GJF_isDigit(filter) {
	if (filter) {
		var sKey = String.fromCharCode(event.keyCode);
		var reg = new RegExp(filter);

		if (!reg.test(sKey)) {
			event.returnValue = false;
		}
	}
}

function GJF_DivSH(DivName, SHType, TdID, CalssNm) {

	if (SHType == "auto") {
		if (DivName.style.display == "none") {
			DivName.style.display = "";
		} else {
			DivName.style.display = "none";
		}
	} else if (SHType == "true") {
		DivName.style.display = "";
	} else if (SHType == "false") {
		DivName.style.display = "none";
	}
	if (CalssNm != "") { TdID.className = CalssNm; }	

}

function GJF_DivSH1(DivName, SHType) {
	if (SHType == "auto") {
		if (DivName.style.display == "none") {
			DivName.style.display = "";
		} else {
			DivName.style.display = "none";
		}
	} else if (SHType == "true") {
		DivName.style.display = "";
	} else if (SHType == "false") {
		DivName.style.display = "none";
	}
}

function GJF_DivSH2(ID, SHType, strUrl, strUrlOv, DivNmae) {
	if (SHType == "auto") {
		if (ID.src== strUrlOv) {
			ID.src= strUrl;
			if (DivNmae!="") { DivNmae.style.display = "none"; }
		} else {
			ID.src=strUrlOv;
			if (DivNmae!="") { DivNmae.style.display = "''"; }
		}
	} else if (SHType == "true") {
		ID.src=strUrlOv;
		if (DivNmae!="") { DivNmae.style.display = ""; }
	} else if (SHType == "false") {
		ID.src=strUrl;
		if (DivNmae!="") { DivNmae.style.display = "none"; }
	}
}

function GJF_PopUpWindow(Url, PopNm, top, left, width, height, scrollbar) {
	window.open(Url,PopNm,'top='+top+',left='+left+',width='+width+',height='+height+',fullscreen=no,menubar=no,status=no,toolbar=no,titlebar=no,location=no,scrollbars='+scrollbar);
}

function GJF_addDate(pInterval, pAddVal, pYyyymmdd, pDelimiter) {
	var yyyy, mm, dd, cDate, oDate, cYear, cMonth, cDay;

	if (pDelimiter != "") {
		pYyyymmdd = pYyyymmdd.replace(eval("/\\" + pDelimiter + "/g"), "");
	}

	yyyy = pYyyymmdd.substr(0,4);
	mm = pYyyymmdd.substr(4,2);
	dd = pYyyymmdd.substr(6,2);

	if (pInterval == "yyyy") { yyyy = (yyyy*1) + (pAddVal*1); }
	else if (pInterval == "m") { mm = (mm*1) + (pAddVal*1); }
	else if (pInterval == "d") { dd = (dd*1) + (pAddVal*1); }

	cDate = new Date(yyyy, mm-1, dd);
	cYear = cDate.getFullYear();
	cMonth = cDate.getMonth() + 1;
	cDay = cDate.getDate();

	cMonth = cMonth < 10 ? "0" + cMonth : cMonth;
	cDay = cDay < 10 ? "0" + cDay : cDay;

	if (pDelimiter != "") { return cYear + pDelimiter + cMonth + pDelimiter + cDay; }
	else { return cYear + cMonth + cDay; }
}
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////

function JGF_Left(Str,Num) {
	if (Num <= 0) { return ""; }
	else if (Num > String(Str).length) { return Str; } 
	else { return String(Str).substring(0,Num); }
}

function JGF_Right(Str,Num) {
	if (Num <= 0) { return ""; }
	else if (Num > String(Str).length) { return Str; } 
	else { var iLen = String(Str).length; return String(Str).substring(iLen, iLen-Num); }
}

String.prototype.Replace = function() {
	return this.replace(/\D/gi,'');
}

String.prototype.onlyNumber = function() {
	return this.replace(/\D/g,'');
}

String.prototype.numberFormat = function() { 
	return this.replace(/(\d)(?=(?:\d{3})+(?!\d))/g,'$1,'); 
} 

String.prototype.ltrim = function() { 
	var re = /\s*((\S+\s*)*)/; return this.replace(re,"$1"); 
} 

String.prototype.rtrim = function() { 
	var re = /((\s*\S+)*)\s*/; return this.replace(re,"$1"); 
} 

String.prototype.trim = function() { 
	return this.replace(/(^\s*)|(\s*$)/gi, ""); 
} 

String.prototype.supplant = function(o) {
	return this.replace(/{([^{}]*)}/g, function (a, b) { var r=o[b]; return r; } );
}

String.prototype.URLEncode = function URLEncode() {
	var SAFECHARS = "0123456789" +     // Numeric
		"ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
	    "abcdefghijklmnopqrstuvwxyz" +
		"-_.!~*'()";     // RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";
	var plaintext = this;
	var encoded = "";
	
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
		if (ch == " ") {
			encoded += "+";    // x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
			encoded += ch;
		} else {
			var charCode = ch.charCodeAt(0);
			
			if (charCode > 255) {
				alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" + "(URL encoding only supports 8-bit characters.)\n" + "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	}
	return encoded;
}

String.prototype.URLDecode = function URLDecode() {
	var HEXCHARS = "0123456789ABCDEFabcdef";
	var encoded = this;
	var plaintext = "";
	var i = 0;
	
	while (i < encoded.length) {
		var ch = encoded.charAt(i);
		if (ch == "+") {
			plaintext += " ";
			i++;
		} else if (ch == "%") {
			if (i < (encoded.length-2) && HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 && HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
			plaintext += ch;
			i++;
		}
	}
	return plaintext;
}

var Utf8 = {
 
	// public method for url encoding
	encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// public method for url decoding
	decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}

///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
function WinCenter(){ 
  
    var x,y; 
    if (self.innerHeight) { // IE 외 모든 브라우저 
        x = (screen.availWidth - self.innerWidth) / 2; 
        y = (screen.availHeight - self.innerHeight) / 2; 
    }else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict 모드 
        x = (screen.availWidth - document.documentElement.clientWidth) / 2; 
        y = (screen.availHeight - document.documentElement.clientHeight) / 2; 
    }else if (document.body) { // 다른 IE 브라우저( IE < 6) 
        x = (screen.availWidth - document.body.clientWidth) / 2; 
        y = (screen.availHeight - document.body.clientHeight) / 2; 
    } 
    window.moveTo(x,y); 
} 

function getPageSize() {

	 var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			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;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}

function getnavigatorType(){
	if (navigator.appName == "Netscape") {
		return "Netscape " + navigator.appVersion.charAt(0);
	} else if (navigator.appName == "Microsoft Internet Explorer") {
		if (navigator.appVersion.charAt(0) == "4" ) {
			if (navigator.appVersion.indexOf("MSIE 5") != -1) {
				return "ie 5";
			} else if (navigator.appVersion.indexOf("MSIE 6") != -1) {
				return "ie 6";
			} else if (navigator.appVersion.indexOf("MSIE 7") != -1) {
				return "ie 7";
			} else if (navigator.appVersion.indexOf("MSIE 8") != -1) {
				return "ie 8";
			} else {
				return "ie 4";
			}
		} else if (navigator.appVersion.charAt(0) == "5") {
			return "ie 5";
		}
	} else {
		return "";
	}
}

function WinReSize() {
	var width, height;
	width = document.body.scrollWidth + 10;
	height = document.body.scrollHeight + 47;

	if( getnavigatorType() == "ie 7" ) { height = height + 33; }
	if( getnavigatorType() == "ie 8" ) { height = height + 33; }
	window.resizeTo( width, height );

	this.focus();
}

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 fnChkImageFile(arg) {
	imgFile = arg.value;

	var extArray = new Array(".gif", ".jpg", ".wmv");

	while (imgFile.indexOf("\\") != -1)
		imgFile = imgFile.slice(imgFile.indexOf("\\") + 1);

	ext = imgFile.slice(imgFile.indexOf(".")).toLowerCase();

	isImage = false;

	for (var i = 0; i < extArray.length; i++)
	{
		if (extArray[i] == ext)
		{
			isImage = true;
			break;
		}
	}

	return isImage
}
/*************************************************************
 *    DYNIFS - Dynamic IFrame Auto Size v1.0.0
 *
 *    Copyright (C) 2006, Markus (phpMiX)
 *    This script is released under GPL License.
 *    Feel free to use this script (or part of it) wherever you need
 *    it ...but please, give credit to original author. Thank you. :-)
 *    We will also appreciate any links you could give us.
 *    http://www.phpmix.org
 *
 *    Enjoy! ;-)
*************************************************************/

var DYNIFS = {
	// Storage for known IFrames.
	iframes: {},
	// Here we save any previously installed onresize handler.
	oldresize: null,
	// Flag that tell us if we have already installed our onresize handler.
	ready: false,
	// The document dimensions last time onresize was executed.
	dim: [-1,-1],
	// Timer ID used to defer the actual resize action.
	timerID: 0,
	// Obtain the dimensions (width,height) of the given document.
	getDim: function(d) {
		var w=200, h=200, scr_h, off_h;
		if( d.height ) { return [d.width,d.height]; }
		with( d.body ) {
			if( scrollHeight ) { h=scr_h=scrollHeight; w=scrollWidth; }
			if( offsetHeight ) { h=off_h=offsetHeight; w=offsetWidth; }
			if( scr_h && off_h ) h=Math.max(scr_h, off_h);
		}
		return [w,h];
	},
	// This is our window.onresize handler.
	onresize: function() {
		// Invoke any previously installed onresize handler.
		if( typeof this.oldresize == 'function' ) { this.oldresize(); }
		// Check if the document dimensions really changed.
		var dim = this.getDim(document);
		if( this.dim[0] == dim[0] && this.dim[1] == dim[1] ) return;
		// Defer the resize action to prevent endless loop in quirksmode.
		if( this.timerID ) return;
		this.timerID = setTimeout('DYNIFS.deferred_resize();', 10);
	},
	// This is where the actual IFrame resize is invoked.
	deferred_resize: function() {
		// Walk the list of known IFrames to see if they need to be resized.
		for( var id in this.iframes ) this.resize(id);
		// Store resulting document dimensions.
		this.dim = this.getDim(document);
		// Clear the timer flag.
		this.timerID = 0;
	},
	// This is invoked when the IFrame is loaded or when the main window is resized.
	resize: function(id) {
		// Browser compatibility check.
		if( !window.frames || !window.frames[id] || !document.getElementById || !document.body )
			return;
		// Get references to the IFrame window and layer.
		var iframe = window.frames[id];
		var div = document.getElementById(id);
		if( !div ) return;
		// Save the IFrame id for later use in our onresize handler.
		if( !this.iframes[id] ) {
			this.iframes[id] = true;
		}
		// Should we inject our onresize event handler?
		if( !this.ready ) {
			this.ready = true;
			this.oldresize = window.onresize;
			window.onresize = new Function('DYNIFS.onresize();');
		}
		// This appears to be necessary in MSIE to compute the height
		// when the IFrame'd document is in quirksmode.
		// OTOH, it doesn't seem to break anything in standards mode, so...
		if( document.all ) div.style.height = '0px';
		// Resize the IFrame container.
		var dim = this.getDim(iframe.document);
		div.style.height = (dim[1]+30) + 'px';
	}
}
