var imageIndex = 0;
var images = new Array();
images[0] = '../images/pic_creditcard.jpg';
images[1] = '../images/pic_ach.jpg';
images[2] = '../images/pic_services.jpg';
images[3] = '../images/pic_text.jpg';
images[4] = '../images/pic_marketing.jpg';

var links = new Array();
links[0] = 'creditcards.html';
links[1] = 'echeck.html';
links[2] = 'services.html';
links[3] = 'rentbytext.html';
links[4] = 'marketingadvantage.html';

function switchImage() {

	var currImage = $('#productimage');
	var currImgLocation = currImage.coords();
	var newImage = dojo.create('img', {id:'newImage'}, dojo.byId('productlearnmore_button_link'));
	newImage.src = currImage.attr('src');
	dojo.style(newImage, 'position', 'absolute');
	dojo.style(newImage, 'top', currImgLocation[0].y + 'px');
	dojo.style(newImage, 'left', currImgLocation[0].x + 'px');
	dojo.style(newImage, 'opacity', 1);

	currImage.attr('src', images[++imageIndex]);
	$('#productlearnmore_button_link').attr('href', links[imageIndex]);

	dojo.fadeOut({node:'newImage', duration:1000, onEnd:function(e){
		dojo.destroy('newImage');
	}}).play();

	if (imageIndex == 4) imageIndex = 0;
	setTimeout(switchImage, 5000);

}

dojo.addOnLoad(function (load) {
	dojox.image.preload(images);
	setTimeout(switchImage, 5000);
});

