window.addEvent('domready',function()
{
	videoShow.init();
	if(document.body.className == 'behindScenes') slideShowNav.init();
});

var slideShowNav =
{
	els: null,
	elsNav:null,
	currLoc: null,
	
	init: function()
	{
		this.els = $$('.section');
		this.elsNav = $$('#sectionNav a');
		
		for(var x=0;x<this.elsNav.length;x++)
		{
			if(x==0) this.elsNav[x].className='selected';
			this.elsNav[x].addEvent('click',function(e)
			{
				e.preventDefault();
				var tempS = this.href.split('#');
				if(tempS[tempS.length-1]!=slideShowNav.currLoc) slideShowNav.click(tempS[tempS.length-1],this);
			});
		}
		
		this.currLoc = 'kitchen';
	},
	
	click: function(string,obj)
	{
		for(var x=0;x<this.elsNav.length;x++)
		{
			if(this.elsNav[x].className=='selected') this.elsNav[x].className=null;
			if(this.els[x].style.display=='block') this.els[x].style.display='none';
		}
		
		obj.className='selected';
		$('sec_'+string).style.display='block';
		this.currLoc = string;
	}
};

var videoShow =
{
	// Trailer String
	0: '<object width="789" height="444"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3185114&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff0179&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3185114&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff0179&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="789" height="444"></embed></object>',
	// First Scene String
	1: '<object width="789" height="444"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1629015&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff0179&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=1629015&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff0179&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="789" height="444"></embed></object>',
	// Outtakes
	2: '<object width="789" height="444"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3189747&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff0179&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3189747&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff0179&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="789" height="444"></embed></object>',
	// Intro 
	3: '<object width="789" height="444"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3198723&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff0179&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3198723&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff0179&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="789" height="444"></embed></object>',
	// Current Location
	currLoc: 'trailer',
	// Anchor Navs
	anchors: null,
	
	init: function()
	{
		if($('videoShow'))
		{
			var els = $('videoNav').getElements('a');
			this.attach(els);
		}
	},
	
	attach: function(els)
	{
		for(var x=0;x<els.length;x++)
		{
			els[x].addEvent('click',function(e)
			{
				if(e.preventDefault) e.preventDefault();
				var tempS = this.href.split('#');
				videoShow.click(tempS[tempS.length-1]);
			});
		}
		
		this.anchors = els;
	},
	
	click: function(string)
	{
		if(string!=this.currLoc)
		{
			this.currLoc = string;
			for(var x=0;x<this.anchors.length;x++)
			{
				if(this.anchors[x].className=='selected') this.anchors[x].className=null;
			}
			
			switch(string)
			{
				case 'firstScene':
					$('theVideo').innerHTML = this[1];
					this.anchors['1'].className='selected';
					break;
				case 'outtakes':
					$('theVideo').innerHTML = this[2];
					this.anchors['2'].className='selected';
					break;
				case 'introCredits':
					$('theVideo').innerHTML = this[3];
					this.anchors['3'].className='selected';
					break;
				default:
					$('theVideo').innerHTML = this[0];
					this.anchors['0'].className='selected';
			}
		}
	}
}
