// JavaScript Document

var now_show = 0;
var all_list = null;

function gGoNext(el) {
	all_list[now_show].style.display = 'none';
	all_list.removeClass('active');
	$(all_list[now_show+1]).addClass('active');
	switchBimg(now_show+2);
	all_list[now_show+4].style.display = '';
	now_show++;
	if (all_list[all_list.length-1].style.display == '')
		el.style.visibility = 'hidden';
	if (all_list[0].style.display == 'none')
		$('#gprev').css('visibility','visible')
}

function gGoPrev(el) {
	all_list[now_show+3].style.display = 'none';
	all_list.removeClass('active');
	$(all_list[now_show]).addClass('active');
	switchBimg(now_show);
	all_list[now_show-1].style.display = '';
	now_show--;
	
	if (all_list[0].style.display == '')
		el.style.visibility = 'hidden';
	$('#gnext').css('visibility','visible')
}

$(document).ready(function(){
	var ul = $('#tabs ul');
	if (ul.length > 0) {
		all_list = ul.find('li')
		all_list.each(function(i){
			if (i > 3)
				this.style.display = 'none'
		})
		var prev = $('<span style="float: left; display: block; position: relative; width: 11px; top: 33px;"><img id="gprev" style="visibility:hidden;cursor:pointer;" src="/images/i-left.gif" width="10" height="16" /></span>');
		prev.insertBefore(ul);
		var next = $('<span style="float: left; display: block; position: relative; width: 11px; text-align:right; top: 33px;"><img  id="gnext" style="visibility:hidden;cursor:pointer;" src="/images/i-right.gif" width="10" height="16" /></span>');
		next.insertAfter(ul);
		
		if (all_list.length > 4) {
			next.find('img')[0].style.visibility = 'visible';
		}

		next.find('img').click(function(){
			gGoNext(this);
		})
		prev.find('img').click(function(){
			gGoPrev(this);
		})
	}



$('table.tbl-content tr.even-row').each(function(){
	this.className = this.className.replace('even-row','');
})
$("table.tbl-content tr:nth-child(odd)").addClass("even-row");


$('div.b-video-item:first').addClass('b-video-item-active');
$('div.b-video-item img').bind('click',function(){
	$('div.b-video-item').removeClass('b-video-item-active');
	$(this).parent().addClass('b-video-item-active');
})
$('div.b-video-item a:nth-child(even)').bind('click',function(){
	$('div.b-video-item').removeClass('b-video-item-active');
	$(this).parent().parent().parent().addClass('b-video-item-active');
})


$('#tabs-box ins').hide();
$('#tabs-box ins:first').show();
$('#tabs-box ul li:first').addClass('active');
$('#tabs-box ul li a').click(function(){ 
$('#tabs-box ul li').removeClass('active');
$(this).parent().addClass('active'); 
var currentTab = $(this).attr('href').replace('l-',''); 
$('#tabs-box ins').hide();
$(currentTab).show();
return false;
});
});


var nsw = 1;
function switchBimg(id) {
	$('#tabb-'+nsw).hide();
	$('#tabb-'+id).show();
	nsw = id;
	var el = $('#tabs').find('li.active')[0];
	if ($(el).hasClass('last')) {
		el.className = 'last last-noactive'
	} else if ($(el).hasClass('first')) {
		el.className = 'first first-noactive'
	} else {
		el.className = ''
	}
	var el = $('#tabs').find('li')[id-1];
	if ($(el).hasClass('last')) {
		el.className = 'last last-active active'
	} else if ($(el).hasClass('first')) {
		el.className = 'first first-active active'
	} else {
		el.className = 'active'
	}
}

