
/* 로테이트 */
function rotatecontents(objectid){
    
    this.pagingobject=null;
    this.pagingstart='';
    this.pagingdelimiter='/';
    this.pagingend='';
    this.rotatemethod=null;
    this.maxzindex=1;
    this.speed=5;
    this.autoplay=true;
    this.autoplaytime=5;
 
    this.buttonobject=null;
    this.buttontype='text';
    this.buttononclassname='on';
    this.buttononimagename='';

    
    var object=document.getElementById(objectid);
    var items=new Array(),itemsnum,titles=new Array();
    var btns=new Array(),btnsmover=new Array(),btnsmout=new Array();
    var speed,timer,nowno=0,canimove=true;
    var isie=(navigator.userAgent.toLowerCase().indexOf('msie')!=-1)? true : false;
 
    this.initialize=function(){
        var isfirst=true,removeobjs=new Array(),childs=object.childNodes;
        for(var i=0,j=-1,max=childs.length; i<max; i++){
            if(childs[i].nodeType==1){
                j++;
                if(!isfirst) childs[i].style.display='none';
                items.push(childs[i]);
                if(this.rotatemethod=='overlap' || this.rotatemethod=='slide' || this.rotatemethod=='fadein' || this.rotatemethod=='vertical'){
                    speed=this.speed;
                    object.style.position='relative';
                    with(childs[i].style){
                        position='absolute';
                        left='0px';
                        top='0px';
                        width=object.offsetWidth+'px';
						//2009-08-25
                        height=object.offsetHeight+'px';
                        
                    }
                    if(this.rotatemethod=='fadein'){
                        setopacity(childs[i],(isfirst)? 100 : 0);
                    }
                }
                if(isfirst) isfirst=false;
            }
        }
        itemsnum=items.length;
        if(removeobjs[0]){
            for(var i=0,max=removeobjs.length; i<max; i++) object.removeChild(removeobjs[i]);
        }
 
        if(this.pagingobject) this.pagingobject=document.getElementById(this.pagingobject);
        this.settitlenpaging(nowno);
        object.style.width=object.offsetWidth+'px';
        //alert(object.style.width);
		object.style.height=object.offsetHeight+'px';
        object.style.overflow='hidden';
        object.onmouseover =function(){
            clearTimeout(eval(objectid).autoplaytimer);
        }
        object.onmouseout=function(){
            eval(objectid).autoplayaction();
        }
        if(this.buttonobject){
            this.buttonobject=document.getElementById(this.buttonobject);
            var childs=this.buttonobject.childNodes;
            for(var i=0,j=0,max=childs.length; i<max; i++){
                if(childs[i].nodeType==1){
                    childs[i].myno=j;
                    if(childs[i].onmouseover) btnsmover.push(childs[i].onmouseover);
                    if(childs[i].onmouseout) btnsmout.push(childs[i].onmouseout);
                    btns.push(childs[i]);
                    j++;
                }
            }
            if(items.length!=btns.length) this.buttonobject=null;
            else this.setbtns();
        }
        this.autoplayaction();
    }
 
    this.settitlenpaging=function(no){
       
        if(this.pagingobject) this.pagingobject.innerHTML=this.pagingstart+(no+1)+this.pagingdelimiter+itemsnum+this.pagingend;
    }
 
    this.setzindex=function(no){
        for(var i=0; i<itemsnum; i++){
            if(i==no){
                items[i].style.zIndex=this.maxzindex+3;
                items[i].style.display='';
            }else if(i==nowno){
                items[i].style.zIndex=this.maxzindex+2;
            }else{
                items[i].style.zIndex=this.maxzindex+1;
                items[i].style.display='none';
            }
        }
    }
 
    this.setbtns=function(no){
        if(!no && no!==0) no=nowno;
        for(var i=0; i<itemsnum; i++){
            if(i==no){
                this.setbtnon(btns[i]);
                btns[i].onmouseover=null;
                btns[i].onmouseout=null;
            }else{
                this.setbtnoff(btns[i]);
                btns[i].onmouseover=function(){
                    eval(objectid).setbtnon(this);
                    if(btnsmover[this.myno]) btnsmover[this.myno]();
                }
                btns[i].onmouseout=function(){
                    eval(objectid).setbtnoff(this);
                    if(btnsmout[this.myno]) btnsmout[this.myno]();
                }
            }
        }
    }
 
    this.setbtnon=function(target){
        var classes,exist=false;
        if(this.buttontype=='image'){
            var btnimg=target.getElementsByTagName('img')[0];
            var btnimgexp=btnimg.src.substring(btnimg.src.lastIndexOf('.'));
            if(btnimg.src.indexOf(this.buttononimagename+btnimgexp)==-1) btnimg.src=btnimg.src.replace(btnimgexp,this.buttononimagename+btnimgexp);
        }
        classes=target.className.split(' ');
        for(var i=0; i<classes.length; i++) if(classes[i]==this.buttononclassname) exist=true;
        if(!exist) target.className=target.className+' '+this.buttononclassname;
    }
 
    this.setbtnoff=function(target){
        var classes;
        if(this.buttontype=='image'){
            var btnimg=target.getElementsByTagName('img')[0];
            var btnimgexp=btnimg.src.substring(btnimg.src.lastIndexOf('.'));
            if(btnimg.src.indexOf(this.buttononimagename+btnimgexp)!=-1) btnimg.src=btnimg.src.replace(this.buttononimagename+btnimgexp,btnimgexp);
        }
        if(target.className.indexOf(this.buttononclassname)!=-1){
            if(target.className.indexOf(' ')==-1) target.className=target.className.replace(this.buttononclassname,'');
            else{
                classes=target.className.split(' ');
                for(var i=0; i<classes.length; i++) if(classes[i]==this.buttononclassname) classes[i]='';
                target.className=classes.join(' ');
            }
        }
    }
 
    this.change=function(no){
        no=no-1;
        if(no!=nowno){
            if(this.rotatemethod=='overlap') this.moveaction('overlap',no,(no<nowno)? 'prev' : 'next');
            else if(this.rotatemethod=='slide') this.moveaction('slide',no,(no<nowno)? 'prev' : 'next');
            else if(this.rotatemethod=='vertical') this.moveaction('vertical',no,(no<nowno)? 'prev' : 'next');
            else if(this.rotatemethod=='fadein') this.fadeinaction(no);
            else this.hideitem(no);
            this.settitlenpaging(no);
            if(this.buttonobject) this.setbtns(no);
        }
    }

	this.stop = function() {
		clearTimeout(eval(objectid).autoplaytimer);
		this.hideitem;
	};

	this.play = function() {
		if(!this.autoplay) return;
        this.autoplaytimer=setTimeout(objectid+'.next()',this.autoplaytime*1000);
	};

	this.viewall = function() {
		
		var viewwrap = document.getElementById('banner_bot');
		var banbtn = document.getElementById('lbtn'); 
		var banclose = document.getElementById('rbtn');
		var bbtn = document.getElementById('bbtn');
		if (viewwrap.style.height == '' )
		{	clearTimeout(eval(objectid).autoplaytimer);
			viewwrap.style.height = '175px';
			viewwrap.style.backgroundImage = 'url(/open_content/images/main/bg_banner_02.gif)';
			var objList = document.getElementById(objectid);
			var objListul = objList.getElementsByTagName('ul');
			objList.style.height = '175px';
			objList.style.paddingTop = '25px';
			for (var i=0; i < objListul.length ; i++)
			{
				objListul[i].style.position = 'static';
				objListul[i].style.display = 'block';
			}	
			banbtn.style.display = 'none';
			banclose.style.display = 'none';
			bbtn.style.display = 'block';
			object.onmouseover = "null";
			object.onmouseout = "null";

		}else {
			
			viewwrap.style.height = '';
			viewwrap.style.backgroundImage = 'url(/open_content/images/main/bg_banner_01.gif)';
			var objList = document.getElementById(objectid);
			var objListul = objList.getElementsByTagName('ul');
			objList.style.height = '50px';
			objList.style.paddingTop = '0';
			for (var i=0; i < objListul.length ; i++)
			{
				objListul[i].style.position = 'absolute';
				objListul[i].style.display = '';
			}
			if(!this.autoplay) return;
			this.autoplaytimer=setTimeout(objectid+'.next()',this.autoplaytime*1000);
			banbtn.style.display = '';
			banclose.style.display = 'block'
			bbtn.style.display = 'none';
		}
	};

    this.prev=function(){
        var prevno=(nowno==0)? itemsnum-1 : nowno-1;
        if(this.rotatemethod=='overlap') this.moveaction('overlap',prevno,'prev');
        else if(this.rotatemethod=='slide') this.moveaction('slide',prevno,'prev');
        else if(this.rotatemethod=='vertical') this.moveaction('vertical',prevno,'prev');
        else if(this.rotatemethod=='fadein') this.fadeinaction(prevno);
        else this.hideitem(prevno);
        this.settitlenpaging(prevno);
		if(this.buttonobject) this.setbtns(prevno);
    }
 
    this.next=function(){
        var nextno=(nowno==(itemsnum-1))? 0 : nowno+1;
        if(this.rotatemethod=='overlap') this.moveaction('overlap',nextno,'next');
        else if(this.rotatemethod=='slide') this.moveaction('slide',nextno,'next');
        else if(this.rotatemethod=='vertical') this.moveaction('vertical',nextno,'next');
        else if(this.rotatemethod=='fadein') this.fadeinaction(nextno);
        else this.hideitem(nextno);
        this.settitlenpaging(nextno);
        if(this.buttonobject) this.setbtns(nextno);
    }
 
    this.autoplaytimer=null;
    this.autoplayaction=function(){
        if(!this.autoplay) return;
        this.autoplaytimer=setTimeout(objectid+'.next()',this.autoplaytime*1000);
    }
 
    this.hideitem=function(no){
        clearTimeout(this.autoplaytimer);
        for(var i=0; i<itemsnum; i++) items[i].style.display=(i==no)? '' : 'none';
        this.autoplayaction();
        nowno=no;
    }
 
    var getleft=function(no){
        return parseInt(items[no].style.left);
    }
    var setleft=function(no,value){
        items[no].style.left=value+'px';
    }

	var gettop=function(no){
        return parseInt(items[no].style.top);
    }
	var settop=function(no,value){
        items[no].style.top=value+'px';
    }
 
    this.moveaction=function(method,no,direction){
        clearTimeout(this.autoplaytimer);
        if(canimove){
            canimove=false;

            if(method=='slide') setleft(no,(direction=='prev')? -(object.offsetWidth) : object.offsetWidth);
            if(method=='vertical') settop(no,(direction=='prev')? -(object.offsetHeight) : object.offsetHeight);
            
            this.setzindex(no);
            var nowv,now,snow,to=0,mv=0;
            var action=function(){
                clearTimeout(timer);
                now=getleft(no);
                nowv=gettop(no);

                if(method=='slide') snow=getleft(nowno);
				if(method=='vertical') snow=gettop(nowno);
                
                if(now!=to){
                    mv=(now-to)/speed;
                    setleft(no,(direction=='prev')? Math.ceil(now-mv) : Math.floor(now-mv));                  
                    if(method=='slide') setleft(nowno,(direction=='prev')? Math.ceil(snow-mv) : Math.floor(snow-mv));                   
                    setTimeout(action,10);
                }else if (nowv!=to)
                {
					mv=(nowv-to)/speed;
                    settop(no,(direction=='prev')? Math.ceil(nowv-mv) : Math.floor(nowv-mv));           
                    if(method=='vertical') settop(nowno,(direction=='prev')? Math.ceil(snow-mv) : Math.floor(snow-mv));
                    setTimeout(action,10);
                }
				else{
                    eval(objectid+'.autoplayaction()');
                    clearTimeout(timer);
                    canimove=true;
                    nowno=no;
                }
            }
            action();
        }
    }
 
    var getopacity=function(target){
        return (isie)? parseInt(target.style.filter.match(/alpha\(opacity=([0-9]+)\)/)[1]) : target.style.opacity*100;
    }
 
    var setopacity=function(target,value){
        if(isie) target.style.filter='alpha(opacity='+value+')';
        else target.style.opacity=value/100;
    }
 
    this.fadeinaction=function(no){
        clearTimeout(this.autoplaytimer);
        if(canimove){
            canimove=false;
            setopacity(items[no],0);
            this.setzindex(no);
            var nowo,to=0;
            var action=function(){
                clearTimeout(timer);
                nowo=getopacity(items[no]);
                if(nowo!=100){
                    setopacity(items[no],Math.ceil(nowo+(100-nowo)/speed));
                    setTimeout(action,10);
                }else{
                    eval(objectid+'.autoplayaction()');
                    clearTimeout(timer);
                    canimove=true;
                    nowno=no;
                }
            }
            action();
        }
    }
 
}

