var time;
$('document').ready(function() {
	$('.js-home li').each(function(i,el) {
		if (i == 0) {
			$(this).css({"left":"0px"});
		} else if (i == 1) {
			$(this).css({"left":"44px"});
		} else if (i== 2) {
			$(this).css({"left":"88px"});
		} else if (i==3) {
			$(this).css({"left":"132px"});
		}
	});
	
	$('.js-home li').click(function() {
		if ($('.js-home li').index($(this)) == 0) {
			window.location.href = 'http://isvonline.org/catalog/browse/programs';
		} else if ($('.js-home li').index($(this)) == 1) {
			window.location.href = 'http://isvonline.org/catalog/browse/volunteer_projects';
		} else if ($('.js-home li').index($(this)) == 2) {
			window.location.href = 'http://isvonline.org/catalog/browse/adventure';
		} else {
			window.location.href = 'http://isvonline.org/catalog/browse/destinations';
		}
		
		
		return false;
	});
	
	time = setTimeout("startOscilate()",6000);
	
});
function startOscilate() {
	if ($('.js-home li:eq(1)').css("left") == "547px") {
		$('.js-home li:eq(1)').animate({ left: '-=503' }, 1000, function() {
		    clearTimeout(time);
			time = setTimeout("startOscilate()",6000);
		});
	} else if ($('.js-home li:eq(2)').css("left") == "591px") {
		$('.js-home li:eq(2)').animate({ left: '-=503' }, 1000, function() {
		    clearTimeout(time);
			time = setTimeout("startOscilate()",6000);
		});
	} else if ($('.js-home li:eq(3)').css("left") == "635px") {
		$('.js-home li:eq(3)').animate({ left: '-=503' }, 1000, function() {
		    clearTimeout(time);
			time = setTimeout("startOscilate()",6000);
		});
	} else if ($('.js-home li:eq(3)').css("left") == "132px") {
		$('.js-home li:eq(3)').animate({ left: '+=503' }, 1000, function() {
		    // Animation complete.
		});
		$('.js-home li:eq(2)').animate({ left: '+=503' }, 1000, function() {
		    // Animation complete.
		});
		$('.js-home li:eq(1)').animate({ left: '+=503' }, 1000, function() {
		    clearTimeout(time);
			time = setTimeout("startOscilate()",6000);
		});
	}
	
}
