/** 
 * default javascript 
 * @author ssbang
 */

/**
 * °øÅë ÇÔ¼ö
 */
String.prototype.toInteger = function() {
    return this.replace(/[^0-9]/g, '') * 1;
}
// ¸¶¿ì½º ¿À¹ö½Ã ¹Ù²Ü ÀÌ¹ÌÁö ³×ÀÓ »ý¼º
String.prototype.imgoverReplace = function (rsname){
    var rollsection = "_r"; //¿À¹öÀÌ¹ÌÁö¿¡ ºÙ´Â ´Ü¾î
    if(rsname != undefined) rollsection = rsname; //¿À¹öÀÌ¹ÌÁö¿¡ ºÙ´Â ´Ü¾î¸¦ ÁöÁ¤ÇÒ °æ¿ì
    var s = this;
    n = s.lastIndexOf(".");
    return s.substring(0,n)+"_r"+s.substring(n,s.length);
}
// ¸¶¿ì½º ¾Æ¿ô½Ã ¹Ù²Ü ÀÌ¹ÌÁö ³×ÀÓ »ý¼º
String.prototype.imgoutReplace = function (rsname){
    var rollsection = "_r"; //¿À¹öÀÌ¹ÌÁö¿¡ ºÙ´Â ´Ü¾î
    if(rsname != undefined) rollsection = rsname; //¿À¹öÀÌ¹ÌÁö¿¡ ºÙ´Â ´Ü¾î¸¦ ÁöÁ¤ÇÒ °æ¿ì
    var s = this;
    return s.replace(rollsection+".",".");
}

/**
 * ÀÌ¹ÌÁö ·Ñ¿À¹ö 
 * imgrollover(imgobject, imgsrc)
 */
function imgrollOver(img,name){
    img.src = name; 
}

function imgOverMany(){
    var args = imgOverMany.arguments;
    var errorid = "";
    try{
        for(i=0; i<args.length; i++){
            errorid = args[i];
            var img = eval("document.getElementById('"+args[i]+"')");
            img.src = img.src.imgoverReplace("_r");
        }
    }catch(e){
        alert("imgOverMany() "+e+"\n"+errorid+" id¸¦ °¡Áø ÀÌ¹ÌÁö°¡ ¾ø½À´Ï´Ù.´Ù½ÃÈ®ÀÎÇØÁÖ¼¼¿ä");
    }
}
function imgOutMany(){
    var args = imgOutMany.arguments;
    var errorid = "";
    try{
        for(i=0; i<args.length; i++){
            errorid = args[i];
            var img = eval("document.getElementById('"+args[i]+"')");
            img.src = img.src.imgoutReplace("_r");
        }
    }catch(e){
        alert("imgOutMany() "+e+"\n"+errorid+" id¸¦ °¡Áø ÀÌ¹ÌÁö°¡ ¾ø½À´Ï´Ù.´Ù½ÃÈ®ÀÎÇØÁÖ¼¼¿ä");
    }
}
/**
 * div µð½ºÇÃ·¹ÀÌÁ¦¾î (º¸ÀÌ±â)
 */
function divDisplay(){
    var args=divDisplay.arguments; 
    var errorid = "";
    try{
        for(i=0; i<args.length; i++){
            errorid = args[i];
            if(args[i] != ""){
                eval("document.getElementById('"+args[i]+"').style.display=''");
            }
        }
    }catch(e){
        alert("divDisplay() "+e+"\n"+errorid+" id¸¦ °¡Áø ·¹ÀÌ¾î(div)°¡ ¾ø½À´Ï´Ù.´Ù½ÃÈ®ÀÎÇØÁÖ¼¼¿ä");
    }
}
/**
 * div µð½ºÇÃ·¹ÀÌÁ¦¾î (¼û±â±â)
 */
function divDisplayNone(){
    var args=divDisplayNone.arguments; 
    var errorid = "";
    try{
        for(i=0; i<args.length; i++){
            errorid = args[i];
            if(args[i] != ""){
                eval("document.getElementById('"+args[i]+"').style.display='none'");
            }
        }
    }catch(e){
        alert("divDisplayNone() "+e+"\n"+errorid+" id¸¦ °¡Áø ·¹ÀÌ¾î(div)°¡ ¾ø½À´Ï´Ù.´Ù½ÃÈ®ÀÎÇØÁÖ¼¼¿ä");
    }
}


