<!--//
/**
* 레이어 이동 멀티 스크립트
* 목적 
* 다중 슬라이딩메뉴 + 위로가기 버튼생성
* 2007.04.05 center container offsetleft 기능추가
*/

function IEZN_quick_menu(input_obj){
	this.hide = new Array(0,0);
	try{
		this.input_obj = input_obj;
		this.input_obj.style.display = 'none';
	}catch(e){
		this.hide[1] = 1;
	}
	var IEZN_quick_menu_counter;
	IEZN_quick_menu_counter = (typeof(IEZN_quick_menu_counter)=='undefined')? 0:IEZN_quick_menu_counter++;
	this.counter = IEZN_quick_menu_counter;
	try{
		this.init();
	}catch(e){}
}

var IEZN_quick_menu_offsetLeft = function(container){
	var left = (parseInt(container.offsetLeft) + parseInt(container.offsetWidth));
	return left;
}

IEZN_quick_menu.prototype = {	
	init : function() {	
		this.move_ok = new Array();//이동허락
		this.move_img_src = new Array();//위,아래 아이콘 이미지 경로
		this.check_img_src = new Array();//슬라이딩 체크이미지
		this.div_obj_top = new Array();//고정 페이지 상단여백(이이상 안올라감)
		this.div_obj_max_move_top = new Array();//이동 페이지 상단여백(이이상 안올라감)
		this.div_obj_left = new Array();//메뉴위치 스몰슬라이딩,메인슬라이딩
		this.div_obj_use = new Array();
		this.timeId	 = new Array();
		this.div_obj = new Array();//sub,main layer object
	},

	
	move : function(){

		var obj = this;
		document.write("<div id='izqm0"+this.counter+"'></div>");
		document.write("<div id='izqm1"+this.counter+"'></div>");

		this.div_obj[0] = document.getElementById("izqm0"+this.counter);
		this.div_obj[1] = document.getElementById("izqm1"+this.counter);
		
		if(this.div_obj_use[0]==0) this.hide[0]=1;
		if(this.div_obj_use[1]==0) this.hide[1]=1;
	
		//선택 obj 에 대한 값을 기준으로 한다
		
		if(this.hide[1]==0){
			if(this.input_obj.style.top){
				this.div_obj_top[1] = parseInt(this.input_obj.style.top);
				this.div_obj_top[0] = this.div_obj_top[1]+50;
			}
			if(this.input_obj.style.left){
				if(typeof(document.getElementById('iezn_container'))=='object'){
					this.div_obj_left[1] = IEZN_quick_menu_offsetLeft(document.getElementById('iezn_container'));
					if(window.addEventListener){
						window.addEventListener('onresize',function(){
							IEZN_quick_menu_offsetLeft(document.getElementById('iezn_container'));
						});
					}else if(window.attachEvent){
						window.attachEvent('onresize',function(){
							var left = IEZN_quick_menu_offsetLeft(document.getElementById('iezn_container'));
							obj.div_obj_left[1] = left;
							obj.div_obj_left[0] = left+50;							
							obj.div_obj[1].style.left = left+'px';

						});
					}
				}else{
					this.div_obj_left[1] = parseInt(this.input_obj.style.left);
				}
				this.div_obj_left[0] = this.div_obj_left[1]-12;
			}
		}		

		if(this.div_obj_top[0]=="")	this.div_obj_top = Array(75,10);//고정 페이지 상단여백(이이상 안올라감)
		if(this.div_obj_left[0]=="") this.div_obj_left = Array(948,960);//메뉴위치 스몰슬라이딩,메인슬라이딩
		if(this.div_obj_max_move_top[0]=="") this.div_obj_max_move_top = Array(85,0);//이동 페이지 상단여백(이이상 안올라감)

		//서브 DIV	
		if(this.hide[0]==0){
			//this.div_obj[0] = document.createElement("div");
			//this.div_obj[0].id='izqm0'+this.counter;
			this.div_obj[0].style.position = 'absolute';
			this.div_obj[0].style.width='10px';
			this.div_obj[0].style.top = this.div_obj_top[0]+'px';
			this.div_obj[0].style.textAlign='center';
			this.div_obj[0].style.left=this.div_obj_left[0]+'px';
			this.div_obj[0].style.backgroundColor='transparent';
			try{
			document.body.appendChild(this.div_obj[0]);				
			}catch(e){}
		}

		//메인 DIV
		if(this.hide[1]==0){
			//this.div_obj[1] = document.createElement("div");
			//this.div_obj[1].id='izqm1'+this.counter;
			this.div_obj[1].style.position = 'absolute';
			this.div_obj[1].style.top=this.div_obj_top[1]+'px';
			this.div_obj[1].style.padding='0px';
			this.div_obj[1].style.left=this.div_obj_left[1]+'px';
			this.div_obj[1].style.backgroundColor='transparent';
			this.div_obj[1].style.overflow='hidden';
			this.div_obj[1].style.textOverflow='ellipsis';
			this.div_obj[1].style.width=this.input_obj.style.width;
			this.div_obj[1].style.border=this.input_obj.style.border;
			this.div_obj[1].style.padding=this.input_obj.style.padding;

			try{
				document.body.appendChild(this.div_obj[1]);			
				this.div_obj[1].innerHTML = this.input_obj.innerHTML;
			}catch(e){}
		}

		//위로이동 이미지 
		if(this.move_img_src[0]!="" && this.hide[0]==0){
			this.move_up_img = document.createElement("img");
			this.move_up_img.src = this.move_img_src[0];
			this.move_up_img.style.marginBottom = '2px';
			this.move_up_img.style.cursor = 'pointer';
			this.move_up_img.style.marginTop = this.div_obj_top[0]+'px';
			addEvent(this.move_up_img,'click',function(){window.scrollTo(0,0)});//move top
			try{
			this.div_obj[0].appendChild(this.move_up_img);
			}catch(e){}
		}
		if(this.hide[0]==0 && this.move_fix==0){
			this.hidden_check_img = new Object();
			this.hidden_check_img[0] = document.createElement("img");
			this.hidden_check_img[0].src = this.check_img_src[this.get_ck(0)];
			this.hidden_check_img[0].style.marginBottom = '2px';
			this.hidden_check_img[0].style.cursor = 'pointer';
			addEvent(this.hidden_check_img[0],'click',function(){obj.move_check(0)});
			try{
			this.div_obj[0].appendChild(this.hidden_check_img[0]);
			}catch(e){}
		}
		if(this.hide[1]==0 && this.move_fix==0){
			this.hidden_check_img[1] = document.createElement("img");
			this.hidden_check_img[1].src = this.check_img_src[this.get_ck(1)];
			this.hidden_check_img[1].style.marginBottom = '2px';
			this.hidden_check_img[1].style.cursor = 'pointer';
			addEvent(this.hidden_check_img[1],'click',function(){obj.move_check(1)});
			try{
			this.div_obj[0].appendChild(this.hidden_check_img[1]);
			}catch(e){}
		}
		//아래로이동 이미지 
		if(this.move_img_src[1]!="" && this.hide[0]==0){
			this.move_down_img = new Image();
			this.move_down_img.src = this.move_img_src[1];
			this.move_down_img.style.cursor = 'pointer';
			addEvent(this.move_down_img,'click',function(){window.scrollTo(0,parseInt(document.body.scrollHeight))});//move bottom
			try{
			this.div_obj[0].appendChild(this.move_down_img);
			}catch(e){}
		}
		for(var no=0;no<2;no++){
			if(typeof(this.div_obj[no])!='defined'){
				if(this.get_ck(no)==1){
					this.move_menu(no,1);
				}
			}
		}
		return true;
	},
	get_ck : function(no){
		v = (this.move_fix==1)? this.move_ok[no]:getCookie("mov["+this.div_obj[no].id+"]");
		if(v==null){
			return 0;
		}else{
			return v;
		}
	},
	set_ck : function(no,ck){
		if(this.move_fix==1){
			setCookie("mov["+this.div_obj[no].id+"]",this.move_ok[no],0);//고정
		}else{
			setCookie("mov["+this.div_obj[no].id+"]",ck,0);
		}
	},	
	move_check : function(no){
		if(this.get_ck(no)==1){//슬라이드 끄기
			window.clearTimeout(this.timeId[this.div_obj[no].id]);//타임삭제
			this.div_obj[no].style.top = parseInt(this.div_obj_top[no])+'px';//원위치로 이동
			this.hidden_check_img[no].src = this.check_img_src[0];
			this.set_ck(no,0);
		}else{
			this.hidden_check_img[no].src=this.check_img_src[1];
			this.set_ck(no,1);
			this.move_menu(no,1);
		}
	},
	move_menu : function (n,ck){
		var obj = this;
		if(ck==1){
			this.div_obj_start = parseInt(this.div_obj[n].style.top,10);
			this.div_obj_end = parseInt(scrollTop()) + parseInt(this.div_obj_max_move_top[n],10);//scroll top xhtml 1.0 check
			if (this.div_obj_end < parseInt(this.div_obj_top[n],10)) this.div_obj_end = parseInt(this.div_obj_top[n],10);
			if (this.div_obj_start != this.div_obj_end ) {
				this.div_obj_offset = Math.ceil(Math.abs( this.div_obj_end - this.div_obj_start ) / 15 );
				t = parseInt(this.div_obj[n].style.top, 10) + ((this.div_obj_end<this.div_obj_start)? this.div_obj_offset*-1:this.div_obj_offset);
				this.div_obj[n].style.top = t+'px';
				this.slide_time = 10;
			}
			this.timeId[this.div_obj[n].id] = window.setTimeout(function(){obj.move_menu(n,ck)},this.slide_time);
		}else{
			window.clearTimeout(this.timeId[this.div_obj[no].id]);
		}
	}
}
//-->


