	var n=0;//initial pic of fimg
	var m=1;//initial pic of bimg
	var picno=0;//id number of div
	var pictotal=mainImgArr.length;//total number of pictures
	var imageurl="dimage/imagerotator/";
	var time1=2000;//image fadeout speed
	var time2=3000;//image static
	var a1url=["#","#"];
	//var a1url=["#","prolist.asp?type=MCG&ctgrid=724","prolist.asp?type=MCG&ctgrid=724","AFL.asp?type=AFL","prosublist.asp?catid=198"];
	var verstr="?ver=6";

		
		function hideimg() {////////
			$("#img"+picno).fadeOut(time1, wait1);//image fadeout speed
			$(".btn").css("background-color", "#ECE9D8");
			$("#btn"+((n+1)%pictotal)).css("background-color", "#dfdfdf");
			$("#a1").attr("href", a1url[((n+1)%pictotal)]);
			n=((n+1)%pictotal);//next pic of fimg

		}

		function wait1()////////
		{
			$(this).attr("src",imageurl+mainImgArr[n]+verstr);
			window.setTimeout(showimg,time2);//time duration fimg hide
		}
		function showimg() {////////
			$("#img"+picno).fadeIn(time1,wait2);//image fadein speed
		}
		function wait2()////////
		{
			window.setTimeout(hideimg,time2);//time duration fimg display
		}

		//  ==================================================================================
		function hideimg2() {
			$("#img"+picno+"_b").fadeOut(time1, wait12);//image fadeout speed
			$(".btn").css("background-color", "#ECE9D8");
			$("#btn"+((m+1)%pictotal)).css("background-color", "#dfdfdf");
			$("#a1").attr("href", a1url[((m+1)%pictotal)]);
			m=((m+1)%pictotal);//next pic of bimg
		}

		function wait12()
		{
			$(this).attr("src",imageurl+mainImgArr[m]+verstr);
			window.setTimeout(showimg2,time2);//time duration bimg hide
		}


		function showimg2() {
			$("#img"+picno+"_b").fadeIn(time1,wait22);//image fadein speed
		}

		function wait22()
		{
			window.setTimeout(hideimg2,time2);//time duration bimg display
		}


	$(document).ready(function(){
		window.setTimeout(function(){hideimg();showimg2();},time1);
			$("#btn1").css("background-color", "#dfdfdf");
	});

	function changeImage(i) {
		var str1 = imageurl + mainImgArr[i] + verstr;
		var str2 = imageurl + (i%mainImgArr.length) +verstr;
		
		if ($("#img"+picno).css("display") != "none")
		{
			$("#img"+picno).attr("src", str1);
			$("#img"+picno+"_b").attr("src", str2);
		}else{
			$("#img"+picno+"_b").attr("src", str1);
			$("#img"+picno).attr("src", str2);
		}
			$(".btn").css("background-color", "#ECE9D8");
			$("#btn"+i).css("background-color", "#dfdfdf");
			$("#a1").attr("href", a1url[i]);
	}