function dynamicContent()
{
	getHttpRequest("includes/gallery.cfm", null, '');
}

var duration = 5000;
var autoplay = true;
var width = 524;
var sliderbox;
var current = 0;
var number;
function initSliderTabs()
{
	if(document.getElementById("carusel"))
	{
		sliderbox = $('gallery');
		number = $$('#carusel li').length;

		sliderbox.fx = new Fx.Morph($('gallery'), {duration: 400});
		
		$('next').addEvent('click', function()
		{
			sliderbox.fx.cancel();
			if(++current>=number)
				current=0;
			
			thumbnails.removeClass("active");
			thumbnails[current].addClass("active");
		
			sliderbox.fx.start({'left': -current*width});
		});
		

		$('prev').addEvent('click', function()
		{
			sliderbox.fx.cancel();
			if(--current<0)
				current=number-1;
				
			thumbnails.removeClass("active");
			thumbnails[current].addClass("active");

			sliderbox.fx.start({'left': -current*width});
		});
		
		$('pause').addEvent('click', function()
		{
			autoplay = false;
		});
		
		/* thumbnails */
		thumbnails = $$('#gallery-buttons li a');
		thumbnails.each(function(el, i)
		{
			el.href = 'javascript:;';
			el.onclick = function()
			{
				thumbnails.removeClass("active");
				sliderbox.fx.cancel();
				sliderbox.fx.start({'left': -i*width});
				current=i;
				el.addClass("active");
			}
		;})

		/* autoplay */
		setTimeout('rotate()', duration);
	}
}

function rotate()
{
	if(autoplay)
	{
		if(++current>=number)
			current=0;
			
		thumbnails.removeClass("active");
		thumbnails[current].addClass("active");

		sliderbox.fx.start({'left': -current*width});
		setTimeout('rotate()', duration);
	}
}

if (window.addEventListener)
	window.addEventListener("load", dynamicContent, false);
else if (window.attachEvent)
	window.attachEvent("onload", dynamicContent);