document.slideDiv = function(content, html, dir) {
	if((content = $(content)) && !content.slideAni) { // Fix content if id, and check if we're in a slide already
		var aniEls = new Array(), aniActions = new Array(), scroller = new Element('div'), container = new Element('div'), newContent = new Element('div'), cSize = content.getSize();
		
		// Wrap a scroller and a container
		scroller.wraps(content);
		container.wraps(scroller);
		
		// Setup the default states for everything
		content.setStyles({width: cSize.x, height: cSize.y});
		container.setStyles({width: cSize.x, height: cSize.y, position: 'relative', overflow: 'hidden'});
		content.setStyles({position: 'absolute', zIndex: 2});
		scroller.setStyles({left: 0, top: 0, position: 'absolute'});
		newContent.setStyles({position: 'absolute', zIndex: 1, left: cSize.x+10, top: 0});
		
		// Add the new content
		newContent.innerHTML = html;
		scroller.adopt(newContent);
		var nSize = newContent.getSize(); // Now we can get the new size!
		
		// Change starting position if not sliding to the right
		if(dir == 'l') newContent.setStyle('left', -(nSize.x+10));
		else if(dir == 't') newContent.setStyles({left: (-(cSize.x - nSize.x) / 2), top: -(nSize.y+10)});
		else if(dir == 'b') newContent.setStyles({left: (-(cSize.x - nSize.x) / 2), top: cSize.y+10});
		else if(dir == 'f') newContent.setStyles({left: 0, top: 0});
		
		if(dir == 'f') {
			aniEls.push(content);
			aniActions.push({opacity: [1, 0]});
		} else {
			aniEls.push(scroller);
			aniActions.push({left: -newContent.offsetLeft, top: -newContent.offsetTop});
		}
		// Animate the container if need be
		if(cSize.x != nSize.x || cSize.y != nSize.y) {
			aniEls.push(container);
			aniActions.push({width: nSize.x, height: nSize.y});
		}
		
		content.slideAni = new Fx.Elements(aniEls, {duration: 750, transition: Fx.Transitions.Quart.easeOut, onComplete: function() {
				// Cleanup old content
				newContent.id = content.id;
				content.destroy();
				
				// Clean up wrappers
				newContent.setStyles({position: 'static', zIndex: (Browser.Engine.trident4 ? 0 : 'auto'), width: 'auto', height: 'auto', top: 0, left: 0});
				newContent.replaces(container);
				
				// Each slide can be different, so don't hang around for new params
				content.slideAni = null;
			}
		});
		
		content.slideAni.start(aniActions);
	}
}

thisImg=1;
function rotate() {
	var content = $('homeRotateContainer');
	if(content) {
		if(!rotatingImageArray[thisImg].complete) {
			setTimeout('rotate();', 1000);
			return;
		}
		
		var html = '<img src="'+rotatingImageData[thisImg]['path']+'" width="450" height="300" border="0" alt="'+rotatingImageData[thisImg]['title'].replace('"', '')+'" title="'+rotatingImageData[thisImg]['title'].replace('"', '')+'">';
		if(rotatingImageData[thisImg]['caption'] != '') {
			html += '<div class="homeImageCaption">';
				if(rotatingImageData[thisImg]['benefit_id'] != 0) {
					html += '<a href="benefits_detail.php?ID='+rotatingImageData[thisImg]['benefit_id']+'">';
				}
				
				html += rotatingImageData[thisImg]['caption'];
				
				if(rotatingImageData[thisImg]['benefit_id'] != 0) {
					html += '</a>';
				}
			html += '</div>';
		}
		
		document.slideDiv(content, html, 'f');
		
		thisImg++;
		if(thisImg >= rotatingImageData.length) thisImg = 0;
		setTimeout('rotate();', 4000);
	}
}