/*
 * since 2008.10.11. by lks
 * prototype-1.6.0.4.js or scriptaculous-1.8.1 or higher required.
 */
 
	/* PNG_IE6Bug */
    function setPng24( obj ){
        obj.width        = obj.height = "1";
        obj.className    = obj.className.replace( /\bpng24\b/i, "" );
        obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + obj.src + "',sizingMethod='image');"
        obj.src = ""; 
        return "";
    }
	
	/* ShowHideLayer */
    function Div_Show( obj ){
        document.getElementById( obj ).style.display = "block"
    }
    function Div_Hide( obj ){
        document.getElementById( obj ).style.display = "none"
    }
	
    /* --  Tabstart -- */
	    function tabEvent( obj, obj_arr, classUse )
    {
        var p_obj = obj.parentNode;
        var c_list = p_obj.getElementsByTagName( "LI" );
        var c_img  = p_obj.getElementsByTagName( "IMG" );

        for( var i=0; i<c_img.length; i++ ) {

            if( i == obj_arr ) {
                c_img[i].src = c_img[i].src.match( "on.gif" ) ? c_img[i].src : c_img[i].src.substr( 0, c_img[i].src.indexOf(".gif") ) + "on.gif";
                if( classUse == true ) c_list[i].className = "m_on";
                if( $(p_obj.id + "_" + i) != null ) $( p_obj.id + "_" + i ).show();

            } else {
                c_img[i].src = c_img[i].src.match( "on.gif" ) ? c_img[i].src.substr( 0, c_img[i].src.indexOf("on.gif") ) + ".gif" : c_img[i].src;
                if( classUse == true ) c_list[i].className = "m_out";
                if( $(p_obj.id + "_" + i) != null ) $( p_obj.id + "_" + i ).hide();
            }
        }
    }

    /* --  Tabend -- */	

    //-----------------------------------------------------------------------------
    // select skin ���
    //
    // ����
    //  new WGN_SD.Selectbox('element_id', {
    //      fontSize      : 11,
    //      lineSize      : 13
    //  });
    //-----------------------------------------------------------------------------
    if ( typeof WGN_SD == "undefined" ) {
        var WGN_SD = new Object();

        WGN_SD.$  = function( id ) {
            return document.getElementById( id );
        }
        WGN_SD.$$ = function() {
            var obj = function() {
                if( this.__const )
                    this.__const.apply( this,arguments );
            }
            WGN_SD.extend( obj.prototype,arguments[0] );

            return obj;
        }
        WGN_SD.$c = function( tag ) {
            return document.createElement( tag );
        }
        WGN_SD.extend = function( obj ) {
            for( var i=0; i<arguments.length; i++ ) {
                for( var x in arguments[i] )
                    obj[x]=arguments[i][x];
            }

            return obj;
        }
        WGN_SD.lim = function( val,min,max ) {
            return Math.max( Math.min( val,max ), min );
        }
    }

    WGN_SD.Selectbox = WGN_SD.$$({
        __const : function( id ) {
            var t = this;
            var s = t._source = WGN_SD.$( id );
            var sd_width,
                sd_height,
                sd_fontSize,
                sd_lineSize,
                sd_FLPadding,
                sd_listSize,
                sd_skinActive,
                sd_skinFormat,
                sd_borderActive,
                sd_borderSet,
                sd_txtElColor,
                sd_txtElBgColor,
                sd_optTxtColor,
                sd_optBgColor,
                sd_optTxtHover,
                sd_optBgHover,
                sd_optTxtPadding;

            if( s.className.match("SD_STYLE01") ) {
                sd_width         = 157;

            }

            if( !sd_width )         sd_width         = s.offsetWidth -2;
            if( !sd_height )        sd_height        = 17;
            if( !sd_fontSize )      sd_fontSize      = 11;
            if( !sd_lineSize )      sd_lineSize      = 13;
            if( !sd_FLPadding )     sd_FLPadding     = 2;
            if( !sd_listSize )      sd_listSize      = 100;
            if( !sd_skinActive )    sd_skinActive    = false;
            if( !sd_skinFormat )    sd_skinFormat    = "/image/board/btn/sd_style08.gif";
            if( !sd_borderActive )  sd_borderActive  = true;
            if( !sd_borderSet )     sd_borderSet     = "1px solid #e1e1e1";
            if( !sd_txtElColor )    sd_txtElColor    = "#6c6c6c";
            if( !sd_txtElBgColor )  sd_txtElBgColor  = "#ffffff";
            if( !sd_optTxtColor )   sd_optTxtColor   = "#999999";
            if( !sd_optBgColor )    sd_optBgColor    = "#ffffff";
            if( !sd_optTxtHover )   sd_optTxtHover   = "#ffffff";
            if( !sd_optBgHover )    sd_optBgHover    = "#cccccc";
            if( !sd_optTxtPadding ) sd_optTxtPadding = "2px 4px";

            t.options = WGN_SD.extend({
                width         : sd_width,           //s.offsetWidth;
                height        : sd_height,          //s.offsetHeight;
                fontSize      : sd_fontSize,
                lineSize      : sd_lineSize,
                FLPadding     : sd_FLPadding,       // FLPadding 2 = optTxtPadding 0 4px
                listSize      : sd_listSize,
                skinActive    : sd_skinActive,
                skinFormat    : sd_skinFormat,      //"./images/sbox_%s.gif";
                borderActive  : sd_borderActive,
                borderSet     : sd_borderSet,
                txtElColor    : sd_txtElColor,
                txtElBgColor  : sd_txtElBgColor,
                optTxtColor   : sd_optTxtColor,
                optBgColor    : sd_optBgColor,
                optTxtHover   : sd_optTxtHover,
                optBgHover    : sd_optBgHover,
                optTxtPadding : sd_optTxtPadding
            }, arguments[1] )

            var o = t.options;
            var e = t._element = WGN_SD.$c( "div" );
            var c = e.appendChild( WGN_SD.$c( "div" ) );
            var p = { left:0, top:0 };

            {
                var _o = t._source;
                do{
                    p.left += _o.offsetLeft;
                    p.top  += _o.offsetTop;
                    _o     =  _o.offsetParent;
                }while( _o )
            }

            s.parentNode.insertBefore( e, s );
            s.style.display = "none";

            if ( o.borderActive )
                e.style.border = o.borderSet;

            with( e.style ) {
                top        = p.top + "px";
                left       = p.left + "px";
                width      = o.width + "px";
                height     = o.height + "px";       // height = ( o.height-2 ) + "px";
                background = o.txtElBgColor;
                lineHeight  = o.lineSize + "px";
            }

            with( c.style ) {
                width    = o.width + "px";
                height   = o.height + "px";         // height   = ( o.height-2 ) + "px";
                fontSize = o.fontSize + "px";
                overflow = "hidden";
                cursor   = "pointer";
            }

            c.onmouseover = function() {
                if( !t._list_el.parentNode || !t._list_el.parentNode.tagName )
                    document.body.appendChild( t._list_el );
            }
            c.onmousedown = function(e) {
                t.onmousedown.call( t, e || window.event );
            }
            c.onmouseup = function() {
                t.onmouseup.apply( t, [] );
            }

            var b = c.appendChild( WGN_SD.$c( "div" ) );

            with( b.style ) {
                background         = "no-repeat url( " + o.skinFormat.replace( '%s','bt' ) + " ) 50% 50%";
                b.style.cssFloat   = "right";
                b.style.styleFloat = "right";
                height             = "100%";
            }
            t._txt_el = c.appendChild( WGN_SD.$c( "div" ) );
            with( t._txt_el ) {
                appendChild( document.createTextNode( s.options[s.selectedIndex].text ) );

                // var tempPadding = Math.max( Math.floor( ( o.height-offsetHeight )/2 ),0 );
                // if( tempPadding > 5 ) tempPadding = 2;

                with( style ) {
                    height      = o.fontSize + "px";
                    lineHeight  = o.lineSize + "px";
                    overflow    = "hidden";
                    //marginTop   = Math.max( Math.floor( ( o.height-offsetHeight )/2 ),0 ) + "px";
                    //marginTop   = tempPadding + "px";
                    marginTop   = "2px";
                    marginLeft  = marginTop;
                    paddingLeft = o.FLPadding + "px";
                    color       = o.txtElColor;
                }
            }
            c.appendChild( WGN_SD.$c( "div" ) ).style.clear = "both";

            var im;
            ( im = WGN_SD.$c( "img" ) ).onload = function() {
                b.style.width = im.width + "px";
            }
            im.src = o.skinFormat.replace( "%s","bt" );
            t._list_el = WGN_SD.$c( "div" );

            with( t._list_el.style ) {
                position   = "absolute";
                border     = o.borderSet;
                display    = "none";
                oveflow    = "auto";
                fontSize   = o.fontSize + "px";
                lineHeight = o.lineSize + "px";
            }
            t._list_el.onmousedown = function(e) {
                t.onscrollbar.call( t, e || window.event );
            }
            t._event_onmousedown = function(e) {
                t.onmousedown.call( t, e || window.event );
            }
            t.paint();
        },
        onmousedown : function(e) {
            if( this._list_el.style.display == "none" ) {
                var t = this;
                var p = { left:0, top:0 }

                {
                    var o = t._element;
                    while( o.offsetParent ) {
                        p.left   += o.offsetLeft;
                        p.top    += o.offsetTop;
                        o        =  o.offsetParent;
                    }
                }

                this.paint();
                this._list_el.style.display = "";

                var pos_el_top;
                var pos_dm;

                pos_el_top = p.top + this._element.offsetHeight - 1;

                if( document.body.scrollHeight < document.body.offsetHeight ) {
                    pos_dm = document.body.offsetHeight - pos_el_top;
                } else{
                    pos_dm = document.body.scrollHeight - pos_el_top;
                }

                if ( pos_dm < this._list_el.offsetHeight ) {
                    pos_el_top = p.top - this._list_el.offsetHeight + 1;
                }

                if ( this._list_el.offsetWidth < this._element.offsetWidth )
                    this._list_el.style.width = this._element.offsetWidth + "px";

                with( this._list_el.style ) {
                    width  = this._element.offsetWidth - 2 + "px";      // ����Ʈ width
                    top    = pos_el_top + "px";
                    left   = p.left + "px";
                    zIndex = 99;
                }
            }else{
                this._list_el.style.display = "none";

                with( document ) {
                    try{
                        detachEvent( "onmousedown", this._event_onmousedown );
                    }catch(e) {
                        removeEventListener( "mousedown", this._event_onmousedown, false );
                    }
                }
            }
            try{
                e.preventDefault();
                e.stopPropagation();
            }catch(e) {
                e.returnValue = false;
                e.cancelBubble = true;
            }
        },
        onmouseup : function() {
            if ( this._list_el.style.display != "none" ) {
                with( document ) {
                    try{
                        attachEvent( "onmousedown", this._event_onmousedown );
                    }catch(e) {
                        addEventListener( "mousedown", this._event_onmousedown );
                    }
                }
            }
        },
        onselect : function(e) {
            var el = e.target || e.srcElement;
            var o  = this.options;
            var s  = this._source;

            s.selectedIndex = el._index;

            this._txt_el.firstChild.nodeValue = s.options[s.selectedIndex].text;
            this.onmousedown();
            if ( this._source.onchange )
                this._source.onchange();
        },
        onover : function(e) {
            var el = e.target || e.srcElement;
            var c  = el.parentNode.childNodes;
            var i  = el._index;
            var o = this.options;

            for( var _i = 0; _i<c.length; _i++ ) {
                c[_i].style.color = o.optTxtColor;
                c[_i].style.background = o.optBgColor;
            }
            el.style.color = o.optTxtHover;
            el.style.background = o.optBgHover;
        },
        onscrollbar : function(e) {
            try{
                e.preventDefault();
                e.stopPropagation();
            }catch(e) {
                e.returnValue  = false;
                e.cancelBubble = true;
            }
        },
        paint : function() {
            var o = this.options;
            var s = this._source;
            var op;

            this._list_el.innerHTML = "";
            this._list_el.style.width = "";
            this._list_el.style.height = "";

            for( var i = 0; i < s.options.length; i++ ) {
                ( op = this._makeOption( s.options[i].value, s.options[i].text ) )._index = i;

                with( op.style ) {
                    padding = o.optTxtPadding;
                    cursor = "pointer";
                    color = ( i == this._source.selectedIndex ) ? o.optTxtHover : o.optTxtColor;
                    background = ( i == this._source.selectedIndex ) ? o.optBgHover : o.optBgColor;
                }
                this._list_el.appendChild( op );
            }

            var old = this._list_el.style.display;

            this._list_el.style.display = "block";

            if ( ( this._list_el.offsetHeight-2 ) > op.offsetHeight * o.listSize )
                this._list_el.style.height = op.offsetHeight*o.listSize;

            this._list_el.style.display = old;
        },
        _makeOption : function( value, text ) {
            var o = WGN_SD.$c( "div" );
            var t = this;

            o._value = value;
            o.appendChild( document.createTextNode( text ) );
            o.onmouseover = function(e) {
                t.onover.call( t, e || window.event )
            }
            o.onmousedown = function(e) {
                t.onselect.call( t ,e || window.event )
            }

            return o;
        }
    });
	//-----------------------------------------------------------------------------
	// Ȱ��ȭ�� �÷��� ����
	//
	// @����
	//    var player1_bgm = new FlashObject( "/flash/playerskin.swf", 140, 46 );
	//    player1_bgm.id        = "pbgm";
	//    player1_bgm.wmode     = "transparent";
	//    player1_bgm.style_str = "margin:0px;"
	//    player1_bgm.Render();
	//-----------------------------------------------------------------------------
	function activeSwf( src, width, height, transparent ){
		object = '';
		object += '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="param" width="' + width + '" height="' + height + '">';
		object += '<param name="movie" value="' + src + '">';

		if( transparent == 'transparent' ) object += '<param name="wmode" value="transparent">';

		object += '<embed src="' + src + '" quality="high" ';

		if( transparent == 'transparent' ) object += ' wmode="transparent" ';

		object += ' bgcolor="#ffffff" menu="false" width="' + width + '" height="' + height + '" swliveconnect="true" id="param" name="param" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
		object += '</object>';

		document.writeln( object );
		
	}

	//-----------------------------------------------------------------------------
	// zoom ��� 
	// @���� : turn_thum( list id, ����(prev, next), ������� ����� ����
	//-----------------------------------------------------------------------------
	function turn_thum( change_thum, direction, viewport_num ){
		var thum = $( change_thum );
		var thum_li = thum.down("LI",0);
		var thum_pos = thum.style.left;

		if( direction == "prev" ){
			slideMenu( change_thum, 0, 16 )
		
		}else if( direction == "next" ){
			slideMenu( change_thum, -thum_li.offsetWidth * viewport_num, 16 )
		}
	}
	/* -----------------------------------------------------------------------------
		slide menu
		@���� : slideMenu( elemList_id, final_x, interval );
	----------------------------------------------------------------------------- */
	function slideMenu( list_id, final_x, interval ){
		var obj = $( list_id );
		var obj_child = obj.childNodes;

		if( obj.movement ) window.clearTimeout( obj.movement );
		if( !obj.style.left ) obj.style.left = "0px";
		
		var obj_xpos = parseInt( obj.style.left );

		if( obj_xpos == final_x ) return true;

		if( obj_xpos < final_x ){
			var dist = Math.ceil( (final_x - obj_xpos)/10 );
			obj_xpos = obj_xpos + dist;
		}else{
			var dist = Math.ceil( (obj_xpos - final_x)/10 );
			obj_xpos = obj_xpos - dist;
		}
		obj.style.left = obj_xpos + "px";

		var repeat = "slideMenu('" + list_id +"', '" + final_x + "', '" + interval + "')";
		obj.movement = setTimeout( repeat, interval );
	}
	
	//-----------------------------------------------------------------------------
	// �˾�â ����
	// @���� : openPopup( "", { width: 400, height: 500, scroll: 0, top: 100, left: 100, name: "name_popup" } );
	// �� �ɼ��� �⺻��: �Ʒ� ��v
	// @return : �˾�â��ü
	//-----------------------------------------------------------------------------
	function openPopup( url, option ){
		var obj_option = option == null ? {} : option;
	
		if( url               == null ) url               = "";
		if( obj_option.width  == null ) obj_option.width  = screen.availWidth;
		if( obj_option.height == null ) obj_option.height = screen.availHeight;
		if( obj_option.scroll == null ) obj_option.scroll = 0;
		if( obj_option.top    == null ) obj_option.top    = ( screen.availHeight - obj_option.height ) / 4;
		if( obj_option.left   == null ) obj_option.left   = ( screen.availWidth  - obj_option.width  ) / 4;
		if( obj_option.name   == null ) obj_option.name   = "";
		if( obj_option.errMsg == null ) obj_option.errMsg = "Please disable popup blocking!";
	
		var newWindow = window.open( url, obj_option.name, "width=" + obj_option.width + ",height=" + obj_option.height + ",scrollbars=" + obj_option.scroll + ",toolbar=0, menubars=0,locationbar=0,historybar=0,statusbar=0,resizable=0,left=" + obj_option.left + ",top=" + obj_option.top + ",channelmode=no,titlebar=no", false );
	
		if( !newWindow ){
			alert( obj_option.errMsg );
			return false;
		}
		newWindow.focus();
	
		return newWindow;
	}	
	
	