/**
 * leftmenu Á¦¾î
 */
function setLeftMenu(leftnum){
    try{
        eval("document.getElementById('left_"+leftnum+"').style.display=''");
    }catch(e){
        window.status = pagetitle+ " ¿Ï·á "+leftnum; 
    }
    window.status = pagetitle+ " : "+leftnum; 
}

/**
 * ¼¿·ºÆ® ¹Ú½º ±âÅ¸ ÀÚ¹Ù½ºÅ©¸³Æ®·Î ¸µÅ©°É±â
 */
function goHref(url){
    if(url != "" && url != "null"){
        location.href = url;
    }
    return;
}

/**
 * windowpopup
 */
function popupwin(url, name, opt){
    if(url != ""){
        window.open(url,name,opt);
    }
    return;
}

/**
 *ÇÁ¸°Æ®
 */
function printOk(){
    var printwin;
    printwin = window.open("/dev/board/print.html","print","left=10px,top=10px,height=600,width=680,scrollbars=yes,toolbar=yes,menubar=yes");
    if(printwin == null) alert('Â÷´ÜµÈ ÆË¾÷À» ÇØÁöÇØ ÁÖ¼¼¿ä');
    else printwin.focus();
}

/**
 * flash menu link
 * menu ¼ø¼­µ¥·Î Á¤¸®
 */
