/**
 * @author timharwood
 */

var firstRun = true;

function $include(original, extended){
	for ( var key in (extended ||{}) ) {
    	if ( !$defined(original[key]) ) original[key] = extended[key];
  	} 
	return original;
};



if ( !$defined(Base) ) var Base={};

Base.ElementFactory = {
  
  elementID:-1,

  extendedAsDOMElement:function(obj, domObj) {

    if (!obj || !domObj) return null;
    
    domObj = $(domObj);
	if (!$chk(domObj)) return null;
    
    $include(domObj,obj);
	
	if ($defined(domObj.setDefaults)) domObj.setDefaults();
	
	if ($defined(obj.removeEvents)) obj.removeEvents();
	if (obj.destroy) obj.destroy();
	delete obj;
	obj = null;
	
	delete args;
	args = null;
	
	if ( $chk(window.CollectGarbage) ) window.CollectGarbage();
	
	return domObj;
  },
  
  removeArguments:function(args,objs) {
  	 var srcArgs=($type(args)=='array')? args : new Array(arguments);
	 var srcObjs=($type(objs)=='array')? objs : new Array(objs);
	 var arrayLength = srcObjs.length;
	 for (var i=0; i<arrayLength; i++) {
	 	srcArgs.erase(srcObjs[i]);
	 }
	 return srcArgs;
  }
};



/**
 * @author NWH
 */

var __windowHeight = null, __contentMenuTriggers = null, __contentMenuContent = null, __contentPanelTriggers = null, __contentPanelContent = null, __contentMenuSliders = null;
var __scrollControls = null, __scrollInners = null, __scrollContainers = null, __scrollUpControls = null, __scrollDnControls = null, __scrollMessages = null;
var __soundSwiff = null, __soundIsLoaded = false, __soundObj = null;
var __sliderContentOpener = null;
var TOOLSHED = {};

// Array to control the colours of the sections [matches CSS classes in toolshed.css]
var __letterColours = new Array();
__letterColours[0] = '#ff4343';
__letterColours[1] = '#ff6e42';
__letterColours[2] = '#ff861c';
__letterColours[3] = '#ffb200';
__letterColours[4] = '#f9e800';
__letterColours[5] = '#cdf600';
__letterColours[6] = '#a3ff1a';
__letterColours[7] = '#87ff42';
__letterColours[8] = '#5bff42';
__letterColours[9] = '#42ff55';
__letterColours[10] = '#42ff81';
__letterColours[11] = '#42ffad';
__letterColours[12] = '#42ffd9';
__letterColours[13] = '#42f9ff';
__letterColours[14] = '#42cdff';
__letterColours[15] = '#42a1ff';
__letterColours[16] = '#4275ff';
__letterColours[17] = '#4249ff';
__letterColours[18] = '#6842ff';
__letterColours[19] = '#9442ff';
__letterColours[20] = '#c042ff';
__letterColours[21] = '#ec42ff';
__letterColours[22] = '#ff42e6';
__letterColours[23] = '#ff42ba';
__letterColours[24] = '#ff428e';
__letterColours[25] = '#ff4262';
__letterColours[26] = '#999999'; // Default Base Colour

window.addEvent('domready', function(){
	
	if(!Browser.Engine.trident){
		$(document.body).set('opacity',0);
	} else {
		$(document.body).set('style','visibility:hidden');
	}
	$(document.body).removeClass('withoutjs');
	
	/*$(document.body).getElements('img').each(function(img,i){
		var imgSrc = img.get('src');
		if(imgSrc.match(/.png/)){
			img.set('src',imgSrc.replace(/.png/,'.gif'));
		}
	});*/

	__contentMenuTriggers = $$('ul.contentmenutriggers li a img');
	__contentMenuContent = $$('div.contentmenu');
	__contentPanelTriggers = $$('ul.contentpaneltriggers li a');
	__contentPanelContent = $$('div.contentpanel');
	__scrollControls = $$('div.scrollcontrol');
	__scrollInners = $$('div.scrollinner');
	__scrollDnControls = __scrollControls.map(function(el,i){ return el.getLast(); });
	__scrollUpControls = __scrollControls.map(function(el,i){ return el.getFirst().getNext(); });
	__scrollMessages = __scrollControls.map(function(el,i){ return el.getFirst().getNext().getNext(); });
	
	__contentMenuSliders = new TOOLSHED.Sliders({
		contentMenuTriggers:__contentMenuTriggers,
		contentMenuSliders:__contentMenuContent,
		contentPanelTriggers:__contentPanelTriggers,
		contentPanelSliders:__contentPanelContent
	});
	
	__scrollContainers = new TOOLSHED.Scrollers({
		scrollInners:__scrollInners,
		scrollControls:__scrollControls,
		scrollUpControls:__scrollUpControls,
		scrollDnControls:__scrollDnControls,
		scrollMessages:__scrollMessages
	});
	
	// init links for work section
	$$('a.tablink, a.worklink').each( function(el, i){
		el.addEvents({
			'click': function(e){
				var id = el.get('href').substr(2); // href is "/#id"
				SWFAddress.setValue(id);
				__sliderContentOpener.open(id);
				e = new Event(e).stop();
			}
		});
	} );
	
	__sliderContentOpener = new TOOLSHED.TargetSliderContent();
});

