// jquery acties bij laden document
$(document).ready(function(){
	// Geef alle a's een pointer als cursor
	$('a').css({ cursor: "pointer"});
	$('#contentbox').hide();
	$('#innerpage').hide();
	$('#content').hide();
	$('#menu').hide();
	$('#copy').hide();
	$('#advertenties').hide();
	// Zo komt de pagina in beeld bij het voor het eerst laden
	$('#contentbox').slideDown(300, function(){
		$('#innerpage').slideDown(500, function() {
			$('#content').fadeIn(500);
			$('#menu').show("slow", function() {
				$('#copy').show("fast");
				//$('#advertenties').show("slow");
			});		
		});		
	});
	$("#loading").hide().ajaxStart(function(){
		$(this).show();
	}).ajaxStop(function(){
		$(this).hide();
	});
	//init_window();
});
function init_window() {
	/* begin floating window */
	$('#windowOpen').bind(
		'click',
		function() {
			if($('#window').css('display') == 'none') {
				$(this).TransferTo(
					{
						to:'window',
						className:'transferer2', 
						duration: 400,
						complete: function()
						{
							$('#window').show();
						}
					}
				);
			}
			this.blur();
			return false;
		}
	);
	$('#windowClose').bind(
		'click',
		function()
		{
			$('#window').TransferTo(
				{
					to:'windowOpen',
					className:'transferer2', 
					duration: 400
				}
			).hide();
		}
	);
	$('#windowMin').bind(
		'click',
		function()
		{
			$('#windowContent').SlideToggleUp(300);
			$('#windowBottom, #windowBottomContent').animate({height: 10}, 300);
			$('#window').animate({height:40},300).get(0).isMinimized = true;
			$(this).hide();
			$('#windowResize').hide();
			$('#windowMax').show();
		}
	);
	$('#windowMax').bind(
		'click',
		function()
		{
			var windowSize = $.iUtil.getSize(document.getElementById('windowContent'));
			$('#windowContent').SlideToggleUp(300);
			$('#windowBottom, #windowBottomContent').animate({height: windowSize.hb + 13}, 300);
			$('#window').animate({height:windowSize.hb+43}, 300).get(0).isMinimized = false;
			$(this).hide();
			$('#windowMin, #windowResize').show();
		}
	);
	$('#window').Resizable(
		{
			minWidth: 200,
			minHeight: 60,
			maxWidth: 700,
			maxHeight: 400,
			dragHandle: '#windowTop',
			handlers: {
				se: '#windowResize'
			},
			onResize : function(size, position) {
				$('#windowBottom, #windowBottomContent').css('height', size.height-33 + 'px');
				var windowContentEl = $('#windowContent').css('width', size.width - 25 + 'px');
				if (!document.getElementById('window').isMinimized) {
					windowContentEl.css('height', size.height - 48 + 'px');
				}
			}
		}
	); /* end floating window */
}
function maketabs() {
	$('#container-1').tabs(1);
}
function showHome() {
	changeBG('home');
	urchinTracker("Home");
	$('#content').fadeOut('fast', function(){
		$(this).html('').css({width:"210px"}).slideDown('slow',function() {
			$.post("handler.php", { name: "home" }, function(data){
				var dataArr = eval("("+data+")");
				$('#content').html(dataArr.inhoud);
				//init_window();
			});
		});
	});
}
function showMenu() {
	changeBG('menu');
	urchinTracker("Menu");
	$('#content').fadeOut('fast', function() {
		$(this).html('').css({width: "500px"}).Grow('slow', function(){
			$.post("handler.php", { name: "menu" }, function(data){
				var dataArr = eval("("+data+")");
				$('#content').html(dataArr.inhoud);
				maketabs();
			});
		});
	});
}
function showPB() {
	changeBG('pb');
	urchinTracker("PB");
	$('#content').fadeOut('fast', function() {
		$(this).html('').css({width: "400px"}).SlideInDown(700, function(){
			$.post("handler.php", { name: "pb" }, function(data){
				var dataArr = eval("("+data+")");
				$('#content').html(dataArr.inhoud);
				maketabs();
			});
		});
	});
}
function showRoute() {
	changeBG('route');
	urchinTracker("Route");
	$('#content').fadeOut('fast', function() {
		$(this).html('').css({width: "350px"}).DropInLeft('slow', function(){
			$.post("handler.php", { name: "route" }, function(data){
				var dataArr = eval("("+data+")");
				$('#content').html(dataArr.inhoud);
			});
		});
	});
}
function showContact() {
	changeBG('contact');
	urchinTracker("Contact");
	$('#content').fadeOut('fast', function() {
		$(this).html('').css({width: "250px"}).slideDown('slow', function(){
			$.post("handler.php", { name: "contact" }, function(data){
				var dataArr = eval("("+data+")");
				$('#content').html(dataArr.inhoud);
			});
		});
	});
}
function showTerras() {
	changeBG('terras');
	urchinTracker("Terras");
	$('#content').fadeOut('fast', function() {
		$(this).html('').css({width: "300px"}).SlideInDown(700, function(){
			$.post("handler.php", { name: "terras" }, function(data){
				var dataArr = eval("("+data+")");
				$('#content').html(dataArr.inhoud);
			});
		});
	});
}
function refresh() {
	window.location.reload( false );
}
function changeBG(bg) {
	switch(bg) {
		case 'home':
		  $('#innerpage').css({ background: "url('../images/bg_home.jpg') no-repeat top left" });
		  break;    
		case 'menu':
		  $('#innerpage').css({ background: "url('../images/bg_menu.jpg') no-repeat top left" });
		  break;
		case 'pb':
		  $('#innerpage').css({ background: "url('../images/bg_pb.jpg') no-repeat top left" });
		  break;  
		case 'route':
		  $('#innerpage').css({ background: "url('../images/bg_route.jpg') no-repeat top left" });
		  break;
		case 'contact':
		  $('#innerpage').css({ background: "url('../images/bg_contact.jpg') no-repeat top left" });
		  break;
		case 'terras':
		  $('#innerpage').css({ background: "url('../images/bg_terras.jpg') no-repeat top left" });
		  break;
		default:
		  alert("nog bckgrnd loaded");
	}	
}
function verstuurVraag() {
	var email = document.getElementById('email').value;
	var naam = document.getElementById('naam').value;
	var opm = document.getElementById('opm').value;
	$.post("verstuurVraag.php", { naam: naam, email: email, opm: opm  },
		function(data){
			$('#content').html(data);
			
		}
	);
}
