function getGames(league_id, odds_type, size, page_type) {
	$('.tabNavigation li a').removeClass('selected');
	$('.tabNavigation a#gamesmenu-league-'+league_id).addClass('selected');
	
	$('.games-table-active').removeClass('games-table-active');
	$('.tab-nav li a').removeClass('active');
	$('.tab-nav li a#menu-odds-'+odds_type).addClass('active');
	/*
	if($('#games-table-'+league_id+'-'+odds_type).length > 0) {
		$('.games-table').css('display', 'none');
		$('#games-table-'+league_id+'-'+odds_type).css('display', 'block');
		$('#games-table-'+league_id+'-'+odds_type).addClass('games-table-active');
	}else{
		$.get('/ajax/getmatches/league_id/'+league_id+'/odds_type/'+odds_type, function(data) {
			$('.games-table').css('display', 'none');
			$('.games-table:first').after(data);
			$('#games-table-'+league_id+'-'+odds_type).addClass('games-table-active');
			customSlideGalleryOdds();
		});
	}
	*/
	$('.games-table .is-loading').css('display', 'block');
	$.get('/ajax/getmatches/league_id/'+league_id+'/odds_type/'+odds_type+'/size/'+size+'/page_type/'+page_type, function(data) {
		$('.games-table').css('display', 'none');
		$('.games-table').replaceWith(data);
		$('#games-table-'+league_id+'-'+odds_type).addClass('games-table-active');
		$('#games-table-'+league_id+'-'+odds_type).addClass('games-table-home');
		customSlideGalleryOdds();
		update_sidebar_height();
	});
	
}

$(window).load(function() {
	customSlideGalleryOdds();
	update_sidebar_height();
	setTimeout(update_sidebar_height, 5000);

});

function update_sidebar_height() {
	var content		= $('#content-right-odds');
	var sidebar		= $('#content-left-main');
	content_height	= parseInt(content.height());
	content_height += parseInt(content.css('padding-top'));
	content_height += parseInt(content.css('padding-bottom'));
	sidebar_height	= parseInt(sidebar.height());
	sidebar_height += parseInt(sidebar.css('padding-top'));
	sidebar_height += parseInt(sidebar.css('padding-bottom'));
	if (sidebar_height > content_height) {
		content.css('height', sidebar_height);
	} else {
		sidebar.css('height', content_height);
	}
}

function customSlideGalleryOdds(){
	var _wrapper = $('.tabs');
	var speed = 500;
	_wrapper.each(function(){
		var _this = $(this);
		var _holder = _this.find('.odds-book');
		var _table = _holder.find('table');
		var _blockW = _holder.width();
		/*var _scrollHolder = _this.find('.more-payment');*/
		var _blockH = _table.outerHeight();
		var _btn = _this.find('.more-sportsbook');
		var _leftOffset = 0;
		var _offset = _leftOffset;
		var _curStep = 0;
		/*_scrollHolder.css({
			width:_leftOffset
		});*/
		var _block = $('<div class="table-wrap"><div class="table-hold"></div></div>');
		_holder.append(_block);
		var _hold = _this.find('.table-wrap');
		_hold.css({
			width:_blockW - _leftOffset,
			height:_blockH,
			left:_leftOffset
		});
		var _stepCount = Math.ceil(_table.outerWidth()/(_blockW - _leftOffset));
		var _stepWidth = _hold.outerWidth();
		var _sumWidth = _table.outerWidth();
		var _slider = _this.find('.table-hold');
		_slider.append(_table.clone()).css({
			marginLeft: -_leftOffset
		});
		
		// recalc 
		function recalc(){
			_stepWidth = _hold.outerWidth();
			if(_curStep != 0) _offset = -_stepWidth*_curStep - 5;
			else _offset = -_leftOffset - 3; 
			var _offset2=_offset;
			if(_offset < _stepWidth-_sumWidth) _offset = _stepWidth-_sumWidth-5;
			//alert('ancien: '+_offset2+"\nnouveau"+_offset+"\n_stepWidth="+_stepWidth+"\n_sumWidth"+_sumWidth);
		}
		
		// btnClick
		_btn.click(function(){
			nextSlide();
			return false;
		});
		
		
		// nextSlide
		
		function nextSlide() {
			recalc();
			if(_curStep < _stepCount-1) _curStep++;
			else _curStep = 0;
			switchSlide();
		}
		
		// switchSlide
		function switchSlide() {
			recalc();
			_slider.animate({marginLeft:_offset},{duration:speed,queue:false,easing:'swing'});
		}
		
		// added for the hover style
		_this.find('td.paiement-value').hover(function() {
			var _parent = $(this).parent();
			_parent.find('td.paiement-value').addClass('highlight-cell');
			var _index_nb = _parent.index();
			_this.find('.options-bookmaker:eq('+_index_nb+')').addClass('highlight-cell');
		}, function() {
			var _parent = $(this).parent();
			_parent.find('td.highlight-cell').removeClass('highlight-cell');
			var _index_nb = _parent.index();
			_this.find('.options-bookmaker:eq('+_index_nb+')').removeClass('highlight-cell');
		});
		
		_this.find('td.options-bookmaker').hover(function() {
			$(this).addClass('highlight-cell');
			var _index_nb = $(this).parent().index() + 1;
			_slider.find('tr:eq('+_index_nb+') td').addClass('highlight-cell');
		}, function() {
			$(this).removeClass('highlight-cell');
			var _index_nb = $(this).parent().index() + 1;
			_slider.find('tr:eq('+_index_nb+') td').removeClass('highlight-cell');
		});
		
	});
}


