	// create & append the links to the banners.
	
	var currentPosition = 0;
	
	$(function(){
		
	// Dropdown nav
		$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
				$("ul.menu li span").click(function() { //When trigger is clicked...			
			//Following events are applied to the subnav itself (moving subnav up and down)
			$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
	
			$(this).parent().hover(function() {
			}, function(){	
				$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
			});
	
			//Following events are applied to the trigger (Hover events for the trigger)
			}).hover(function() { 
				$(this).addClass("subhover"); //On hover over, add class "subhover"
			}, function(){	//On Hover Out
				$(this).removeClass("subhover"); //On hover out, remove class "subhover"
		});
				
		$('ul.menu ul.subnav li:first-child').addClass('nobordertop');
		$('ul.menu ul.subnav li:last-child').addClass('noborderbot');


			   
			   
			   
			   
			   
			   
			   
			   
			   
			   
	
		var links = "<ul id=\"links\" class=\"clearfix\"><li class=\"previous\"><a href=\"#\">Previous</a> | </li><li class=\"separator\"></li><li class=\"next\"><a href=\"#\">Next</a></li><li class=\"position\" id=\"one\"><a href=\"#\" class=\"active\">1</a></li><li class=\"position\" id=\"two\"><a href=\"#\" class=\"nonactive\">2</a></li><li class=\"position\" id=\"three\"><a href=\"#\" class=\"nonactive\">3</a></li></ul>";
		$("#content #rotating").after(links);
		
		/*
		 * Hero Banners.
		 * 11/10/2009
		 * simon winter
		 * ----
		 * Set up the rotating hero banners on the homepage.
		 * - Add the links to navigate through each banner.
		 * - 
		 * */		 		

		// set up initial status of the previous link.
		//$("#links .previous a").replaceWith("<div>Previous</div>");		 

		// the 3 position indicator elements.
		var positionElements = $("#links").children(".position");		 

		// click events for all the links.		

		// first position link
		$("#links #one").click(function() {																	
			switchBanner(0,"firstbanner","one");
		});		

		// second position link
		$("#links #two").click(function() {
			switchBanner(1,"secondbanner","two");
		});		

		// third position link
		$("#links #three").click(function() {
			switchBanner(2,"thirdbanner","three");
		});		 

		// next link
		$("#links .next").click(function() {
			if(currentPosition >= 2)
				return;		

			var next = 1;
			var banner = "firstbanner";
			var id = "one";			

			switch(currentPosition) {
				case 0:
				{
					next = 1;
					banner = "secondbanner";
					id = "two";
					break;
				}
				case 1:
				{
					next = 2;
					banner = "thirdbanner";
					id = "three";
					break;
				}
			}
			switchBanner(next,banner,id);
		});		

		// previous link
		$("#links .previous").click(function() {
			if(currentPosition <= 0)
				return;			

			var previous = 0;
			var banner = "firstbanner";
			var id = "one";
			
			switch(currentPosition) {
				case 1:
				{
					previous = 0;
					banner = "firstbanner";
					id = "one";
					replaceContent = "<li class=\"previous\">Previous</li>";
					break;
				}
				case 2:
				{
					previous = 1;
					banner = "secondbanner";
					id = "two";
					break;
				}
			}
			switchBanner(previous,banner,id);
		});
		/* End Hero Banners
		 * */		
	});
	
	
	
	/* ------------
	 * switchBanner
	 * 12/10/2009
	 * simon winter
	 * ----
	 * This is called bby click events for the buttons on the 
	 * banner rotator. It also checks to see if it needs to 
	 * disable the previous/next buttons.
	 * ------------ */
	 
	function switchBanner( position, banner, id) {
		if(currentPosition != position) {
			currentPosition = position;
			$("#rotating li").hide();
			$("#rotating li."+banner).fadeIn();
			$("#links li.position a").attr("class","nonactive");
			$("#links #"+id+" a").attr("class","active");				

			// check the next & previous links - adjust if necessary.
			/*if(currentPosition == 0) {
				$("#links .next").html("<a href=\"#\">Next</a>");
				$("#links .previous a").replaceWith("<div>Previous</div>");
			} else if(currentPosition == 2) {
				$("#links .next a").replaceWith("<div>Next</div>");
				$("#links .previous").html("<a href=\"#\">Previous</a>");
			} else {
				$("#links .previous").html("<a href=\"#\">Previous</a>");
				$("#links .next").html("<a href=\"#\">Next</a>");
			}*/
		}
	}

	
	