/* Quick Menu*/
function initMoving(target) {
	if (!target)
		return false;

	var obj = target;
	obj.initTop = 159;
	obj.initLeft = 918;
	obj.bottomLimit = document.documentElement.scrollHeight + 200;
	obj.topLimit = 159;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;
	obj.style.top = obj.top + "px";
	obj.style.left = obj.left + "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 235;
		}
	}
	obj.move = setInterval(function() {
		pos = obj.getTop() + obj.getHeight() / 3 - 200;//110;

		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";
	}, 40)
}

/* 글자 크기 조절 */
var fontSize = 12;
function  fn_font(type){
	if(type == 'plus' && fontSize < 20){
		fontSize = fontSize + 1;
	}
	if(type == 'minus'&& fontSize > 10){
		fontSize = fontSize - 1;
	}
	else if(type == 'default'){
		fontSize = 12;
	}
	document.body.style.fontSize = fontSize+"px";
}
/* 네비게이션 */
function topmenu(num,onoff,target) {
	if(onoff=="on") {

		if( target!=0 && document.getElementById('submenu'+target) ){
			document.getElementById("submenu"+target).style.display="none";
			document.getElementById("mainmenu"+target).className="mainmenu";
		}
		if(document.getElementById('submenu'+num)){
			document.getElementById("submenu"+num).style.display="block";
			document.getElementById("mainmenu"+num).className="mainmenu_on";
		}

	} else {
		if( target!=0 && document.getElementById('submenu'+target) ){
			document.getElementById("submenu"+target).style.display="block";
			document.getElementById("mainmenu"+target).className="mainmenu_on";
		}
		if(document.getElementById('submenu'+num)){
			document.getElementById("submenu"+num).style.display="none";
			document.getElementById("mainmenu"+num).className="mainmenu";
		}
	}
}

/* 통합검색 */
function divShow(){
 var divStatus = document.getElementById("search_cdn");
 if (divStatus.style.display == "block"){
 divStatus.style.display = "none";
 }else{
 divStatus.style.display = "block";
 }
}



/* rss 팝업*/
function rssService(){
	//window.open('/jsp/util/pop_rss.jsp','','width=470, height=595, top=0 , left=0 ,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no, resizable=yes');
	location.href = '/jsp/util/rsspage.jsp';
}

/* 직원검색 */
function empSearch(obj){
	if(obj.name == ''){
		alert('직원이름을 입력하세요.');
		return false;
	}
	return true;
}

/* email 팝업 */
function emaiPopup(){
	window.open('/jsp/util/reject.jsp','','width=470, height=210, top=0 , left=0 ,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no, resizable=yes');
}




/* Tab Content */

function initTabMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", "_off.gif");
				} else {
					currentmenu.className = currentmenu.className.replace("on", "");
				}
			}

			this.targetEl.style.display = "block";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace("_off.gif", "_on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

function menuOn(imgEl) {
	imgEl.src = imgEl.src.replace(".gif", "_on.gif");
}

function menuOut(imgEl) {
	imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}


function chTeb(val){

	for(i=0; i<5; i++) {
		document.getElementById("tabcon"+(i+1)).style.display = "none";
		document.getElementById("tab_con"+(i+1)).src = "/images/main_new/tab_menu"+(i+1)+"_off.gif";

	}

	document.getElementById("tabcon"+val).style.display = "block";
	document.getElementById("tab_con"+val).src = "/images/main_new/tab_menu"+val+"_on.gif";
}


var zoomRate = 5;			//확대/축소시 증감률
var maxRate = 150;			//최대확대률
var minRate = 50;			//최소축소률

function GetCookie(name){
	if (document.cookie != "") {
		zoomc = document.cookie.split("; ");
		for (var i=0; i < zoomc.length; i++) {
			zoomv = zoomc[i].split("=");
			if (zoomv[0] == name) {
				return  unescape(zoomv[1]);
			}
		}
	}else{
		return "";
	}
}

function SetCookie(name,value){
	document.cookie = name + "=" + escape (value)+";";
}

//Zoom In & Zoom Out
function zoomInOut(contentid, how) {

	if (GetCookie("zoomVal") != null && GetCookie("zoomVal") != ""){
		document.body.style.zoom = GetCookie("zoomVal");
		currZoom=GetCookie("zoomVal");
	}
	else{
		document.body.style.zoom = '100%';
		currZoom = '100%';
	}
	if (((how == "in") && (parseInt(currZoom) >= maxRate)) || ((how == "out") && (parseInt(currZoom) <= minRate)) ) {
		return;
	}
	if (how == "base") {
		return;
	}
	else if (how == "in") {
		document.body.style.zoom = parseInt(document.body.style.zoom)+zoomRate+'%';
	}
	else if (how == "out") {
		document.body.style.zoom = parseInt(document.body.style.zoom)-zoomRate+'%';
	}
	else {
		document.body.style.zoom = '100%';
	}
	SetCookie("zoomVal",document.body.style.zoom);
}

//	+, - key event
document.onkeypress = getKey;

function getKey(keyStroke) {
	isNetscape=(document.layers);
	eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
	which = String.fromCharCode(eventChooser).toLowerCase();
	which2 = eventChooser;

	var el=event.srcElement;

	if ((el.tagName != "INPUT") && (el.tagName != "TEXTAREA"))		//input,textarea 안에서의 +.-값은 실행안되도록
	{
		if(which == "+" )
			zoomInOut('zoom', 'in');
		else if(which == "-" )
			zoomInOut('zoom', 'out');
	}
}
