function LTrim(s) {
	return s.replace(/^\s+/g,"");
}

function RTrim(s) {
	return s.replace(/\s+$/g,"");
}

function Trim(s) {
	return LTrim(RTrim(s));
}

function Len(s) {
	var s1 = Trim(s);
	return s1.length;
}

function ByteLen(s){
	var len = 0;
	var tlen = 0;
	var tstr = "";
	if ( s == null ) return 0;
	for(var i=0;i<s.length;i++){
		var c = escape(s.charAt(i));		
		if ( c.length == 1 ) len++;
			else if ( c.indexOf("%u") != -1 ) len+=2;
			else if ( c.indexOf("%") != -1 ) len+=c.length/3;
		
		tstr+=s.charAt(i);
	}	
	return len;
}

function num_only()
{
	if(((event.keyCode<48) || (event.keyCode>57)) && (event.keyCode != 46)) {
	event.returnValue=false;
	}
}

function CheckNum(s) {
    if (Len(s) == 0) return false;

    for (i=0; i < s.length; i++) {
        if (!(s.charAt(i) >= "0" && s.charAt(i) <= "9")) 
            return false;
	}

    return true;
}

function CheckStrNum(s) {
    if (Len(s) == 0) return false;

    for (i=0; i < s.length; i++) {
        if (!((s.charAt(i) >= "a" && s.charAt(i) <= "z") ||
	      (s.charAt(i) >= "A" && s.charAt(i) <= "Z") ||
	      (s.charAt(i) >= "0" && s.charAt(i) <= "9")))
            return false;
	}

    return true;
}

function CheckExceptStrNum(s) {
    if (Len(s) == 0) return false;

    for (i=0; i < s.length; i++) {
        if (!((s.charAt(i) >= "a" && s.charAt(i) <= "z") ||
	      (s.charAt(i) >= "A" && s.charAt(i) <= "Z") ||
	      (s.charAt(i) >= "0" && s.charAt(i) <= "9") ||
	      (s.charAt(i) == "_"))) 
            return false;
	}

    return true;
}

function CheckSpace(s) {
    if (Len(s) == 0) return false;

    for (i=0; i < s.length; i++) {
        if (s.charAt(i) == " ") 
            return false;
	}

    return true;
}

function CheckEmail(s) {
	var strEmail = s;
	var invalidChars = "~`!@#$%^&*()+=|\<,>?/'";
	
	if (Len(strEmail) == 0) {
		alert('\nEmail À» ÀÔ·ÂÇÏ¿©ÁÖ¼¼¿ä');
		return false;
	}
	
	if (strEmail.indexOf("@") < 1) {
		alert('\nEmail Çü½ÄÀÌ Æ²·È½À´Ï´Ù.\nÇü½Ä : °èÁ¤ÀÌ¸§@¼­¹ö¸í');
		return false;
	}
	
	var atPos = strEmail.indexOf("@", 1);
	var strID = strEmail.substring(0, atPos);
	var strServerName = strEmail.substring(atPos + 1);
	
	for(var i=0; i<invalidChars.length; i++ ) {
		var strBadChar = invalidChars.charAt(i);
		
		if (strID.indexOf(strBadChar) > -1) {
			alert('\nEmail ÁÖ¼Ò°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.');
			return false;
		}	
	}
	
	if (strServerName.indexOf(".") < 1) {
		alert('\nEmail ÁÖ¼Ò°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.');
		return false;
	}	
	
	for(var i=0; i<invalidChars.length; i++ ) {
		var strBadChar = invalidChars.charAt(i);
		
		if (strServerName.indexOf(strBadChar) > -1) {
			alert('\nEmail ÁÖ¼Ò°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.');
			return false;
		}	
	}
	
	return true;
}	

function namosw_exchange_src() { 
	str = namosw_exchange_src.arguments[0];
	str = (navigator.appName == 'Netscape') ? 'document.' + str : 'document.all.' + str;
	
	img = eval(str);
	if (img) {
		if (img.ori_src == null) {
			img.ori_src = img.src;
			img.src     = namosw_exchange_src.arguments[1];
		} else {
			var temp    = img.src;
			img.src     = img.ori_src;
			img.ori_src = temp;
		}
	} 
}

function namosw_preload_img() { 
	var img_list = namosw_preload_img.arguments;
	if (document.preloadlist == null) document.preloadlist = new Array();

	var top = document.preloadlist.length;

	for (var i=0; i < img_list.length; i++) {
		document.preloadlist[top+i]     = new Image;
		document.preloadlist[top+i].src = img_list[i];
	} 
}

function viewImage(image_path) {
	var imagePopup = showModalDialog("/common/lib/viewImage.asp?image_path=" + image_path, window, "dialogWidth=100px;dialogHeight=100px;status=no;scroll=no;help=no;resizable=no;center=yes")
}

