var loadedImages = [];
var img = 1;
var image = false;
	
window.addEvent('load', function(e) {
	//var tip = new Tips($$('.tips'), {offsets:{x:5, y:5}});
	var imgEffect = new Fx.Tween('loadpic', {duration: 1500});
	new Asset.images(images, {
		onProgress: function(i) {			
			loadedImages[i] = this;
		},
		onComplete: function() {
			imageShow();
		}
	});
});

function imageShow() {

	efx = function() {
		if (img == loadedImages.length) img = 1;
		image = loadedImages[img];
		var imgEffect = new Fx.Tween('loadpic', {duration: 1500});		
		imgEffect.start('opacity', 1, 0).chain(function() {	
			$('loadpic').src = image.src;			
			this.start('opacity', 0, 1).chain(function() {
				img++;
				imageShow();				
			});
		});		
	}.delay(100);
}

function imageChange(dir) {	
	var o = loadedImages[img];
	if (dir == 'next') img = img + 1;
	if (dir == 'prev') img = img - 1;
	if (img >= loadedImages.length - 1) img=1;
	if (img <= 1) img=loadedImages.length - 1;
	var n = loadedImages[img];	
	var oEffect = new Fx.Tween('loadpic', {duration: 1500});
	var nEffect = new Fx.Tween('loadpic', {duration: 1500});
	oEffect.start('opacity', 0, 1).chain(function() {	
		o.destroy();	
		n.inject('stylepic');		
		nEffect.start('opacity', 1, 0);
	});
}