var scrollObj = function(targetEle, isVertical, sumMargin, movePx, startNum, interval, isInverse, stopDuration) {
	if (!document.getElementById) { return false; }
	if (!document.getElementsByTagName) { return false; }
	if (!document.getElementById(targetEle)) { return false; }
	
	var targetEle = document.getElementById(targetEle);
	var isVertical = (typeof isVertical != "undefined")? isVertical : false;
	var sumMargin = (typeof sumMargin != "undefined")? sumMargin : 0;
	var movePx = (typeof movePx != "undefined")? movePx : 1;
	var startNum = (typeof startNum != "undefined")? startNum : 2;

	this.interval = (typeof interval != "undefined")? interval : 25;
	this.isInverse = (typeof isInverse != "undefined")? isInverse : false;
	this.stopDuration = (typeof stopDuration != "undefined")? stopDuration : 0;
	this.isStop = false;
	
	if(!targetEle.getElementsByTagName("li")) { return false; }
	
	var liArray = targetEle.getElementsByTagName("li");
	if (liArray.length < startNum || startNum < 2) { return false; }

	for (var i = 0; i < startNum - 1; i++)
	{
		targetEle.insertBefore(liArray[liArray.length - 1], liArray[0]);
	}
	var currentPos = 0;
	for (var j = 0; j < startNum - 1; j++)
	{
		currentPos -= (isVertical)? (liArray[j].offsetHeight + sumMargin) : (liArray[j].offsetWidth + sumMargin);
	}
	var scrollOn = function (sender, timerInterval) {
		var newThis = sender;
		window.setTimeout(function () { newThis.scrollStart() }, timerInterval);
	}
	
	var stopDistance = 0;

	this.scrollStart = function () {
		if (!this.isStop) { 
			var moveDistance = (this.isInverse)? movePx : -movePx;
			currentPos = parseInt(currentPos) + moveDistance;
			stopDistance += moveDistance;
			var indexEle = (this.isInverse)? liArray[startNum - 2] : liArray[startNum - 1];
			var stopEleDim = (isVertical)? indexEle.offsetHeight + sumMargin : indexEle.offsetWidth + sumMargin;
			var moveInterval = this.interval;
			if (Math.abs(stopDistance) >= stopEleDim)
			{
				var lastEleDim = (isVertical)? liArray[liArray.length - 1].offsetHeight + sumMargin : liArray[liArray.length - 1].offsetWidth + sumMargin;
				var firstEleDim = (isVertical)? liArray[0].offsetHeight + sumMargin : liArray[0].offsetWidth + sumMargin;
				if (this.isInverse && stopDistance > 0)
				{
					currentPos  -= lastEleDim;
					currentPos -= (stopDistance - stopEleDim)
					targetEle.insertBefore(liArray[liArray.length - 1], liArray[0]);
					stopDistance = 0;
					moveInterval = this.stopDuration;
				} else if (!this.isInverse && stopDistance < 0) 
				{
					currentPos += firstEleDim;
					currentPos -= (stopDistance + stopEleDim)
					targetEle.appendChild(liArray[0]);
					stopDistance = 0;
					moveInterval = this.stopDuration;
				}
			}
			currentPos += "px";
			if (isVertical)
			{
				targetEle.style.top = currentPos;
			} else {
				targetEle.style.left = currentPos;
			}
		}
		scrollOn(this, moveInterval);
	}
	this.scrollStart();
}

