$(document).ready(function() {

// Show / Hide homepage
	//$("#hideText").delay(4000);
	//$("#hideText").show('slow');
	$('#hideText').click(function() {
	    	$('#homeContent').slideToggle('fast');
	
	}).toggle(function() {
		$('#hideText').attr("id","showText");
	    	$('#showHide').attr('src','/wp-content/themes/castlecourt/images/hideText.jpg');	
	    	$('.entry-content').jScrollPane({showArrows:true, scrollbarWidth: 10});
	}, function() {
		$('#showHide').attr('src', '/wp-content/themes/castlecourt/images/showText.jpg');
		$('#showText').attr("id","hideText");
	});
	
	
// Show / Hide Internal
	$('#showTextInternal').click(function() {
	    	$('#content').slideToggle('fast');
	
	}).toggle(function() {
		$('#showTextInternal').attr("id","hideTextInternal");
	    	$('#showHide').attr('src','/wp-content/themes/castlecourt/images/showText.jpg');	
	    	$('.entry-content').jScrollPane({showArrows:true, scrollbarWidth: 10});
	}, function() {
		$('#showHide').attr('src', '/wp-content/themes/castlecourt/images/hideText.jpg');
		$('#hideTextInternal').attr("id","showTextInternal");
	});
	
// Show / Hide Special
	$('#showTextSpecial').click(function() {
	    	$('#specialContent').slideToggle('fast');
	
	}).toggle(function() {
		$('#showTextSpecial').attr("id","hideTextInternal");
	    	$('#showHide').attr('src','/wp-content/themes/castlecourt/images/showText.jpg');	
	    	$('.entry-content-special').jScrollPane({showArrows:true, scrollbarWidth: 10});
	}, function() {
		$('#showHide').attr('src', '/wp-content/themes/castlecourt/images/hideText.jpg');
		$('#hideTextInternal').attr("id","showTextSpecial");
	});
	
// Show / Hide for Pop Up Pages
	var clicked = false;

	$("#popupPages ul li h3").click(function() {
	    //check what the margin is originally
		var thisParent = $(this).parent();
		var ulParent = $(thisParent).parent();
		if (clicked) {
			$(ulParent).children().animate({
			    marginTop: "95px"
			}, '400', 'easeOutQuint');
		}
		if($(thisParent).css("margin-top")=="95px") {
			$(this).parent().animate({
			      marginTop: "0px"
			}, 400, 'easeOutQuint');
			clicked = true;
		} else {
			$(this).parent().animate({
			      marginTop: "95px"
			}, 400, 'easeOutQuint');
			clicked = false;
		}
	});
	
// jScroller
	$('.entry-content').jScrollPane({showArrows:true, scrollbarWidth: 10});
	$('.entry-content-special').jScrollPane({showArrows:true, scrollbarWidth: 10});
	$('.entry-content-sitemap').jScrollPane({showArrows:true, scrollbarWidth: 10});
	
// Pop up 
	//$(".carousel2").delay(4000);
	//$(".carousel2").show('slow');
	$('#closeButton').click(function() {
		$('.carousel2').hide('fast', function() {
			// Animation complete.
		});
	});
	
//Popup Carousel
	$(function() {
    		$(".carousel2").jCarouselLite({
			btnNext: ".nextImage2",
			btnPrev: ".previous2",
			visible: 1,
     			auto: 8000,
			speed: 1000
   		});
	});
	
// Gallery
	$("#galleria").galleria({
		autoplay: 4000,
		transition: 'fade',
		transitionSpeed: 1500,
		thumbnails: false,
		showCounter: false,
		showInfo: false
	});
	
});
