/* png 파일 */
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 '';
}




/* 화면 확대,축소
-----------------------------------------------*/
var nowZoom = 100; // 현재비율
var maxZoom = 150; // 최대비율(500으로하면 5배까지 커진다)
var minZoom = 80;  // 최소비율

function zoomInOut(value) {

	var browser = navigator.userAgent.toLowerCase();
	if(browser.indexOf('msie') == -1){
		alert("익스플로러에서만 동작합니다. \n브라우저 메뉴의 확대축소 기능을 이용하세요.") ;
	}else {

		if(value == "in") {
			if (nowZoom < maxZoom) {
				nowZoom += 10;
			} else {
				alert("더이상 커지지 않습니다.");
				return;
			}
		}
		else if(value == "out") {
			if (nowZoom > minZoom) {
				nowZoom -= 10;
			} else {
				alert("더이상 작아지지 않습니다.");
				return;
			}
		}
		else if(value == "base") {
			nowZoom = 100;
		}
		else {
			return;
		}

		document.getElementsByTagName("body").item(0).style.position = "relative";
		document.getElementsByTagName("body").item(0).style.zoom = nowZoom + "%";
	}
}



// JavaScript Document


var currentFontSize = 3;
function zoomUtil(state, e){
		//alert('d')
	var idx;
	var arrFontSize = new Array();

	arrFontSize[0] = "65%";
	arrFontSize[1] = "75%";
	arrFontSize[2] = "85%";
	arrFontSize[3] = "100%";
	arrFontSize[4] = "110%";
	arrFontSize[5] = "120%";
	arrFontSize[6] = "130%";

	var e = e || window.event;
	if (e) {
		if (state == "in") {
			if (currentFontSize < 6 ) {
				idx = currentFontSize + 1;
				currentFontSize = idx;
			}else{
				idx = 6;
				currentFontSize = idx;
			}
		} else if (state == "default") {
			idx = 1;
			currentFontSize = idx;
		} else if (state == "out") {
			if ( currentFontSize >= 1) {
				idx = currentFontSize - 1;
				currentFontSize = idx;
			}else{
				idx = 0;
				currentFontSize = idx;
			}
		}
	}
	document.getElementById('wrap').style.zoom = arrFontSize[idx];
	document.body.style.zoom = arrFontSize[idx];
	return false;
}



var pageNum, pageNum2, pageNum3;

function gnb(){
	var GNB = KR('gnb');
	if(!GNB) return false;
	var one = GNB.child();
	var acTime = 1000;
	var subTag = "div";

	GNB.onmouseover = function(){
		clearTimeout(GNB.act)
		this.state = true;
		this.onmouseout = function(){
			this.state = false;
			start();
		}
	}
	//  img rollover
	// gnb Function
	for(i=0;i<one.length; i++){
		var btn = one[i].first('a');
		btn.n = i;
		btn.onmouseover = btn.onfocus = function(){
			clear();
			var img_1 = this.first('img');
			img_1.src = img_1.src.replace("_off","_on");
			one[this.n].style.zIndex="100";
			if(one[this.n].first(subTag))
				one[this.n].first(subTag).show();
		}
		if(!one[i].first(subTag)) continue;
		if(!one[i].first(subTag).first("ul")) continue;
		var two = one[i].first(subTag).first("ul").child();
		for(j=0;j<two.length; j++){
			var btn2 = two[j].first('a');
			btn2.onmouseover = function(){
				clearTimeout(GNB.act)
				var img = this.first('img'),twoAct = false;;
				if(this.className.indexOf('on')>=0) twoAct = true;
				else{
					if(img)
					img.src = img.src.replace('_off','_on');
					this.parent().addClass('on');
				}
				GNB.state = true;
				this.onmouseout = function(){
					if(!twoAct)
						if(img)
						img.src = img.src.replace('_on','_off');
					this.parent().removeClass('on')
					start();
					GNB.state = false;
				}
			}
			btn2.onfocus = function(){
				clearTimeout(GNB.act)
				var img = this.first('img'), twoAct = false;;
				if(img)
				if(img.src.indexOf('_on')>0) twoAct = true;
				if(img)
				img.src = img.src.replace('_off','_on');
				GNB.state = true;
				this.onblur = function(){
					if(!twoAct)
						if(img)
						img.src = img.src.replace('_on','_off');
					start();
					GNB.state = false;
				}
			}
		}

	}
	var start = function(){
		GNB.act = setTimeout(function(){
			if(!GNB.state) active();
		},acTime)
	}
	var clear = function(){
		for (i=0; i<one.length ; i++ ){
			one[i].style.zIndex="1"
			var img_1 = one[i].first('img');
			if(one[i].first(subTag))
				one[i].first(subTag).hide();
			if(img_1)
				img_1.src = img_1.src.replace("_on","_off")
		}
	}
	var active = function(){
		clear();
		if(subNum && one[subNum-1]){
			one[subNum-1].style.zIndex="100"
			var img_1 = one[subNum-1].first('img');
			img_1.src = img_1.src.replace("_off","_on");

			if(!one[subNum-1] || !one[subNum-1].first(subTag)) return false;
			if(!one[subNum-1] || !one[subNum-1].first(subTag).first("ul")) return false;
			var two = one[subNum-1].first(subTag).first("ul").child();
			one[subNum-1].first(subTag).show();
			if(pageNum && two[pageNum-1]){
				two[pageNum-1].first('a').className = "on";
				var twoIMG = two[pageNum-1].first('img');
				if(twoIMG)
				twoIMG.src = twoIMG.src.replace("_off","_on")
			}
		}
	}
	active();
}




