	$(document).ready(function() {
		
		// var windowHeight = $(window).height();
		// var mantleHeight = $('#mantle-wrapper').height();
		// var headerHeight = $('#header').height();
		// 
		// var leftOvers = windowHeight - mantleHeight - headerHeight;
		// var mantlePadding = leftOvers; 
		// 
		// alert(mantlePadding);
		// 
		// $('#mantle-wrapper').animate({
		// 	'margin-bottom':''+mantlePadding+'px'
		// });
		
		$('.subpage .main-content a.screenshot img').animate({
			left : '0px'
		});


		$('.sidebar-left ul li a').each(function(){
			$(this).append('<span> &rsaquo;&rsaquo;</span>');
			$('span',this).hide();
		});

		$('.sidebar-left ul li a').hover(
			function(){
				$('span',this).show();
			},
			function(){
				$('span',this).hide();
			}
		);
		
		var currentNews = 0;
		var newsTimer;
		var newsLength;
		var ranNum = 0;
		var ranNum2 = 0;
		var newsIndex = 0;
		var newsLength = $('div.news-digest').length;
		
	
	// MANTLE -------------------------------- >>
		
		var imgWidth = $('.mantle-item').outerWidth();
		var imgCount = $('.mantle-item').length;
		var newLeft = 0;
		var newLeftTmp = 0;
		var newPos = 0;
		var current = 1;
		var reset = false;
		var resetBack = false;
		
		$('#mantle').width(imgWidth*(imgCount+2));
		$('#mantle .mantle-item').first().addClass('mantle_first');
		$('#mantle .mantle-item').last().addClass('mantle_last');
		$('.mantle_first').clone().appendTo('#mantle');
		$('.mantle_last').clone().prependTo('#mantle');
		$('#mantle').css('left','-'+imgWidth+'px');
		$('#mantle').fadeIn(300);
		
		$('#mantle-prev').click(function(){
			window.clearInterval(myTimer);
			resetBack = false;
			current--;
			mantleAction("reverse");
			mantleSwitch();
		});
		
		$('#mantle-next').click(function(){
			window.clearInterval(myTimer);
			reset = false;
			current++;
			mantleAction();
			mantleSwitch();
		});
		
		mantleSwitch = function() {	
			myTimer = setInterval(function(){
				reset = false;
				resetBack = false;
				current++;
				mantleAction();
				return false;
			},7000);
		}
		
		$('#mantle .mantle-content').hover(
			function() {
				window.clearInterval(myTimer); 
			},
			function() {
				mantleSwitch();
			}
		);
		
		mantleAction = function(dir){
			if(current == imgCount){
				reset = true;
			}
			if(current == 0){
				resetBack = true;
			}
			newLeftTmp = $('#mantle').position();
			if(dir == "reverse"){
				newLeft = newLeftTmp.left + (imgWidth) + 5;
			} else {
				newLeft = newLeftTmp.left + (-1*imgWidth) - 5;
			}
			
			$('#mantle .mantle-content').fadeOut(300, function() {
				$('#mantle').stop().animate({'left':newLeft+'px'},function(){

				}, function() {
					if(reset == true){
						$('#mantle').css({left: '0px'});
						current = 0;
					}
					if(resetBack == true){
						$('#mantle').css({left: '-'+((imgCount*imgWidth) + (imgCount*5)) +'px'});
						current = imgCount;
					}
					$('#mantle .mantle-content').fadeIn(300);
				});
			});
		}

		mantleSwitch();
		
		
	});