function SendMail(theValue) {
	location.href='/guidance/letter_board/list.asp?board_seq=' + theValue;
}



function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function SetFont(type,select) {
	if (type == "plus") {		
		switch (readCookie("font_size")) {
			case "12px" :
				document.getElementById(select).style.fontSize = "14px";
				createCookie("font_size", "14px", 365);
				break;
			case "14px" :
				document.getElementById(select).style.fontSize = "16px";
				createCookie("font_size", "16px", 365);
				break;
			case "16px" :
				document.getElementById(select).style.fontSize = "18px";
				createCookie("font_size", "18px", 365);
				break;
			case "18px" :
				document.getElementById(select).style.fontSize = "20px";
				createCookie("font_size", "20px", 365);
				break;
		}
	} else if (type == "minus") {
		switch (readCookie("font_size")) {
			case "14px" :
				document.getElementById(select).style.fontSize = "12px";
				createCookie("font_size", "12px", 365);
				break;
			case "16px" :
				document.getElementById(select).style.fontSize = "14px";
				createCookie("font_size", "14px", 365);
				break;
			case "18px" :
				document.getElementById(select).style.fontSize = "16px";
				createCookie("font_size", "16px", 365);
				break;
			case "20px" :
				document.getElementById(select).style.fontSize = "18px";
				createCookie("font_size", "18px", 365);
				break;
		}
	} else {
		document.getElementById("doc_content").style.fontSize = "12px";
		createCookie("font_size", "12px", 365);
	}
}

function Print(CatSeq, NewsSeq) {
	print_win = window.open('/common/news/print.asp?cat_seq=' + CatSeq + '&news_seq=' + NewsSeq, 'print_win', 'scrollbars=yes,left=217,top=' + (screen.height - 550) / 2 + ',width=758,height=550');
	print_win.focus();
	return;
return;
}
function PopBook(url, f_wid, f_hei) {

	var flash_book = window.open('/common/commonwindow/flash_book.asp?file_path=' + escape(url) + '&wid=' + f_wid + '&hei=' + f_hei, 'flash_book', 'left=' + (screen.availWidth - f_wid)/2 + ',top=' + (screen.availHeight-f_hei)/2 + ',width=' + f_wid + ',height=' + f_hei +',scrollbars=no,resizable=no');
	flash_book.focus();
	return;
}
	/* ---------------------------------------------------------------------------------------------------------------------------------------------
	Round
	--------------------------------------------------------------------------------------------------------------------------------------------- */
	function NiftyCheck(){
		if(!document.getElementById || !document.createElement)
		
		return(false);

		var b=navigator.userAgent.toLowerCase();
		if(b.indexOf("msie 5")>0 && b.indexOf("opera")==-1)
			return(false);
		return(true);
	}

	// Å×µÎ¸®¸¸ ¶ó¿îµå Ã³¸®
	function BorderRounded(selector,bk,color){
		if(!NiftyCheck()) return;

		var v=getElementsBySelector(selector);
		var l=v.length;
		var html = '';

		for(var i, i=0;i<l;i++){
			html += '<table width=\"100%\" celllpadding=\"0\" cellspacing=\"0\"><tr><td>';
			html += '<div class=rnd style=\'color: ' + color + '; border-color: ' + color + '; background: ' + bk + ';\'>';
			html += '<i class=rnd1 style=\'border-color: ' + color + '; background: ' + color + '\'></i>';
			html += '<i class=rnd2 style=\'border-color: ' + color + '; background: ' + bk + ';\'></i>';
			html += '<i class=rnd3 style=\'border-color: ' + color + '; background: ' + bk + ';\'></i>';
			html += '<i class=rnd4 style=\'border-color: ' + color + '; background: ' + bk + ';\'></i>';
			html += '<div class=rnd5 style=\'border-color: ' + color + '; background: ' + bk + ';\'>';
			html += v[i].innerHTML;
			html += '</div>';
			html += '<i class=rnd4 style=\'border-color: ' + color + '; background: ' + bk + ';\'></i>';
			html += '<i class=rnd3 style=\'border-color: ' + color + '; background: ' + bk + ';\'></i>';
			html += '<i class=rnd2 style=\'border-color: ' + color + '; background: ' + bk + ';\'></i>';
			html += '<i class=rnd1 style=\'border-color: ' + color + '; background: ' + color + '\'></i>';
			html += '</div>';
			html += '</td></td></table>';

			v[i].innerHTML = html;
		}
	}

	// ÀüÃ¼¸¦ ¶ó¿îµå Ã³¸®
	function Rounded(selector,bk,color,size){
		var i;
		var v=getElementsBySelector(selector);
		var l=v.length;

		for(i=0;i<l;i++){
			v[i].style.backgroundColor = color;
			AddTop(v[i],bk,color,size);
			AddBottom(v[i],bk,color,size);
		}
	}

	function AddTop(el,bk,color,size){
		var i;
		var d=document.createElement("b");
		var cn="r";
		var lim=4;
		
		if(size && size=="small"){ cn="rs"; lim=2}
		
		d.className="rtop";
		d.style.backgroundColor=bk;
		for(i=1;i<=lim;i++){
			var x=document.createElement("b");
			x.className=cn + i;
			x.style.backgroundColor=color;
			d.appendChild(x);
		}
		el.insertBefore(d,el.firstChild);
	}

	function AddBottom(el,bk,color,size){
		var i;
		var d=document.createElement("b");
		var cn="r";
		var lim=4;

		if(size && size=="small"){ cn="rs"; lim=2}
		
		d.className="rbottom";
		d.style.backgroundColor=bk;
		
		for(i=lim;i>0;i--){
			var x=document.createElement("b");
			x.className=cn + i;
			x.style.backgroundColor=color;
			d.appendChild(x);
		}
		el.appendChild(d,el.firstChild);
	}

	function getElementsBySelector(selector){
		var i;
		var s=[];
		var selid="";
		var selclass="";
		var tag=selector;
		var objlist=[];
		if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
			s=selector.split(" ");
			var fs=s[0].split("#");
			if(fs.length==1) return(objlist);
			return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
		}
		if(selector.indexOf("#")>0){ //id selector like "tag#id"
			s=selector.split("#");
			tag=s[0];
			selid=s[1];
		}
		if(selid!=""){
			objlist.push(document.getElementById(selid));
			return(objlist);
		}
		if(selector.indexOf(".")>0){  //class selector like "tag.class"
			s=selector.split(".");
			tag=s[0];
			selclass=s[1];
		}
		var v=document.getElementsByTagName(tag);  // tag selector like "tag"
		if(selclass=="")
			return(v);
		for(i=0;i<v.length;i++){
			if(v[i].className==selclass){
				objlist.push(v[i]);
			}
		}
		return(objlist);
	}

