var updatecounter; // tel de update
	
function changeHomeFotoAspectStaand() {
	$("#Home_Foto").stop().animate({ width: "463px" }, "slow");
	$(".Home_Image").stop().animate({ width: "463px" }, "slow");
	$("#Home_Tekst").stop().animate({ width: "454px" }, "slow");
	$("#Home_Nextrandom").stop().animate({ width: "463px" }, "slow");
}

function changeHomeFotoAspectLiggend() {
	$("#Home_Foto").stop().animate({ width: "582px" }, "slow");
	$(".Home_Image").stop().animate({ width: "582px" }, "slow");
	$("#Home_Tekst").stop().animate({ width: "335px" }, "slow");
	$("#Home_Nextrandom").stop().animate({ width: "582px" }, "slow");
}			
	
	
function changeHomeFotoAspectStaandnoanim() {
	$("#Home_Foto").stop().css({ width: "463px" });
	$(".Home_Image").stop().css({ width: "463px" });
	$("#Home_Tekst").stop().css({ width: "454px" });
	$("#Home_Nextrandom").stop().css({ width: "463px" });
}

function changeHomeFotoAspectLiggendnoanim() {
	$("#Home_Foto").stop().css({ width: "582px" });
	$(".Home_Image").stop().css({ width: "582px" });
	$("#Home_Tekst").stop().css({ width: "335px" });
	$("#Home_Nextrandom").stop().css({ width: "582px" });
}

function addItemsUpdates() {
	//alert('test');
	$("#UpdatesContainer").append("<div id=\"UpdateContent"+updatecounter+"\"></div>");
	//$("#UpdateContent"+updatecounter).append("twetwet");
	$("#UpdateContent"+updatecounter).hide().load("./includes/getupdates.inc.php?count="+updatecounter, function() {
		refreshFonts();
		$(this).slideDown("slow");
	});
	//}
	updatecounter = updatecounter + 10;
//	alert(updatecounter);
}


			
function loadPage(page, openupdate) {  //laad pagina	
		updatecounter = 10; // init updatecounter (om de updates te tellen bij het uitklappen!)
			$('#Main_Content').stop().fadeOut("fast", function() {
				$('#Main_Content').load('./text_fetcher_jquery.php?page='+page, function() { 
					if (page == "home") {
						var isStaand = $('#homeslide').hasClass('staand');
 		 				if (isStaand == true) {
 		 					changeHomeFotoAspectStaandnoanim();
 		 				} else {
 		 					changeHomeFotoAspectLiggendnoanim();
 		 				}
					}
					
					refreshFonts();
					$('#Main_Content').stop().fadeTo('slow', 1);
				});	
      		});
     }

function goToUpdates() {
		menuselect = 'updates';
 			changeMenuStatus();
			changeMenu("#Menu_Updates");
			loadPage(menuselect);	
			refreshFonts();
}

function goToHome() {
		menuselect = 'home';
 		changeMenuStatus();
		changeMenu("#Menu_Home");
		loadPage(menuselect);	
		refreshFonts();
}

function goToUpdatesOpen() {
		menuselect = 'updates';
 			changeMenuStatus();
			changeMenu("#Menu_Updates");
			loadPage(menuselect, 'test');	
			refreshFonts();
}

function goToInfo() {
			menuselect = 'info';
 		 	changeMenuStatus();
			changeMenu("#Menu_Info");
			loadPage(menuselect);	
			refreshFonts();
}




function changeMenu(page) {   // gekozen menuitem
		$(page).css({ color: "#FFFFFF"});
		$(page).stop().animate({ backgroundColor: "#C7CDCD" }, "slow");
	}
	
