// 롤오버

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

// 팝업

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
/*
// 모든 링크와 img 태그에 onfocus=blur() 처리
function bluring(){ 
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 
document.onfocusin=bluring; 
*/

/*
IE Flash ActiveContent Activation Script
Method: FlashObject
 Param1: SWF path
 Param2: Movie width
 Param3: Movie height
 Param4: BGColor
 Param5: Flashvars (Optional)
*/



function FlashObject(swf, width, height, bgcolor, id, flashvars)
{
    var strFlashTag = new String();
    if (navigator.appName.indexOf("Microsoft") != -1)
    {
		//익스
        strFlashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        strFlashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=version=8,0,0,0" ';
        strFlashTag += 'id="' + id + '" width="' + width + '" height="' + height + '">';
        strFlashTag += '<param name="movie" value="' + swf + '"/>';
        
        if(flashvars != null) {strFlashTag += '<param name="flashvars" value="' + flashvars + '"/>'};
        strFlashTag += '<param name="quality" value="best"/>';
        strFlashTag += '<param name="bgcolor" value="' + bgcolor + '"/>';
        strFlashTag += '<param name="menu" value="false"/>';
        strFlashTag += '<param name="salign" value="LT"/>';
        strFlashTag += '<param name="scale" value="noscale"/>';
        strFlashTag += '<param name="wmode" value="transparent"/>';
        strFlashTag += '<param name="allowScriptAccess" value="sameDomain"/>';
        strFlashTag += '</object>';
    }
    else
    {
    	//파폭
        strFlashTag += '<embed src="' + swf + '" ';
        strFlashTag += 'quality="best" ';
        strFlashTag += 'bgcolor="' + bgcolor + '" ';
        strFlashTag += 'width="' + width + '" ';
        strFlashTag += 'height="' + height + '" ';
        strFlashTag += 'menu="false" ';
        strFlashTag += 'scale="noscale" ';
        strFlashTag += 'id="' + id + '" ';
        strFlashTag += 'salign="LT" ';
         //strFlashTag += 'wmode="transparent" ';
        strFlashTag += 'allowScriptAccess="sameDomain" ';
        if(flashvars != null) {strFlashTag += 'flashvars="' + flashvars + '" '};
        strFlashTag += 'type="application/x-shockwave-flash" ';
        strFlashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        strFlashTag += '</embed>';
    }

 document.write(strFlashTag);
}

function popsite(ina)
{
	if(ina)window.open(ina);
}


//베너모듈
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 = 100; //움직이는 타임딜레이
	this.time_dealy_pause = 0;//하나의 대상이 새로 시작할 때 멈추는 시간, 0 이면 적용 안함
	this.time_timer=null;
	this.time_timer_pause=null;
	this.mouseover=false;
	this.init();
	this.set_direction(this.direction);
}
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();thisC.time_timer_pause=null;}
		if(this.time_timer_pause){clearTimeout(this.time_timer_pause);}
		this.time_timer_pause = window.setTimeout(act,this.time_dealy_pause);
		this.pause();
	}
}
js_rolling.prototype.pause = function(){ //일시 멈춤
	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
}
//제작
function to_pause(no){
	if(!no)	return false;
	if(no==1){
		roll1.pause();
	}
}
function to_pause2(no){
	if(!no)	return false;
	if(no==1){
		roll2.pause();
	}
}
//
function to_top(no){
	if(!no)	return false;
	if(no==1){
		roll1.pause();
		roll1.direction=1;
		roll1.resume();
	}

}

function to_bottom(no){
	if(!no)	return false;
	if(no==1){
		roll1.pause();
		roll1.direction=3;
		roll1.resume();
	}
}

function to_left(no){
	
	if(!no)	return false;
	if(no==1){
		roll2.pause();
		roll2.direction=4;
		roll2.resume();
	}

}

function to_right(no){
	if(!no)	return false;
	if(no==1){
		roll2.pause();
		roll2.direction=2;
		roll2.resume();
	}
}

function to_top(no){
	if(!no)	return false;
	if(no==1){
		roll1.pause();
		roll1.direction=1;
		roll1.resume();
	}

}