/*  */	
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

/* tab */
function ceoProfile() {
	if (!document.getElementById("tabMamage")) return false;
	if (!document.getElementById("viewProfile")) return false;
	var profile = document.getElementById("tabMamage");
	var profileTab = profile.getElementsByTagName("li");
	for ( var i=0; i<profileTab.length;i++) {
		var profileOn = profileTab[1];
	}
	var viewProfile = document.getElementById("viewProfile");
	var profileImg = viewProfile.getElementsByTagName("img");
		for ( var i=0; i<profileImg.length;i++) {
		var clickProfileImg = profileImg[0];
	}
	clickProfileImg.onclick = function () {
	return tabEvent(profileOn,"1");
	}
	return false;
}
addLoadEvent (ceoProfile);

/* gateLayerControl */
function layerControl (str) {
	if (!document.getElementById("snb")) return false;
	var snb = document.getElementById("snb");
	if ( str == "0" ) {
		snb.style.height ="50px";
	}
	else {
		snb.style.height ="17px";
	}
	return;	
}
addLoadEvent (layerControl);

/* ��Ʈ�ι��� SKIP */
function introComplete(){
    document.location.href = "/main.do"; 
}

//-----------------------------------------------------------------------------
// ����Ʈ�޴� �����̵� üũ
//-----------------------------------------------------------------------------
function initCheck(){
	if( getCookie_min( "gmMenu" ) != "done" ){
		window.document.Gate.jasCheck();
		setCookie_min( "gmMenu", "done", 30 );
	}
}