function menulink(num){
    switch(num){
        //HOME
        case 0 :
            location.href = "/kor/index.jsp"; break;
        //¾Ë¸²¸¶´ç
        case 1 :
            location.href = "/kor/notice/notice.jsp"; break; 
        case 101 : //º¸µµ/ÇØ¸íÀÚ·á
            location.href = "/kor/notice/notice_01.jsp"; break; 
        case 102 : //
            location.href = "/dev/board/board.jsp?id=notice_02"; break; 
        case 103 : //
            location.href = "/dev/board/board.jsp?id=notice_03"; break; 
        case 104 : //
            location.href = "/dev/schedule/schedule.jsp"; break;
        case 105 : //
            location.href = "/dev/board/board.jsp?id=notice_05"; break;
        case 106 : //
            location.href = "/dev/board/board.jsp?id=notice_06"; break;
		case 107 : //
            location.href = "/dev/board/board.jsp?id=notice_07_01"; break;

        //ÀüÀÚ¹Î¿øÃ»±¸
        case 2 :
            location.href = "/kor/civil/civil.jsp"; break;
        case 201 :
            location.href = "/kor/civil/civil_01.jsp"; break;
        case 202 :
            location.href = "/kor/civil/civil_02.jsp"; break;
        case 203 :
            location.href = "/kor/civil/civil_03_01.jsp"; break;
        case 204 :
            location.href = "/dev/minwon/request_minwon.jsp"; break;
        case 205 :
            location.href = "/dev/minwon/reservation_list.jsp"; break;
        case 206 :
            location.href = "/kor/civil/civil_06_01.jsp"; break;
        case 207 :
            location.href = "/kor/civil/civil_07_01.jsp"; break;
        case 208 :
            location.href = "/kor/civil/civil_08.jsp"; break;
        case 209 :
            location.href = "/kor/civil/civil_09.jsp"; break;
        
        
        //Á¤º¸¸¶´ç
        case 3 :
            location.href = "/kor/info/info.jsp"; break;
        case 301 :
            location.href = "/kor/info/info_01_01.jsp"; break;
        case 302 :
            location.href = "/dev/board/board.jsp?id=civil_07_03&dirinfo=info"; break;
        case 303 :
            location.href = "/kor/info/info_03_01.jsp"; break;
        case 304 :
            location.href = "/dev/env/env_list.jsp"; break;
        case 305 :
            location.href = "/dev/env/env_list.jsp?id=prev"; break;
        case 306 :
            location.href = "/kor/info/info_10.jsp"; break;
        case 307 :
            location.href = "/dev/info/info_menu_gover.jsp"; break;
        case 308 :
            location.href = "/dev/info/info_menu_field.jsp"; break;
        case 309 :
            location.href = "/kor/info/info_06_01.jsp"; break;
        case 310 :
            location.href = "/kor/info/info_08_01.jsp"; break;
        case 311 :
            location.href = "/kor/info/info_09_01.jsp"; break;
        
        //»ýÈ°¼ÓÀÇÈ¯°æ
        case 4 :
            location.href = "/kor/life/life.jsp"; break;
        case 401 :
            location.href = "/dev/board/board.jsp?id=life_01"; break;
        case 402 :
            location.href = "/kor/life/life_02.jsp"; break;
        case 403 :
            location.href = "/dev/board/board.jsp?id=life_03_01"; break;
        case 404 :
            location.href = "/kor/life/life_04_01.jsp"; break;
        case 405 :
            location.href = "/kor/life/life_05_01.jsp"; break;
        case 406 :
            location.href = "/dev/board/board.jsp?id=life_06_01"; break;
        case 407 :
            location.href = "/kor/life/life_07.jsp"; break;

        
        //Âü¿©¸¶´ç
        case 5 :
            location.href = "/kor/entry/entry.jsp"; break;
        case 501 :
            location.href = "/kor/entry/entry_01.jsp"; break;
        case 502 :
            location.href = "/dev/board/board.jsp?id=entry_02_01"; break;
        case 503 :
            location.href = "/kor/entry/entry_03_01.jsp"; break;
        case 504 :
            location.href = "/kor/entry/entry_07_01.jsp"; break;
        case 505 :
            location.href = "/kor/entry/entry_04_01.jsp"; break;
        case 506 :
            location.href = "/dev/board/board.jsp?id=entry_05_01"; break;
        case 507 :
            location.href = "#"; break;

            
        //È¯°æºÎ¼Ò°³
        case 6 :
            location.href = "/kor/intro/intro.jsp"; break;
        case 601 :
            location.href = "/kor/intro/intro_01_01.jsp"; break;
        case 602 :
            location.href = "/kor/intro/intro_02.jsp"; break;
        case 603 :
            location.href = "/kor/intro/intro_03_02.jsp"; break;
        case 604 :
            location.href = "/kor/intro/intro_04_01.jsp"; break;
        case 605 :
            location.href = "/dev/board/board.jsp?id=intro_06"; break;
        case 606 :
            location.href = "/kor/intro/intro_08_02.jsp"; break;
        case 607 :
            location.href = "/kor/intro/intro_09.jsp"; break;
        case 608 :
            location.href = "/kor/intro/intro_10_01.jsp"; break;
        
        //HOME
        case 1000 :
            location.href = "/kor/index.jsp"; break;
        //·Î±×ÀÎ
        case 2000 :
            login(); break;
        //·Î±×¾Æ¿ô
        case 2001 :
            logout(); break;
        
        //È¸¿ø°¡ÀÔ
        case 3000 :
            location.href = "/kor/member/member_join_01.jsp"; break;
        //english
        case 4000 :
            window.open("http://eng.me.go.kr/","",""); break;

        //sitemap 
        case 5000 :
            location.href = "/kor/support/support_02.jsp"; break;
        //mobile 
        case 6000 :
            location.href = "/kor/support/support_10.jsp"; break;
        default :
            break;
    }

    return;

}
/*
 * ¸ÞÀÎ °Ë»ö¹Ø¿¡ ¿òÁ÷ÀÌ´Â ÇÃ·¡½Ã ¸µÅ©
 */
function mainflashlink(num){
    switch(num){
	
	case 1 :
        location.href = "/kor/civil/civil.jsp"; break;

    case 101 :
        location.href = "/kor/civil/civil_01.jsp"; break;
    case 102 :
        location.href = "/dev/minwon/request_minwon.jsp"; break;
    case 103 :
        location.href = "/kor/civil/civil_06_01.jsp"; break;
    case 104 :
        location.href = "/kor/civil/civil_07_01.jsp"; break;

	case 2 :
        location.href = "/dev/board/board.jsp?id=notice_06"; break;
    case 201 :
        location.href = "/dev/board/board.jsp?id=notice_06"; break;

	case 3 :
        location.href = "/kor/info/info_01_01.jsp"; break;
    case 301 :
        location.href = "/kor/info/info_01_02.jsp"; break;
    case 302 :
        location.href = "/kor/info/info_01_03.jsp"; break;
    case 303 :
        window.open('/kor/info/info_01_04.jsp','',0,0,1024,768,0,0,0,0,0); break;
    case 304 :
        location.href = "/kor/info/info_01_05.jsp"; break;

	case 4 :
        location.href = "/dev/board/board.jsp?id=civil_07_03&dirinfo=info"; break;
    case 401 :
        location.href = "/dev/board/board.jsp?id=civil_07_03&dirinfo=info"; break;
    case 402 :
        location.href = "#"; break;
    case 403 :
        location.href = "#"; break;
    case 404 :
        location.href = "/dev/board/board.jsp?id=info_02_04"; break;

	case 5 :
        location.href = "/kor/info/info_13_01.jsp"; break;
    case 501 :
        location.href = "/kor/info/info_13_01.jsp"; break;
    case 502 :
        location.href = "#"; break;
    case 503 :
        location.href = "/kor/info/info_06_03.jsp"; break;
    case 504 :
        location.href = "#"; break;

    default :
        break;
    }
    return;
}
/**
 * top °Ë»ö ºÎºÐ
 */
