var slideTimer;
var slide = 0;
function nextSlide() {
	slideTimer = setTimeout( "nextSlide()", 4000 );
	$content = $('.content');
	contentWidth = $content.width();
    var $active = $('.active', $content);
    if ( $active.length == 0 ) $active = $('.slide:last', $content);
	slide =  $active.next().length ? slide + 1 : 0;
	var $next = $('.slide', $content).eq(slide);
	$active.addClass('last-active');
	$('.slides .active').fadeTo(1000, 0.5);
	$('.slides li').eq(slide).addClass('active').fadeTo(1000, 1);
    $next.css({opacity: 1.0, left: contentWidth}).addClass('active').animate({left: 0}, 1000, function() {
		$active.removeClass('active last-active');
	});
}
function sizeAdjust() {
	windowWidth = $(window).width();
	windowHeight = $(window).height();
	if (windowWidth < 1000) {
		windowWidth = 1000;
	}
	if (windowHeight < 550) {
		windowHeight = 550;
	}
	browserWidth = windowWidth - 245;
	browserHeight = windowHeight - 100;
	if (browserWidth / browserHeight > 1.5) {
		contentHeight = browserHeight;
		contentWidth = Math.floor(contentHeight * 1.5);
	} else {
		contentWidth = browserWidth;
		contentHeight = Math.floor(contentWidth / 1.5);
	}
	$('.wrapper').width(contentWidth);
	$('.content').width(contentWidth);
	$('.content').height(contentHeight);
	$('.slide').width(contentWidth);
}
function interact() {
	jQuery.easing.def = "easeInOutExpo";
	sizeAdjust();
	$('.slides li:not(.active)').css({opacity: 0.5});
	slide = 0;
	//slideTimer = setTimeout( "nextSlide()", 2000 );
	$(window).resize(function(){
		sizeAdjust();
    });
	$('.slides li a').click(function() {
		clearTimeout(slideTimer);
		href = $(this).attr('href');
		slide = href.substr(href.length - 1, href.length) - 2;
		nextSlide();
		return false;
	});
}
$(document).ready(function() {interact();});
