function bindMore() {
	$('.b-random-combination._poker .more').bind('click', function(e) {
		e.preventDefault();
		image = $('#shirt-first'); 
		image.animate({top: '85px'}, 1000, function() {
			$('#hidden-card').fadeIn(1000);
			$('.b-random-combination._poker h5').fadeIn(1000, function() {
				$('.b-combination-info').click(function(e) {  
					$.get($(e.currentTarget).attr('href'), function(data) {
						$(data).modal({
							closeHtml: '<a href="#" title="Закрыть" class="simplemodal-close">X</a>',
							position: ['28%',],
							overlayId: 'simplemodal-overlay',
							containerId: 'simplemodal-container',
							onOpen: function(dialog) {
								dialog.data.fadeIn(200, function () {
									dialog.container.fadeIn(200, function () {
										dialog.overlay.fadeIn(200);
									});
								});
                        	},
                        	onClose: function(dialog) {
                        		dialog.data.fadeOut(200, function () {
                        			dialog.container.fadeOut(200, function () {
                        				dialog.overlay.fadeOut(200, function () {
                        					$.get('/poker', function(data){
                        						$('.b-random-combination._poker').replaceWith(data);
                        						bindMore();
                        					}); 
                        					$.modal.close(); 
                        				});
                        			});
                        		});
                        	}
						});
					});
					
					return false;    
                });
			});
			
			image.fadeOut(1000);
		});
    
		return false;
	});
}

function bindBlackjack(){
	$('.b-random-combination._blackjack .more').bind('click', function(e) {
		e.preventDefault();
		$('._blackjack .more').remove();
		image = $('._blackjack #shirt-first'); 
		image.animate({top: '85px'}, 1000, function() {
			$('._blackjack #hidden-card').fadeIn(1000);
			$('.b-random-combination._blackjack h5').fadeIn(1000);
			image.fadeOut(1000);
		});
    
		return false;
	});
}

function bindBlackjackReload(){
	$('.b-random-combination._blackjack .reload').bind('click', function(e) {
		e.preventDefault();
		$.get('/blackjack', function(data){
			$('.b-random-combination._blackjack').replaceWith(data);
			bindBlackjack();
			bindBlackjackReload();
		});
	});
	return false;
}
$(document).ready(function() {
	bindMore();
	bindBlackjack();
	bindBlackjackReload();
});
