$(document).ready(function() {
	var wheels = $('.btn');
	var content = $('.sccontent');
	var arrow = $('#arrow img');

	$('.btn').mouseenter(function() {
		clearInterval(rotateIcon);
	});

	$('.btn').mouseleave(function() {
		rotation();
	});

	$('#bgpos1').click(function() {
		moveArrow("-739px"); //Change values to move arrow to corresponding position
	});
	$('#bgpos2').click(function() {
		moveArrow("-512px");
	});
	$('#bgpos3').click(function() {
		moveArrow("-451px");
	});
	$('#bgpos4').click(function() {
		moveArrow("-389px");
	});
	$('#bgpos5').click(function() {
		moveArrow("-166px");
	});
	$('#bgpos6').click(function() {
		moveArrow("-104px");
	});

	$('#bottomm').delegate('.btn', 'click', function(){
			//Show or hide the content divs based on which icon is clicked
			$(content).hide();
			$(content).eq($(this).index()).fadeIn();	
	});
		
	function moveArrow(pos) {
		$(arrow).stop().animate({"left": pos}, 500);
	}
	
	function rotation() {
		rotateIcon = setInterval(nextIcon, 7500);
	}
	
	i = 0;

	function nextIcon() {
		$(content).fadeOut(1000).hide();
		$(content[i]).fadeIn();
		
		if (i<5) {
			i++;	
		} else {
			i = 0;
		}
		if (i==1) {
			moveArrow("-739px"); //Change these values also to move arrow to corresponding position
		} else if (i==2) {
			moveArrow("-512px");
		} else if (i==3) {
			moveArrow("-451px");
		} else if (i==4) {
			moveArrow("-389px");
		} else if (i==5) {
			moveArrow("-166px");
		} else if (i==0) {
			moveArrow("-104px");
		}	
	};

	function stopRotation() {
		clearInterval(rotateIcon);
	}
	
	nextIcon();
	rotation();

});

			
			//Newstickers			
			$(document).ready(function(){
    			$("#container").jStockTicker({interval: 45});
			});