function to_bottom(no){
	if(!no)	return false;
	if(no==1){
		roll1.pause();
		roll1.direction=3;
		roll1.resume();
	}
}

function to_left(no){
	
	if(!no)	return false;
	if(no==1){
		roll2.pause();
		roll2.direction=4;
		roll2.resume();
	}

}

function to_right(no){
	if(!no)	return false;
	if(no==1){
		roll2.pause();
		roll2.direction=2;
		roll2.resume();
	}
}

/* 팝업존 */
//이미지 팝업존
var popup_timer = null;
var popup_delay_time = 4000;
var popup_pause = false;
var popup_button_pause = false;
var select_popup_num = 1;
  
function popup_display(popupIDX, move, strid, nochange) {
	if(!popupIDX)  {
  		popupIDX = select_popup_num;
  		if(popup_pause==true && !move) return;
  		if(popup_button_pause==true && !move) return;
  		if(!move) move = 'next';
  		hide_popup(strid, popupIDX);
  	}else{
		hide_popup(strid, select_popup_num);
  		show_popup(strid, popupIDX);
  	}
  	if(move=='prev') {
  		if(popupIDX==1) {
  			popupIDX = popup_object_num;
  		} else {
  			popupIDX--;
  		}
  	} else if(move=='next') {
  		if(popupIDX==popup_object_num) {
  			popupIDX = 1;
  		} else {
  			popupIDX++;
  		}
  	} else if(move=='pause') {
  		if(popup_button_pause==true) {
  			popup_button_pause=false;
			
			if(nochange != '1'){
	  			document.getElementById("popup_pause_img").src='/images/sliding_menu_btn12.gif';
	  			document.getElementById("popup_pause_img").alt='일시정지 팝업';
			}
  		} else if(popup_button_pause==false) {
  			popup_button_pause=true;	

			if(nochange != '1'){
  				document.getElementById("popup_pause_img").src='/images/sliding_menu_btn13_ov.gif';
  				document.getElementById("popup_pause_img").alt='재생 팝업'
			}
  		}
  	}
  	show_popup(strid, popupIDX);
  	select_popup_num = popupIDX;
}
  
function hide_popup(strid, num) {
  	document.getElementById(strid + num).style.display = 'none';
	document.getElementById("popup_number" + num).src = '/images/sliding_menu_btn' + num + '.gif';
//	document.getElementById("popup_number" + num).style.backgroundColor = "#eeeeee";
}
  
function show_popup(strid, num) {
  	document.getElementById(strid + num).style.display = 'block';
	document.getElementById("popup_number" + num).src = '/images/sliding_menu_btn' + num + '_ov.gif';
//	document.getElementById("popup_number" + num).style.backgroundColor = "#3cb203";
}

function popup_scroll(strid) {
  	popup_timer = setInterval("popup_display('','','"+strid+"')",popup_delay_time); 
}



/* 이벤트 존 용 */
var popup_timer2 = null;
var popup_delay_time2 = 3000;
var popup_pause2 = false;
var popup_button_pause2 = false;
var select_popup_num2 = 1;

function popup_display2(popupIDX, move, strid, nochange) {
	if(!popupIDX)  {
		popupIDX = select_popup_num2;
		if(popup_pause2==true && !move) return;
		if(popup_button_pause2==true && !move) return;
		if(!move) move = 'next';
		hide_popup2(strid, popupIDX);
	}else{
		hide_popup2(strid, select_popup_num2);
		show_popup2(strid, popupIDX);
	}
	if(move=='prev') {
		if(popupIDX==1) {
			popupIDX = event_main_num;
		} else {
			popupIDX--;
		}
	} else if(move=='next') {
		if(popupIDX==event_main_num) {
			popupIDX = 1;
		} else {
			popupIDX++;
		}
	} else if(move=='pause') {
		if(popup_button_pause2==true) {
			popup_button_pause2=false;
			
			if(nochange != '1'){
	  			document.getElementById("event_pause_img").src='/images/event_menu_pause.gif';
	  			document.getElementById("event_pause_img").alt='일시정지 팝업';
			}
		} else if(popup_button_pause==false) {
			popup_button_pause2=true;	

			if(nochange != '1'){
				document.getElementById("event_pause_img").src='/images/event_menu_pause_ov.gif';
				document.getElementById("event_pause_img").alt='재생 팝업'
			}
		}
	}
	show_popup2(strid, popupIDX);
	select_popup_num2 = popupIDX;
}