function addoverimage(objid,onimagename){
    obj=document.getElementById(objid);
    imgs=obj.getElementsByTagName('img');
    for(var i=0,max=imgs.length; i<max; i++){
        imgs[i].onmouseover=function(){
            overimage(this,onimagename);
        }
    }
}
function overimage(obj,onimagename){
    var format=obj.src.substring(obj.src.lastIndexOf('.'));
    var onimagename=(onimagename)? onimagename+format : '_on'+format;
    if(obj.src.indexOf(onimagename)==-1) obj.src=obj.src.replace(format,onimagename);
    obj.onmouseout=function(){
        if(this.src.indexOf(onimagename)!=-1) this.src=this.src.replace(onimagename,format);
   }
}

/* GNB */
/* 
function gnbMenu(objNum, subNum) {
	var _d = document,
		outEventTime = 3, //본 레이어로 돌아가는 시간
		objID = _d.getElementById('navi'),
		objUl = objID.getElementsByTagName('ul'),
		objUlLength = objUl.length,
		objList = [],
		objImage = [],
		currentNum = 0,
		objSetTime;

	var initialize = function() {
		for (var i=0; i<objUlLength; i++) {
	
			if (i != 0) {
				objList[i] = objUl[i].parentNode;
				objImage[i] = objList[i].getElementsByTagName('img')[0];
				objEvent(i);
			}
		}

		
		if (objNum >= 0) {
			objNum = objNum + 1;
			objImage[objNum].src = objImage[objNum].src.replace('_off.gif', '_on.gif');
			objUl[objNum].style.display = 'block';
			
		}
		
	};

	var objEvent = function(num) {
		objList[num].onmouseover = function() {
			currentNum = num;
			clearTimeout(objSetTime);
			for (var i=0; i<objUlLength; i++) {
				if (i != 0) {
					if (i == num) {
						//Do nothing
					} else {
						objImage[i].src = objImage[i].src.replace('_on.gif', '_off.gif');
						objUl[i].style.display = 'none';
					}
				}
			}

			if (objImage[num].src.indexOf('_on.gif') == -1)
				objImage[num].src = objImage[num].src.replace('_off.gif', '_on.gif');

				
			objUl[num].style.display = 'block';

		};
		objList[num].onkeyup = objList[num].onmouseover;

		objID.onmouseout = function(e) {
			var evt = e || window.event;
			var relatedNode = evt.relatedTarget || evt.toElement;
			searchOutNode(relatedNode, this);
		};
	};

	var outEvent = function() {
		if (!objNum) {
			objImage[currentNum].src = objImage[currentNum].src.replace('_on.gif', '_off.gif');
			objUl[currentNum].style.display = 'none';

		} else if (objNum && currentNum != objNum) {
			if (objImage[objNum].src.indexOf('_on.gif') == -1)
				objImage[objNum].src = objImage[objNum].src.replace('_off.gif', '_on.gif');
				objUl[objNum].style.display = 'block';
			


			objImage[currentNum].src = objImage[currentNum].src.replace('_on.gif', '_off.gif');
			objUl[currentNum].style.display = 'none';
		}

		if (!subNum) {
			objImage[currentNum].src = objImage[currentNum].src.replace('_on.gif', '_off.gif');

		} else if (objNum && currentNum != objNum) {
			if (objImage[objNum].src.indexOf('_on.gif') == -1)
				objImage[objNum].src = objImage[objNum].src.replace('_off.gif', '_on.gif');
			


			objImage[currentNum].src = objImage[currentNum].src.replace('_on.gif', '_off.gif');
			objUl[currentNum].style.display = 'none';
		}
	};

	var searchOutNode = function (obj1, obj2) { //이벤트 버블링현상 제거
		while (obj1 != obj2) {
			if (!obj1) {
				objSetTime = setTimeout(outEvent, (outEventTime * 1000));
				return true;
			}
			obj1 = obj1.parentNode;
		}
		return false;
	};

	initialize();
}

*/
/* top navigation */
 