function topSearch(obj_form){
    return false;
}
/**
 * login 
 */
function loginformCheck(obj_form){
    if(obj_form.user_id.value.length == 0 || obj_form.user_id.value == ""){
        alert('¾ÆÀÌµð¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä');
        obj_form.user_id.focus();
        return false;
    }
    if(obj_form.passwd.value.length == 0 || obj_form.passwd.value == ""){
        alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä');
        obj_form.passwd.focus();
        return false;
    }
    return true;
}


/**
 * µû¶ó´Ù´Ï´Â ¹è³Ê ½ºÅ©¸³Æ®
 */
function follow_banner(div_id, origin_top, limit_top, margin_top)
{
    var d, t, s, g, target_height;
    origin_top *= 1;
    limit_top *= 1;
    margin_top *= 1;

    d = document.getElementById(div_id);
    s = document.body.scrollTop + "";

    target_height = s.toInteger() + margin_top;
    if(target_height < limit_top) {
        target_height = origin_top;
    }

    t = d.style.top.toInteger();

    if(t != target_height) {
        g = Math.ceil((t - target_height) / 5);
        if(g > 50) {
            g = 50;
        } else if (g < -50) {
            g = -50;
        }
        d.style.top = (t - g) + "px";
    }
    setTimeout("follow_banner('" + div_id + "', " + origin_top + ", " + limit_top + ", " + margin_top + ");", 10);
}

function setCookie( name, value, expiredays )  {
	var todayDate = new Date(); 
	todayDate.setDate( todayDate.getDate() + expiredays ); 
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
}

//»õÃ¢ °ü·Ã ÇÔ¼ö (ÄíÅ°°ª)
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 download(path,filename) {
	location.href="/dev/common/download2.jsp?file="+filename+"&path="+path;
}

function download4(path,filename) {
	location.href="/dev/common/download_m.jsp?file="+filename+"&path="+path;
}

//index POPUPZONE ½ºÅ©¸³Æ®À§ÇÑ ÇÔ¼ö Ãß°¡ 2006-12-13 ÀÓ±Ù¸ð
// http://www.mofe.go.kr
// http://hyeonseok.com/pmwiki/index.php/Javascript/GetElementsBySelector
function getAllChildren(e) {
	// Returns all children of element. Workaround required for IE5/Windows. Ugh.
	return e.all ? e.all : e.getElementsByTagName('*');
}

/* document.getElementsBySelector(selector)
	 - returns an array of element objects from the current document
		 matching the CSS selector. Selectors can contain element names, 
		 class names and ids and can be nested. For example:
		 
			 elements = document.getElementsBySelect('div#main p a.external')
		 
		 Will return an array of all 'a' elements with 'external' in their 
		 class attribute that are contained inside 'p' elements that are 
		 contained inside the 'div' element which has id="main"

	 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
	 See http://www.w3.org/TR/css3-selectors/#attribute-selectors

	 Version 0.4 - Simon Willison, March 25th 2003
	 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
	 -- Opera 7 fails 
*/