var npop_flag = false;

function npop_change(value) { 

	if(value > npop_length) value = 1;
	if(value < 1) value = npop_length;
	current_popup=value;

	var maxSize = 0 + (20 * npop_length) ; 
	//for(i=npop_length;i>=1;i--) {
	var size =  0;
	for(i=1;i<=npop_length;i++) {
		//var size =  maxSize -  ( 15 * i );
		size =  (15 * i) - 8 ;
		if(obj = document.getElementById("npop_cont"+i)) {
			if(i==value) {
				if (!npop_flag )	{
					var left = (Number((document.getElementById("npop_num"+i).style.left).replace("px", "")) + size) + "px";
					obj.style.position="absolute";
					obj.style.top = "0px";
					obj.style.height = "0px";
					document.getElementById("npop_num"+i).style.position = "absolute";
					document.getElementById("npop_num"+i).style.left = left;
				}
				obj.style.display="block";
				document.getElementById("npop_num"+i).className = "on";
			} else {
				if (!npop_flag )	{
					var left = (Number((document.getElementById("npop_num"+i).style.left).replace("px", "")) + size) + "px";
					obj.style.position="absolute";
					obj.style.top = "0px";
					obj.style.height = "0px";
					document.getElementById("npop_num"+i).style.position = "absolute";
					document.getElementById("npop_num"+i).style.left = left;
				}
				obj.style.display="none";
				document.getElementById("npop_num"+i).className = "";
			}
		}
	} 
	npop_flag = true;
}
function npop_play(value) {
	if(value == 0) popup_play = 0;
	else if(value == 1) popup_play = 1;
	if(popup_play==1) {
	npop_change(current_popup+1);
	setTimeout("npop_play()", 3000);
	}
}

var npop_length;
var current_popup ;
var popup_play ;

/*
function npop_change(value) {
	if(value > npop_length) value = 1;
	if(value < 1) value = npop_length;
	current_popup=value;
	for(i=1;i<=npop_length;i++) {
		if(obj = document.getElementById("npop_cont"+i)) {
			if(i==value) {
				obj.style.display="block";
				obj.style.position="absolute";
				document.getElementById("npop_num"+i).className = "on";
				document.getElementById("npop_num"+i).style.position = "absolute";
			} else {
				obj.style.display="none";
				obj.style.position="absolute";
				obj.style.top = "0px";
				document.getElementById("npop_num"+i).className = "";
				document.getElementById("npop_num"+i).style.position = "absolute";
			}
		}
	}
}
function npop_play(value) {
	if(value == 0) popup_play = 0;
	else if(value == 1) popup_play = 1;
	if(popup_play==1) {
	npop_change(current_popup+1);
	setTimeout("npop_play()", 3000);
	}
}

var npop_length;
var current_popup ;
var popup_play ;
*/

