$(function(){
	abc=0;
	setTimeout(function(){
	ca1('a2','#image2',3,3);},8000);
	$('#a1').click(function(){
		abc=1;
		ca1('a1','#image1',2,2);
	});	
		$('#a2').click(function(){
		abc=2;
		ca1('a2','#image2',3,3);

	});	
		$('#a3').click(function(){
		abc=3;
		ca1('a3','#image3',4,4);
	});	
		$('#a4').click(function(){
		abc=4;
		ca1('a4','#image4',5,5);
		
	});	
		$('#a5').click(function(){
		abc=5;
		ca1('a5','#image5',1,1);
		

	});	
	function ca1(oid,oimg,aid,aimg){
		$('#image1').fadeOut(500);
		$('#image2').fadeOut(500);
		$('#image3').fadeOut(500);
		$('#image4').fadeOut(500);
		$('#image5').fadeOut(500);		
		$(oimg).fadeIn(1500)
		document.getElementById('a1').style.backgroundColor='#060';
		document.getElementById('a2').style.backgroundColor='#060';
		document.getElementById('a3').style.backgroundColor='#060';
		document.getElementById('a4').style.backgroundColor='#060';
		document.getElementById('a5').style.backgroundColor='#060';
		document.getElementById(oid).style.backgroundColor='#F60';
	if(abc!=0){
		aid=abc;
		abc=0;
		return;		
	}
	else{
		if((aid+1)<=5)
		{	
			time1=setTimeout(function(){
			ca1('a'+aid,"#image"+aimg,(aid+1),(aimg+1));	
			},8000);
		}
		else{
			time1=setTimeout(function(){
			ca1('a'+aid,"#image"+aimg,1,1);	
			},8000);	
		}
	}
	}
	
	
});

