$(document).ready(function(){

	$('.imgDiv').css("visibility", "visible");
	$('.imgDiv').hide();
	
	var index = 0;
	$('.imgDiv').each(function(index) {
	if (index < 2)
	{
		$(this).show();
	}
	index = index + 1;
	});
	
	$(".imgDiv").click(function(){
		nextTwoImages(speed);
	});

});

function nextTwoImages(speed)
{
	speed = speed * 1;
	var delay = speed + 25;
	var counter = 0;
	$('.imgDiv').each(function(){
		
		if ( ($(this).css("display") != "none") && ($(this).css('opacity') == 1) )
		{
			if ( counter+1 < $('.imgDiv').length-1 )
			{
				$(this).fadeOut(speed);
				$($('.imgDiv')[counter+1]).fadeOut(speed);
				
				setTimeout("$($('.imgDiv')["+ (counter+2) +"]).fadeIn("+ speed +")", delay);
				setTimeout("$($('.imgDiv')["+ (counter+3) +"]).fadeIn("+ speed +")", delay);
				
				return false;
			}
			else
			{
				$(this).fadeOut(speed);
				$($('.imgDiv')[counter+1]).fadeOut(speed);
				
				setTimeout("$($('.imgDiv')[0]).fadeIn("+ speed +")", delay);
				setTimeout("$($('.imgDiv')[1]).fadeIn("+ speed +")", delay);
				
				return false;
			}
		}
	counter++;
	});
}
