$(document).ready(			  
	function(){	
		var ptotalimg=$('#indeximgbox').find('.indeximg').length;
		var curindeximg="#indeximg1";
		var newshowimg="";
		var btnno=0; // Skip first image. To show the first image first
		var showlist=new Array();

		for(i=1;i<ptotalimg+1;i++){
			showlist.push(i)
		}

		function resertArray(){	
			for(i=1;i<30;i++){
				var randomNumberPos=Math.max(1,Math.round(Math.random()*ptotalimg))
				if (randomNumberPos!=1){ // always keep first image in the first array
					var getthisno=showlist[randomNumberPos-1]
					showlist.splice(randomNumberPos-1,1)
					showlist.push(getthisno)
				}
			}
		}
		
		for(i=1;i<ptotalimg+1;i++){
			var tempimg="#indeximg" + i;
			$(tempimg).hide();
			$(tempimg).fadeOut();
		}
		
		$('#indeximg1').show();
		$('#indeximg1').fadeIn();
		resertArray()
		
		window.setInterval(function(){autoimg();},4000); 		

		function autoimg(){
			if (btnno <ptotalimg-1){
				btnno++;
			}else{
				btnno= 0 ;
			}
			var showthis=showlist[btnno]
			newshowimg="#indeximg" + showthis;
			$(newshowimg).fadeIn(2000);
			$(curindeximg).fadeOut(2000);
			curindeximg=newshowimg;
		}
	}<!--function-->
)<!--ready-->
