function slideSwitch() {
    var $active = $('#tourslideshow div.active');
		
          if ( $active.length == 0 ) 
          $active = $('#tourslideshow div:last');
  		
  			//alert($active.length);
  		
          var $next =  $active.next().length ? $active.next()
                  : $('#tourslideshow div:first');
  		
          $active.addClass('last-active');
  		  
  		  $active.css("display","none");
          
          $next.css({opacity: 0.0,display: 'block'})
                  .addClass('active')
                  
                  .animate({opacity: 1.0}, 1000, function() {
                          $active.removeClass('active last-active');
                  });
}

$(function() {
   
   var playSlideshow =  setInterval( "slideSwitch()", 10000 );
   
   $('#tourslideshow').hover(function() {
           clearInterval(playSlideshow);
   },
   function() {
           playSlideshow =  setInterval( "slideSwitch()", 6000 );
   });	   
   
   $("#tourslideshow div").hover(
          function () {
                 //	alert($(this).attr("id"));
                 var targetid = '#'+$(this).attr("id")+'main';
                 //	alert(targetid);
                 $(targetid).css("z-index","12");
                 $(targetid).addClass('active');
                 clearInterval(playSlideshow);
          },
          function () {
                 //	alert($(this).attr("id"));
                 var targetid = '#'+$(this).attr("id")+'main';
                 //	alert(targetid);
                 $(targetid).css("z-index","8");
                 $(targetid).addClass('last-active');
                 //playSlideshow =  setInterval( "slideSwitch()", 5000 );
          }
    );
   //setInterval("slideSwitch()", 5000 );
});