window.addEvent('load', function(){

	FLIR.init();
	$$('span.textreplace').each( function(el,i) { 
		var newText = el.get('text').substring(1);
		el.set('text',newText);
		if(!Browser.Engine.trident && !Browser.Engine.presto){
			FLIR.replace(el);
		}
	});

	
	if($chk($('soundcontainer'))){
		__soundSwiff = new swfobject.embedSWF(
			'/includes/video/audioplayer.swf',
			'soundcontainer',
			'10',
			'10',
			'9.0.0',
			'includes/scripts/swfobject/expressInstall.swf',
			{
				onReady: 'soundReady',
				src: ''
			},
			{
				menu: 'false',
				//wmode: 'transparent', -- stops sound playing in WinFF
		        bgcolor: '#ffffff',
				allowScriptAccess: 'always',
				allowFullScreen: 'false'
			},
			{
				id:'soundSwiff',
				name:'soundSwiff'
			}
		);
		__soundIsLoaded = true;
	}
	/* **** REMOVED 'GENERIC' videoplayer embed from here, added into new TOOLSHED.ContentPanel class **** */
	
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	new Asset.javascript(gaJsHost + "google-analytics.com/ga.js", {
	    onload: function() {
	        var pageTracker = _gat._getTracker("UA-5433474-1");
	        pageTracker._initData();
	        pageTracker._trackPageview();
	    }
	});
});



window.addEvent('resize', function(){
	__windowHeight = (window.getSize().y - 38);
	if(__windowHeight < 540){
		__windowHeight = 540;
	}
	$('mainnavigation').getFirst().tween('height',__windowHeight);
	$('contentmenuinner').tween('height',__windowHeight);
	$('contenttodisplayinner').tween('height',__windowHeight);
	__scrollInners.each(function(el,i){
		el.tween('height',(__windowHeight-260));
	});
});

TOOLSHED.Scrollers = new Class({
	Implements:[Events, Options, Chain],
	options:{// set all the options here
		scrollInners:null,
		scrollControls:null,
		scrollUpControls:null,
		scrollDnControls:null,
		scrollMessages:null
	},
	scrollEffects:[],
	elementScrolledTo:[],
	initialize: function(options){
		this.setOptions(options);
		this.initScrollers();
	},// end init
	initScrollers: function(){
		this.setUpScrollers();
		this.setUpClickables();
	},
	setUpScrollers: function(){
		this.options.scrollInners.each(function(el,i){
			//var dur = (this.options.scrollInners[i].getScrollSize().y * 2);
			this.scrollEffects[i] = new Fx.Scroll(el,{link:'ignore',fps:50,duration:2000}).toTop();
			this.elementScrolledTo[i] = 0;
		}.bind(this));
	},
	setUpClickables: function(){
		this.options.scrollDnControls.each(function(el,i){
			if (this.isScrollable(i)) {
				el.addEvents({
					'mousedown': function(e){
						this.scrollDnInner(el,i);
						e = new Event(e).stop();
					}.bindWithEvent(this),
					'mouseup': function(e){
						this.scrollEffects[i].cancel();
						e = new Event(e).stop();
					}.bindWithEvent(this),
					'mouseover': function(e){
						this.showTooltip(el,i,'downmsg');
						el.addClass('hover');
					}.bindWithEvent(this),
					'mouseout': function(e){
						this.hideTooltip(el,i,'downmsg');
						el.removeClass('hover');
					}.bindWithEvent(this)
				});
			} else {
				el.setOpacity(.2);
			}
		}.bind(this));
		this.options.scrollUpControls.each(function(el,i){
			if (this.isScrollable(i)) {
				el.addEvents({
					'mousedown': function(e){
						this.scrollUpInner(el,i);
						e = new Event(e).stop();
					}.bindWithEvent(this),
					'mouseup': function(e){
						this.scrollEffects[i].cancel();
						e = new Event(e).stop();
					}.bindWithEvent(this),
					'mouseover': function(e){
						this.showTooltip(el,i,'upmsg');
						el.addClass('hover');
					}.bindWithEvent(this),
					'mouseout': function(e){
						this.hideTooltip(el,i,'upmsg');
						el.removeClass('hover');
					}.bindWithEvent(this)
				});
			} else {
				el.setOpacity(.2);
			}
		}.bind(this));
	},
	scrollDnInner: function(el,i){
		this.scrollEffects[i].toBottom();
	},
	scrollUpInner: function(el,i){
		this.scrollEffects[i].toTop();
	},
	showTooltip: function(el,i,type){
		//this.options.scrollMessages[i].set('style','visibility:visible');
		this.options.scrollMessages[i].addClass(type);
	},
	hideTooltip: function(el,i,type){
		//this.options.scrollMessages[i].set('style','visibility:hidden');
		this.options.scrollMessages[i].removeClass(type);
	},
	isScrollable: function(i){
		return this.options.scrollInners[i].getScrollSize().y > 300;
	}
});

