$(document).ready(function(){
	//hide tricky bits
	$("div.tricky").hide();
    $("h3.tricky").addClass("closed");
    
    //show the note about expandable headings to everyone who gets to see them    
    $(".jqueried").css('display', 'block');

	//toggle tricky bits on demand
	$("h3.tricky").click(function(){
	  $(this).next("div.tricky").slideToggle(100)
	  $(this).toggleClass("open closed");	  		 
	  return false;
	});

	//hide all tricky bits
	$(".hide_the_tricky").click(function(){
	  $(".tricky div").slideUp(100)
	  $(".tricky h3.open").toggleClass("open closed");
	  return false;
	});

	//show all tricky bits
	$(".give_me_tricky").click(function(){
	  $(".tricky div").slideDown();
	  $(".tricky h3.closed").toggleClass("open closed");
	  return false;
	});
	
		
	//Allow a switch to show and hide an application box, and expand posts accordingly
	if ($("#posts").hasClass("expanded")){
		$(".slideright").hide();
	}
	else {
		$(".slideleft").hide();
	}
	$(".slideright").click(function () {
      $(this).hide();
      $(".slideleft").show();
      $("#appDiv").hide();//"slide", { direction: "right" }, "fast");
      $("#posts").animate({"width": "700px"}, "fast");
      $("#posts").addClass("expanded");
      return false;
	});

	$(".slideleft").click(function () {
      $(this).hide();
      if ($("#appBox").hasClass("uninitialised")){
		  $("#appBox").attr("src", $(".boxlink").attr("href"));
		  $("#appBox").removeClass("uninitialised");
	  }
      $(".slideright").show();
      $("#posts").animate({"width": "300px"}, "fast");
      $("#posts").removeClass("expanded");
      $("#appDiv").show();//show("slide", { direction: "left" }, "fast");
	});
	
	$(".boxlink").click(function () {
		$(".slideleft").click();
		return true;
	});

});

