// JavaScript Document

/*
NOTES:
	The string "ajaxCall" is added to URLs to tell Fusebox not to load the layout components such as
	htmlHeader, banner, menus, etc.  Just the core content is then generated to load into the nominated
	content area.  

 */

$(function (){
	$("#accordionNav").accordion({autoHeight: false, active: true, collapsible: true, navigation: true});
	/*
	 	active: true, opens site with all panels closed, 	
	 	collapsible: true toggles a panel open/closed, 
	 	autoHeight: false allows each panel to open to its natural height, rather than the height of the highest panel.
	*/
});

$(function (){
	$(".accordionMain, .accordionSub").click (function (e) {
		//Load nominated content to the contentData div for all left menu items.
		e.preventDefault();
		var urlTarget = $.trim(e.target) + "&ajaxCall&anchorLabel="+encodeURIComponent($.trim($(this).text()));
		$("#contentData").load(urlTarget);
	});
	
	$("#topMenu2 a").click(function(e){
		//When a link appearing anywhere in the content area is of the standard form,
		//(a href), replace the current contentData div content with the requested content.
		e.preventDefault();
		var urlContentTarget = $.trim($(this).attr('href')) + "&ajaxCall";
		$("#contentData").load(urlContentTarget);
	});		
	
	$("#contentData a").delegate("", "click", function(e){
		//When a link appearing anywhere in the content area is of the standard form,
		//(a href), replace the current contentData div content with the requested content.

		var doAjaxLoad = true;
		var urlContentTarget = $.trim($(this).attr('href')) + "&ajaxCall&anchorLabel="+encodeURIComponent($.trim($(this).text()));
		if ((urlContentTarget.indexOf("cart") > -1) || (urlContentTarget.indexOf("pdf") > -1) || (urlContentTarget.indexOf("index.cfm") == -1)  ) {
			//Exclude unsuitable targets from the ajax load method ie;
			// loading the cart, loading a pdf, or linking off-site.
			doAjaxLoad = false;
		}
		if (doAjaxLoad == true) {
			e.preventDefault();
			//prompt("FOO",urlContentTarget);
			$("#contentData").load(urlContentTarget);
		}
	});
});