TOOLSHED.ContentPanel = new Class({
    _element:null,
    _videoElements:null,
    initialize: function(objRef) {
	    return Base.ElementFactory.extendedAsDOMElement(this,objRef);
    },
	
	setDefaults: function() {
        this._videoElements=[];
        this.getVideoElementList();
    },
    
    getVideoElementList:function() {
        // add video container DIV to the _videoElements array
        this._videoElements = this.getElements('div.videocontainer');
    },
    
    createVideoPlayers:function() {
        this._videoElements.each(function(videoContainer,i){
            var videoFile = videoContainer.getProperty('id');
            if (!videoFile) return;
			var player = new Swiff('/includes/video/videoplayer.swf', {
			    width: 430,
			    height: 320,
			    params: {
			        wmode: 'transparent',
			        bgcolor: '#ffffff'
			    },
			    vars: {
			        globalColor: __letterColours[26],
					imagePath: '/images/assets/backgrounds/ajax-loading-big.gif',
					filePath: '/file/video?f=' + videoFile,
					play: false,
					loop: false
			    },
			    callBacks: {
			        
			    }
			});
			
			player.inject(videoContainer);

        })
    },
    
    destroyVideoPlayers:function() {
        this._videoElements.each(function(videoContainer,i){
            videoContainer.empty();
        })
    }
});

