var interval;
var counter = 0;
var contentelements = Array("menu", "content", "info", "afbeelding", "black1", "black2", "black3");

function load(t) {
	interval = setInterval("run()", t);
}
function run() {
	$("#" + contentelements[counter]).fadeIn(3000);
	counter++;
	if(counter == contentelements.length) {
		clearInterval(interval);
	}
}

function emptyField(name, value) {
	value = unescape(value);
	
	if($("#" + name).val() == value) {
		$("#" + name).val("");
	}
}

function goToTop(top) {
	currenturl = document.location.href;
	if(currenturl.indexOf(top) != -1) {
		currenturl.replace("#" + top, "");
	}
	document.location.href = currenturl + "#" + top;
}
 
//wordt niet gebruikt
function getPage(id, module, view) {
	
	var currentTime = new Date();
	
	params = {
	type: "page",
	module: module,
	id: id
	};

	$.post("ajax_site.php",
   	params,
   	function(data){
   		$("#" + view).html(data);
   	}
 	);
}
//wordt niet gebruikt
function getOverview(id, module, view) {
	
	var currentTime = new Date();
	
	params = {
	type: "overview",
	module: module,
	id: id
	};

	$.post("ajax_site.php",
   	params,
   	function(data){
   		$("#" + view).html(data);
   	}
 	);
}

function openRespons(id) {
	reactie = $("#reactietxt_" + id).html();
	
	reactie_field = "<textarea class=\"respons_field\" name=\"bericht\" id=\"bericht\">" + reactie + "</textarea>";
	$("#reactietxt_" + id).html(reactie_field);

	$("#reactief_" + id).css("display", "none");
	$("#reactief_" + id + "_opslaan").css("display", "block");
}

function editRespons(id) {
	
	var currentTime = new Date();
	
	params = {
	type: "edit",
	id: id, 
	bericht: $("#bericht").val()
	};

	$.post("ajax_respons.php",
   	params,
   	function(data){
   		$("#reactietxt_" + id).html(data);
   	}
 	);
	
 	$("#reactief_" + id).css("display", "block");
	$("#reactief_" + id + "_opslaan").css("display", "none");
}

function deleteRespons(id) {
	//removing FCK editor produces errors, therefore only hide it...
	$("#chapter_" + id).css("display", "none");
	$("#chapter_title_" + id).remove();
	
	//ajax call to delete chapter
	params = {
	id: id,
	type: "del"
	};

	$.get("ajax_chapter.php",
   	params,
   	function(data){
   	
   	}
 	);
}

window.onload = function(){
	
	var options = {
		animate:			false,
        autoplayMovies:     false
    };
	
	Shadowbox.init(options);

};