document.getElementsBySelector = function(selector) {
		// Attempt to fail gracefully in lesser browsers
		if (!document.getElementsByTagName) {
			return new Array();
		}
		// Split selector in to tokens
		var tokens = selector.split(' ');
		var currentContext = new Array(document);
		for (var i = 0; i < tokens.length; i++) {
			token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
			if (token.indexOf('#') > -1) {
				// Token is an ID selector
				var bits = token.split('#');
				var tagName = bits[0];
				var id = bits[1];
				var element = document.getElementById(id);
				if (tagName && element.nodeName.toLowerCase() != tagName) {
					// tag with that ID not found, return false
					return new Array();
				}
				// Set currentContext to contain just this element
				currentContext = new Array(element);
				continue; // Skip to next token
			}
			if (token.indexOf('.') > -1) {
				// Token contains a class selector
				var bits = token.split('.');
				var tagName = bits[0];
				var className = bits[1];
				if (!tagName) {
					tagName = '*';
				}
				// Get elements matching tag, filter them for class selector
				var found = new Array;
				var foundCount = 0;
				for (var h = 0; h < currentContext.length; h++) {
					var elements;
					if (tagName == '*') {
							elements = getAllChildren(currentContext[h]);
					} else {
							elements = currentContext[h].getElementsByTagName(tagName);
					}
					for (var j = 0; j < elements.length; j++) {
						found[foundCount++] = elements[j];
					}
				}
				currentContext = new Array;
				var currentContextIndex = 0;
				for (var k = 0; k < found.length; k++) {
					if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
						currentContext[currentContextIndex++] = found[k];
					}
				}
				continue; // Skip to next token
			}
			// Code to deal with attribute selectors
			if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
				var tagName = RegExp.$1;
				var attrName = RegExp.$2;
				var attrOperator = RegExp.$3;
				var attrValue = RegExp.$4;
				if (!tagName) {
					tagName = '*';
				}
				// Grab all of the tagName elements within current context
				var found = new Array;
				var foundCount = 0;
				for (var h = 0; h < currentContext.length; h++) {
					var elements;
					if (tagName == '*') {
							elements = getAllChildren(currentContext[h]);
					} else {
							elements = currentContext[h].getElementsByTagName(tagName);
					}
					for (var j = 0; j < elements.length; j++) {
						found[foundCount++] = elements[j];
					}
				}
				currentContext = new Array;
				var currentContextIndex = 0;
				var checkFunction; // This function will be used to filter the elements
				switch (attrOperator) {
					case '=': // Equality
						checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
						break;
					case '~': // Match one of space seperated words 
						checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
						break;
					case '|': // Match start with value followed by optional hyphen
						checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
						break;
					case '^': // Match starts with value
						checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
						break;
					case '$': // Match ends with value - fails with "Warning" in Opera 7
						checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
						break;
					case '*': // Match ends with value
						checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
						break;
					default :
						// Just test for existence of attribute
						checkFunction = function(e) { return e.getAttribute(attrName); };
				}
				currentContext = new Array;
				var currentContextIndex = 0;
				for (var k = 0; k < found.length; k++) {
					if (checkFunction(found[k])) {
						currentContext[currentContextIndex++] = found[k];
					}
				}
				// alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
				continue; // Skip to next token
			}
			// If we get here, token is JUST an element (not a class or ID selector)
			tagName = token;
			var found = new Array;
			var foundCount = 0;
			for (var h = 0; h < currentContext.length; h++) {
				var elements = currentContext[h].getElementsByTagName(tagName);
				for (var j = 0; j < elements.length; j++) {
					found[foundCount++] = elements[j];
				}
			}
			currentContext = found;
		}
		return currentContext;
}


// Log ºÐ¼® ½ºÅ©¸³Æ® (070903)

if( typeof NU_rl == 'undefined' ){
var NU_rl = 'http://'+'mlog.me.go.kr:8080'; var PCHKIMG = new Image(); var NL_bn=navigator.appName;
if( document.URL.substring(0,8) == 'https://' ){ NU_rl = 'https://sslc1.acecounter.com/sslb1'; 
}else{
if( NL_bn.indexOf("Netscape") > -1 || NL_bn=="Mozilla"){ setTimeout("PCHKIMG.src = NU_rl+'/?cookie';",1); } else{ PCHKIMG.src = NU_rl+'/?cookie'; };
}
document.writeln("<scr"+"ipt language='javascript' src='/LogInside/loginside_mainscript.js'></scr"+"ipt>");
}



/* That revolting regular expression explained 
/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
	\---/	\---/\-------------/		\-------/
		|			|				 |							 |
		|			|				 |					 The value
		|			|		~,|,^,$,* or =
		|	 Attribute 
	 Tag
*/
