$(document).ready(function() {
		
		$('#featured-right table').click( function() {
			switch_slide(this);
		});
		var timer = setInterval( function() {
			islider();
			//console.info(obj);
		}
		,5000);
		
		$('#featured').mouseenter(function() {clearInterval(timer)})
					  .mouseleave(function() {timer = setInterval( function() {
			islider();
			//console.info(obj);
		}
		,5000);});
		function switch_slide(obj) {
			$('#featured-right table.active').removeClass('active');
			$(obj).addClass('active');
			var id = $(obj).attr('id');
			var matches = id.match(/^featmenu([0-9]+)$/);
			id = matches[1];
			$('#featured-left .featured-item:visible').fadeTo('400',0.3,function() {
				$(this).hide();
				$('#featured-'+id).fadeTo('600',1);
			});
			return false;
		}
		
		function islider() {
			var o = $('#featured-right table.active');
			if ($(o).is(':last-child')) {
				var obj = $('#featured-right table:first');
			}  else {
				var obj = $(o).next();
			}
			switch_slide(obj);
		}
});


