/*
#####################################################
# 
# Phenotype.net v2009
# 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() {
		
		// Setup external links
		externalLinks();

		// Setup lightbox
		$('a[@rel*=lightbox]').lightBox();
		
		// Setup slideshow sliders and image lazy-loading
		if($('.slideshow')[0]) {
			
			if($('.portfolio')[0]){
				
				// Portfolio slideshows
				contentSlider({ slides: '.slide', container: '.slideshow-container', scroller: '.slideshow-scroller', parent: '.slideshow', navigation: '.slideshow-navigation' }, { orientation: "horizontal", buttons: false }, { easing: 'easeOutBounce', duration: 900 });
				
			} else {
				
				// Default slideshows
				contentSlider({ slides: '.slide', container: '.slideshow-container', scroller: '.slideshow-scroller', parent: '.slideshow', navigation: '.slideshow-navigation' }, { orientation: "horizontal", buttons: false }, { easing: 'easeOutBounce', interval: 5000, duration: 900, force: true });
				
			}
			
			$('.slideshow-scroller img').lazyload({
				threshold		: 400,
				failurelimit	: 10,
				container		: $(".slideshow-scroller"),
				placeholder 	: "/assets/templates/phenotype/images/template/common/loading.gif",
				background		: "#ffffff",
				effect      	: "fadeIn",
				effectspeed		: 500
			});
		}
		
		// Setup page sliders and image lazy-loading
		if($('.page-container')[0]) {
			
			contentSlider({ slides: '.page', container: '.page-container', scroller: '#content-body', parent: '#content', navigation: '.page-navigation' }, { orientation: 'horizontal', type: 'fluid', buttons: true }, { easing: 'easeOutBounce', duration: 900 });
			
			$('#content-body img').lazyload({
				threshold		: 400,
				failurelimit	: 10,
				container		: $("#content-body"),
				placeholder 	: "/assets/templates/phenotype/images/template/common/loading.gif",
				background		: "#ffffff",
				effect      	: "fadeIn",
				effectspeed		: 500
			});
			
		}
		
		// Setup overlay animation
		if(!$.browser.msie) {
		
			$('span.overlay').css({ 'background-position': 'center center', 'opacity': 0}).hover(function () { $(this).stop().animate({ 'opacity': 1}, { duration: 300 }) }, function () { $(this).stop().animate({ 'opacity': 0}, { duration: 300 }) });
		
		} else {
			
			// IE
			$('span.overlay').css({ 'background-position': 'center center', 'opacity': 0}).hover(function () { $(this).stop().animate({ 'opacity': 0.75}, { duration: 300 }) }, function () { $(this).stop().animate({ 'opacity': 0}, { duration: 300 }) });
		}
		
		// Setup navigation animation
		animatedNavigation('#navigation li', {
			selectedClass		: 'selected',
			hoverClass			: 'hover',
			fadeInDuration		: 200,
			fadeOutDuration		: 400
		});
		
	} // 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() {

	
	} // End pageSetup()