var js_rolling = function(box){
		// 시간단위는 ms로 1000이 1초
		if(box.nodeType==1){
			this.box = box;
		}else{
			this.box = document.getElementById(box);
		}
		this.is_rolling = false;
		this.mouseover_pause = true;
		this.direction = 1; //1:top, 2:right, 3:bottom, 4:left (시계방향) // 1번과 4번만 됨
		this.children =	null;
		this.move_gap = 1;	//움직이는 픽셀단위
		this.time_dealy = 50; //움직이는 타임딜레이
		this.time_dealy_pause = 1000;//하나의 대상이 새로 시작할 때 멈추는 시간, 0 이면 적용 안함
		this.time_timer=null;
		this.time_timer_pause=null;
		this.mouseover=false;
		this.init();
		this.set_direction(this.direction);
		this.box.style.overflow='hidden';
	}
	js_rolling.prototype.init = function(){
		this.box.style.position='relative';
		this.box.style.overflow='hidden';
		var children = this.box.childNodes;
		for(var i=(children.length-1);0<=i;i--){
			if(children[i].nodeType==1){
				children[i].style.position='relative';
			}else{
				this.box.removeChild(children[i]);
			}
		}
		var thisC=this;

		this.box.onmouseover=function(){
			if(!thisC.mouseover_pause){	return;	}
			thisC.mouseover=true;
			if(!thisC.time_timer_pause){
				thisC.pause();
			}
		}
		this.box.onmouseout=function(){
			if(!thisC.mouseover_pause){return;}
			thisC.mouseover=false;
			if(!thisC.time_timer_pause){
				thisC.resume();
			}
		}	
	}
	js_rolling.prototype.set_direction = function(direction){
		this.direction=direction;
		if(this.direction==2 ||this.direction==4){
			this.box.style.whiteSpace='nowrap';
		}else{
			this.box.style.whiteSpace='normal';
		}
		var children = this.box.childNodes;
		for(var i=(children.length-1);0<=i;i--){
				if(this.direction==1){
					children[i].style.display='block';
				}else if(this.direction==2){
					children[i].style.textlign='right';
					children[i].style.display='inline';
				}else if(this.direction==3){
					children[i].style.display='block';
				}else if(this.direction==4){
					children[i].style.display='inline';
				}
		}
		this.init_element_children();	
	}
	js_rolling.prototype.init_element_children = function(){
		var children = this.box.childNodes;
		this.children = children;
		for(var i=(children.length-1);0<=i;i--){
				if(this.direction==1){
					children[i].style.top='0px';
				}else if(this.direction==2){
					children[i].style.left='-'+this.box.firstChild.offsetWidth+'px';
				}else if(this.direction==3){
					children[i].style.top='-'+this.box.firstChild.offsetHeight+'px';
				}else if(this.direction==4){
					children[i].style.left='0px';
				}
		}
	}
	js_rolling.prototype.act_move_up = function(){
		for(var i = 0,m=this.children.length;i<m;i++){
			var child = this.children[i];
			child.style.top=(parseInt(child.style.top)-this.move_gap)+'px';
		}
		if((this.children[0].offsetHeight+parseInt(this.children[0].style.top))<=0){
			this.box.appendChild(this.children[0]);
			this.init_element_children();
			this.pause_act();		
		}
	}
	js_rolling.prototype.move_up = function(){
		if(this.direction!=1&&this.direction!=3){return false;}
		this.box.appendChild(this.children[0]);
		this.init_element_children();
		this.pause_act();	
	}
	js_rolling.prototype.act_move_down = function(){
		for(var i = 0,m=this.children.length;i<m;i++){
			var child = this.children[i];
			child.style.top=(parseInt(child.style.top)+this.move_gap)+'px';
		}
		if(parseInt(this.children[0].style.top)>=0){
			this.box.insertBefore(this.box.lastChild,this.box.firstChild);
			this.init_element_children();
			this.pause_act();	
		}
	}
	js_rolling.prototype.move_down = function(){
		if(this.direction!=1&&this.direction!=3){return false;}	
		this.box.insertBefore(this.box.lastChild,this.box.firstChild);
		this.init_element_children();
		this.pause_act();
	}
	js_rolling.prototype.act_move_left = function(){
		for(var i = 0,m=this.children.length;i<m;i++){
			var child = this.children[i];
			child.style.left=(parseInt(child.style.left)-this.move_gap)+'px';
		}
		if((this.children[0].offsetWidth+parseInt(this.children[0].style.left))<=0){
			this.box.appendChild(this.box.firstChild);
			this.init_element_children();
			this.pause_act();		
		}
	}
	js_rolling.prototype.move_left = function(){
		if(this.direction!=2&&this.direction!=4){return false;}		
		this.box.appendChild(this.box.firstChild);
		this.init_element_children();
		this.pause_act();		
	}
	js_rolling.prototype.act_move_right = function(){
		for(var i = 0,m=this.children.length;i<m;i++){
			var child = this.children[i];
			child.style.left=(parseInt(child.style.left)+this.move_gap)+'px';
		}
		
		if(parseInt(this.box.lastChild.style.left)>=0){
			this.box.insertBefore(this.box.lastChild,this.box.firstChild);
			this.init_element_children();
			this.pause_act();		
		}
	}
	js_rolling.prototype.move_right = function(){
		if(this.direction!=2&&this.direction!=4){return false;}			
		this.box.insertBefore(this.box.lastChild,this.box.firstChild);
		this.init_element_children();
		this.pause_act();
	}
	js_rolling.prototype.start = function(){ //롤링 시작
		var thisC = this;
		this.stop();
		this.is_rolling = true;
		var act = function(){
			if(thisC.is_rolling){
				if(thisC.direction==1){thisC.act_move_up();}
				else if(thisC.direction==2){thisC.act_move_right();}
				else if(thisC.direction==3){thisC.act_move_down();}
				else if(thisC.direction==4){thisC.act_move_left();}
			}
		}
		this.time_timer = setInterval(act,this.time_dealy);
	}
	js_rolling.prototype.pause_act = function(){ //일시 동작
		if(this.time_dealy_pause){
			var thisC = this;
			var act = function(){thisC.resume();clearTimeout(thisC.time_timer_pause);thisC.time_timer_pause=null;}
			if(this.time_timer_pause){clearTimeout(this.time_timer_pause);}
			this.time_timer_pause = setTimeout(act,this.time_dealy_pause);
			this.is_rolling = false;
		}
	}
	js_rolling.prototype.pause = function(){ //일시 멈춤
		if(this.time_timer_pause){clearTimeout(this.time_timer_pause);}
		this.is_rolling = false;
	}
	js_rolling.prototype.resume = function(){ //일시 멈춤 해제
		if(!this.mouseover){
			this.is_rolling = true;
		}
	}
	js_rolling.prototype.stop = function(){ //롤링을 끝냄
		this.is_rolling = false;
		if(!this.time_timer){
			clearInterval(this.time_timer);
		}
		this.time_timer = null;
}

