jQuery(function($) {
   var
   $itemBody = $('.addBanner4'),
   $active = $itemBody.find('.item:first'),
   $item = $itemBody.find('.item'),
   $banner = $itemBody.find('.bannerimg');
   $active.addClass('active'); 
   $banner.find('img').eq($active.index()).show();
   rotate4 = function(){	
		$item.removeClass('active'); 
       	$active.addClass('active'); 
		$banner.find('img').hide();
		$banner.find('img').eq($active.index()).show();
	}; 
//	rotate4();
	
	rotate4Switch = function(){		
		play4 = setInterval(function(){ 
			$active = $itemBody.find('.item.active').next();
			if ( $active.length === 0) { 
				$active = $itemBody.find('.item:first'); 
			}
			rotate4(); 
		}, 3000); 
	};
	
    rotate4Switch(); 
	
	$item.hover(function() {
		clearInterval(play4); //Stop the rotation
        $active = $(this);
		rotate4();
	}, function() {
		rotate4Switch(); //Resume rotation
	});	
	
	$banner.hover(function() {
		clearInterval(play4); //Stop the rotation
		rotate4();
	}, function() {
		rotate4Switch(); //Resume rotation
	});	
	
	$banner.click(function(){
	     	var tar = $item.eq($active.index()).attr('target');
			var url = $item.eq($active.index()).attr('href');
			windowlink(url,tar);	
	});
	
	$item.click(function(){
			var tar = $(this).attr('target');
			var url = $(this).attr('href');
			
			windowlink(url,tar);	
	});
   
   windowlink = function(klink, target)
	{
        	if(target == "_self"){
				location= klink;
			}else if(target == "_blank"){
				window.open(klink);
			}else if(target == "_parent"){
				parent.location=klink;
			}
	}

});