function hide_popup2(strid, num) {
	document.getElementById(strid + num).style.display = 'none';
	document.getElementById("event_number" + num).src = '/images/event_menu_btn' + num + '.gif';
//	document.getElementById("popup_number" + num).style.backgroundColor = "#eeeeee";
}

function show_popup2(strid, num) {
	
	document.getElementById(strid + num).style.display = 'block';
	document.getElementById("event_number" + num).src = '/images/event_menu_btn' + num + '_ov.gif';
//	document.getElementById("popup_number" + num).style.backgroundColor = "#3cb203";
}

function popup_scroll2(strid) {
	popup_timer2 = setInterval("popup_display2('','','"+strid+"')",popup_delay_time2); 
}
// 이벤트 용


//초기 DIV 레이어의 위치를 잡습니다.
function ImageSlide_Position(){
	var Position=0;
	Max=document.getElementsByName("slide_image").length;
	for(i=0; i<Max; i++){
		var DivID=document.getElementById("image_"+i);
		if(Direction=="left" || Direction=="right"){
			Position=i*DivWidth;
			DivID.style.left=Position+"px";
			DivID.style.top=0+"px";
		}else if(Direction=="top" || Direction=="bottom"){
			Position=i*DivHeight;
			DivID.style.top=Position+"px";
			DivID.style.left=0+"px";
		}
	}
}

//슬라이드 무빙을 시작합니다.
function ImageSlide_Move(){
	var MinX=DivWidth*(-1);
	var MaxX=(Max-1)*DivWidth;
	var MinY=DivHeight*(-1);
	var MaxY=(Max-1)*DivHeight;

	if(Max>=MoveNum){
		
		for(i=0; i<Max; i++){
			var DivID=document.getElementById("image_"+i);
			var Left=parseInt(DivID.style.left);
			var Top=parseInt(DivID.style.top);
						if(Direction=="left"){
				DivID.style.left=Left-Speed+"px";
				if(Left<=(MinX-Speed)){
					DivID.style.left=MaxX+"px";
				}
			}else if(Direction=="right"){
				DivID.style.left=Left+Speed+"px";
				if(Left>=(MaxX-Speed)){
					DivID.style.left=MinX+"px";
				}
			}else if(Direction=="top"){
				DivID.style.top=Top-Speed+"px";
				if(Top<=(MinY-Speed)){
					DivID.style.top=MaxY+"px";
				}
			}else if(Direction=="bottom"){
				DivID.style.top=Top+Speed+"px";
				if(Top>=(MaxY-Speed)){
					DivID.style.top=MinY+"px";
				}
			}
		}

		if(Mode=="t"){
			ChkNum ++;
		}else{
			ChkNum=0;
		}
		
		if(Direction=="left" || Direction=="right"){
			var Check=DivWidth;
		}else if(Direction=="top" || Direction=="bottom"){
			var Check=DivHeight;
		}

		if(ChkNum>=Check){
			StartImageSlide=window.setTimeout("ImageSlide_Start()",Limit);
			ChkNum=0;
		}else{
			ImageSlide_Start();
		}
	}else{
		clearTimeout(StartImageSlide);
	}
}

//슬라이드를 멈춥니다.
function ImageSlide_Stop(){
	clearTimeout(StartImageSlide);
}

//슬라이드를 시작합니다.
function ImageSlide_Start(){
	StartImageSlide=window.setTimeout("ImageSlide_Move()",1);
}

//슬라이드 방향을 변경합니다.
function ImageSlide_Direct(D){
	Direction=D;
	clearTimeout(StartImageSlide);
	StartImageSlide=window.setTimeout("ImageSlide_Move()",1);
}



