$last_banner = '';

$(document).ready(function()
{
	$('#menu').fadeTo(0, 0.5);
	rotateBanner();
	$(document).everyTime("15s", rotateBanner);	
	
	hs.graphicsDir = 'images/highslide/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.fadeInOut = true;
	hs.dimmingOpacity = 0.8;
	hs.outlineType = 'rounded-white';
	hs.captionEval = 'this.thumb.alt';
	hs.marginBottom = 105 // make room for the thumbstrip and the controls
	hs.numberPosition = 'caption';

	// Add the slideshow providing the controlbar and the thumbstrip
	hs.addSlideshow({
		//slideshowGroup: 'group1',
		interval: 5000,
		repeat: false,
		useControls: true,
		overlayOptions: {
			className: 'text-controls',
			position: 'bottom center',
			relativeTo: 'viewport',
			offsetY: -60
		},
		thumbstrip: {
			position: 'bottom center',
			mode: 'horizontal',
			relativeTo: 'viewport'
		}
	});
});

function buildMenu()
{
	$.ajax({
		type: 'GET',
		url: 'xmlhttp/buildmenu.xmlhttp.php',
		success: function($response)
		{
			$('#menu_items').html($response);
		}
	});	
}

function loadPage($page)
{
	$.ajax({
		type: 'GET',
		url: 'xmlhttp/loadpage.xmlhttp.php',
		data: 'page=' + $page + '',
		success: function($response)
		{
			$('#content').html('<table style="width:500px; padding:0; border:0;"><tr><td>' + $response + '</td></tr><tr><td><img src="images/footer.jpg" /></td></tr></table>');
		}
	});
}

function rotateBanner()
{
	$.ajax({
		type: 'GET',
		url: 'xmlhttp/getbanner.xmlhttp.php',
		data: 'last_banner=' + $last_banner + '',
		success: function($response)
		{
			$banner = eval('(' + $response + ')'); //Hehe
			
			$('#banner').fadeOut('fast', function()
			{
				$('#banner').html('<img src="' + $banner.url + '" />');
				$('#banner').fadeIn('slow');
				
				$last_banner = $banner.url;
			});
		}
	});
}

function sendForm()
{
	$data = '';
	
	$('.sendme').each(function(){
		$data += this.id + '=' + this.value + '&';
	});
	
	$.ajax({
		type: 'GET',
		url: 'xmlhttp/send_form.xmlhttp.php',
		data: $data,
		success: function($response)
		{
			$('#contactform').html('Bedankt voor het invullen van het contactformulier. Indien nodig nemen wij zo snel mogelijk contact met u op.');
		}
	});
}