/*-- ¿À¸¥ÂÊ ¸¶¿ì½º ±ÝÁö -- */
	function clickIE4(){
		if (event.button==2){
			alert(message);
		return false;
		}
	}

	function clickNS4(e){
		if (document.layers||document.getElementById&&!document.all){
		if (e.which==2||e.which==3){
			alert(message);
			return false;
			}
		}
	}

/*-- ÀÎ¼â½Ã Á¤±Ô½Ä »ç¿ëÀ¸·Î ÇÊ¿ä ¾ø´Â Å×±× Á¦°Å --*/
function removeScript()
{
 var re = /\r\n/g
 var strBox1 = $('print').value;
 strBox1 = strBox1.replace(re, "@!-_-!@");
	re = /<\s*body.+?\<div\s*id\=(contents)\s*>/gi
 strBox1 = strBox1.replace(re, "");
	re = /<\!--\s*(contents_detail)\s*\(e\).+?<\/\s*body\s*>/gi
 strBox1 = strBox1.replace(re, "");
	re = /<\s*div\s*class\=(print_navi).+?\s*\/\s*div\s*>/gi
 strBox1 = strBox1.replace(re, "");
 re = /@!-_-!@/g
 strBox1 = strBox1.replace(re, "\r\n");
 re = /^\r\n/g
 strBox1 = strBox1.replace(re, "");
 $('print').value = strBox1;
/*	var win = new Window(Application.getNewId(), {title: "ÀÎ¼â", width:610, height:700,  zIndex: 100,
	resizable: true, url:"/include/print_preview.asp", showEffectOptions: {duration:1}});
	win.showCenter();*/
	print_win = window.open('/include/print_preview.asp', 'print_win', 'scrollbars=yes,left=' + (screen.availWidth - 610)/2 + ',top=' + (screen.availHeight - 700) / 2 + ',width=610,height=700');
	print_win.focus();
	return;
}

function dialog() {
  Dialog.alert("Test of alert panel, check out debug window after closing it", 
               {windowParameters: {className: "alphacube", width:300, height:100}, okLabel: "close", 
                ok:function(win) {debug("validate alert panel"); return true;}, cancel:function(win) {debug("validate cancel panel"); return true;}});
}
var date = new Date();
date.setYear(date.getYear()+1903);
/*---  ½Ç¸íÃ¼Å© ºñ¹Ð¹øÈ£ Ã¼Å© --- */

function sil_popup(returnURL){
	var win = new Window(Application.getNewId(), {title: "½Ç¸íÀÎÁõ", 
	top:120, left:300, width:500, height:250,  zIndex: 100,
	resizable: true, url: "/common/login/default.asp?return_url="+returnURL, showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff});
	win.show();
	
}

