var Site = {
		
	start: function(){
		Site.setExternals();
		Site.fixExplorer();
		
		if( $$('#nav_produits ul') )  Site.menu();
		if( $$('.produit_famille .ssfamille') )  Site.sousFamilles();
		
		if($('slide')) {
			var data = [
				'1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg'
			];
			var myShow = new Slideshow('slide', data, { height: 187, hu: BASEURL+'public/diapo/', width: 211, loader:false });
		}	
		
		//if( Browser.Engine.trident4 ) Site.ie6();
		
		if( $$('.actu_item')) {
			
			$$('.actu_item').setStyles({
						'padding-top': '3px',
						'padding-bottom': '3px'
					});
			
			$$('.actu_item').addEvents({
				'mouseover': function(){ 
					this.getElements('a').setStyle('text-decoration','none');

					this.setStyles({
						'background': '#feeede'
					});
				},
				'mouseout': function(){ 
					this.setStyle('background', '#fff');
				}
			});
		}
	},
		
	setExternals: function(){
		$$('.external').addEvent('click', function(ev){
			window.open(this.href); new Event(ev).stop(); return; });
	},

	fixExplorer: function() {
		$('container').getElements('input[type=radio]').setStyle('border', '0');
		$('container').getElements('input[type=checkbox]').setStyle('border', '0');
		
		$$('textarea').addEvents({
			'focus': function(){ this.addClass('highlight');},
			'blur': function(){ this.removeClass('highlight');}
		});
		
		$$('select').addEvents({
			'focus': function(){ this.addClass('highlight');},
			'blur': function(){ this.removeClass('highlight');}
		});
	},
	
	menu: function(){
		
		$('intro').setStyle('z-index', '10'); 
		$('content').setStyle('z-index', '1'); 
		$('main_nav').setStyle('z-index', '10');
		$('leftcolumn').setStyle('z-index', '1');
		
		
		$('nav_produits').addEvents({
			'mouseenter': function(){ 
				this.getElement('a').addClass('hover');
				this.getElement('ul').setStyle('display', 'block'); 
			},
			'mouseleave': function(){ 
				this.getElement('a').removeClass('hover');
				this.getElement('ul').setStyle('display', 'none'); 
			}
		});
	},
	
	sousFamilles: function(){
		var height = 0; 
		$$('.produit_famille .ssfamille ul').each(function(el){
			var size = el.getSize();
			if( size.y > height ) {
				height = size.y ;
			}
		});
			
		$$('.produit_famille .ssfamille ul').setStyle('height', height);
	},
	
	ie6: function() {
		
		var div = new Element('div', {
		    'id': 'message-ie6',
			'class': 'message-ie6',
		    'styles': {
		        'display': 'block',
				'background': '#000',
				'width': '100%',
				'color': '#fff',
				'text-align': 'center',
				'padding': '5px 0 10px 0',
		        'border': '1px solid black'
		    }
		});
		
		var message = new Element('p', {
			'html': 'Vous utilisez actuellement le navigateur Internet Explorer 6. Pour des raisons de sécurité, nous vous conseillons de mettre à jour votre navigateur.<br />Utiliser un navigateur de dernière génération tel que <a href="http://www.microsoft.com/france/windows/ie/" target="_blank" style="color:#fff;text-decoration:underline">Internet Explorer 7</a>, <a href="http://www.mozilla-europe.org/fr/firefox/" target="_blank" style="color:#fff;text-decoration:underline">Firefox</a>, <a href="http://www.opera.com/" target="_blank" style="color:#fff;text-decoration:underline">Opéra</a>, <a href="http://www.apple.com/fr/safari/" target="_blank" style="color:#fff;text-decoration:underline">Safari</a>.',
			'styles': {
				'line-height': '15px'
			}
		});
		
		var close = new Element('a', {
			'html': '&raquo; Fermer ce message',
		    'styles': {
				'color': '#ccc',
				'padding-left': '10px',
				'cursor': 'pointer'
		    },
		    'events': {
		        'click': function(){
		           $('message-ie6').set({'styles': {'display':'none'}});
				   var cookie = Cookie.write('closeMessage', 'ok', {duration: 1});
				   
				   alert(Cookie.read('closeMessage'));
		        }
		    }
		});
		
		message.inject(div);
		close.inject(message);
		
		alert(Cookie.read('closeMessage'));
		
		if (Cookie.read('closeMessage') != 'ok') div.inject($(document.body), 'top');

	}	
	
};

window.addEvent('domready', function(){ Site.start(); });


