
// quickmenu
function initMoving(target, topPosition, topLimit, btmLimit) {
	if (!target)
		return false;

	var obj = target;
	obj.initTop = topPosition;
	obj.topLimit = topLimit;
	obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;
	obj.style.top = obj.top + "px";

	obj.getTop = function() {
		if (document.documentElement.scrollTop) {
			return document.documentElement.scrollTop;
		} else if (window.pageYOffset) {
			return window.pageYOffset;
		} else {
			return 0;
		}
	}
	obj.getHeight = function() {
		if (self.innerHeight) {
			return self.innerHeight;
		} else if(document.documentElement.clientHeight) {
			return document.documentElement.clientHeight;
		} else {
			return 620;
		}
	}
	obj.move = setInterval(function() {
		//pos = obj.getTop() + obj.getHeight() / 2 - 15;
		pos = obj.getTop() + topPosition;

		if (pos > obj.bottomLimit)
			pos = obj.bottomLimit
		if (pos < obj.topLimit)
			pos = obj.topLimit

		interval = obj.top - pos;
		obj.top = obj.top - interval / 5;
		obj.style.top = obj.top + "px";
	}, 30)
	}

/*
//----------------------------------------------
//Floating v1.1 Source By Bermann
//dobermann75@gmail.com
//———————————————-
//new Floating(적용할개체 , X축여백 , Y축여백 , 미끄러지는속도:작을수록빠름..기본20 , 빠르기:작을수록부드러움..기본10);
function Floating(FloatingObj,MarginX,MarginY,Percentage,setTime) {
	this.FloatingObj = FloatingObj;
	this.FloatingObj.bottomLimit = document.documentElement.scrollHeight - 400;
	this.MarginX = (MarginX) ? MarginX : 0;
	this.MarginY = (MarginY) ? MarginY : 0;
	this.Percentage = (Percentage) ? Percentage : 20;
	this.setTime = (setTime) ? setTime : 10;
	this.FloatingObj.style.position = "absolute";
	this.Body = null;
	//this.setTimeOut = null;
	this.Run();
}

Floating.prototype.Run = function () {
	if ((document.documentElement.scrollLeft + document.documentElement.scrollTop) > (document.body.scrollLeft + document.body.scrollTop)) {
		this.Body = document.documentElement;
	} else {
		this.Body = document.body;
	}
	var This = this;
	var FloatingObjLeft = (this.FloatingObj.style.left) ? parseInt(this.FloatingObj.style.left,10) : this.FloatingObj.offsetLeft;
	var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top,10) : this.FloatingObj.offsetTop;
	var DocLeft = this.Body.scrollLeft + this.MarginX;
	var DocTop = this.Body.scrollTop + this.MarginY;
	var MoveX = Math.abs(FloatingObjLeft - DocLeft);
	MoveX = Math.ceil(MoveX / this.Percentage);
	var MoveY = Math.abs(FloatingObjTop - DocTop);
	MoveY = Math.ceil(MoveY / this.Percentage);
	if (FloatingObjLeft < DocLeft) {
		this.FloatingObj.style.left = FloatingObjLeft + MoveX + "px";
	} else {
		this.FloatingObj.style.left = FloatingObjLeft - MoveX + "px";
	}
	if (FloatingObjTop < DocTop) {
		this.FloatingObj.style.top = FloatingObjTop + MoveY + "px";
	} else {
		this.FloatingObj.style.top = FloatingObjTop - MoveY + "px";
	}
	window.clearTimeout(this.setTimeOut);
	this.setTimeOut = window.setTimeout(function () { This.Run(); },this.setTime);
}
*/

/* Flash 출력 */
function getFlash(id,url,w,h,t,bg){
	if(!t) var t='transparent'; if(!bg) var bg='none';
	var flashOut='<object type="application/x-shockwave-flash" data="' + url + '" width='+w+' height='+h+' id='+id+'>';
	flashOut+='<param name="movie" value='+url+'/><param name="wmode" value='+t+' /><param name="base" value="." /><param name="bgcolor" value='+bg+'/>';
	flashOut+='<param name="allowScriptAccess" value="sameDomain" /><param name="quality" value="high" /><param name="menu" value="false" />';
	//flashOut+='<embed base="." src='+url+' width='+w+' height='+h+' name='+id+' wmode='+t+' bgcolor='+bg+' swLiveConnect="true" allowScriptAccess="sameDomain" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	flashOut+='</object>';
	document.write(flashOut);
}

