var ctr = 1;

function initAnimation() {
	a1 = new Image();
	a1.src = "http://solarcone.net/home/images/anim1.gif";
	a2 = new Image();
	a2.src = "http://solarcone.net/home/images/anim2.gif";
	a3 = new Image();
	a3.src = "http://solarcone.net/home/images/anim3.gif";
	a4 = new Image();
	a4.src = "http://solarcone.net/home/images/anim4.gif";
	a5 = new Image();
	a5.src = "http://solarcone.net/home/images/anim5.gif";

	$('img1').setAttribute("src","http://solarcone.net/home/images/anim1.gif");
	$('img2').setAttribute("src","http://solarcone.net/home/images/anim2.gif");
	$('img3').setAttribute("src","http://solarcone.net/home/images/anim3.gif");
	$('img4').setAttribute("src","http://solarcone.net/home/images/anim4.gif");
	$('img5').setAttribute("src","http://solarcone.net/home/images/anim5.gif");
	
	new Effect.Opacity('img1',{from: 1.0, to: 0.0});
	new Effect.Opacity('img2',{from: 1.0, to: 0.0});
	new Effect.Opacity('img3',{from: 1.0, to: 0.0});
	new Effect.Opacity('img4',{from: 1.0, to: 0.0});
	new Effect.Opacity('img5',{from: 1.0, to: 0.0});

	startAnimation();
	}

function resetAnimation() {
	ctr = 2;
	startAnimation();
	}

function startAnimation() {
	if(ctr == 1) {
		new Effect.Parallel([		
			new Effect.Opacity('img0',{from: 1.0, to: 0.0, sync: true}),
			new Effect.Opacity('img1',{from:0.0, to: 1.0, sync: true})		
			], {duration: 2, queue: 'end'});
		}
		
	if(ctr > 1) {
	new Effect.Parallel([		
		new Effect.Opacity('img5',{from: 1.0, to: 0.0, sync: true}),
		new Effect.Opacity('img1',{from:0.0, to: 1.0, sync: true})		
		], {duration: 3.5, queue: 'end'});
		}
		
	new Effect.Parallel([		
		new Effect.Opacity('img1',{from: 1.0, to: 0.0, sync: true}),
		new Effect.Opacity('img2',{from:0.0, to: 1.0, sync: true})		
		], {duration: 3.5, queue: 'end'});
		
	new Effect.Parallel([		
		new Effect.Opacity('img2',{from: 1.0, to: 0.0, sync: true}),
		new Effect.Opacity('img3',{from:0.0, to: 1.0, sync: true})		
		], {duration: 3.5, queue: 'end'});
		
	new Effect.Parallel([		
		new Effect.Opacity('img3',{from: 1.0, to: 0.0, sync: true}),
		new Effect.Opacity('img4',{from:0.0, to: 1.0, sync: true})		
		], {duration: 3.5, queue: 'end'});
		
	new Effect.Parallel([		
		new Effect.Opacity('img4',{from: 1.0, to: 0.0, sync: true}),
		new Effect.Opacity('img5',{from:0.0, to: 1.0, sync: true})		
		], {duration: 3.5, queue: 'end', afterFinish: resetAnimation});		
		
	}
	
Event.observe(window,'load',initAnimation);