//-----------------------------------------------------------------------------
// ��Ű�� ���Ѹ��� �� ����(�ڽ�â)
// @���� : wgn.setCookie( "name_project", "value_project", 3600 );
// String(key), String(value), Number(��,minutes)
// @return : void
//-----------------------------------------------------------------------------
function setCookie_min( name, value, expireMinutes )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getMinutes() + expireMinutes );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}


//-----------------------------------------------------------------------------
// ��Ű �� ����(�θ�â)
// @���� : wgn.getCookie( "name_project" );
// �� �ɼ��� �⺻��: �Ʒ� ��v
// @return : String(�Էµ� key-������� ��:-�� �ش��ϴ� ��)
//-----------------------------------------------------------------------------
function getCookie_min( 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 "";
}

//-----------------------------------------------------------------------------
// ���ã�� �߰�
//    bookmarksite( site title, url )
//-----------------------------------------------------------------------------
function bookmarkSite( title, url ){
	if( window.sidebar ){
		// firefox
		window.sidebar.addPanel(title, url, "");

	}else if( window.opera && window.print ){
		// opera
		var elem = document.createElement( 'a' );
		elem.setAttribute( 'href', url );
		elem.setAttribute( 'title', title );
		elem.setAttribute( 'rel', 'sidebar' );
		elem.click();
	}else if( document.all ){
		// ie
		window.external.AddFavorite( url, title );

	}
}