function changeMenuStatus() {  // de rest van de ongekozen menuitems veranderen. had mooier gekund, maar ja.
	if (menuselect == 'home'){
		$("#Menu_Gallery").stop().css({ backgroundColor: "#ffffff" });
		$("#Menu_Gallery").stop().css({ color: "#000000"});
		$("#Menu_Updates").stop().css({ backgroundColor: "#ffffff" });
		$("#Menu_Updates").stop().css({ color: "#000000"});
		$("#Menu_Info").stop().css({ backgroundColor: "#ffffff" });
		$("#Menu_Info").stop().css({ color: "#000000"});
	}

	if (menuselect == 'gallery'){
		$("#Menu_Home").stop().css({ backgroundColor: "#ffffff" });
		$("#Menu_Home").stop().css({ color: "#000000"});
		$("#Menu_Updates").stop().css({ backgroundColor: "#ffffff" });
		$("#Menu_Updates").stop().css({ color: "#000000"});
		$("#Menu_Info").stop().css({ backgroundColor: "#ffffff" });
		$("#Menu_Info").stop().css({ color: "#000000"});
	}
	
	if (menuselect == 'updates'){
		$("#Menu_Home").stop().css({ backgroundColor: "#ffffff" });
		$("#Menu_Home").stop().css({ color: "#000000"});
		$("#Menu_Gallery").stop().css({ backgroundColor: "#ffffff" });
		$("#Menu_Gallery").stop().css({ color: "#000000"});
		$("#Menu_Info").stop().css({ backgroundColor: "#ffffff" });
		$("#Menu_Info").stop().css({ color: "#000000"});
	}
	
	if (menuselect == 'info'){
		$("#Menu_Home").stop().css({ backgroundColor: "#ffffff" });
		$("#Menu_Home").stop().css({ color: "#000000"});
		$("#Menu_Gallery").stop().css({ backgroundColor: "#ffffff" });
		$("#Menu_Gallery").stop().css({ color: "#000000"});
		$("#Menu_Updates").stop().css({ backgroundColor: "#ffffff" });
		$("#Menu_Updates").stop().css({ color: "#000000"});
	}
}

function refreshFonts() {
	Cufon.replace('* > span.martenfont');
    Cufon.replace("* span.martenfont");	
    Cufon.replace('* > span.martenfont_menu');
    Cufon.replace("* span.martenfont_menu");
    Cufon.replace('* > span.martenfont_titel');
    Cufon.replace("* span.martenfont_titel");
    Cufon.replace('* > span.martenfont_kleintitel');
    Cufon.replace("* span.martenfont_kleintitel");
}

$(document).ready(function() {
	 // variable init

	menuselect = 'home';  // standaardwaarde
	$("#Menu_Home").css({ color: "#FFFFFF"});
	$("#Menu_Home").css({ backgroundColor: "#C7CDCD" });
	 loadPage(menuselect);	 			
	refreshFonts();
	// animaties knoppen
	$("#Menu_Home").click(
 		function () {
 			menuselect = 'home';
 			changeMenuStatus();
 			changeMenu(this);
 			loadPage(menuselect);	 			
			refreshFonts(); 
		}
	);
	
	$("#Menu_Gallery").click(
 		function () {
 			tester = 'sjaak';
 			menuselect = 'gallery';
 			changeMenuStatus();
			changeMenu(this);
			loadPage(menuselect);	
			refreshFonts(); 
			}
	);
	
	$("#Menu_Updates").click(
 		function () {
 			menuselect = 'updates';
 			changeMenuStatus();
			changeMenu(this);
			loadPage(menuselect);	
			refreshFonts();
			}
	);

	$("#Menu_Info").click(
 		 function () {
 		 	menuselect = 'info';
 		 	changeMenuStatus();
			changeMenu(this);
			loadPage(menuselect);	
			refreshFonts();
			}
	);

	$("#Menu_Home").hover(
 		 function () {
			if (menuselect != 'home') {
			$(this).stop().css({ backgroundColor: "#f3f3f3" });
			}
  	}, 
 		 function () {
 		 	if (menuselect != 'home') {
			//$(this).stop().animate({ backgroundColor: "white" }, "slow");
			$(this).stop().css({ backgroundColor: "white" });
			}
  		}
	);
	
	$("#Menu_Gallery").hover(
 		 function () {
 		 if (menuselect != 'gallery') {
			$(this).stop().css({ backgroundColor: "#f3f3f3" });
		 }
  	}, 
 		 function () {
 		 if (menuselect != 'gallery') {
			//$(this).stop().animate({ backgroundColor: "white" }, "slow");
			$(this).stop().css({ backgroundColor: "white" });
  		 }
  		}
	);
	
	$("#Menu_Updates").hover(
 		 function () {
 		 if (menuselect != 'updates') {
			$(this).stop().css({ backgroundColor: "#f3f3f3" });
		 }
  	}, 
 		 function () {
 		 if (menuselect != 'updates') {
			//$(this).stop().animate({ backgroundColor: "white" }, "slow");
			$(this).stop().css({ backgroundColor: "white" });
		 }
  		}
	);
	

	$("#Menu_Info").hover(
 		 function () {
 		 if (menuselect != 'info') {
			$(this).stop().css({ backgroundColor: "#f3f3f3" });
		 }
  	}, 
 		 function () {
 		 if (menuselect != 'info') {
			//$(this).stop().animate({ backgroundColor: "white" }, "slow");
			$(this).stop().css({ backgroundColor: "white" });
		 }
  		}
	);



});


