﻿(function($) {
	$(function() {
		// sidebar height fixed
		var _contentwrap_height = $('#contentWrap').height(),
			_sidebar_height = $('#sidebar');
		$(_sidebar_height).height(_contentwrap_height);
	
		// tab
		//$('.tab-anchor li a').click(function(){
		$('.tab-anchor li a#shoppingZone').click(function(){
			var _hash = this.hash,
				_tab_cont = $('.tab-cont');
				_parent = $('.tab-anchor li');
			_parent.removeClass('now');
			$(this).parent().addClass('now');
			$(_tab_cont).css('display', 'none');
			$(_hash).css('display','block');
			return false;
		});
		
		// 앤티비 인기채널
		$('.m-sidebar ul.popular-cont li').hover(function() {
			var _list = $('.m-sidebar ul.popular-cont li');
			
			_list.removeClass('now');
			$(this).addClass('now');
			// mouse out
			$(this).mouseleave(function(){
				_list.removeClass('now');
			});
		});
		
        // 썸네일 롤오버 마스크효과
		$('.thumb-video a').mouseenter(function() {
                            $(this).prepend('<span class="thumb-mask mask-v"></span>');
                     }).mouseleave(function() {
                            $('.thumb-mask').remove();
                     });
		$('.thumb-channel a').mouseenter(function() {
                            $(this).prepend('<span class="thumb-mask mask-c"></span>');
                     }).mouseleave(function() {
                            $('.thumb-mask').remove();
                     });
		
		// family Site
		$('.family-site .ctrl').click(function(){
			var _list = $('.family-site .list'),
				_ctrl = $('.family-site .ctrl'),
				_anchor = $('.family-site a');
				
			if(_list.css('display') == 'none'){
				_list.slideDown('fast');
			}else {
				_list.slideUp('fast');
			}
			$('.family-site').mouseleave(function(){
				_list.slideUp('fast');
			});
			$(_anchor).click(function(){
				_list.fadeOut('500');
			});
		});
		
		// bbs content control
		$('.bbs-typ01 .tb-left a').click(function(){
			var _hash = this.hash,
				_view_wrap = $('.view-cont-wrap'),
				_view_cont = $('.view-cont-wrap .view-cont'),
				_close = $('.view-cont-wrap .btn-close');
				
			_view_cont.slideUp('fast');
			
			$(_hash).slideDown('fast');
			$(_close).click(function(){
				$(_view_cont).slideUp('fast');
			});
			return false;
		});		
	});	
})(jQuery);
/*
*/

function rolling(options) {
    var self = this;
    this.object = document.getElementById(options.rollId);
    this.object.onmouseover = function() { self.stop(); };
    this.object.onmouseout = function() { self.play(); };
    this.delay = options.delay || 1000;
    this.speed = options.speed || 50;
    this.step = options.step || 1;
    this.mover = options.mover || false;
    this.elChildHeight = options.childHeight;
    this.elHeight = this.object.offsetHeight;
    this.elPosition = 0;
    this.object.appendChild(this.object.cloneNode(true));
    this.control = setTimeout(function() {self.play()}, this.delay);
}
rolling.prototype = {
    play:function() {
        var self = this, time;
        this.elPosition = this.elPosition>(this.mover?this.elHeight:0) ? this.elPosition-this.elHeight : this.elPosition+1;
        this.object.style.top = (this.mover ? -this.elPosition : this.elPosition) + "px";
        this.control = setTimeout(function() {self.play()}, this.elPosition%(this.elChildHeight*this.step)==0?this.delay:this.speed);
    },
    stop:function() {
        clearTimeout(this.control);
    }
}
var roll1 = null;
$(document).ready(function() {
    roll1 =  new rolling({rollId: "rollText1", delay: 3500, speed: 10, step: 1, mover: true, childHeight: 25});
});

