var Site = new Class (
{	
	initialize: function(section)
	{		
		window.addEvent
		(
			'domready',
			function() 
			{	
				this.setMenu();
				switch(section)
				{
					case "boutique":
						this.setBoutique();
						break;
					case "design":
						this.setDesign();
						break;
					case "guy_laroche":
						this.setLaroche();
						break;
					case "company":
						this.setCompany();
						break;	
					case "showroom":
						this.setShowroom();
						break;	
					case "newsroom":
						this.setNewsroom();
						break;	                        					
					default:
						break;
				}
			}.bind(this)
		);
	},
	
	setMenu: function()
	{
		$('navcontainer_background').setStyle('opacity', .8);
		var navlist = $('navlist');
		var lis = $$('#navlist ul li');
		
		var w = 0;
		
		$each
		(	
			lis,
			function(li, index)
			{
				w += li.getStyle('width').toInt();
			},
			this
		)
		
		var x = ($('navcontainer').getStyle('width').toInt() - w - (lis[0].getStyle('margin-right').toInt())*(lis.length - 1))/2;
		if(x > 0 && x < 200) navlist.setStyle('left', x.round());
		$('navcontainer').setStyle('top', 525);
	},
	
	setBoutique: function()
	{
		$('boutique_background').setStyle('opacity', .8);
	},
	
	setDesign: function()
	{
		$('design_background').setStyle('opacity', .8);
	},
	
	setLaroche: function()
	{
		$('guy_laroche_background').setStyle('opacity', .8);
	},
	
	setCompany: function()
	{
		$('company_background').setStyle('opacity', .8);
	},
	
	setShowroom: function()
	{
		$('showroom_background').setStyle('opacity', .8);
	},
    
	setNewsroom: function()
	{
		$('newsroom_background').setStyle('opacity', .8);
	},    
	
	setAlpha: function(element, alpha)
	{
		element.setStyle('opacity', alpha);
	}
}
);

var Slideshow = new Class (
{	
	data: null,
	rank:null,
	goeshome:null, 
	
	initialize: function(_data, _goeshome)
	{	
		data = _data,
		goeshome = _goeshome;
		rank = 0;
			
		window.addEvent
		(
			'domready',
			function() 
			{	
				
			}.bind(this)
		);
	},
	
	displayPrevious: function()
	{
		if(rank>0) 
		{
			rank--;
			if(goeshome) this.displayPixGoesHome(data[rank]);
			else this.displayPix(data[rank]);
		}
	},
	
	displayNext: function()
	{
		if(rank < data.length - 1) 
		{
			rank++;
			if(goeshome) this.displayPixGoesHome(data[rank]);
			else this.displayPix(data[rank]);
		}
	},
	
	displayPix: function(pix)
	{
		var slideshow = $('slideshow');
		this.setAlpha(slideshow, 0);
		slideshow.set('html', '<a href="#"><img src="'+pix+'" width="347" height="463"></a>');
		slideshow.tween('opacity', 1);
	},
	
	displayPixGoesHome: function(pix)
	{
		var slideshow = $('goes_home_slideshow');
		this.setAlpha(slideshow, 0);
		slideshow.set('html', '<a href="#"><img src="'+pix+'" width="555" height="422"></a>');
		slideshow.tween('opacity', 1);
	},
	
	setAlpha: function(element, alpha)
	{
		element.setStyle('opacity', alpha);
	}
}
);
