$(document).ready(function(){   	
	$('img').attr("title",function() { return $(this).attr("alt"); });
	var numtext = $('#texts').children('p').size();
	var pos = 1;
	if(numtext == 1) {
		$('#right').css("visibility","hidden");
	}
	$('#right').click(function() {
		pos = pos - -1;
		move = (pos -1) *  -196;
		$('#texts').animate({marginLeft: move + "px"}, 300);
		if(pos == numtext) {
			$('#right').css("visibility","hidden");
		}
		if(pos > 1) {
			$('#left').css("visibility","visible");
		}
		return false;
	});
	$('#left').click(function() {
		pos = pos - 1;
		move = (pos -1) *  -196;
		$('#texts').animate({marginLeft: move + "px"}, 300);
		
		if(pos == 1) {
			$('#left').css("visibility","hidden");
		}
		if(pos < numtext) {
			$('#right').css("visibility","visible");
		}
		return false;
	});
	
	
	$('#tekstKnop').click(function() {
		if($('#texts2').css("display") == "block"){
			$('#texts2').css({"display" : "none"});
			$('#texts').css({"display" : "block"})
			
		}
		else if($('#texts2').css("display") == "none" && $('#texts').css("display") == "block"){
			$('#texts').css({"display" : "none"});
		}
		else if($('#texts').css("display") == "none" && $('#texts2').css("display") == "none"){
			$('#texts').css({"display" : "block"});
		}
		
		
		if($(this).children('img').attr('src') == "images/text.png") {
			$(this).children('img').attr('src',"images/text_actief.png");
			$('#menuKnop').children('img').attr('src',"images/menu_actief.png");
		} else {
			$(this).children('img').attr('src',"images/text.png");
			
			
		}
		$.get("templates/settext.php");
		return false;
	});
	
	$('#menuKnop').click(function() {
		if($('#texts').css("display") == "block"){
			$('#texts').css({"display" : "none"});
			$('#texts2').css({"display" : "block"})
			
		}
		else if($('#texts').css("display") == "none" && $('#texts2').css("display") == "block"){
			$('#texts2').css({"display" : "none"});
		}
		else if($('#texts2').css("display") == "none" && $('#texts').css("display") == "none"){
			$('#texts2').css({"display" : "block"});
		}
		if($(this).children('img').attr('src') == "images/menu.png") {
			$(this).children('img').attr('src',"images/menu_actief.png");
			
			
		} else {
			$(this).children('img').attr('src',"images/menu.png");
			$('#tekstKnop').children('img').attr('src',"images/text.png");
			
		}
		$.get("templates/setmenu.php");
		return false;
	});
	
	
	$('.reactie').focus(function() {
		$(this).attr("tmp",$(this).val());
		$(this).val(""); 
	});
	$('.reactie').blur(function() {
		if($(this).val() == "") {
			$(this).val($(this).attr("tmp"));
		} else {
			$(this).unbind();	
		}
	});
	$('#verzend').click(function() {
		var data = $("form").serialize();
		$.post('templates/mail.php',data,function(terug) {
			$('#melding').html(terug);								
		});
		return false;
	});
	
	
	$("#content").show();
	$("#content").animate({
		height:"360px",
		top:"0px"
		}, 1000);		
	/*$("#newcontent").hover(function(){
		$("#nav").show();	
		$("#nav2").show();	
	}, function(){
		$("#nav").hide();	
		$("#nav2").hide();	
	});
	$('body').click(function(){
		$("#nav").hide();	
		$("#nav2").hide();						 
	 });*/
	
	$('#nav2 a').click(function(){
		var href = $(this).attr('href');
		$("#content").animate({
			top:"-600px"
			}, 1000);		
		$("#content").animate({opacity:0},1,function(){
				window.location.href = href;
		});
		return false;
	});
	$('#nav a').click(function(){
		var href = $(this).attr('href');
		$("#content").animate({
			top:"-600px"
			}, 1000);		
		$("#content").animate({opacity:0},1,function(){
				window.location.href = href;
		});
		return false;
	});
	
// pijltjes voor de tekstpagina //
	
	$("#text2").animate({
		height:"360px",
		top:"0px"
		}, 1000);		
	/*$("#newcontent2").hover(function(){
		$("#navtek").show();	
		$("#navtek2").show();	
	}, function(){
		$("#navtek").hide();	 
		$("#navtek2").hide();	
	});
	$('body').click(function(){
		$("#navtek").hide();	
		$("#navtek2").hide();						 
	 });*/
	
	$('#navtek2 a').click(function(){
		var href = $(this).attr('href');
		$("#text2").animate({
			top:"-600px"
			}, 1000);		
		$("#text2").animate({opacity:0},1,function(){
				window.location.href = href;
		});
		return false;
	});
	$('#navtek a').click(function(){
		var href = $(this).attr('href');
		$("#text2").animate({
			top:"-600px"
			}, 1000);		
		$("#text2").animate({opacity:0},1,function(){
				window.location.href = href;
		});
		return false;
	});
	
// pijltjes voor de tekstpagina //
	
});

function setIsPlaying(status)
{
	// status is true of false
	//alert ("is playing: " + status);
	$.get("templates/setsound.php?status="+status);
}

function setVolume(num)
{
	// variable 'num' is een getal tussen 0 en 100 en geeft het percentage van het volume van het geluid weer.
	$.get("templates/setvolume.php?volume="+num);
}