function initTopMenu(el,depth1) {

	topMenuOut(el,depth1,el.getElementsByTagName("img").item(0));
	
	if(el.id == "top-menu" + depth1) {
		topMenuOver(el.getElementsByTagName("img").item(0));
	}
}
function topMenuOver(img) {
	img.src = img.src.replace("_off.gif", "_on.gif");
}
function topMenuOut(el,depth1,img) {
	img.src = img.src.replace("_on.gif", "_off.gif");		
}

function selectTopmenuByMenuId() {
	var depth1 = this.id.substring("top-menu-head".length,this.id.length);
	var menuId = "sub-menu" + depth1;		
	var selectDepth1 = "top-" + depth1 + "-1";
	var topnav = document.getElementById("navi");
	if(!topnav) return;
	var topEl = topnav.getElementsByTagName("ul");
	for(i = 0 ; i < topEl.length ; i++){
		if(topEl[i].id.substring(0,12) == "top-sub-menu") {
			topEl[i].style.display = "none";
		}
	}
	var topEl2 = topnav.getElementsByTagName("li");
	for(i = 0 , seq = 1; i < topEl2.length ; i++){
		if(topEl2[i].id.substring(0,8) == "top-menu") {
			initTopMenu(topEl2[i],depth1);
		}
	}
	
	var nav = document.getElementById("top-" + menuId);
	if(!nav) return;
	nav.style.display = "block";
	menuEl = nav.getElementsByTagName("li");
	for(i = 0; i < menuEl.length; i++) {
		var imgEl = menuEl.item(i).getElementsByTagName("img")
		if(imgEl != null && imgEl.length>0) {
			imgEl.item(0).onmouseover = menuOver;
			imgEl.item(0).onmouseout = menuOut;
			imgEl.item(0).onfocus = menuOver;
			imgEl.item(0).onblur = menuOut;
		}
	}
} 