function chk_popup(checkURL){
	var win = new Window(Application.getNewId(), {title: "ºñ¹Ð¹øÈ£ È®ÀÎ", width:300, height:100,  zIndex: 100,
	resizable: true, url:checkURL, showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff});
	win.showCenter();
}

function steppoll_popup(){	
	var win = new Window(Application.getNewId(), {title: "Á÷¿øÆò°¡", 
	top:0, left:0, width:660, height:600,  zIndex: 999,
	resizable: true, url: "/steppoll/default.asp?theID=", showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff});
	win.showCenter();

}
function zoomImg(theValue, lngWidth, lngHeight, theTitle){
	var win = new Window(Application.getNewId(), {className: "dialog", width:lngWidth, height:lngHeight, zIndex: 100, resizable: true, title: theTitle, showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff, draggable:true, wiredDrag: true})

	win.getContent().innerHTML= '<img src="' + theValue + '" alt="' + theTitle + '" />';
	win.showCenter();
}
function show_popup(lngPopSeq, strTitle, lngTop, lngLeft, lngWidth, lngHeight){
	var win = new Window(Application.getNewId(), {title: strTitle, 
	top:lngTop, left:lngLeft, width:lngWidth, height:lngHeight,  zIndex: 9999,
	resizable: true, url: "/layer_popup/popup.asp?no=" + lngPopSeq, showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff});
	win.show();
}
function layer_close(){
	Windows.closeAll();
}

// Sitelink thumbnail
// Developer: FireJune(http://firejune.com)
var Linkthumb = {
    align:function(array) {
        var thisUrl = document.domain;
        if (thisUrl.split('.')[0] == 'www') 
            thisUrl = thisUrl.substring(4, thisUrl.length);
        $$(array).each(function(element) {
            var url = element.href;
            if(url.indexOf(thisUrl) == -1) {
				if (url.indexOf('mailto') == -1)
				{
					var img = Linkthumb.create(url);
					element.appendChild(img);
					Event.observe(element, 'mouseover', function(){img.style.display = 'block'});
					Event.observe(element, 'mouseout', function(){img.style.display = 'none'});
				}
            }
        });
    },
    create:function(url) {
        var img = document.createElement('IMG');
        var url = url.replace(/[^:]*:\/\/([^:\/]*)(:{0,1}\/{1}.*)/, '$1');
        img.src = 'http://msnsearch.srv.girafa.com/srv/i?s=MSNSEARCH&r='+ url;
        img.className = 'linkthumb';
        img.alt = url;
        img.style.display = 'none';
        return img;
    }
}
///////////////////SLIDER/////////////////////////////
function fillup(){
    if (iedom){
        cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
        cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
        cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
        actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
        cross_slide2.style.left=actualwidth+slideshowgap+"px"
    }
    else if (document.layers){
        ns_slide=document.ns_slidemenu.document.ns_slidemenu2
        ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
        ns_slide.document.write(leftrightslide)
        ns_slide.document.close()
        actualwidth=ns_slide.document.width
        ns_slide2.left=actualwidth+slideshowgap
        ns_slide2.document.write(leftrightslide)
        ns_slide2.document.close()
    }
    lefttime=setInterval("slideleft()",30)
}
function slideleft(){
    if (iedom){
    if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
        cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
    else
        cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"
    if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
        cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
    else
        cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"
    }
    else if (document.layers){
    if (ns_slide.left>(actualwidth*(-1)+8))
        ns_slide.left-=copyspeed
    else
        ns_slide.left=ns_slide2.left+actualwidth+slideshowgap
    if (ns_slide2.left>(actualwidth*(-1)+8))
        ns_slide2.left-=copyspeed
    else
        ns_slide2.left=ns_slide.left+actualwidth+slideshowgap
    }
}
/* ---------------------------------------------------------------------------------------------------------------------------------------------
ÃÊ±âÈ­ ÇÔ¼ö
--------------------------------------------------------------------------------------------------------------------------------------------- */

window.onload=function (){
	/*
	if (document.getElementById("doc_content")) {
		if (readCookie("font_size") == "null") {
			document.getElementById("doc_content").style.fontSize = "12px";
			createCookie("font_size", "12px", 365);
		} else {
			document.getElementById("doc_content").style.fontSize = readCookie("font_size");
			createCookie("font_size", readCookie("font_size"), 365);
		}
	}
    */
	if (document.layers){
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown=clickNS4;
	}
	else if (document.all&&!document.getElementById){
		document.onmousedown=clickIE4;
	}

	try {
		SetRound();
	} catch(e) {
	}
	try{
		$('print').value=document.body.outerHTML;
	}catch(e){
	}

	try{
		f_setInit();
		f_setVoice();
	} catch(e) {
	}

	try{
//		Linkthumb.align('#contents a');
	}catch(e){
	}
	try{
		fillup();
	}catch(e){
	}
//	document.oncontextmenu=new Function("return false;")
}