var ticker_news;



function tab(id,num){
	var activeTab = 0;
	var Box = KR(id);
	var tabA = Box.childsFirst('a');
	var tabLIst = Box.getElementsByTagName('div');
	for (i=0; i<tabLIst.length; i++)
	{
		var btn = tabA[i];
		btn.count = i;
		btn.onclick = btn.onfocus = function (){
			var tabIMG  = this.first('img');
			
			for (j=0; j<tabA.length; j++ )
			{	
				try{ tabA[j].first('img').src = tabA[j].first('img').src.replace('_on','_off')
				}catch(e){ tabA[j].className = tabA[j].className.replace('on','off')}
				tabLIst[j].style.display = 'none'
			}
			try{ tabIMG.src = tabIMG.src.replace('_off','_on')
			}catch(e){ this.className = this.className.replace('off','on')}
			tabLIst[this.count].style.display = '';
			activeTab = this.count;
			return false;
		}

		btn.onmouseover = function(){
			var img = this.getElementsByTagName('img')[0]
			if(img.src.indexOf('_on')>0) return false;
			img.src = img.src.replace('_off','_on');
			this.onmouseout  = function(){
				if(activeTab == this.count) return false;
					img.src = img.src.replace('_on','_off');
			}
		}
		tabLIst[i].style.display = 'none';
		tabLIst[i].style.position = "absolute";
	}
	tabLIst[0].style.display = '';
	tabLIst[0].style.position = "absolute";
}