var m1_timerID;
var d1,d2,d3,d4,mid;

function initTopmenuByMenuId(depth1, depth2, depth3, depth4, menuId) {
	d1 = depth1;
	d2 = depth2;
	d3 = depth3;
	d4 = depth4;
	mid = menuId;
	var selectDepth1 = "top-" + depth1 + "-" + depth2;
	var selectDepth2 = "top-" + depth1 + "-" + depth2 + "-" + depth3;
	var selectDepth3 = "top-" + depth1 + "-" + depth2 + "-" + depth3 + "-" + depth4;
	var topnav = document.getElementById("navi");
	if(!topnav) return;
	var topEl = topnav.getElementsByTagName("ul");
	for(var i = 0 ; i < topEl.length ; i++){
		if(topEl[i].id.substring(0,12) == "top-sub-menu") {
			topEl[i].style.display = "none";
		}
	}
	
	var topEl2 = topnav.getElementsByTagName("a");

	for(i = 0, seq = 0 ; i < topEl2.length ; i++){
		if(topEl2[i].id.substring(0,13) == "top-menu-head") {
			topEl2[i].onmouseover =  selectTopmenuByMenuId;
			topEl2[i].onfocus = selectTopmenuByMenuId;
			if ( topEl2[i].id.substring(13) == depth1) {
				topEl2[i].onmouseover();
			}
			seq++;
		}
	}
	
	var nav = document.getElementById("top-" + menuId);
	if(!nav) return;
	nav.style.display = "block";
	menuEl = nav.getElementsByTagName("li");
	for(i = 0; i < menuEl.length; i++) {
		var menuElItm = menuEl.item(i);
		var imgEl = menuElItm.getElementsByTagName("img");
		if(imgEl == null || imgEl.length == 0)  {
			var aEl = menuElItm.getElementsByTagName("a");
			var itm = aEl.item(0);
			if (menuElItm.id == selectDepth1 || menuElItm.id == selectDepth2  || menuElItm.id == selectDepth3  ) {
				itm.className = "on";
			}
		} else {
			var itm = imgEl.item(0);
			if (menuElItm.id == selectDepth1 || menuElItm.id == selectDepth2  || menuElItm.id == selectDepth3  ) {
				itm.src = itm.src.replace("_off.gif", "_on.gif");
				itm.onmouseover = null;
				itm.onmouseout = null;
				itm.onfocus = null;
				itm.onblur = null;
			}
			else {
				itm.onmouseover = menuOver;
				itm.onmouseout = menuOut;
				itm.onfocus = menuOver;
				itm.onblur = menuOut;
			}
		}
	}
}

