Cufon.replace('h1, h2, #lndng-pg-cntnt h3, #whats-on-info h3, #whats-on-box h3, #week-picker h3, #calendar div.watermark, a#find-out-whats-on');

jQuery(document).ready(function(){

	/* Open external links in new tab */
	
		jQuery("a[rel=external]").attr({ target: "_blank" });

	/* Run the more complex functions */

		expandList();

	/*Expanding list - site map, org diagrams etc */
	
		function expandList(){
			var expandText = "(expand)"
			var closeText = "(close)"
			jQuery(".expnd-lst li>ul").addClass("hide");
			jQuery(".expnd-lst li").each( function(){
				var $this = jQuery(this);
				if($this.find("ul").length > 0){
					var expandTextAdditonal = "<em class=\"hide\">" + $this.text().split("\n")[0] + "</em>";
					$this.addClass("off").find("ul:first").before(" <a class=\"expand\" href=\"#\"><small>"+expandText+expandTextAdditonal+"</small><span></span></a>")
				}
			});
			
			jQuery(".expand").click(function(){
				var $this = jQuery(this);
				var expandTextAdditonal = "<em class=\"hide\">" + $this.parent().text().split("\n")[0] + "</em>";
				//if($this.text().indexOf(expandText)!=-1){
				if($this.parent().hasClass("off")){
					$this.parent().addClass("on").removeClass("off").find("ul:first").removeClass("hide");
					$this.find("small").html(closeText+expandTextAdditonal);
				} else {
					$this.parent().addClass("off").removeClass("on").find("ul:first").addClass("hide");
					$this.find("small").html(expandText+expandTextAdditonal);
				}
				return false;
			});
		};
});