function BoxController(id,num){
	var box = document.getElementById(id);
	var status = box.style.display;
	box.style.display = "none";
	status != "block" ? box.style.display = 'block': box.style.display = 'none';

}

function quickDpn(){
	var quickCnt = document.getElementById("layerQuick");
	quickCnt.style.display = "none";
}

function tabRoll(lBt,rBt,rot){
var lBtn = document.getElementById(lBt);
var rBtn = document.getElementById(rBt) ;
var root = document.getElementById(rot);
var roota = root.getElementsByTagName('li');
var nowNum = 2;
	root.style.height = "65px";
	root.style.overflow = "hidden";
	rBtn.onclick = function(){
		root.insertBefore(roota[roota.length-1],roota[0])
	}
	lBtn.onclick = function(){
		root.appendChild(roota[0])
	}
}


/* 배너슬라이드 */
var mainbanner_which = 0;
var mainbanner_timer = [];
var action = 'f';
// var main_totalSize = 6;
var main_totalSize = 1+1;
function mainbanner_forward(){
//	mainbanner_which++;
//	if (mainbanner_which > main_totalSize-1 || mainbanner_which < 0) mainbanner_which = 0;
//	for (var i=0;i<main_totalSize;i++) {
//		var fld = document.getElementById("mainbanner_"+i);
//		fld.style.display = (i == mainbanner_which) ? 'block' : 'none';
//	}
}
function mainbanner_backward(){
	mainbanner_which--;
	if (mainbanner_which < 0) mainbanner_which = main_totalSize-1;
	for (var i=0;i<main_totalSize;i++) {
		var fld = document.getElementById("mainbanner_"+i);
		fld.style.display = (i == mainbanner_which) ? 'block' : 'none';
	}
}
function mainbanner_Stopdisplay(){
	clearInterval(mainbanner_timer);
}
function mainbanner_Startdisplay(act){
	if (act == 'f'){
		action = 'f'
		mainbanner_Stopdisplay();
		mainbanner_timer = setInterval('mainbanner_forward()',3000);
	}else{
		action = 'b'
		mainbanner_Stopdisplay();
		mainbanner_timer = setInterval('mainbanner_backward()',3000);
	}
}
function cmainbanner_forward(){
	if (action == 'b'){
		action = 'f'
	}
	mainbanner_forward();
	mainbanner_Stopdisplay();
	mainbanner_Startdisplay('f');
}

function cmainbanner_backward(){
	if (action == 'f'){
		action = 'b';
	}
	mainbanner_backward();
	mainbanner_Stopdisplay();
	mainbanner_Startdisplay('b');
}
function banOFH(){
	var banner = document.getElementById('bannerImg');;
	banner.style.height = "27px";
	banner.style.overflow = "hidden";
}

mainbanner_Startdisplay('f'); 



function onLoadFunc(){
//	npop_length = document.getElementById("npop").getElementsByTagName("LI").length;
//	current_popup = 1;
//	popup_play = 0;

//	gnb();
//	npop_play(1);
//	npop_change(1);

//	ticker_news = null;
//	ticker_news = new js_rolling('rollTxt');
//	ticker_news.set_direction(1);
//	ticker_news.time_dealy = 50;
//	ticker_news.time_dealy_pause = 3000;
//	setTimeout('ticker_news.start()', 3000);

//	tab('tab',0);
//	tab('mainTab',1);
}

addLoadEvent(onLoadFunc)


