var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

Nom = navigator.appName;
Version = navigator.appVersion;
var ie6 = (Nom == 'Microsoft Internet Explorer' && BrowserDetect.version <= 6 ) ? 1:0


function getWindowHeight() {
			var windowHeight = 0;
			if (typeof(window.innerHeight) == 'number') {
				windowHeight = window.innerHeight;
			}
			else {
				if (document.documentElement && document.documentElement.clientHeight) {
					windowHeight = document.documentElement.clientHeight;
				}
				else {
					if (document.body && document.body.clientHeight) {
						windowHeight = document.body.clientHeight;
					}
				}
			}
			return windowHeight;
		}
		function setContent() {
			if (document.getElementById) {
				var windowHeight = getWindowHeight();
				if (windowHeight > 0) {
					var contentElement = document.getElementById('content');
					var contentHeight = contentElement.offsetHeight;
					if (windowHeight - contentHeight > 0) {
						contentElement.style.position = 'relative';
						contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
					}
					else {
						contentElement.style.position = 'static';
					}
				}
			}
			alignerPied();
		}
		
		function alignerPied()
		{
			var windowWidth = document.body.clientWidth;
			var diff = (windowWidth-960)/2;
			if(diff>0)
			{
				$('pied').style.width = 960+diff+'px';
			}
			else
			{
				$('pied').style.width = 960+'px';
			}
		}
		
		
		
Event.observe(window, 'load', setContent );
Event.observe(window, 'resize', setContent );


Event.observe(window, 'load', function() {

$$('dl.list_dl').each(function(s) {
		Event.observe(s,'mouseover',function() {
			$('dd_'+s.id).style.display = 'block';
			//Effect.Appear($('form'+s.id+"_dd"),{ duration:0.4});
			//afficherListe($("form"+s.id));
		});
	});
	
$$('dl.list_dl').each(function(s) {
	Event.observe(s,'mouseout',function() {
		$('dd_'+s.id).style.display = 'none';
		//Effect.Fade($('form'+s.id+"_dd"),{ duration:0.4});
		//afficherListe($("form"+s.id));
	});
});

/*event window*/
if($('vcredits')) {
	Event.observe('vcredits','click',function() {
		lire_credits();
	});
	
	Event.observe('vmentionslegales','click',function() {
		lire_ml();
	});
	
	Event.observe('vcredits2','click',function() {
		lire_credits();
	});
	
	Event.observe('vmentionslegales2','click',function() {
		lire_ml();
	});
}
});
function lire_credits() {
			var contenu = '<div class="pop_lescredits">Conception & design de <a target="_blank" style="text-decoration:underline;" href="http://www.bienvenuechezlautre.fr">L’Autre</a><br/>';
			contenu+='Réalisation: AcheTTP interactive (Guillaume & Houzéfa)<br/>';
			contenu+='Toute reproduction interdite © Juillet 2009</div>';
			Dialog.alert(contenu, {className:"alphacube" ,windowParameters: {zIndex:10,width:350, height:80}, okLabel: "fermer"});
		
}

function lire_ml() {
				Nom = navigator.appName;
				Version = navigator.appVersion;
				ie6 = (Nom == 'Microsoft Internet Explorer' && BrowserDetect.version <= 6 ) ? 1:0
				if(ie6)
				{
					
					window.open('html/ml.html'); 
					return;
				}

				win = new Window({className: "alphacube",resizable: true,maximizable:true,recenterAuto:true, title: "Mentions légales",width:944, height:540,zIndex:10,url:"html/ml.html", showEffectOptions: {duration:0.4},hideEffectOptions: {duration:0.4}});				
				win.showCenter();
				win.showCenter();
}

/*************************************************************/
var speed = 10;
var transition = 10;

// Dimensions du preloader en GIF animé
var GIFpreloadLargeur = 20;
var GIFpreloadHauteur = 20;

var timer= 0;
var opaciT = 100;

function opacity()
{
    opaciT = opaciT - transition;

    var object = document.getElementById("preloader").style;
    object.opacity = (opaciT / 100);
    object.MozOpacity = (opaciT / 100);
    object.KhtmlOpacity = (opaciT / 100);
    object.filter = "alpha(opacity=" + opaciT + ")";
     
     if (opaciT <= 0)
     {
          document.getElementById("preloader").style.visibility="hidden";
          clearInterval(timer);
     }

}
 
function preload()
{ 
	/*var content='<div id="preloader"><div id="preloadIMG"><img src="/themes/seawatt/images/loading.gif" alt="" /></div></div>';
	$$('div.corps').each(function(s) {
		s.update(content+s.innerHTML);
	});*/
	
	if($("preloader") && !ie6) timer = setInterval("opacity()",speed);
}

// GÉNÉRER LE CSS POUR LE PRELOADER
var myCSS;
myCSS = "<style type=\"text/css\">";



   



myCSS += "#preloader {";
myCSS += "position:absolute;";
myCSS += "top:0px;";
myCSS += "left:0px;";
myCSS += "margin:0px;";
myCSS += "padding:0px;";
myCSS += "background-color:white;";
myCSS += "width:100%;";
myCSS += "overflow:hidden;";
myCSS += "height:100%; ";
myCSS += "display:block;";
myCSS += "z-index:100000;";
myCSS += "}";

myCSS += " #preloader .loading-indicator{";
myCSS += "        background:white;";
myCSS += "        color:#444;";
myCSS += "        font:bold 13px tahoma,arial,helvetica;"
myCSS += "        padding:0px;";
myCSS += "        margin:0px;";
myCSS += "        height:auto;";
myCSS += "	width:210px;";
myCSS += "    }";

myCSS += "#loading-msg { font: normal 10px arial,tahoma,sans-serif;}";

myCSS += "#preloader a {color:#225588;}";


myCSS += "#preloadIMG {";
myCSS += "position:absolute;";
myCSS += "left:45%;";
myCSS += "width:" + GIFpreloadLargeur + "px;";
myCSS += "height:" + GIFpreloadHauteur + "px;";
myCSS += "margin-left:-" + (GIFpreloadLargeur / 2) + "px;";
myCSS += "top:47%;";

myCSS += "}";




myCSS += "</style>";


var altCSS ="<style>#preloader {display:none;}</style>";
// ÉCRITURE DES CSS
if(!ie6)window.document.write(myCSS);
else window.document.write(altCSS);

// ÉXÉCUTION
window.onload = function() { 

preload();

sommaire();

 }
 
 
 function sommaire()
{
 
	if($('aller_sommaire'))
	{
	
		Event.observe($('aller_sommaire'),'click',function(s) {
				new Effect.Fade($('corps2'));
			});
			
		Event.observe($('aller_descriptif'),'click',function(s) {
				new Effect.Appear($('corps2'));
			});
			
			
	}
}


