$(window).load(function(){
	
var images = '<div><a href="/hosting/cloud_hosting"><img src="/assets/images/enterprise_slides/cloud_hosting.jpg" alt="Zimcom Cloud Hosting" /></a></div><div><a href="/services/remote_backup"><img src="/assets/images/enterprise_slides/remote_backup.jpg" alt="Remote Backup" /></a></div>';
	
	var first_div = $('.image_wrapper > div').first(),
		last_div = $('.image_wrapper > div').last(),
		wrapper = $('.image_wrapper');
		wrapper.css({'width': 9999, 'left': -300 });
		last_div.detach().prependTo(wrapper);
	    wrapper.append(images);
	
	function rotate_right() {
		var wrapper = $('.image_wrapper'),
			item = $('.image_wrapper > div');
			wrapper.animate({ left: '-=300'},function(){
				item.first().detach().appendTo(wrapper);
				wrapper.css('left', -300);
			});
	};	

	function rotate_left() {
		var wrapper = $('.image_wrapper'),
			item = $('.image_wrapper > div');
			wrapper.animate({ left: '+=300'},function(){
				item.last().detach().prependTo(wrapper);
				wrapper.css('left', -300);
			});
	};
			
			
	$('#left_arrow').click(function(){
		rotate_left();
	});
	
	$('#right_arrow').click(function(){
		rotate_right();
	});
	
	
	$('#left_arrow').hover(function(){
		$('#left_arrow > img').attr("src","/assets/images/left_arrow_hover.png");
	},function() {
		$('#left_arrow > img').attr("src","/assets/images/left_arrow.png");				
	});

	$('#right_arrow').hover(function(){
		$('#right_arrow > img').attr("src","/assets/images/right_arrow_hover.png");
	},function() {
		$('#right_arrow > img').attr("src","/assets/images/right_arrow.png");				
	});
	
});
