var rotate =
{
	currentItem: 0,
	url: new Array(),
	caption: new Array(),
	//paused: false,

	initialize: function() {
		rotate.url[0] = '/library/media/1033/windows/images/products/winfamily/windowshomeserver/photos/gallery_image1.jpg';
		rotate.url[1] = '/library/media/1033/windows/images/products/winfamily/windowshomeserver/photos/gallery_image2.jpg';
		rotate.url[2] = '/library/media/1033/windows/images/products/winfamily/windowshomeserver/photos/gallery_image3.jpg';
		rotate.url[3] = '/library/media/1033/windows/images/products/winfamily/windowshomeserver/photos/gallery_image4.jpg';
		rotate.url[4] = '/library/media/1033/windows/images/products/winfamily/windowshomeserver/photos/gallery_image5.jpg';
		rotate.url[5] = '/library/media/1033/windows/images/products/winfamily/windowshomeserver/photos/gallery_image6.jpg';
		rotate.url[6] = '/library/media/1033/windows/images/products/winfamily/windowshomeserver/photos/gallery_image7.jpg';
		rotate.url[7] = '/library/media/1033/windows/images/products/winfamily/windowshomeserver/photos/gallery_image8.jpg';
		rotate.url[8] = '/library/media/1033/windows/images/products/winfamily/windowshomeserver/photos/gallery_image9.jpg';
		rotate.url[9] = '/library/media/1033/windows/images/products/winfamily/windowshomeserver/photos/gallery_image10.jpg';
		rotate.url[10] = '/library/media/1033/windows/images/products/winfamily/windowshomeserver/photos/gallery_image11.jpg';
		rotate.url[11] = '/library/media/1033/windows/images/products/winfamily/windowshomeserver/photos/gallery_image12.jpg';

		rotate.caption[0] = '';
		rotate.caption[1] = '';
		rotate.caption[2] = '';
		rotate.caption[3] = '';
		rotate.caption[4] = '';
		rotate.caption[5] = '';
		rotate.caption[6] = '';
		rotate.caption[7] = '';
		rotate.caption[8] = '';
		rotate.caption[9] = '';
		rotate.caption[10] = '';
		rotate.caption[11] = '';
		
		//preload images
		for (var i = 0; i < rotate.url.length; i++) {
			var loadImage = new Image();
			loadImage.src = rotate.url[i];
		}
		
		document.getElementById('imageRotation').src = rotate.url[rotate.currentItem];
		document.getElementById('imageRotationCaption').innerHTML = rotate.caption[rotate.currentItem];

		//$('#imageRotation')[0].attachEvent('onmouseover', rotate.pauseRotation);
		//$('#imageRotation')[0].attachEvent('onmouseout', rotate.startRotation);
	},

	/*pauseRotation: function() {
		rotate.paused = true;
	},
	
	startRotation: function() {
		rotate.paused = false;
	},*/
	
	changeImage: function() {
	//if (rotate.paused == false) {
		$('#imageRotation').animate({ opacity: 0.1 }, 'normal', function() {

			if (rotate.currentItem >= (rotate.url.length - 1))
				rotate.currentItem = 0;
			else
				rotate.currentItem = rotate.currentItem + 1;

			document.getElementById('imageRotation').src = rotate.url[rotate.currentItem];
			document.getElementById('imageRotationCaption').innerHTML = rotate.caption[rotate.currentItem];
			//document.getElementById('imageRotation').alt = rotate.caption[0];
			$('#imageRotation').animate({ opacity: 1 }, 'normal');
		});
		//}
	}
}

$(document).ready(function() {
	rotate.initialize();
	setInterval(rotate.changeImage, 6000);
});