TOOLSHED.Sliders = new Class({
	Implements:[Events, Options, Chain],
	options:{// set all the options here
		contentMenuOpen:false,
		oldContentMenu:null,
		activeContentMenu:0,
		contentMenuTriggers:null,
		contentMenuSliders:null,
		contentPanelOpen:false,
		oldContentPanel:null,
		activeContentPanel:0,
		contentPanelTriggers:null,
		contentPanelSliders:null,
		targetContentPanel:null,
		contentMenuWidth:198,
		activeColour:null
	},
	contentMenuEffects:[],
	contentPanelEffects:[],
	initialize: function(options){
		this.setOptions(options);
		this.initSliders();
	},// end init
	initSliders: function(){
		this.createHTML();			// Adds new elements to DOM for sliding and transitions
		this.setUpSliders();		// Set up menu and panel sliders
		this.setUpClickables();		// Set up menu and panel links
		window.fireEvent('resize'); // Call to change page height to match browser
	},
	openContent: function(el, i, panel){
		// If letter clicked is different from last time... (else do nothing)

		if(!el.getParent().getParent().hasClass('clicked')){
			// Sets the background colour of all letters to default colour and then removes clicked class
	
			this.options.contentMenuTriggers.each(function(el,i){
				if(el.getParent().getParent().hasClass('clicked')){
					el.getParent().getParent().tween('background-color', __letterColours[26], __letterColours[26]);
				}
				el.getParent().getParent().removeClass('clicked');
			});
			// Sets page colouration for links and background colours
			(function(){this.setPageColouration(el)}).delay(750,this);
			// Adds clicked class to highlight letter
			el.getParent().getParent().addClass('clicked');
			// Tween effect to change colour of letter background
			el.getParent().getParent().tween('background-color', __letterColours[26], __letterColours[i]);
			// Sets old content menu
			this.options.oldContentMenu = this.options.activeContentMenu;
			// Set new active menu
			this.options.activeContentMenu = i;
			// Works out content to display based on letter clicked
			this.options.activeContentPanel = panel;
			this.options.targetContentPanel = panel;
			// Call to action - open menu and panel
			this.openContentGroup();
		}
	},
	setUpClickables: function(){
		this.options.contentMenuTriggers.each(function(el,i){
			if(this.options.contentMenuSliders[i].getElements('li').length>0){
				el.addEvents({
					'click': function(e){
						// If letter clicked is different from last time... (else do nothing)
						if(!el.getParent().getParent().hasClass('clicked')){
							// Sets the background colour of all letters to default colour and then removes clicked class
							this.options.contentMenuTriggers.each(function(el,i){
								if(el.getParent().getParent().hasClass('clicked')){
									el.getParent().getParent().tween('background-color', __letterColours[26], __letterColours[26]);
								}
								el.getParent().getParent().removeClass('clicked');
							});
							// Sets page colouration for links and background colours
							(function(){this.setPageColouration(el)}).delay(750,this);
							// Adds clicked class to highlight letter
							el.getParent().getParent().addClass('clicked');
							// Sets old content menu
							this.options.oldContentMenu = this.options.activeContentMenu;
							// Set new active menu
							this.options.activeContentMenu = i;
							// Works out content to display based on letter clicked
							this.options.targetContentPanel = this.getTargetContentPanel(el,i);
							// Call to action - open menu and panel
							this.openContentGroup();
						}
						e = new Event(e).stop();
					}.bindWithEvent(this),
					'mouseover': function(e){
						if(!el.getParent().getParent().hasClass('clicked')){
							// Tween effect to change colour of letter background
							el.getParent().getParent().tween('background-color', __letterColours[26], __letterColours[i]);
							// Call sound if sound file loaded
							if(__soundIsLoaded && __soundObj != null){
								try {
								__soundObj.playSoundByte('/includes/audio/' + i + '.mp3');
								} catch (e) { /*console.log(e);*/ }
							}
						}
					},
					'mouseout': function(e){
						if(!el.getParent().getParent().hasClass('clicked')){
							// Tween effect to reset colour of letter background
							el.getParent().getParent().tween('background-color', __letterColours[i],__letterColours[26]);
						}
					}
					
				});
				
			} else {
				el.addEvents({
					'click': function(e){
						e = new Event(e).stop();
					}
				});
			}
		}.bind(this));
		this.options.contentPanelTriggers.each(function(el,i){
			el.addEvents({
				'click': function(e){
					this.changeToContentPanel(el,i);
					e = new Event(e).stop();
				}.bindWithEvent(this)
			});
		}.bind(this));
	},
	changeToContentPanelNumber:function(i) {
		var el = this.options.contentPanelTriggers[i];
		this.changeToContentPanel(el,i);
	},
	changeToContentPanel:function(el,i) {
		el.addClass('hover'); // Adds hover class to highlight content panel link
		this.options.oldContentPanel = this.options.activeContentPanel; // Sets old content panel
		this.options.activeContentPanel = i; // Set new active content panel
		this.switchContentPanel(); // Change content panel to be the one clicked
	},
	openContentGroup: function(){
		// If menu and content panels are not currently open
		if(!this.options.contentMenuOpen){
			this.chain(
				function(){ this.fadeContent(this.options.activeContentMenu,'menu','show'); this.fadeContent(this.options.targetContentPanel,'panel','show'); this.callChain(); },
				function(){ this.openContentMenu(); (function(){ this.openContentPanel(); }).delay(200,this) }
			)
		} else {
			// If not current content panel, fade old menu and panel, close old panels then open new panels
			if(this.options.oldContentMenu != this.options.activeContentMenu) {
				this.chain(
					function(){ this.fadeContent(this.options.oldContentMenu, 'menu', 'out'); this.fadeContent(this.options.oldContentPanel, 'panel', 'out'); this.callChain(); },
					function(){ this.closeContentMenu(); this.closeContentPanel(); }, 
					function(){ this.openContentPanel(); this.openContentMenu(); }
				)
			}
		}
		this.callChain();
		// Set active and open vars
		this.options.oldContentPanel = this.options.activeContentPanel;
		this.options.contentPanelOpen = true;
		this.options.contentMenuOpen = true;
	},
	switchContentPanel: function(){
		// If not current content panel, close old then open new panel and set active and open vars
		if(this.options.oldContentPanel != this.options.activeContentPanel){
			this.chain(
				function(){ this.closeContentPanel(); },
				function(){ this.openContentPanel(); }
			)
			this.callChain();
			this.options.oldContentPanel = this.options.activeContentPanel;
			this.options.contentPanelOpen = true;
		}
	},
	openContentMenu: function(){
		// Fades in old content and slides in
		this.contentMenuEffects[this.options.activeContentMenu].fade('show');
		this.contentMenuSlider.tween('margin-left','0');
	},
	closeContentMenu: function(){
		// Fades out old content and slides out
		this.contentMenuEffects[this.options.oldContentMenu].fade('out');
		this.contentMenuSlider.tween('margin-left','-' + this.contentMenuSlider.getSize().x);
	},
    
	openContentPanel: function(){

        var panelEl = this.options.contentPanelSliders[this.options.activeContentPanel];
        panelEl.createVideoPlayers();
        
		// Fades in content panel, set trigger class to be highlighted, slide panel in
		this.fadeContent(this.options.activeContentPanel,'panel','show');
		this.options.contentPanelTriggers[this.options.activeContentPanel].addClass('hover');
		this.contentPanelSlider.tween('margin-left','0');
		SWFAddress.setValue(panelEl.get('id'));
	},
    
	closeContentPanel: function(){

        this.options.contentPanelSliders[this.options.oldContentPanel].destroyVideoPlayers();
        
		// Fade out old content panel, set trigger class to be default, slide panel out
		this.fadeContent(this.options.oldContentPanel,'panel','out');
		this.options.contentPanelTriggers[this.options.oldContentPanel].removeClass('hover');
		this.contentPanelSlider.tween('margin-left','-' + (this.contentPanelSlider.getSize().x + this.options.contentMenuWidth));
	},
	fadeContent: function(i,type,method){
		// Fades or shows content panels and menus
		if(type == 'menu'){
			this.contentMenuEffects[i].fade(method);
		} else {
			this.contentPanelEffects[i].fade(method);
		}
	},
	setPageColouration: function(el){
		// Sets active colour based on link href and sets top most class to be the colour class
		this.options.activeColour = (el.getParent().get('href').split('#')[1].toLowerCase() + '-colour');
		$('container').set('class', this.options.activeColour);
	},
	getTargetContentPanel: function(el,i){
		// Get target panel link href
		var targetContentPanel = $(el.getParent().get('href').split('#')[1]).getChildren()[1].getFirst().getElements('a')[0].get('href');
		// Compare link href with each link in panel trigger array, if matched set target content with integer of array position
		this.options.contentPanelTriggers.each(function(el,i){
			if(this.options.contentPanelTriggers[i].get('href') == targetContentPanel){
				targetContentPanel = i;
				this.options.activeContentPanel = i;
			}
		}.bind(this));
		return targetContentPanel;
	},
	setUpSliders: function(){
        
		// Set Up Menu Slider Element
		this.contentPanelSlider = $('contenttodisplay').set('tween', {duration: 900,transition: 'sine:in:out',onComplete: function(){ this.callChain(); }.bind(this)});
		// Move all content panels in to content panel inner and fade out of sight
		this.options.contentPanelSliders.each(function(el,i){
            var cpSlider = new TOOLSHED.ContentPanel(el);
			this.contentPanelInner.adopt(cpSlider);
			this.contentPanelEffects[i] = cpSlider.set('tween', {duration: 250,transition: 'sine:in:out',onComplete: function(){ /*this.callChain();*/ }.bind(this)});
			this.contentPanelEffects[i].fade('out');
		}.bind(this));
		this.contentPanelSlider.tween('margin-left','-' + (this.contentPanelSlider.getSize().x + this.options.contentMenuWidth));
        
		// Set Up Menu Slider Element
		this.contentMenuSlider = $('contentmenu').set('tween', {duration: 700,transition: 'sine:in:out',onComplete: function(){ /*this.callChain();*/ }.bind(this)});
		// Move all content menus in to content menu inner and fade out of sight
		this.options.contentMenuSliders.each(function(el,i){
			this.contentMenuInner.adopt(el);
			this.contentMenuEffects[i] = el.set('tween', {duration: 250,transition: 'sine:in:out',onComplete: function(){ /*this.callChain();*/ }.bind(this)});
			this.contentMenuEffects[i].fade('out');
		}.bind(this));
		this.contentMenuSlider.tween('margin-left','-' + this.contentMenuSlider.getSize().x);
	},
	createHTML: function(){
		// Create element used as panel slider
		this.contentPanel = new Element('div',{'id':'contenttodisplay'}).injectBefore($('mainnavigation'));
		// Create inner element for panel slider
		this.contentPanelInner = new Element('div',{'id':'contenttodisplayinner'}).injectInside(this.contentPanel);
		// Create element used as menu slider		
		this.contentMenu = new Element('div',{'id':'contentmenu'}).injectBefore($('mainnavigation'));
		// Create inner element for menu slider		
		this.contentMenuInner = new Element('div',{'id':'contentmenuinner'}).injectInside(this.contentMenu);
	}
});