/*  Font Size 조절 */
function cntFontSize(value){
	//fontSize Setting
	if(document.body.style.fontSize == null || document.body.style.fontSize == ''){
		document.body.style.fontSize = "12px";
	}
	
	var fontSize = document.body.style.fontSize.replace("px","");
	
	if(value > 0 && fontSize < 20){
		document.body.style.fontSize = (parseInt(fontSize) + 2) + "px";
	}else if(value < 0 && fontSize > 9){
		document.body.style.fontSize = (parseInt(fontSize) - 1) + "px";
	}else if(value == 0){
		document.body.style.fontSize = "12px";
	}
}

var nowZoom = 100;
var maxZoom = 115;
var minZoom = 95;
var quickRight = 0;

function zoomInOut(how) {
	var browser = navigator.userAgent; 
	if(browser.indexOf('MSIE') < 0 && browser.indexOf('Safari') < 0 && browser.indexOf('Chrome') < 0){
		alert('Zoom 기능이 지원되지 않는 브라우저입니다. \nCtrl키를 누른 상태에서 +/-키를 누르세요.');
		return;
	}

	if (how == 'in' && nowZoom < maxZoom) {
		nowZoom += 5;
		quickRight -= 10;
	} else if (how == 'out' && nowZoom > minZoom) {
		nowZoom -= 5;
		quickRight += 10;
	} else if (how == 'init') {
		nowZoom = 100;
		quickRight = 0;
	}else {
		return;
	}

	document.getElementById('head').style.zoom = nowZoom + "%";
	document.getElementById('foot').style.zoom = nowZoom + "%";
	document.getElementById('quickMenu').style.zoom = nowZoom + "%";
	document.getElementById('quickMenu').style.right = quickRight + "px";
}

/* Print Page */
function printPage(URL){
	window.open('/common/print.jsp','print','toolbar=no,width=678,height=800,location=no,resizable=no,status=no,menubar=no,scrollbars=yes');
}