/* side navigation */
function initSubmenuByMenuId(depth1, depth2, depth3,depth4, menuId) {
	selectDepth1 = "menu" + depth1 + "-" + depth2;
	selectDepth2 = "menu" + depth1 + "-" + depth2 + "-" + depth3;
	selectDepth3 = "menu" + depth1 + "-" + depth2 + "-" + depth3 + "-" + depth4;

	//alert("selectDepth1: " + selectDepth1 + " , " + "selectDepth2: " + selectDepth2 + "selectDepth3: " + selectDepth3);
	nav = document.getElementById(menuId);
	if(!nav) return;
	menuEl = nav.getElementsByTagName("li");

	for (i = 0; i < menuEl.length; i++) {
	   
		if (menuEl.item(i).id == selectDepth1 || menuEl.item(i).id == selectDepth2  || menuEl.item(i).id == selectDepth3  ) {
			var im = menuEl.item(i).getElementsByTagName("img");
			if(im && im.length > 0 ) {
				im.item(0).src = im.item(0).src.replace("_off.gif", "_on.gif");
				//im.item(0).parentNode.parentNode.style.backgroundImage = 'url(/Image/common/bul/bl_arr02.gif)';
			}
			else {
				var anc = menuEl.item(i).getElementsByTagName("a");
				alert(anc)
				if(anc && anc.length > 0) {
					anc.item(0).className = "on";
					if(menuEl.item(i).id == selectDepth3) {
						anc.item(0).className += " leaf";
					}
				}
			}
		} else {
			var im = menuEl.item(i).getElementsByTagName("img");
			if( im == null || im.length == 0)  continue;
			im.item(0).onmouseover = menuOverS;
			im.item(0).onmouseout = menuOutS;
			im.item(0).onfocus = menuOverS;
			im.item(0).onblur = menuOutS;
			if (menuEl.item(i).getElementsByTagName("ul").item(0)) {
				menuEl.item(i).getElementsByTagName("ul").item(0).style.display = "none";
			}
		}
	}	
	menuId = "menu" + depth1;
	initTopmenuByMenuId(depth1,depth2,depth3,depth4,menuId);
}

