$(document).ready(function() {

	// Single.php view --------------------------
	$("#post-single-container p").hide(); // hide all <p>
	$("#post-single-container p:first-child").show(); // show 1st <p>
	
	$("#post-single-container p:first-child").next().addClass('post-single-imgtext').show(); // show 2nd <p> 
	
		if ( $(".post-single-imgtext").next().length ) { 
			$(".post-single-imgtext").append('<span id="post-single-more">Meer info &gt;&gt;</span>').show(); // add 'link' if 3rd <p> exists
		} 
	
	$("#post-single-container p:first-child").next().next().addClass('post-single-info'); // add class to 3rd <p>
	$("#post-single-container p:first-child").next().next().append('<span id="post-single-back"><img src="/wp-content/themes/Starkers/images/arrow-x.gif" alt="Terug"></span>'); // add back 'link' to 3rd <p>

	$("#post-single-more").click(function (i) { // if clicked on 'link' in 2nd <p>; show all <p> but hide 1st & 2nd
		$("#post-single-container p").show();
		$("#post-single-container p:first-child").hide();
		$("#post-single-container p:first-child").next().hide();
		$(".post-head-nav").hide();
		
	});
	$("#post-single-back").click(function (i) { // if clicked on 'link' in 3rd <p>; hide all <p> but show 1st & 2nd
		$("#post-single-container p").hide();
		$(".post-head-nav").show();
		$("#post-single-container p:first-child").show();
		$("#post-single-container p:first-child").next().show();
	});


						   





	$("#imgContainer p").hide();
	$("#imgContainer p:first-child").show();
	$("#imgContainer p:first-child").next().show();
	
	// Galery --------------------------

	var activeImg = 1;
	var nthChild = 1;
	
	$("#previous_img").click(function (i) {
		if ( activeImg == 1 ) {
			// deze knop werkt niet
		} else {
			activeImg = activeImg - 1;
			nthChild = nthChild - 2;
			$("#imgContainer p").hide();
			var childNumber = ":nth-child(" + nthChild + ")";
			$("#imgContainer p" + childNumber).show();
			$("#imgContainer p" + childNumber).next().show();
		}
    });
	
	$("#next_img").click(function (i) {
								   
		var amountOfImages = $("#imgContainer img").size();		
		
		if ( activeImg == amountOfImages ) {							   
			// deze knop werkt niet
		} else {									   
			activeImg = activeImg + 1;
			nthChild = nthChild + 2;	
			$("#imgContainer p").hide();
			var childNumber = ":nth-child(" + nthChild + ")";
			$("#imgContainer p" + childNumber).show();
			$("#imgContainer p" + childNumber).next().show();
		}
    });

	
	$("#textContainer #text").hide();

	$("#previous_text").click(function (i) {
		$("#textContainer #mainImg").show();					   
		$("#textContainer #text").hide();
    });
	
	$("#next_text").click(function (i) {
		$("#textContainer #mainImg").hide();					   
		$("#textContainer #text").show();
	});




});


