$(window).load(function(){

// slider easing settings 
speed = 600;
easing = 'easeInOutBack';


i=0;
amount = $("#featured_reel ul li").size();
slideSize = 240;
slides = slideSize * amount;
$('#featured_reel').css('width', slides + 480);
if(showSlideControls == true){
$('.controls').show();
}else{
$('.controls').hide();	
};
$('#featured_reel>ul>li:first').css('margin-left', 240);

$('#left_control').bind('click',function(){moveLeft();});
$('#right_control').bind('click',function(){moveRight();});

delay = 5000;
var timer;
timer = setInterval(function(){
	if(amount >= 5){
	moveRight();
	};
},delay);


function moveRight(){
if (!$('#featured_reel').is(':animated')) {
i++;
	$('#featured_reel').stop().animate({'left' : -480},speed,easing,function(){
	$('#featured_reel ul li:first').clone(true,true).appendTo('#featured_reel ul');
	$('#featured_reel ul li').css('margin-left', 0);
	$('#featured_reel').css('left', -240);
	$('#featured_reel ul li:first').remove();
	$('#featured_reel ul li:first').css('margin-left', 240);
	});};
};

function moveLeft(){
if (!$('#featured_reel').is(':animated')) {
i--;	
$('#featured_reel ul li:last').clone(true,true).prependTo('#featured_reel ul');
$('#featured_reel ul li').css('margin-left', 0);
$('#featured_reel').stop().animate({'left' : 0},speed,easing, function(){
	$('#featured_reel').css('left', -240);
	$('#featured_reel ul li:last').remove();
	$('#featured_reel ul li:first').css('margin-left', 240);
	});
};};

if(amount >= 5){
$('#featured_window_contain, .controls').mouseenter(function(){
	clearInterval(timer);
	if(showSlideControls == true){
		$('.controls').show();
	}else{
		if(!$(this).is(':animated')) {
			$('.controls').stop().fadeTo(200, 1, function(){$(this).show();});
		};	
	};
	});
$('#featured_window_contain').mouseleave(function(){
	clearInterval(timer);
	timer = setInterval(moveRight, delay);
	if(showSlideControls == true){
		$('.controls').show();
	}else{
		if(!$(this).is(':animated')) {
			$('.controls').stop().fadeTo(200, 0, function(){$(this).hide();});
		};
	};
	});
};

$('.feat_item a').bind('click',function(){
	whchFeatStr = $(this).attr('href').replace('#!/','');
	whchFeatType = whchFeatStr.substring(0, whchFeatStr.indexOf('-'));
	switch(whchFeatType) {
	case 'ent':
	window.open('http://www.parxcasino.com/calendar.php?id='+whchFeatStr,'_self');
	break;
	case 'jax':
	window.open('http://www.parxcasino.com/calendar.php?id='+whchFeatStr,'_self');
	break;		
	case 'gen':
	window.open('http://www.parxcasino.com/calendar.php?id='+whchFeatStr,'_self');
	break;	
	};
	if(whchFeatStr == 'visit'){
	window.open('http://www.parxcasino.com/visit.php','_self');
	};
});

$('#featured_reel li a').each(function(){
	if($(this).hasClass('buy now')){
		$(this).append('<div class="buy_tag"></div>');
	}else if($(this).hasClass('buy tickets')){
		$(this).append('<div class="tickets_tag"></div>');
	};
});

});
