var fading 	  	= false;
var currentimg 	= 1;
var nextimg 	= 1;

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function swap2() {
	fading = false;
	$("#img" + currentimg).css("display", "none");
	currentimg = nextimg;
	$("#img" + currentimg).css("display", "");
	$("#img" + currentimg).animate(
		{
			opacity: 1.0
		},
		'normal',
		'linear'
	);
}

function swap(img) {
	if (currentimg != img) {
		if (fading == false) {
			fading = true;
			$("#img" + currentimg).animate(
				{
					queue:	 false,
					opacity: 0.0
				},
				'normal',
				'linear',
				swap2
			);
		}
	}
	nextimg = img;
	window.status = '';
	return true;
}


function previous() {
	if (currentimg > 1) {
	// call swap() with currentimg - 1
	swap(currentimg - 1)
	}
	
}

function next(count) {
	if (currentimg < (count-1)) { 
	// call swap() with currentimg + 1 
	swap(currentimg + 1)
	}
	
}