



//메인 롤링 이미지
function roll_main_img(time_x,speed){

		if(time_x/2 < speed)	time_x = 2*speed;

		var stopped	=	false;

		var count	=	$('#roll_img dl').length;
		var now = 1;
		var before	=	0;

		//y축 에니메이션
		var dl_roll	=	function(){
            
			if(!stopped){
				now++;
				now = (now>=(count+1)) ? 1 : now;
				$('#roll_border').animate({right:0,top:65*(now-1)},speed);

                var _index =   $("#roll_img dl").index($('#roll_img dl:visible')[0]);
                var _index_next  =  now-1;
                $("#roll_thumb div").eq(_index).css('filter','gray');
                $("#roll_thumb div").eq(_index_next).css('filter','');

                $('#roll_img dl:visible').addClass('fade_out').css('z-index','-1').fadeOut(speed,function(){
                    $(this).removeClass('fade_out');
                });
                $('#roll_img dl').eq(now-1).addClass('fade_in').css('z-index','0').fadeIn(speed,function(){
                    $(this).removeClass('fade_in');
                });
			}
			setTimeout(dl_roll,time_x);
		}
		
		//버튼에 의한 수동롤링
		var dl_roll_by_btn	=	function(a){
            if((a+1) != now){
                $('#roll_border').stop();
                $('#roll_img dl.fade_out').stop().removeClass('fade_out').hide().css('opacity',1);
                $('#roll_img dl.fade_in').stop().removeClass('fade_in').show().css('opacity',1);

                now	=	a+1;
                $('#roll_border').animate({right:0,top:65*(now-1)},speed);


                var _index =   $("#roll_img dl").index($('#roll_img dl:visible')[0]);
                var _index_next  =  now-1;
                $("#roll_thumb div").eq(_index).css('filter','gray');
                $("#roll_thumb div").eq(_index_next).css('filter','');

                $('#roll_img dl:visible').addClass('fade_out').css('z-index','-1').fadeOut(speed,function(){
                    $(this).removeClass('fade_out');
                });
                $('#roll_img dl').eq(now-1).addClass('fade_in').css('z-index','0').fadeIn(speed,function(){
                    $(this).removeClass('fade_in');
                });
            }
		}

		//지금버튼과 이전버튼의 상태를 바꾼다

		
		//마우스 오버시 롤링 스톱
		$('.main_show').mouseover(function(){stopped = true;});
		$('.main_show').mouseout(function(){stopped = false;});

		//버튼에 수동 rolling 달기
		$('#roll_thumb div').each(function(a,n){$(n).mouseover(function(){dl_roll_by_btn(a);})});
		setTimeout(dl_roll,time_x);
}


//	초기 이벤트 바인딩 부분
function load_init()	{
    roll_main_img(3000,400);
}
$(window).bind("load", load_init);

function layer_hide(srl){
    if(!srl)   return false;
    $('#layer_'+srl).remove();
}

function close_layer_today(srl){
    if(!srl)   return false;
	var now_date	=	new Date();
	var yy	=	now_date.getFullYear();
	var mm	=	now_date.getMonth();
	var dd	=	now_date.getDate();
	document.cookie = "qugou_layer_"+srl+"=" + escape('1') + ("; expires=" + new Date(yy, mm, dd, 23, 59, 59).toUTCString()) + "; path=/";
    $('#layer_'+srl).remove();
}
