//슬라이드배너
var TINY={};

function T$(i){return document.getElementById(i)}
function T$$(e,p){return p.getElementsByTagName(e)}

TINY.slider=function(){
	function slide(n,p){this.n=n; this.init(p)}
	slide.prototype.init=function(p){
		var s=T$(p.id), u=this.u=T$$('ul',s)[0], c=T$$('li',u), l=c.length, i=this.l=this.c=0;
		if(p.navid&&p.activeclass){this.g=T$$('li',T$(p.navid)); this.s=p.activeclass}
		this.a=p.auto||0; this.p=p.resume||0; this.v=p.vertical||0; s.style.overflow='hidden';
		for(i;i<l;i++){if(c[i].parentNode==u){this.l++}}
		if(this.v){;
			u.style.top=0; this.h=p.height||c[0].offsetHeight; u.style.height=(this.l*this.h)+'px'
		}else{
			u.style.left=0; this.w=p.width||c[0].offsetWidth; u.style.width=(this.l*this.w)+'px'
		}
		this.pos(p.position||0,this.a?1:0)
	},
	slide.prototype.auto=function(){
		this.u.ai=setInterval(new Function(this.n+'.move(1,1)'),this.a*1000)
	},
	slide.prototype.move=function(d,a){
		var n=this.c+d, i=d==1?n==this.l?0:n:n<0?this.l-1:n; this.pos(i,a)
	},
	slide.prototype.pos=function(p,a){
		clearInterval(this.u.ai); clearInterval(this.u.si);
		var o=this.v?parseInt(this.u.style.top):parseInt(this.u.style.left),
		t=this.v?p*this.h:p*this.w, d=t>Math.abs(o)?1:-1; t=t*-1; this.c=p;
		if(this.g){for(var i=0;i<this.l;i++){this.g[i].className=i==p?this.s:''}}
		this.u.si=setInterval(new Function(this.n+'.slide('+t+','+d+','+a+')'),20)
	},
	slide.prototype.slide=function(t,d,a){
		var o=this.v?parseInt(this.u.style.top):parseInt(this.u.style.left);
		if(o==t){
			clearInterval(this.u.si); if(a||(this.a&&this.p)){this.auto()}
		}else{
			var v=o-Math.ceil(Math.abs(t-o)*.15)*d+'px';
			this.v?this.u.style.top=v:this.u.style.left=v
		}
	};
	return{slide:slide}
}();


//멤버십메인비주얼
function membership_visual(){
	for(i=1;i<=visualItemCount;i++){
		if(membership_visualTmpVal!=1) {
			membership_visualVal = membership_visualTmpVal;
			membership_visualTmpVal = 1;
		}
		if(membership_visualVal == visualItemCount+1)	membership_visualVal = 1;
		if(membership_visualVal == 0 )membership_visualVal = 1;
		id1 = "visualNum"+i
		id2 = "visualBanner_"+i
		if(membership_visualVal==i){
			document.getElementById(id1).src = "/img/membership/main_visual_btn_"+membership_visualVal+"_on.png";
			document.getElementById(id2).style.display	= "";
		}else{
			document.getElementById(id1).src = "/img/membership/main_visual_btn_"+i+".png";
			document.getElementById(id2).style.display	= "none";
		}
	}

	membership_visualVal = membership_visualVal + 1;
	autocontrolvar=setTimeout("membership_visual()",3000);
}


function membership_visualStop(chk){
	if(chk){
		clearTimeout(autocontrolvar);
	}else{
		clearTimeout(autocontrolvar);
		membership_visual();
	}
}

function membership_visualMove(num){
	for(i=1;i<=visualItemCount;i++){
		id1 = "visualNum"+i
		id2 = "visualBanner_"+i
		if(num==i){
			document.getElementById(id1).src = "/img/membership/main_visual_btn_"+num+"_on.png";
			document.getElementById(id2).style.display	= "";
		}else{
			document.getElementById(id1).src = "/img/membership/main_visual_btn_"+i+".png";
			document.getElementById(id2).style.display	= "none";
		}
	}
	membership_visualVal = num;
	membership_visualTmpVal = num;
	membership_visualStop(1);
}



//작은 숫자12345  배너
function bn_zone_small_red(){
	for(i=1;i<=bn_coount_small_red;i++){
		if(bn_zoneTmpVal_small_red!=1) {
			bn_zoneVal_small_red = bn_zoneTmpVal_small_red;
			bn_zoneTmpVal_small_red = 1;
		}
		if(bn_zoneVal_small_red == bn_coount_small_red+1)	bn_zoneVal_small_red = 1;
		if(bn_zoneVal_small_red == 0 )bn_zoneVal_small_red = 1;
		id1 = "btn_num_small_red"+i
		id2 = "bn_img_small_red_"+i
		if(bn_zoneVal_small_red==i){
			document.getElementById(id1).src = "/img/common/bn_s_no_"+bn_zoneVal_small_red+"_on.gif";
			document.getElementById(id2).style.display	= "";
		}else{
			document.getElementById(id1).src = "/img/common/bn_s_no_"+i+".gif";
			document.getElementById(id2).style.display	= "none";
		}
	}

	bn_zoneVal_small_red = bn_zoneVal_small_red + 1;
	autocontrolvar=setTimeout("bn_zone_small_red()",3000);
}


