/*
#####################################################
# 
# Global Leaders Academy
# JavaScript setup routines
#
# Hand-crafted by Phenotype (phenotype.net)
#
#####################################################
*/

	////////////////////////////////////////////////////////////////////
	//	Initialise setup routines
	////////////////////////////////////////////////////////////////////
	
	// Called when DOM is ready
	$(document).ready(domSetup);
	
	// Called when entire page is loaded
	window.onload = pageSetup;
	
	////////////////////////////////////////////////////////////////////
	//	Define setup routines
	////////////////////////////////////////////////////////////////////
	
	/* 
	domSetup()
	
	All JavaScripts requiring initialisation on DOM LOAD should be called
	from this routine
	-----------------------------------------------------------------------
	*/
	
	function domSetup() {
		
		// Hide content for animation
		hideContent();
		
		// Setup external links
		externalLinks();
		
		// Contact form
		if($('#contact')[0]){
			setupContactForm();
		}
		
		// Insert Flash
		insertFlash();   
		
		// Setup pointless hide window feature
		$('#toggle-window > a').click(toggleWindow);
		
	} // End domSetup()
	
	/* 
	pageSetup()
	
	All JavaScripts requiring initialisation on PAGE LOAD should be called
	from this routine (all images and elements should be loaded and ready to
	manipulate by this point)
	-----------------------------------------------------------------------
	*/
	
	function pageSetup() {
		
		// Check for presence of Flash (to determine which content to show) and the user's OS (to avoid Linux + Flash z-index issues)
		if(swfobject.hasFlashPlayerVersion("9") && (navigator.platform.indexOf('Linux') == -1) && !$('#community')[0] && !$('#news')[0]) {
			// Correct Flash version is installed, and user is not on Linux;
			// Wait for Flash to call animateContent() when it's fully loaded
		} else {
		
			// Flash isn't installed, or user is on Linux;
			// OR user is in #community or #news
			// Animate in static content
			animateContent();
		}
		
	} // End pageSetup()
		
		
	/*
	postSetup()
	
	Function to be called after page setup is complete
	-----------------------------------------------------------------------
	*/
		
	function postSetup() {
		
		// Play Flash animations if Flash is installed
		if(swfobject.hasFlashPlayerVersion("9") && (navigator.platform.indexOf('Linux') == -1) && !$('#community')[0] && !$('#news')[0]) {
			(jQuery.browser.msie ? window["tree-animation-replaced"] : document["tree-animation-replaced"]).playAnimation();
		}
		
		// Create scroll panes if needed
		if($('#community')[0] || $('#news')[0] || $('#contact')[0] || $('#grounding')[0]){
			$('#inner-content').jScrollPane({
				showArrows: 'true',
				scrollbarWidth: 15,
				arrowSize: 15
			});
		}
		
	}  // End postSetup()