/**
 * Open a content panel using its id
 * 
 * Basically this is a wrapper around TOOLSHED.Sliders.openContent, determining
 * the 3 parameters from the ID of the content div. The parameters are: the img
 * element of the main menu letter, the position of the letter menu div (so the 
 * alphabetic position - the letter menus are written out in order), and the 
 * position of the content div. [2010-05-14] 
 * 
 * @see TOOLSHED.Sliders.openContent
 */
TOOLSHED.TargetSliderContent = new Class({
	open: function(id) {
		// get first letter of the content's id
		var letter = id.substring(0,1).toUpperCase();
		
		// get alphabetical position
		var alphaPos = letter.charCodeAt(0) - 65; // 65 is code of 'A', we start from 0
		
		// array of matching elements, should only be one
		var letterImgs = $$('ul.contentmenutriggers li.' + letter + ' img');
		
		// work out where the content panel is relative to its siblings
		//console.log('id ' + id);
		var content = $(id);
		var siblings = content.getParent().getChildren();
		var contentPos = null;
		for (var i = 0; i < siblings.length; i++) {
			if (siblings[i] == content) {
				contentPos = i;
				break;
			}
		}
		
		// open content if we have everything we need
		if (letterImgs.length > 0 && alphaPos > -1 && contentPos != null) {
			__contentMenuSliders.openContent(letterImgs[0], alphaPos, contentPos);
			__contentMenuSliders.changeToContentPanelNumber(contentPos);
		}
	}
});

