var ind1="";
$(document).ready(function() {	
	$(".paging").show().children("a:first").addClass("active");
	$(".image_reel_cont, .image-reel > img").hide().eq(0).show();
	$(".image_reel_more").hide().eq(0).show();

	$(".paging a").click(function() {
		//$(".image_reel img").eq($(this).index()).fadeOut("slow", "linear").next().fadeIn("slow", "linear");
		$('.tooltip').eq(ind1).hide();
		var ind = $(this).index();
		$(".image-slider").fadeOut().eq(ind).fadeIn(2000, function(){
			$(".image_reel_cont").fadeOut("slow").eq(ind).fadeIn("slow", "linear");
			$(".image_reel_more").fadeOut("slow").eq(ind).fadeIn("slow", "linear");			
		});
		$(".paging a").removeClass("active").eq(ind).addClass("active");
		return false; //Prevent browser jump to link anchor
	});	


//$(".tooltip").mouseover(function () {
	//var pp=event.currentTarget === this ;
			//$(this).addClass("tooltip");
		 // });



	$(".image_reel_more_link, .tooltip").hover(
		  function (e) {
			ind1 = $('.paging a.active').index();
			$('.tooltip').eq(ind1).fadeIn();
			$('.tooltip').css("filter","alpha(opacity=70)");
			clearTimeout(play);
			clearTimeout(to);
			//$(this).addClass("tooltip");			
		},
		function()
		{
		
		  to = setTimeout( function(){
				var ind1 = $('.paging a.active').index();
				$(".tooltip").eq(ind1).fadeOut();
					//$('.tooltip').eq(ind1).hide("slow");
					rotateSwitch();
			}, 1000 );
		});

	rotateSwitch = function(){		
		//$('.tooltip').eq(ind1).hide("slow");
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			$active = $('.paging a.active').next();
			if ( $active.length === 0) { //If paging reaches the end...
				$active = $('.paging a:first'); //go back to first
			}
			$active.click();
			$('.tooltip').eq(ind1).hide();
			
		}, 10000); //Timer speed in milliseconds (3 seconds)
	};



	rotateSwitch(); 

});