function MglmoMenu(obj) {
	var menu = document.getElementById(obj);
	menu.len = menu.childNodes.length;
	menu.topmenu = new Array();
	menu.menuseq = -1;
	menu.submenuseq = -1;
	menu.current = null;
	menu.subcurrent = null;
	menu.isOver = null;

	submenuTag = menu.getElementsByTagName("ul");

	for(i = 0; i < submenuTag.length; i++) {
		submenuTag.item(i).onmouseover = submenuTag.item(i).onfocus = function () {
			menu.isOver = true;
		}
		submenuTag.item(i).onmouseout = submenuTag.item(i).onblur = function () {
			menu.isOver = false;
			
			setTimeout(function () {
				if (menu.isOver == false) {
					if (menu.topmenu[menu.menuseq])
						menu.topmenu[menu.menuseq].onmouseover();
					else if(menu.current) {
						menuImg = menu.current.childNodes.item(0);
						menuImg.src = menuImg.src.replace("on.gif", ".gif");
						if (menu.current.submenu)
							menu.current.submenu.style.display = "none";
						menu.current = null;
					}
					if ( menu.menuseq == -1)
						document.getElementById("greetingMessage").style.display = 'block';
				}
			}, 300);
		}
	}

	//Menu item 정의
	for ( i = 0; i < menu.len; i++ ) {
		tempNode = menu.childNodes.item(i);

		//FF, Chrome 빈 textNode를 제외하고 추출
		if (tempNode.nodeType != '3') {
			var j = menu.topmenu.length;
			menu.topmenu[j] = tempNode.getElementsByTagName("a").item(0);
			menu.topmenu[j].submenu = tempNode.getElementsByTagName("ul").item(0);
			menu.topmenu[j].submenuA = new Array();

			for ( k = 0; k < tempNode.getElementsByTagName("ul").item(0).childNodes.length; k++ ) {
				tempChildNode = tempNode.getElementsByTagName("ul").item(0).childNodes.item(k);
				
				if (tempChildNode.nodeType != '3') {
					var l = menu.topmenu[j].submenuA.length;
					menu.topmenu[j].submenuA[l] = tempChildNode.getElementsByTagName("a").item(0);
				}
			}
		}
	}
	
	//Event 정의
	for ( i = 0; i < menu.topmenu.length; i++ )	{
		menu.topmenu[i].onmouseover = function () {
			if (menu.current) {
				menuImg = menu.current.childNodes.item(0);
				menuImg.src = menuImg.src.replace("on.gif", ".gif");
				if (menu.current.submenu)
					menu.current.submenu.style.display = "none";
				menu.current = null;
			}

			if (menu.current != this) {
				menuImg = this.childNodes.item(0);
				menuImg.src = menuImg.src.replace(".gif", "on.gif");
				menu.current = this;
				if (this.submenu)
					this.submenu.style.display = "block";
			} 

			menu.isOver = true;

			if (menu.menuseq == -1)
				document.getElementById("greetingMessage").style.display = 'none';
		}

		for ( j = 0; j < menu.topmenu[i].submenuA.length; j++ )	{
			menu.topmenu[i].submenuA[j].onmouseover = function() {
				
				if (menu.subcurrent != this) {
					menuImg = this.childNodes.item(0);
					if ( menuImg.src.indexOf("on.gif") < 0 ) 
						menuImg.src = menuImg.src.replace(".gif", "on.gif");
				} 
				
				menu.isOver = true;

				if (menu.menuseq == -1)
					document.getElementById("greetingMessage").style.display = 'none';
			}
			menu.topmenu[i].submenuA[j].onmouseout = function() {
				if (menu.subcurrent != this) {
					menuImg = this.childNodes.item(0);
					menuImg.src = menuImg.src.replace("on.gif", ".gif");
				}
				menu.isOver == false
			}
		}

		menu.topmenu[i].onmouseout = function () {
		}
	}
	
	this.init = function(menuSeq, submenuSeq) {
		if (menuSeq != '-1') {		
			if (menu.topmenu[menuSeq])
				menu.topmenu[menuSeq].onmouseover();
		} 

		if (menuSeq != '-1' && submenuSeq != '-1') {		
			if (menu.topmenu[menuSeq].submenuA[submenuSeq]) {
				menu.topmenu[menuSeq].submenuA[submenuSeq].childNodes.item(0).src 
					= menu.topmenu[menuSeq].submenuA[submenuSeq].childNodes.item(0).src.replace(".gif", "on.gif");
				menu.subcurrent = menu.topmenu[menuSeq].submenuA[submenuSeq]
			}
		} 
			
		menu.menuseq = menuSeq;
		menu.submenuseq = submenuSeq
		
		if (menu.menuseq == -1)
			document.getElementById("greetingMessage").style.display = 'block';
	}
}


function molegIntro(){
	var popup = isPopup();
	
	if(popup){
		WinCenterOpen('/introduction/molegIntro.html','Intro', 850, 600,'scrollbars=no,resize=no');
	}else{
		var html = "<div style='text-area:center;background-color:#000000;'><a href='#' onclick='Shadowbox.close();return false;' onkeypress='this.onclick();'><img src='/images/common/intro_moleg_close.gif' width='850px' height='17px'/></a>";
		html = html +   "<object type='application/x-shockwave-flash' data='/swf/moleg_intro.swf' width='850' height='600' id='moleg_intro' align='middle'>"
					+		"<param name='allowScriptAccess' value='always' />"
					+		"<param name='movie' value='/swf/moleg_intro.swf' />"
					+		"<param name='quality' value='high' />"
					+		"<param name='bgcolor' value='#000000' />"
					//+		"<embed src='/swf/moleg_intro.swf' quality='high' bgcolor='#000000' width='850' height='600' name='moleg_intro' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'/>"
					+	"</object></div>";
		
	
		var options = {
	    	player:     		'html',
	        content:    		html,
	        width:      		852,
	        height:     		619
	    };
	    
		Shadowbox.open(options);
	}
}