/* roll over-out image */
function menuOver() {
	var s = this.src;
	s = s.replace("_on.gif", "_off.gif");
	this.src = s.replace("_off.gif", "_on.gif");
}

function menuOut() {
	this.src = this.src.replace("_on.gif", "_off.gif");	
}

function menuOverS() {
	var s = this.src;
	s = s.replace("_on.gif", "_off.gif");
	this.src = s.replace("_off.gif", "_on.gif");
	//this.parentNode.parentNode.style.backgroundImage = 'url(/Image/common/bul/bl_arr02.gif)';
}

function menuOutS() {
	this.src = this.src.replace("_on.gif", "_off.gif");	
	//this.parentNode.parentNode.style.backgroundImage = 'url(/Image/common/bul/bl_arr01.gif)';
}

function m1_mouseout(){
    m1_timerID = setTimeout("call()",500)

}

function m1_mouseover(){ 
    clearTimeout(m1_timerID)
}

function call(){
 if(d1 == "00") {
  //this.src = this.src.replace("_on.gif", "_off.gif"); 
  var topnav = document.getElementById("navi");
  var topEl2 = topnav.getElementsByTagName("li");
  for(i = 0 , seq = 1; i < topEl2.length ; i++){
   if(topEl2[i].id.substring(0,8) == "top-menu") {
    initTopMenu(topEl2[i],d1);
   }
  }
 }
 initTopmenuByMenuId(d1,d2,d3,d4,mid);
}