function btn_stop_small_red(chk_small_red){
	if(chk_small_red){
		clearTimeout(autocontrolvar);
	}else{
		clearTimeout(autocontrolvar);
		bn_zone_small_red();
	}
}

function btn_move_small_red(num_small_red){
	for(i=1;i<=bn_coount_small_red;i++){
		id1 = "btn_num_small_red"+i
		id2 = "bn_img_small_red_"+i
		if(num_small_red==i){
			document.getElementById(id1).src = "/img/common/bn_s_no_"+num_small_red+"_on.gif";
			document.getElementById(id2).style.display	= "";
		}else{
			document.getElementById(id1).src = "/img/common/bn_s_no_"+i+".gif";
			document.getElementById(id2).style.display	= "none";
		}
	}
	bn_zoneVal_small_red = num_small_red;
	bn_zoneTmpVal_small_red = num_small_red;
	btn_stop_small_red(1);
}


//버튼 오렌지색 12345배너
function bn_zone(){
	for(i=1;i<=bn_coount;i++){
		if(bn_zoneTmpVal!=1) {
			bn_zoneVal = bn_zoneTmpVal;
			bn_zoneTmpVal = 1;
		}
		if(bn_zoneVal == bn_coount+1)	bn_zoneVal = 1;
		if(bn_zoneVal == 0 )bn_zoneVal = 1;
		id1 = "btn_num"+i
		id2 = "bn_img_"+i
		if(bn_zoneVal==i){
			document.getElementById(id1).src = "/img/common/bn_no_"+bn_zoneVal+"_on.jpg";
			document.getElementById(id2).style.display	= "";
		}else{
			document.getElementById(id1).src = "/img/common/bn_no_"+i+".jpg";
			document.getElementById(id2).style.display	= "none";
		}
	}

	bn_zoneVal = bn_zoneVal + 1;
	autocontrolvar=setTimeout("bn_zone()",3000);
}


function btn_stop(chk){
	if(chk){
		clearTimeout(autocontrolvar);
	}else{
		clearTimeout(autocontrolvar);
		bn_zone();
	}
}

function btn_move(num){
	for(i=1;i<=bn_coount;i++){
		id1 = "btn_num"+i
		id2 = "bn_img_"+i
		if(num==i){
			document.getElementById(id1).src = "/img/common/bn_no_"+num+"_on.jpg";
			document.getElementById(id2).style.display	= "";
		}else{
			document.getElementById(id1).src = "/img/common/bn_no_"+i+".jpg";
			document.getElementById(id2).style.display	= "none";
		}
	}
	bn_zoneVal = num;
	bn_zoneTmpVal = num;
	btn_stop(1);
}

//버튼 노란색 12345배너 - 메인 법률중개사
function bn_zone_yellow(){
	for(i=1;i<=bn_coount_yellow;i++){
		if(bn_zoneTmpVal_yellow!=1) {
			bn_zoneVal_yellow = bn_zoneTmpVal_yellow;
			bn_zoneTmpVal_yellow = 1;
		}
		if(bn_zoneVal_yellow == bn_coount_yellow+1)	bn_zoneVal_yellow = 1;
		if(bn_zoneVal_yellow == 0 )bn_zoneVal_yellow = 1;
		id1 = "btn_num_yellow_"+i
		id2 = "bn_img_yellow_"+i
		if(bn_zoneVal_yellow==i){
			document.getElementById(id1).src = "/img/common/bn_no_"+bn_zoneVal_yellow+"_on_yellow.jpg";
			document.getElementById(id2).style.display	= "";
		}else{
			document.getElementById(id1).src = "/img/common/bn_no_"+i+".jpg";
			document.getElementById(id2).style.display	= "none";
		}
	}

	bn_zoneVal_yellow = bn_zoneVal_yellow + 1;
	autocontrolvar_yellow=setTimeout("bn_zone_yellow()",3000);
}


function btn_stop_yellow(chk_yellow){
	if(chk_yellow){
		clearTimeout(autocontrolvar_yellow);
	}else{
		clearTimeout(autocontrolvar_yellow);
		bn_zone_yellow();
	}
}

function btn_move_yellow(num){
	for(i=1;i<=bn_coount_yellow;i++){
		id1 = "btn_num_yellow_"+i
		id2 = "bn_img_yellow_"+i
		if(num==i){
			document.getElementById(id1).src = "/img/common/bn_no_"+num+"_on_yellow.jpg";
			document.getElementById(id2).style.display	= "";
		}else{
			document.getElementById(id1).src = "/img/common/bn_no_"+i+".jpg";
			document.getElementById(id2).style.display	= "none";
		}
	}
	bn_zoneVal_yellow = num;
	bn_zoneTmpVal_yellow = num;
	btn_stop_yellow(1);
}