function molegPR(lang){
	var w = lang=='kor' ? 583 : 643;
	var h = lang=='kor' ? 592 : 500;
	
	var options = {
    	player:     		'iframe',
        content:    		'/introduction/movieView_'+lang+'.html',
        width:      		w,
        height:     		h
    };
    
	Shadowbox.open(options);
}

function molegPR2(lang){

	var w = 582;
	var h = 592;
	
	var options = {
    	player:     		'iframe',
        content:    		'/introduction/movieView_'+lang+'.html',
        width:      		w,
        height:     		h
    };
    
	Shadowbox.open(options);
}

function oneclickPR(){
	var options = {
    	player:     		'iframe',
        content:    		'/introduction/oneclickPR.html',
        width:      		817,
        height:     		619
    };
    
	Shadowbox.open(options);
}

function isPopup(){
  var popup = true;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth-20;
    myHeight = window.innerHeight-20;
    
    if(myWidth > 890 && myHeight > 722)
    	popup = false;
    
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
    
    if(myWidth > 894 && myHeight > 703)
    	popup = false;
  }
  
  return popup;
}

/* 팝업창 */
function WinCenterOpen(strUrl, strWinName, intWidth, intHeight, strOption){
    if (screen.width <= 800){
        intTop=0;
        intLeft=0;
    }
    else {
        intTop = (screen.height)?(screen.height-intHeight)/2:100;
        intLeft = (screen.width)?(screen.width-intWidth)/2:100;
    }
    if(strOption.length > 0) strOption = "," + strOption;
    window.open(strUrl, strWinName, "top="+intTop+", left="+intLeft+", width="+intWidth+", height="+intHeight + strOption);
}
/* 팝업창 */
function WinOpen(strUrl, strWinName, strOption){
    window.open(strUrl, strWinName, strOption);
}
function getCookie(name) { 
	var Found = false; 
	var start, end;
	var i = 0;
	 
	while(i <= document.cookie.length) { 
		start = i; 
		end = start + name.length;
	  
		if(document.cookie.substring(start, end) == name) { 
			Found = true; 
			break; 
		} 
		i++; 
	} 
	if(Found == true) { 
		start = end + 1; 
		end = document.cookie.indexOf(";", start); 
		if(end < start) 
			end = document.cookie.length; 
	 	return document.cookie.substring(start, end); 
	} 
	 
	return "";
}

/*************************** wiselog start ******************************************/
function Nethru_getCookieVal(offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function Nethru_SetCookie(name, value){
   var argv = Nethru_SetCookie.arguments;
   var argc = Nethru_SetCookie.arguments.length;
   var expires = (2 < argc) ? argv[2] : null;
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;

  // alert("DOMAIN = " + domain);
   document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires="+expires.toGMTString())) +
     ((path == null) ? "" : ("; path=" + path)) +
     ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");

//	alert(document.cookie);
}

function Nethru_GetCookie(name){
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen)
      {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return Nethru_getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0)
         break;
      }
  return null;
}

function Nethru_makePersistentCookie(name,length,path,domain)
{
    var today = new Date();
    var expiredDate = new Date(2100,1,1);
    var cookie;
	var value;

    cookie = Nethru_GetCookie(name);
    if ( cookie ) {
//		alert(cookie);
        return 1;
	}

	var values = new Array();
	for ( i=0; i < length ; i++ ) {
		values[i] = "" + Math.random();
	}

	value = today.getTime();

	// use first decimal
	for ( i=0; i < length ; i++ ) {
		value += values[i].charAt(2);
	}

    Nethru_SetCookie(name,value,expiredDate,path,domain);
}

function Nethru_getDomain() {
	var _host   = document.domain;
	var so      = _host.split('.');
	var dm    = so[so.length-2] + '.' + so[so.length-1];
	return (so[so.length-1].length == 2) ? so[so.length-3] + '.' + dm : dm;
}

var Nethru_domain  = Nethru_getDomain();

Nethru_makePersistentCookie("PCID",10,"/",Nethru_domain);
/*************************** wiselog end ******************************************/