function initImgEffect(ImgEls,SelImg) {
	
	MenuImg = document.getElementById(ImgEls).getElementsByTagName("img");
	MenuImgLen = MenuImg.length;

	for (i=0; i<MenuImgLen; i++) {
		MenuImg.item(i).onmouseover = menuOver;
		MenuImg.item(i).onmouseout = menuOut;
		if (i == SelImg) {
			MenuImg.item(i).onmouseover();
			MenuImg.item(i).onmouseover = null;
			MenuImg.item(i).onmouseout = null;
		}
	}
}

//브라우저 종류 가져오기
function GetBrowserKind() {
    var browvalue = 'IE';
    var browser = navigator.userAgent;

    var bChrome = browser.indexOf('Chrome') > 0 ? true : false;
    var bIE = browser.indexOf('MSIE') > 0 ? true : false;
    var bFF = browser.indexOf('Firefox') > 0 ? true : false;
    var bOpera = browser.indexOf('Presto') > 0 ? true : false;

    if (bChrome == false && browser.indexOf('Safari') > 0) //Chrome에서도 Safari라는 명칭이 들어가 있으므로, Chrome글자를 처리해야함
        bSafari = true;

    if (bIE) {
        browvalue = 'IE';
        //if (browser.indexOf('MSIE 9.0') > 0) //IE 9.0이면,
        //    browvalue = 'IE 9.0';
    }
    else if (bFF)
        browvalue = 'FireFox';
    else if (bChrome)
        browvalue = 'Chrome';
    else if (bSafari)
        browvalue = 'Safari';
    else if (bOpera)
        browvalue = 'Opera';
    return browvalue;
}



//메뉴실행
function ExeMenu(first, second, third) {
    var xmlDoc = null;
    var xmlFile = "/swf/xml/menu.xml";
    jQuery.ajax({
        type: "get"
          , dataType: "xml"
          , url: xmlFile
          , success: function(xml) {
              xmlDoc = xml;
              var path = GetXPath(first, second, third);
              var node = xmlDoc.selectSingleNode(path);

              document.location.href = node.getAttribute("link");
              //location.href = node.getAttribute("link");
          }
           , error: function() { }
    });
}

//메뉴실행 XML경로 찾기
function GetXPath(first, second, third) {
    var temp = 0;
    var path = "NaviConfig/m" + first;

    //2Depth가 있으면,
    if (parseInt(second) > temp) {
        path += "/m" + second;

        //3Depth가 있으면,
        if (parseInt(third) > temp) {
            path += "/m" + third;
        }
    }

    
    return path;
}


