var switchtime = 8000; // Time (in milliseconds) that each image is displayed for
var fadetime = 1000; // Time (in milliseconds) that the fade transition lasts for

var image_count = new Array();
var current_image = new Array();
var old_image = new Array();

$(document).ready(function(){

	galleryRows = $(".advertgalleryrow").size();
	for (count=0;count<galleryRows;count=count+1)
	{
		image_count[count] = $(".advertgalleryrow").eq(count).find("img").hide().size();
		current_image[count] = 0;
		$(".advertgalleryrow").eq(count).find("img").eq(current_image[count]).show();
	}
	
	
	$("body").everyTime(switchtime,function() {
		for (count=0;count<galleryRows;count=count+1)
		{
			old_image[count] = current_image[count];
			current_image[count] ++;
			if (current_image[count] > (image_count[count]-1)) { current_image[count] = 0; }
			
			$(".advertgalleryrow").eq(count).find("img").eq(current_image[count]).fadeIn(fadetime);
			$(".advertgalleryrow").eq(count).find("img").eq(old_image[count]).fadeOut(fadetime);
		}
	});

});