/**
 * SWFAddress event handler
 * 
 * This is fired once when the page loads, and then whenever the SWFAddress 
 * value changes. 
 * 
 * Remember that if the page is loaded with no SWFAddress value in the URL this
 * function will be called twice - once when the page loads, and once 
 */
function handleChange(){
	if(firstRun) {
		// get initial id if exists, otherwise 'about-us'
		var initialContentId = 'about-us';
		var openContent = true;
		if (location.hash.length > 0) {
			// remove the '#'
			var hash = location.hash.substring(1);
			// remove the '/' if this is a SWFAddress style URL
			if (hash.charAt(0) == '/') {
				hash = hash.substring(1);
			}
			// set initialContentId if content panel exists
			if ($$('div#contenttodisplayinner div#'+hash).length == 1) {
				initialContentId = hash;
			}
		}
		
		// reveal page and set initial SWFAddress value
		if(!Browser.Engine.trident){
			var revealPage = function(){ 
				$(document.body).set('opacity',1);
				SWFAddress.setValue(initialContentId);
				__sliderContentOpener.open(initialContentId);
			};
			revealPage.delay(2000);
			revealPage = null;
		} else {
			var revealPage = function(){ 
				$(document.body).set('style', 'visibility:visible');
				SWFAddress.setValue(initialContentId);
				__sliderContentOpener.open(initialContentId);
			};
			revealPage.delay(2000);
			revealPage = null;
		}
		
		firstRun = false;
	} else {
		// SWFAddress value has leading '/'
		__sliderContentOpener.open(SWFAddress.getValue().substring(1));
	}
}
SWFAddress.addEventListener(SWFAddressEvent.CHANGE, handleChange);

/**
 * Audio player onReady handler (called from the swf)
 */
function soundReady() {
	__soundObj = document.getElementById('soundSwiff');
}

