﻿if(maxIndex==1)
{
	var num = document.getElementById('ctrl');
	var imgLogo = document.getElementById('imgnav');
	imgLogo.style.height = 110;
	num.parentNode.removeChild(num);
}

var interval = 4000;

$(function(){
            $("#img img")
			.eq(1).stop(true,true).fadeIn(1000).parent().siblings().find("img").hide();
	 var index = 0;
	 $("#btn span").mouseover(function(){
		index  =  $("#btn span").index(this);
		showImg(index);
	});	
	 //stop & play new one.
	 $('#imgnav').hover(function(){
			  if(MyTime){
				 clearInterval(MyTime);
			  }
	 },function(){
			  MyTime = setInterval(function(){
			    showImg(index)
				index++;
				if(index==maxIndex){index=0;}
			  } , interval);
	 });
	 //auto-start
	 var MyTime;
	 MyTime = setInterval(function(){
		showImg(index)
		index++;
		if(index==maxIndex){index=0;}
	 } , interval);
})

function showImg(i){
		$("#img img")
			.eq(i).stop(true,true).fadeIn(1000).parent().siblings().find("img").hide();
			
		$("#msg li")
			.eq(i).stop(true,true).fadeIn(1000).siblings().hide();
			
		 $("#btn span")
			.eq(i).addClass("hov").siblings().removeClass("hov");
			
}
