var firstImage = new Image;
var i = new Number();
var descriptionCh = new String;
i = 0;

var nimage = new Image();
var BGwidth;
var BGheight;
function swapThumb ( image ) {
	oImage = image.src;
	image.src = image.src.replace ( ".jpg", "-2.jpg" );
//	whichImage.src = image.src;
}
function swapThumbBack( image ) {
	image.src = oImage;
}
function swapLarge ( image ) {
	if ( typeof image == 'object' ){
		nimage.src = LGRename(image.src);
	}
	else {
		nimage.src = image;
	}
	nimage.onload = function () {
		new Effect.Opacity('large', { from: 1.0, to: 0, duration: 0.1 });
		var t=setTimeout("LargeSwap()",700);
	}
	return nimage.src;
};
function LargeSwap () {
	document.getElementById( "large" ).src = nimage.src;
	new Effect.Opacity('large', { from: 0, to: 1, duration: 0.1 });
	document.getElementById('rotatetext').innerHTML= descriptionCh;
};
function LGRename (image) {
	var txt1 = RegExp ('/thumbs/');
	if ( txt1.test(image) ) {
		var NewImage = image.replace ( "/thumbs/", "/" );
		return NewImage;
	}
	else {
		return image;
	}
};

function rotateimage(imgArrayv, imgDescv){
	i += 1;
	if ( i == imgArrayv.length ){
		i = 0;
	}
	
	if ( typeof imgDescv == 'object' ) {
		descriptionCh = imgDescv[i];
		swapLarge(imgArrayv[i]);
	}
	else {
		descriptionCh = imgDescv;
		swapLarge(imgArrayv);
	}
};

function alerter (){
	alert('yep');
};
