//once dom is ready
$(function() {

//	$("#imgswap").html("<img src='swaphome_img/01.jpg' />");
	
/*	$("#imgswap").everyTime(3000, function() {
		$(this).animate({
			opacity:'toggle'
		}, 'slow', function() {
			$(this).html("<img src='swaphome_img/02.jpg' />").animate({
				opacity:'toggle'
			}, 'slow');
		});
	});
*/

	$("#imgswap").each( function() {
		image_list = $(this).attr("images").split(',');
		current_position = 0;
		timer = parseInt($(this).attr("timer"));

//		$(this).everyTime(5000, function() {
//			$(this).html( '<img src="' + image_list[current_position] + '" />' );
//
//			current_position += 1;
//			if (current_position > (image_list.length-1)) {
//				current_position = 0;
//			}
//		});
		$(this).everyTime(timer, function() {
			$(this).animate({
				opacity:0
			}, 'slow', function() {
				$(this).html('<img src="' + image_list[current_position] + '" />').animate({
					opacity:1
				}, 'slow');
				
				current_position += 1;
				if (current_position > (image_list.length-1)) {
					current_position = 0;
				}
			});
		});
	});

});
