// JavaScript Document
var thePathArray;
var thePage;
var theId;
var trefw;
var reg;
var strt;
var stp;
var indiv;
var organ;

			
$(document).ready(function(){
	
	
	$.ajaxSetup({
		error:function(x,e){
			if(x.status==0){
			$("#links").html('U bent offline...\n Gelieve uw internetverbinding te controleren.');
			}else if(x.status==404){
			$("#links").html('Sorry, deze pagina werd niet gevonden.');
			}else if(x.status==500){
			$("#links").html('Interne serverfout.');
			}else if(e=='parsererror'){
			$("#links").html('Er is een fout gebeurd, gelieve later opnieuw te proberen.');
			}else if(e=='timeout'){
			$("#links").html('Er is een time-out opgetreden, gelieve later opnieuw te proberen.');
			}else {
			$("#links").html('Onbekende fout.\n'+x.responseText);
			}
		}
	});
		$("#menucontainer").load("content/menu.php", {}, function() { 
				$('#hetmenu  > li').bind('mouseover', menu_open);
				$('#hetmenu  > li').bind('mouseout',  menu_timer);
				$('.klein,').click(function() { $.address.value($(this).attr('rel')); });
				$('.menuitem').click(function() { $.address.value($(this).attr('rel')); });
				$('.submenuitem').click(function() { $.address.value($(this).attr('rel')); });	
				
				$('span').removeClass('green');
				$("span[rel='pagina/"+theId+"']:not(.menuitem_nonactive, .klein_nonactive, .klein)").addClass('green');
			});
		
		$.address.change(function(event) {  
			 thePathArray = event.value.split('/');
			 thePage = thePathArray[1];
			 theId = thePathArray[2];
			 trefw = thePathArray[3];
			 reg = thePathArray[4];
			 strt = thePathArray[5];
			 stp = thePathArray[6];
			 indiv = thePathArray[7];
			 organ = thePathArray[8];
			
			if (!thePage) {
				thePage='pagina';
				theId=1;
			}
			
			$('span').removeClass('green');
			$("span[rel='pagina/"+theId+"']:not(.menuitem_nonactive, .klein_nonactive, .klein)").addClass('green');
			//$("span[rel='pagina/"+theId+"']").addClass('green');
			
			$("#links").load("content/"+thePage+".php"
							,{ id: theId, trefwoord: trefw, regio: reg, start: strt, stop: stp, ind: indiv, org: organ}
							, function() {
								}
			);
			
			if (thePage=='pagina' && theId==1) {
				$("#rechts").load("content/news.php", {}, function() {
					$("#newscontent").load("content/newscontent.php", {limit1:0, limit2:5}, function() { 
						$('.newsitem').click(function() { $.address.value($(this).attr('rel'));  });
					}); 
				});	
			}
			else if (thePage=='pagina' && theId==13) {
				$("#rechts").load("content/contact.php", {}, function() {	
				});	
			}
			else {
				$("#rechts").load("content/"+thePage+"rechts.php", { id: theId, trefwoord: trefw, regio: reg, start: strt, stop: stp, ind: indiv, org: organ},function(){
					$("a[rel^='prettyPhoto']").prettyPhoto({
						theme:'light_square',
						overlay_gallery: false
					});
				});	
			}
		}); 
		
		
});
	
	function tagAddressChange(id) {$.address.value('werksoort/'+id);}
	function browseAddressChange(i) {$.address.value(i);}

	function loadMoreNews(l1,l2) {
		$("#newscontent").load("content/newscontent.php", {limit1:l1, limit2:l2}, function() { 
			$('.newsitem, #nieuwsbrieflink').click(function() { $.address.value($(this).attr('rel')); });
		});
	}

	function ClickToPrint(div, title)
		 {
		var DocumentContainer = document.getElementById(div);
        var WindowObject = window.open('', 'Print','width=740, height=325, top=200, left=250, toolbars=no, scrollbars=yes, status=no, resizable=yes');
       
		WindowObject.document.writeln("<html><head><title>"+title+"</title><link rel='stylesheet' type='text/css' href='css/groepintro.css' /></head><body>");
		WindowObject.document.writeln(DocumentContainer.innerHTML);
        WindowObject.document.writeln("</body></html>");
        WindowObject.document.close();
        WindowObject.focus();
        WindowObject.print();
        //WindowObject.close();

		}
		
			
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-2811101-48']);
	_gaq.push(['_trackPageview']);
	
	(function() {
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	})();
	
