/**
 * 
 */
function redirectURL (obj){
	if (obj && obj.href){
		window.open(obj.href);
	}
	return false;
}

$(function(){	
	function cycle() {
		$('#carousel > li:eq(0)').not(':animated').fadeOut().next('li').fadeIn().end().appendTo('#carousel');				
	}
	
	if ($('#carousel > li').length > 1){
		var timer = window.setInterval(cycle, 10000);
		
		$('#photo-controls a.prev').click(function(){
			$('#carousel > li:eq(0)').fadeOut().parent().find('li:last-child').fadeIn().prependTo('#carousel');
			
			if (timer){
				window.clearInterval(timer);
				timer = window.setInterval(cycle, 10000);
			}
			
			return false;
		});
		
		$('#photo-controls a.next').click(function(){		
			$('#carousel > li:eq(0)').fadeOut().next('li').fadeIn().end().appendTo('#carousel');
			
			if (timer){
				window.clearInterval(timer);
				timer = window.setInterval(cycle, 10000);
			}
			
			return false;
		});
	}
})

