/*
#####################################################
# 
# Neil Lerner Kitchens
# JavaScript setup routines
# Last modified: 12:16 05/01/2009
#
# Hand-crafted by Phenotype (phenotype.net)
#
#####################################################
*/

	////////////////////////////////////////////////////////////////////
	//	Initialise setup routines
	////////////////////////////////////////////////////////////////////

	// jQuery no conflict mode
	jQuery.noConflict(); // Otherwise QuickEdit's mootools will stop jQuery working
	
	// Called when DOM is ready
	jQuery(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 tabs
		jQuery("ul#canvas-navigation").tabs({
			fx: {height: 'toggle'},
			selected: 0
		});
		
		// Setup external links
		externalLinks();
		
		// Setup dropdown menus
		jQuery('ul.dropdown-menu').superfish({
			dropShadows: false,
			animation : { width: 'show', height: 'show'},
			speed : 'slow'
		});
		
		// Setup tooltips
		jQuery('a.tooltip').cluetip({
			width: 'auto',
			sticky: true,
			topOffset: 10,
			leftOffset: 10, 
			waitImage: false,
			closePosition: 'title',
			arrows: true,
			hideLocal: true,
			dropShadow: true,
			activation: 'hover',
			cursor: 'pointer',
			fx: {
				open: 'show', // can be 'show' or 'slideDown' or 'fadeIn'
				openSpeed: ''
			},
			local: true,
			cluezIndex: 998
		});
		
		// Setup scrapbook popup
               if (jQuery.cookie('hidePopup')!='1') {
		  jQuery('#popup').animate({ width: 'show', height: 'show'}, "slow");
               }
		jQuery('#popup-close > a').click(function(){
			jQuery('#popup').animate({ width: 'hide', height: 'hide'}, "slow");
                        jQuery.cookie('hidePopup', '1');
			return false;
		});
		
		// Setup background changing
		var pageBackgrounds = [
			"page-background-01.jpg"
			,"page-background-02.jpg"
			,"page-background-03.jpg"
			,"page-background-04.jpg"
			,"page-background-05.jpg"
			,"page-background-06.jpg"
			,"page-background-07.jpg"
			,"page-background-08.jpg"
			,"page-background-09.jpg"
			,"page-background-10.jpg"
			];
		
		// Random background image on page load
		randomBackgroundImage(pageBackgrounds, "assets/templates/nl/images/template/screen/page-backgrounds/", "#background img");
		
		// Moodboard
		if(document.getElementById('scrapbook')){
			jQuery('.scrapbook-layout').hide();
			jQuery('.scrapbook-layout').tsort('',{order:'rand'});
			jQuery('.scrapbook-layout:hidden:eq(0)').fadeIn('normal', function() {
				jQuery(this).next().fadeIn('normal', arguments.callee);		
			});
		}
		
	} // 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()