window.addEvent('domready', function() {

	function getY(oElement)
	{
	  var errorTimer;
	  function errorHidden(){
	  	$('usererror').style.visibility='hidden';
	  }
	  var iReturnValue = 0;
	  while (oElement != null)
	  {
	    iReturnValue += oElement.offsetTop;
	    oElement = oElement.offsetParent;
	  }
	  return iReturnValue;
	}
	
	function getX(oElement)
	{
	  var iReturnValue = 0;
	  while (oElement != null)
	  {
	    iReturnValue += oElement.offsetLeft;
	    oElement = oElement.offsetParent;
	  }
	  return iReturnValue;
	}			
	function emailvalid(mail){
		if ((mail.indexOf("@") >= 0) && (mail.indexOf(".") >= 0)) {
			return true
			alert('ok');
		}
		else {
			return false
			alert('pas ok');
		}
	} 			
	function Errorcheck(a,b){
		var temp=false;
		var j=0;
		if(a==0)$('inscriptionalertmsg'+b).style.visibility='collapse';
		else $('inscriptionalertmsg'+b).style.visibility='';
		for(i=0;i<6;i++){
			j=i+1;
			if($('inscriptionalertmsg'+j).style.visibility=='visible')temp=true;
		}
		if(temp==true)$('inscriptionalert').style.visibility='';
		else $('inscriptionalert').style.visibility='collapse';
	}			

/*****************************************************************
 * 				COOKIES
 */
	function Delete_Cookie( name, path, domain ) {
		if ( Get_Cookie( name ) ) document.cookie = name + "=" +
		( ( path ) ? ";path=" + path : "") +
		( ( domain ) ? ";domain=" + domain : "" ) +
		";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
	
	function Set_Cookie( name, value, expires, path, domain, secure )
	{
		// set time, it's in milliseconds
		var today = new Date();
		today.setTime( today.getTime() );
	
		/*
		if the expires variable is set, make the correct
		expires time, the current script below will set
		it for x number of days, to make it for hours,
		delete * 24, for minutes, delete * 60 * 24
		*/
		if ( expires )
		{
			expires = expires * 1000 * 60 * 60 * 24;
		}
		var expires_date = new Date( today.getTime() + (expires) );
	
		document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
		( ( path ) ? ";path=" + path : "" ) +
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
	}
	
	function Get_Cookie( name ) {

		var start = document.cookie.indexOf( name + "=" );
		var len = start + name.length + 1;
		if ( ( !start ) &&
		( name != document.cookie.substring( 0, name.length ) ) )
		{
		return null;
		}
		if ( start == -1 ) return null;
		var end = document.cookie.indexOf( ";", len );
		if ( end == -1 ) end = document.cookie.length;
		return unescape( document.cookie.substring( len, end ) );
		}
		
/****************************************************************
 * 				GESTION DES PAGES
 */
	
	$('parametre_ok_div').fade('out');
	$('motdepasse_ok_div').fade('out');
	$('parametre_mail').addEvent('keypress', function(e) {
		$('usererror').style.visibility='hidden';
	});
	$('parametre_mail').addEvent('blur', function(e) {
		if(!emailvalid($('parametre_mail').value)){
			document.getElementById('usererror').style.left=getX(document.getElementById('parametre_mail'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('parametre_mail'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />Email non valide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if($('parametre_mail').value.length==0){
			document.getElementById('usererror').style.left=getX(document.getElementById('parametre_mail'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('parametre_mail'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />l\'email ne peut être vide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if($('parametre_mail').value.length>0){
			var req = new Request({url:'testmail.php',
				onSuccess:function(reponse) {
					if(reponse==1){$('parammailok').value=1;}
					else{			
						document.getElementById('usererror').style.left=getX(document.getElementById('parametre_mail'))+150+ "px";;
						document.getElementById('usererror').style.top=getY(document.getElementById('parametre_mail'))-3+ "px";;
						$('usererror').style.visibility='';
						$('usererror2').innerHTML='<br />l\'email est déjà enregistré.';
						errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
						$('parammailok').value=0;
					}
				},
				onFailure:function() {alert('Erreur de connexion au server');}
			});
			req.send("mail="+mail+"&key="+$('userkey').value);
		}

	});
	$('parametre_nom').addEvent('keypress', function(e) {
		$('usererror').style.visibility='hidden';
	});
	$('parametre_nom').addEvent('blur', function(e) {
		if($('parametre_nom').value.length==0){
			document.getElementById('usererror').style.left=getX(document.getElementById('parametre_nom'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('parametre_nom'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />le nom ne peut être vide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
	});
	$('parametre_prenom').addEvent('keypress', function(e) {
		$('usererror').style.visibility='hidden';
	});
	$('parametre_prenom').addEvent('blur', function(e) {
		if($('parametre_prenom').value.length==0){
			document.getElementById('usererror').style.left=getX(document.getElementById('parametre_prenom'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('parametre_prenom'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />le prénom ne peut être vide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
	});
	$('parametre-button').addEvent('click', function(e){
		var test=true;
		if(!emailvalid($('parametre_mail').value)){
			document.getElementById('usererror').style.left=getX(document.getElementById('parametre_mail'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('parametre_mail'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />Email non valide.';
			test=false;
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if($('parametre_mail').value.length==0){
			document.getElementById('usererror').style.left=getX(document.getElementById('parametre_mail'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('parametre_mail'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />l\'email ne peut être vide.';
			test=false;
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if($('parammailok').value==1){
			document.getElementById('usererror').style.left=getX(document.getElementById('parametre_mail'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('parametre_mail'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />l\'email est déjà enregistré.';
			test=false;
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if($('parametre_nom').value.length==0){
			document.getElementById('usererror').style.left=getX(document.getElementById('parametre_nom'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('parametre_nom'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />le nom ne peut être vide.';
			test=false;
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if($('parametre_prenom').value.length==0){
			document.getElementById('usererror').style.left=getX(document.getElementById('parametre_prenom'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('parametre_prenom'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />le prénom ne peut être vide.';
			test=false;
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		if(test==true){
			var req = new Request({url:'user.php',
				onSuccess:function(reponse) {
					$('parametre_ok_div').fade('in');
					window.setTimeout("$('parametre_ok_div').fade('out')",2000);
				},
				onFailure:function() {alert('Erreur de connexion au server');}
			});
			req.send("do=save&userkey="+$('userkey').value+"&mail="+$('parametre_mail').value+"&nom="+$('parametre_nom').value+"&prenom="+$('parametre_prenom').value+"&societe="+$('parametre_societe').value+"&tel="+$('parametre_tel').value+"&mobile="+$('parametre_mobile').value+"&fax="+$('parametre_fax').value+"&adresse="+$('parametre_adresse').value+"&zip="+$('parametre_zip').value+"&ville="+$('parametre_ville').value);		
		}
	});
	$('motdepasse_password2').addEvent('keypress', function(e) {
		$('usererror').style.visibility='hidden';
	});
	$('motdepasse_password2').addEvent('blur', function(e) {
		if($('motdepasse_password2').value!=$('motdepasse_password').value){
			document.getElementById('usererror').style.left=getX(document.getElementById('motdepasse_password2'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('motdepasse_password2'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />les mots de passe ne sont pas identiques.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
	});
	$('motdepasse-button').addEvent('click', function(e){
		var test=true;
		if($('motdepasse_password').value.length<7){
			document.getElementById('usererror').style.left=getX(document.getElementById('motdepasse_password'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('motdepasse_password'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />le mot de passe ne peut être inférieur à 6 caractères.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
			test=false;
		}
		else if($('motdepasse_password2').value!=$('motdepasse_password').value){
			document.getElementById('usererror').style.left=getX(document.getElementById('motdepasse_password2'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('motdepasse_password2'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />les mots de passe ne sont pas identiques.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
			test=false;
		}
		if(test==true){
			var req = new Request({url:'user.php',
				onSuccess:function(reponse) {
					$('motdepasse_ok_div').fade('in');
					window.setTimeout("$('motdepasse_ok_div').fade('out')",2000);
				},
				onFailure:function() {alert('Erreur de connexion au server');}
			});
			req.send("do=pwd&userkey="+$('userkey').value+"&pwd="+$('motdepasse_password').value);					
		}
	});
	var mainsocieteEl = $('main_societe');
	var mainfondementEl = $('main_fondement');
	var mainactiviteEl = $('main_activite');
	var maininscriptionEl = $('main_inscription');
	var whatEl = 1;
	var whatEl2 = 1;
	
	$('societesociete').addEvent('click', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=1){
			tween();
			mainsocieteEl.style.visibility='';
			mainsocieteEl.set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '530px');
			whatEl=1;
		}
	});
	$('societefondement').addEvent('click', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=2){
			tween();
			mainfondementEl.style.visibility='';
			mainfondementEl.set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '530px');
			whatEl=2;
		}
	});
	$('societeactivite').addEvent('click', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=3){
			tween();
			mainactiviteEl.style.visibility='';
			mainactiviteEl.set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '730px');
			whatEl=3;
		}
	});
	$('inscription').addEvent('click', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=4){
			tween();
			$('menugauche').set('tween', {duration: 2000}).tween('height', '0px');
			$('menugauche').style.overflow='hidden';
			$('menugauche2').set('tween', {duration: 2000}).tween('height', '0px');
			$('menugauche2').style.overflow='hidden';
			maininscriptionEl.style.visibility='';
			maininscriptionEl.set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '530px');
			whatEl=4;
		}
	});
	$('mdplost').addEvent('click', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=5){
			tween();
			$('menugauche').set('tween', {duration: 2000}).tween('height', '0px');
			$('menugauche').style.overflow='hidden';
			$('menugauche2').set('tween', {duration: 2000}).tween('height', '0px');
			$('menugauche2').style.overflow='hidden';
			$('user-lost').style.visibility='';
			$('user-lost').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '530px');
			whatEl=5;
		}
	});
	$('societereference').addEvent('click', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=18){
			tween();
			$('main_reference').style.visibility='';
			$('main_reference').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '530px');
			whatEl=18;
		}
	});
	function tween(){
		if(whatEl==1){mainsocieteEl.style.visibility='hidden';mainsocieteEl.set('tween', {}).tween('height', '0px');}
		if(whatEl==2){mainfondementEl.style.visibility='hidden';mainfondementEl.set('tween', {}).tween('height', '0px');}
		if(whatEl==3){mainactiviteEl.style.visibility='hidden';mainactiviteEl.set('tween', {}).tween('height', '0px');}
		if(whatEl==4){maininscriptionEl.style.visibility='hidden';maininscriptionEl.set('tween', {}).tween('height', '0px');$('main_inscription2').style.visibility='hidden';$('main_inscription2').set('tween', {}).tween('height', '0px');}
		if(whatEl==5){$('user-lost').style.visibility='hidden';$('user-lost').set('tween', {}).tween('height', '0px');$('user-lost2').style.visibility='hidden';$('user-lost2').set('tween', {}).tween('height', '0px');}
		if(whatEl==6){$('contact').style.visibility='hidden';$('contact').set('tween', {}).tween('height', '0px');}
		if(whatEl==7){$('mentionslegalesdiv').style.visibility='hidden';$('mentionslegalesdiv').set('tween', {}).tween('height', '0px');}
		if(whatEl==8){$('parametre').style.visibility='hidden';$('parametre').set('tween', {}).tween('height', '0px');}
		if(whatEl==9){$('documentation').style.visibility='hidden';$('documentation').set('tween', {}).tween('height', '0px');}
		if(whatEl==10){$('agiltrack').style.visibility='hidden';$('agiltrack').set('tween', {}).tween('height', '0px');}
		if(whatEl==11){$('user-motdepasse').style.visibility='hidden';$('user-motdepasse').set('tween', {}).tween('height', '0px');}
		if(whatEl==12){$('main_agilbox').style.visibility='hidden';$('main_agilbox').set('tween', {}).tween('height', '0px');}
		if(whatEl==13){$('main_agilsante').style.visibility='hidden';$('main_agilsante').set('tween', {}).tween('height', '0px');}
		if(whatEl==14){$('main_agilsecurite').style.visibility='hidden';$('main_agilsecurite').set('tween', {}).tween('height', '0px');}
		if(whatEl==15){$('main_agilmarine').style.visibility='hidden';$('main_agilmarine').set('tween', {}).tween('height', '0px');}
		if(whatEl==16){$('main_agiltransport').style.visibility='hidden';$('main_agiltransport').set('tween', {}).tween('height', '0px');}
		if(whatEl==17){$('main_news').style.visibility='hidden';$('main_news').set('tween', {}).tween('height', '0px');}
		if(whatEl==18){$('main_reference').style.visibility='hidden';$('main_reference').set('tween', {}).tween('height', '0px');}
	}
	$('fondement-innov').addEvent('mouseenter', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		$('fondement-innov-t').className='t2';
		$('fondement-precision-t').className='t';
		$('fondement-optim-t').className='t';
		$('fondement-fiabilite-t').className='t';
		if(whatEl2!=1){
			tween2();
			$('fondement-innov-div').style.visibility='';
			$('fondement-innov-div').set('tween', {
				duration: 2000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '200px');
			whatEl2=1;
		}
	});
	$('fondement-precision').addEvent('mouseenter', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		$('fondement-innov-t').className='t';
		$('fondement-precision-t').className='t2';
		$('fondement-optim-t').className='t';
		$('fondement-fiabilite-t').className='t';
		if(whatEl2!=2){
			tween2();
			$('fondement-precision-div').style.visibility='';
			$('fondement-precision-div').set('tween', {
				duration: 2000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '200px');
			whatEl2=2;
		}
	});
	$('fondement-optim').addEvent('mouseenter', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		$('fondement-innov-t').className='t';
		$('fondement-precision-t').className='t';
		$('fondement-optim-t').className='t2';
		$('fondement-fiabilite-t').className='t';
		if(whatEl2!=3){
			tween2();
			$('fondement-optim-div').style.visibility='';
			$('fondement-optim-div').set('tween', {
				duration: 2000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '200px');
			whatEl2=3;
		}
	});
	$('fondement-fiabilite').addEvent('mouseenter', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		$('fondement-innov-t').className='t';
		$('fondement-precision-t').className='t';
		$('fondement-optim-t').className='t';
		$('fondement-fiabilite-t').className='t2';
		if(whatEl2!=4){
			tween2();
			$('fondement-fiabilite-div').style.visibility='';
			$('fondement-fiabilite-div').set('tween', {
				duration: 2000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '200px');
			whatEl2=4;
		}
	});
	function tween2(){
		if(whatEl2==1){$('fondement-innov-div').style.visibility='hidden';$('fondement-innov-div').set('tween', {}).tween('height', '0px');}
		if(whatEl2==2){$('fondement-precision-div').style.visibility='hidden';$('fondement-precision-div').set('tween', {}).tween('height', '0px');}
		if(whatEl2==3){$('fondement-optim-div').style.visibility='hidden';$('fondement-optim-div').set('tween', {}).tween('height', '0px');}
		if(whatEl2==4){$('fondement-fiabilite-div').style.visibility='hidden';$('fondement-fiabilite-div').set('tween', {}).tween('height', '0px');}
	}
	$('menu-societe').addEvent('click', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		$('menugauche').set('tween', {duration: 2000}).tween('height', '175px');
		if(whatEl!=1){
			tween();
			mainsocieteEl.style.visibility='';
			mainsocieteEl.set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '530px');
			whatEl=1;
		}
		$('menugauche').style.visibility='';
		$('menugauche').style.position='relative';
		$('menugauche2').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche2').style.overflow='hidden';
	});
	$('menu-produit').addEvent('click', function(e) {
	});
	$('menu-agilbox').addEvent('click', function(e) {
	});
	$('menu-news').addEvent('click', function(e) {
	});
	$('menu-contact').addEvent('click', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=6){
			tween();
			$('contact').style.visibility='';
			$('contact').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '530px');
			whatEl=6;
		}
		$('menugauche').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche').style.overflow='hidden';
		$('menugauche2').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche2').style.overflow='hidden';
	});
	$('mentionslegalesbtn').addEvent('click', function(e) {
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=7){
			tween();
			$('mentionslegalesdiv').style.visibility='';
			$('mentionslegalesdiv').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut 
			}).tween('height', '530px');
			whatEl=7;
		}
		$('menugauche').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche').style.overflow='hidden';
		$('menugauche2').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche2').style.overflow='hidden';
	});
	$('password').addEvent('keypress', function(e) {
		$('usererror').style.visibility='hidden';
	});
	$('identifiant').addEvent('keypress', function(e) {
		$('usererror').style.visibility='hidden';
	});
	$('identifiant').addEvent('blur', function(e) {
		$('usererror').style.visibility='hidden';
		var mail=$('identifiant').value;
		if(!emailvalid(mail)){
			document.getElementById('usererror').style.left=getX(document.getElementById('identifiant'))+170+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('identifiant'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />Email non valide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		
		if(mail.length>0 && emailvalid(mail)){
		var req = new Request({url:'testmail.php',
			onSuccess:function(reponse) {
				if(reponse==0){
					document.getElementById('usererror').style.left=getX(document.getElementById('identifiant'))+170+ "px";;
					document.getElementById('usererror').style.top=getY(document.getElementById('identifiant'))-3+ "px";;
					$('usererror').style.visibility='';
					$('usererror2').innerHTML='<br />Email inconnu, <br />veuillez vous inscrire.';
					errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
				}else{
					$('usererror').style.visibility='hidden';
				}					
			},
			onFailure:function() {alert('Erreur de connexion au server');}
		});
		req.send("mail="+mail);
		}
	});
	$('userlogout').addEvent('click', function(e) {
		$('username').value='';
		$('username2').innerHTML='';
		$('userid').value='0';
		$('userkey').value='';
		$('menuuserlog').style.visibility='hidden';
		$('menuuser').style.position='relative';
		$('menuuser').style.visibility='';
		$('menuuserlog').style.position='absolute';
		Delete_Cookie( 'agiltech', null, null );
	});
	$('usercompte').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=8){
			tween();
			$('parametre').style.visibility='';
			$('parametre').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '530px');
			whatEl=8;
		}
		$('menugauche').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche').style.overflow='hidden';
		var req = new Request({url:'user.php',
			onSuccess:function(reponse) {
				var a=reponse.split('|');
				$('usererror').style.visibility='hidden';
				$('parametre_mail').value=a[1];
				$('parametre_nom').value=a[2];
				$('parametre_prenom').value=a[3];
				$('parametre_societe').value=a[4];
				$('parametre_tel').value=a[5];
				$('parametre_mobile').value=a[6];
				$('parametre_fax').value=a[7];
				$('parametre_adresse').value=a[8];
				$('parametre_zip').value=a[9];
				$('parametre_ville').value=a[10];
			},
			onFailure:function() {alert('Erreur de connexion au server');}
		});
		req.send("do=compte&userkey="+$('userkey').value);
		$('menugauche2').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche2').style.overflow='hidden';
	});
	$('userdoc').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=9){
			tween();
			$('documentation').style.visibility='';
			$('documentation').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '430px');
			whatEl=9;
		}
		$('menugauche').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche').style.overflow='hidden';
		$('menugauche2').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche2').style.overflow='hidden';
	});
	$('useragil').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		var req = new Request({url:'compte.php',
			onSuccess:function(reponse) {
				
			},
			onFailure:function() {alert('Erreur de connexion au server');}
		});
		req.send("userkey="+$('userkey').value);		
		if(whatEl!=10){
			tween();
			$('agiltrack').style.visibility='';
			$('agiltrack').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '530px');
			whatEl=10;
		}		
		$('menugauche').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche').style.overflow='hidden';
		$('menugauche2').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche2').style.overflow='hidden';
	});
	$('usermdpchg').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=11){
			tween();
			$('user-motdepasse').style.visibility='';
			$('user-motdepasse').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '430px');
			whatEl=11;
		}
		$('menugauche').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche').style.overflow='hidden';
		$('menugauche2').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche2').style.overflow='hidden';
	});

/********************************************************************************
 * 					PAGE INSCRIPTION
 */
	$('inscription_mail').addEvent('keypress', function(e){
		$('usererror').style.visibility='hidden';
	});
	$('inscription_mail').addEvent('blur', function(e){
			$('usererror').style.visibility='hidden';
		if(!emailvalid($('inscription_mail').value)){
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_mail'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_mail'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />Email non valide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if($('inscription_mail').value.length==0){
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_mail'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_mail'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />l\'email ne peut être vide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}		
		else if($('inscription_mail').value.length>0){
			var req = new Request({url:'testmail.php',
				onSuccess:function(reponse) {
					if(reponse==1){$('inscriptionmailok').value=1;}
					else{			
						document.getElementById('usererror').style.left=getX(document.getElementById('inscription_mail'))+150+ "px";;
						document.getElementById('usererror').style.top=getY(document.getElementById('inscription_mail'))-3+ "px";;
						$('usererror').style.visibility='';
						$('usererror2').innerHTML='<br />l\'email est déjà enregistré.';
						errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
						$('inscriptionmailok').value=0;
					}
				},
				onFailure:function() {alert('Erreur de connexion au server');}
			});
			req.send("mail="+$('inscription_mail').value);
			}

	});
	$('inscription_password').addEvent('keypress', function(e) {
		$('usererror').style.visibility='hidden';
	});
	$('inscription_password').addEvent('blur', function(e) {
		if($('inscription_password').value.length==0){
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_password'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_password'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />le mot de passe ne peut être vide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
	});
	$('inscription_password2').addEvent('keypress', function(e) {
		$('usererror').style.visibility='hidden';
	});
	$('inscription_password2').addEvent('blur', function(e) {
		if($('inscription_password2').value!=$('inscription_password').value){
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_password2'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_password2'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />les mots de passe ne correspondent pas.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
	});
	$('inscription_nom').addEvent('keypress', function(e) {
		$('usererror').style.visibility='hidden';
	});
	$('inscription_nom').addEvent('blur', function(e) {
		if($('inscription_nom').value.length==0){
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_nom'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_nom'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />le nom ne peut être vide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
	});
	$('inscription_prenom').addEvent('keypress', function(e) {
		$('usererror').style.visibility='hidden';
	});
	$('inscription_prenom').addEvent('blur', function(e) {
		if($('inscription_prenom').value.length==0){
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_prenom'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_prenom'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />le prénom ne peut être vide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
	});
	$('inscription-button').addEvent('click', function(e) {
		var mail=document.getElementById("inscription_mail").value;
		var password=document.getElementById("inscription_password").value;
		var password2=document.getElementById("inscription_password2").value;
		var nom=document.getElementById("inscription_nom").value;
		var prenom=document.getElementById("inscription_prenom").value;
		var societe=document.getElementById("inscription_societe").value;
		var telephone=document.getElementById("inscription_tel").value;
		var mobile=document.getElementById("inscription_mobile").value;
		var fax=document.getElementById("inscription_fax").value;
		var adresse=document.getElementById("inscription_adresse").value;
		var zip=document.getElementById("inscription_zip").value;
		var ville=document.getElementById("inscription_ville").value;
		var ok=true;
		if($('inscriptionmailok').value==1 ){
			ok=false;
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_mail'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_mail'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />l\'email est déjà enregistré.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if(!emailvalid(mail)){
			ok=false;
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_mail'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_mail'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />l\'email est invalide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if(mail.length==0){
			ok=false;
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_mail'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_mail'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />l\'email ne peut être vide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if(password.length<7){
			ok=false;
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_password'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_password'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />le mot de passe ne peut être inférieur à 6 caractères.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if(password2!=password){
			ok=false;
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_password2'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_password2'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />les mots de passe ne correspondent pas.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if(nom.length==0){
			ok=false;
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_nom'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_nom'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />le nom ne peut être vide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		else if(prenom.length==0){
			ok=false;
			document.getElementById('usererror').style.left=getX(document.getElementById('inscription_prenom'))+150+ "px";;
			document.getElementById('usererror').style.top=getY(document.getElementById('inscription_prenom'))-3+ "px";;
			$('usererror').style.visibility='';
			$('usererror2').innerHTML='<br />le prénom ne peut être vide.';
			errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
		}
		if(ok==true){
			var req = new Request({url:'connect.php',
				onSuccess:function(reponse) {
					if(reponse==1){
						$('main_inscription').style.visibility='hidden';
						$('main_inscription2').style.visibility='';
						$('main_inscription').set('tween', {}).tween('height', '0px');
						$('main_inscription2').set('tween', {
							duration: 4000,
							transition: Fx.Transitions.Bounce.easeOut 
						}).tween('height', '530px');
					}
					else alert('inscription échouée !!!')
				},
				onFailure:function() {alert('Erreur de connexion au server');}
			});
			req.send("do=inscription&mail="+mail+"&password="+password+"&nom="+nom+"&prenom="+prenom+"&societe="+societe+"&telephone="+telephone+"&mobile="+mobile+"&fax="+fax+"&adresse="+adresse+"&zip="+zip+"&ville="+ville);
		}
	});
	$('connectbtn').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		var identifiant=document.getElementById("identifiant").value;
		var password=document.getElementById("password").value;
		var souvenir=document.getElementById("souvenir").value;
		var conid=$('conid').value;
		var req = new Request({url:'connect.php',
			onSuccess:function(reponse) {
				var a=reponse.split("|");
				if(a[0]==0){
					document.getElementById('usererror').style.left=getX(document.getElementById('password'))+170+ "px";;
					document.getElementById('usererror').style.top=getY(document.getElementById('password'))-3+ "px";;
					$('usererror').style.visibility='';
					$('usererror2').innerHTML='<br />Mot de passe incorrect.';
					errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
				}
				else if (a[0]==1){
					if(souvenir=="on"){
						Set_Cookie( "agiltech", a[4], 7, null, null, null );
					}
					$('username').value=a[2]+' '+a[3];
					$('username2').innerHTML=a[2]+' '+a[3];
					$('userid').value=a[1];
					$('userkey').value=a[4];
					$('menuuser').style.visibility='hidden';
					$('menuuserlog').style.position='relative';
					$('menuuserlog').style.visibility='';
					$('menuuser').style.position='absolute';
				}
				else if (a[0]==2){
					document.getElementById('usererror').style.left=getX(document.getElementById('connectbtn'))+100+ "px";;
					document.getElementById('usererror').style.top=getY(document.getElementById('connectbtn'))-3+ "px";;
					$('usererror').style.visibility='';
					$('usererror2').innerHTML='<br />Utilisateur '+a[2]+' '+a[3]+' reconnu. <br /> Email non confirmé. <br />Vous devez confirmer votre email pour vous connecter.';
					errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
				}				
			},
			onFailure:function() {alert('Erreur de connexion au server');}
		});
		req.send("conid="+conid+"&do=connect&login="+identifiant+"&password="+password+"&souvenir="+souvenir);		
	});
	var cookie=Get_Cookie("agiltech");
	if(cookie!=null){
		var conid=$('conid').value;
		var req = new Request({url:'connect.php',
			onSuccess:function(reponse) {
				var a=reponse.split("|");
				if (a[0]==1){
					Set_Cookie( "agiltech", a[4], null, null, null, null );
					$('username').value=a[2]+' '+a[3];
					$('username2').innerHTML=a[2]+' '+a[3];
					$('userid').value=a[1];
					$('userkey').value=a[4];
					$('menuuser').style.visibility='hidden';
					$('menuuserlog').style.position='relative';
					$('menuuserlog').style.visibility='';
					$('menuuser').style.position='absolute';
				}
			},
			onFailure:function() {alert('Erreur de connexion au server');}
		});
		req.send("conid="+conid+"&do=connectkey&key="+cookie);				
	}
	$('userlost-button').addEvent('click', function(e) {
		$('usererror').style.visibility='hidden';
		var mail=document.getElementById("userlost_mail").value;
		var req = new Request({url:'connect.php',
			onSuccess:function(reponse) {
				if(reponse==0){
					document.getElementById('usererror').style.left=getX(document.getElementById('userlost_mail'))+150+ "px";;
					document.getElementById('usererror').style.top=getY(document.getElementById('userlost_mail'))-3+ "px";;
					$('usererror').style.visibility='';
					$('usererror2').innerHTML='<br />Email inconnu. <br />Veuillez vous inscrire.';
					errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
				}
				else if(reponse==2){
					document.getElementById('usererror').style.left=getX(document.getElementById('userlost_button'))+150+ "px";;
					document.getElementById('usererror').style.top=getY(document.getElementById('userlost_button'))-3+ "px";;
					$('usererror').style.visibility='';
					$('usererror2').innerHTML='<br />Echec de l\'envoie de l\'email. <br />Veuillez éssayer à nouveau ou nous contacter à <a href="mailto:contact@agiltech.fr">contact@agiltech.fr</a>.';
					errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
				}
				else {
					$('user-lost').fade('out');
					$('user-lost').set('tween', {}).tween('height', '0px');
					$('user-lost2').set('tween', {
						duration: 4000,
						transition: Fx.Transitions.Bounce.easeOut 
					}).tween('height', '530px');
				}
			},
			onFailure:function() {alert('Erreur de connexion au server');}
		});
		req.send("do=userlost&mail="+mail);				
	});
	$('userlost_mail').addEvent('focus', function(e) {
		$('usererror').style.visibility='hidden';
	});
	$('menu-produit').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=12){
			tween();
			$('main_agilbox').style.visibility='';
			$('main_agilbox').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '630px');
			whatEl=12;
		}
		$('menugauche').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche').style.overflow='hidden';
		$('menugauche2').set('tween', {duration: 2000}).tween('height', '200px');
	});
	$('menu-agilbox').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=12){
			tween();
			$('main_agilbox').style.visibility='';
			$('main_agilbox').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '630px');
			whatEl=12;
		}
		$('menugauche').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche').style.overflow='hidden';
		$('menugauche2').set('tween', {duration: 2000}).tween('height', '200px');
	});
	$('menu-news').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=17){
			tween();
			$('main_news').style.visibility='';
			$('main_news').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '630px');
			whatEl=17;
		}
		$('menugauche').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche').style.overflow='hidden';
		$('menugauche2').set('tween', {duration: 2000}).tween('height', '0px');
		$('menugauche2').style.overflow='hidden';
	});
	$('produitagilbox').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=12){
			tween();
			$('main_agilbox').style.visibility='';
			$('main_agilbox').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '630px');
			whatEl=12;
		}
	});
	$('produitsante').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=13){
			tween();
			$('main_agilsante').style.visibility='';
			$('main_agilsante').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '530px');
			whatEl=13;
		}
	});
	$('produitsecurite').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=14){
			tween();
			$('main_agilsecurite').style.visibility='';
			$('main_agilsecurite').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '530px');
			whatEl=14;
		}
	});
	$('produitmarine').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=15){
			tween();
			$('main_agilmarine').style.visibility='';
			$('main_agilmarine').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '1130px');
			whatEl=15;
		}
	});
	$('produittransport').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		if(whatEl!=16){
			tween();
			$('main_agiltransport').style.visibility='';
			$('main_agiltransport').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '530px');
			whatEl=16;
		}
	});
	$('boitier-tarifs').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		if($('userid').value!=0){
			$('boitier_div').style.visibility='hidden';
			  var myWidth = 0;
			  if( typeof( window.innerWidth ) == 'number' ) {
			    //Non-IE
			    myWidth = window.innerWidth;
			  } else if( document.documentElement && document.documentElement.clientWidth ) {
			    //IE 6+ in 'standards compliant mode'
			    myWidth = document.documentElement.clientWidth;
			  } else if( document.body && document.body.clientWidth ) {
			    //IE 4 compatible
			    myWidth = document.body.clientWidth;
			  }
			  
			 $('tarif_div').style.left=(myWidth/2)-300+'px';
			 $('tarif_div').style.top='50px';
			 $('tarif_div').style.visibility='';
			 $('tarif_div').set('tween', {
				duration: 4000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '500px');
		}else{
			alert('Vous devez vous identifier, pour pouvoir acceder aux tarifs.')
		}
	});
	$('tarif-div-close').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		$('tarif_div').style.visibility='hidden';
	});
	$('boitier-carac').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		$('tarif_div').style.visibility='hidden';
		e.stop();
	  var myWidth = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myWidth = window.innerWidth;
	  } else if( document.documentElement && document.documentElement.clientWidth ) {
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	  } else if( document.body && document.body.clientWidth ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	  }
	  
	 $('boitier_div').style.left=(myWidth/2)-300+'px';
	 $('boitier_div').style.top='50px';
	 $('boitier_div').style.visibility='';
	 $('boitier_div').set('tween', {
		duration: 4000,
		transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
	}).tween('height', '500px');
	});
	$('boitier-div-close').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		$('boitier_div').style.visibility='hidden';
	});
	$('user_gestion_command_button').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		$('tarif_div').style.visibility='hidden';
		e.stop();
		  var myWidth = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		  } else if( document.documentElement && document.documentElement.clientWidth ) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = document.documentElement.clientWidth;
		  } else if( document.body && document.body.clientWidth ) {
		    //IE 4 compatible
		    myWidth = document.body.clientWidth;
		  }
		  
		 $('cmd1').value=1;
		 $('cmd2').value=0;
		 $('cmd3').value=0;
		 $('cmd4').value=0;
		 calculcmd();
		 calculopen();
		  
		 $('commande_div').style.left=(myWidth/2)-400+'px';
		 $('commande_div').style.top='20px';
		 $('commande_div').style.visibility='';
		 $('commande_div').set('tween', {
			duration: 4000,
			transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
		}).tween('height', '500px');
	});	
	$('commande1').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		$('tarif_div').style.visibility='hidden';
		e.stop();
		  var myWidth = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		  } else if( document.documentElement && document.documentElement.clientWidth ) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = document.documentElement.clientWidth;
		  } else if( document.body && document.body.clientWidth ) {
		    //IE 4 compatible
		    myWidth = document.body.clientWidth;
		  }
		  
		 $('cmd1').value=1;
		 $('cmd2').value=0;
		 $('cmd3').value=0;
		 $('cmd4').value=0;
		 calculcmd();
		 calculopen();
		  
		 $('commande_div').style.left=(myWidth/2)-400+'px';
		 $('commande_div').style.top='20px';
		 $('commande_div').style.visibility='';
		 $('commande_div').set('tween', {
			duration: 4000,
			transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
		}).tween('height', '500px');
	});	
	$('commande2').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		$('tarif_div').style.visibility='hidden';
		e.stop();
		  var myWidth = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		  } else if( document.documentElement && document.documentElement.clientWidth ) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = document.documentElement.clientWidth;
		  } else if( document.body && document.body.clientWidth ) {
		    //IE 4 compatible
		    myWidth = document.body.clientWidth;
		  }
		  
		 $('cmd1').value=0;
		 $('cmd2').value=1;
		 $('cmd3').value=0;
		 $('cmd4').value=0;
		 calculcmd();
		 calculopen();
		  
		 $('commande_div').style.left=(myWidth/2)-400+'px';
		 $('commande_div').style.top='20px';
		 $('commande_div').style.visibility='';
		 $('commande_div').set('tween', {
			duration: 4000,
			transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
		}).tween('height', '500px');
	});
	$('commande3').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		$('tarif_div').style.visibility='hidden';
		e.stop();
		  var myWidth = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		  } else if( document.documentElement && document.documentElement.clientWidth ) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = document.documentElement.clientWidth;
		  } else if( document.body && document.body.clientWidth ) {
		    //IE 4 compatible
		    myWidth = document.body.clientWidth;
		  }
		  
		 $('cmd1').value=0;
		 $('cmd2').value=0;
		 $('cmd3').value=1;
		 $('cmd4').value=0;
		 calculcmd();
		 calculopen();
		  
		 $('commande_div').style.left=(myWidth/2)-400+'px';
		 $('commande_div').style.top='20px';
		 $('commande_div').style.visibility='';
		 $('commande_div').set('tween', {
			duration: 4000,
			transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
		}).tween('height', '500px');
	});	
	$('commande4').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		$('tarif_div').style.visibility='hidden';
		e.stop();
		  var myWidth = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		  } else if( document.documentElement && document.documentElement.clientWidth ) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = document.documentElement.clientWidth;
		  } else if( document.body && document.body.clientWidth ) {
		    //IE 4 compatible
		    myWidth = document.body.clientWidth;
		  }
		  
		 $('cmd1').value=0;
		 $('cmd2').value=0;
		 $('cmd3').value=0;
		 $('cmd4').value=1;
		 calculcmd();
		 calculopen();
		  
		 $('commande_div').style.left=(myWidth/2)-400+'px';
		 $('commande_div').style.top='20px';
		 $('commande_div').style.visibility='';
		 $('commande_div').set('tween', {
			duration: 4000,
			transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
		}).tween('height', '500px');
	});
	$('commande-div-close').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		$('commande_div').style.visibility='hidden';
	});
	$('commande-response-div-close').addEvent('click', function(e){
		$('usererror').style.visibility='hidden';
		e.stop();
		$('commande_response_div').style.visibility='hidden';
	});
	function calculcmd(){
		
		var cmd1=$('cmd1').value;
		var cmd2=$('cmd2').value;
		var cmd3=$('cmd3').value;
		var cmd4=$('cmd4').value;
		
		$('cmd1mat').innerHTML=(cmd1*418)+',00 €';
		$('cmd1ser').innerHTML=(cmd1*90)+',00 €';
		
		$('cmd2mat').innerHTML=(cmd2*342)+',00 €';
		$('cmd2ser').innerHTML=(cmd2*90)+',00 €';
		
		$('cmd3mat').innerHTML=(cmd3*192)+',00 €';
		$('cmd3ser').innerHTML=(cmd3*90)+',00 €';
		
		$('cmd4mat').innerHTML=(cmd4*0)+',00 €';
		$('cmd4ser').innerHTML=(cmd4*135)+',00 €';
		
		$('cmdmat').innerHTML=(cmd1*418)+(cmd2*342)+(cmd3*192)+(cmd4*0)+',00 €';
		$('cmdser').innerHTML=(cmd1*90)+(cmd2*90)+(cmd3*90)+(cmd4*135)+',00 €';
		
		var mattva=(((cmd1*418)+(cmd2*342)+(cmd3*192)+(cmd4*0))*19.6)/100;
		var sertva=(((cmd1*90)+(cmd2*90)+(cmd3*90)+(cmd4*135))*19.6)/100;
		
		$('cmdmattva').innerHTML=mattva.toFixed(2)+' €';
		$('cmdsertva').innerHTML=sertva.toFixed(2)+' €';
		
		var matttc=(((cmd1*418)+(cmd2*342)+(cmd3*192)+(cmd4*0))+mattva);
		var serttc=(((cmd1*90)+(cmd2*90)+(cmd3*90)+(cmd4*135))+sertva);
		
		$('cmdmatttc').innerHTML=matttc.toFixed(2)+' €';
		$('cmdserttc').innerHTML=serttc.toFixed(2)+' €';
		
		var tot=matttc+serttc;
		
		if(serttc!=0){
			$('cmdcomment').innerHTML='Merci de prendre connaissance des conditions générales de vente.<br />Vous devez éffectuer un premier versement de '+tot.toFixed(2)+' €.<br />Puis chaque début de trimestre, un versement de '+serttc.toFixed(2)+' €<br />Un contrat va vous être envoyer, merci de le remplir et de valider vos coordonnées bancaire ainsi que remplir l\'autorisation de prélèvement.';
			$('commandeValid').style.visibility='';
		}else{
			$('cmdcomment').innerHTML='';
			$('commandeValid').style.visibility='hidden';
		}
		
	}
	$('cmd1').addEvent('keyup',function(e){
		pos=$('cmd1').caretPos;
		if(!$('cmd1').value.charAt(pos)<10)
		{
			var a='';
			for(i=0;i<$('cmd1').value.length;i++){
				if($('cmd1').value.charAt(i)<10){
					a+=''+$('cmd1').value.charAt(i);
				}
			}
			$('cmd1').value=a;
		}
		calculcmd();
	});
	$('cmd1').addEvent('blur',function(e){
		calculcmd();
	});
	$('cmd2').addEvent('keyup',function(e){
		pos=$('cmd2').caretPos;
		if(!$('cmd2').value.charAt(pos)<10)
		{
			var a='';
			for(i=0;i<$('cmd2').value.length;i++){
				if($('cmd2').value.charAt(i)<10){
					a+=''+$('cmd2').value.charAt(i);
				}
			}
			$('cmd2').value=a;
		}
		calculcmd();
	});
	$('cmd2').addEvent('blur',function(e){
		calculcmd();
	});
	$('cmd3').addEvent('keyup',function(e){
		pos=$('cmd3').caretPos;
		if(!$('cmd3').value.charAt(pos)<10)
		{
			var a='';
			for(i=0;i<$('cmd3').value.length;i++){
				if($('cmd3').value.charAt(i)<10){
					a+=''+$('cmd3').value.charAt(i);
				}
			}
			$('cmd3').value=a;
		}
		calculcmd();
	});
	$('cmd3').addEvent('blur',function(e){
		calculcmd();
	});
	$('cmd4').addEvent('keyup',function(e){
		pos=$('cmd4').caretPos;
		if(!$('cmd4').value.charAt(pos)<10)
		{
			var a='';
			for(i=0;i<$('cmd4').value.length;i++){
				if($('cmd4').value.charAt(i)<10){
					a+=''+$('cmd4').value.charAt(i);
				}
			}
			$('cmd4').value=a;
		}
		calculcmd();
	});
	$('cmd4').addEvent('blur',function(e){
		calculcmd();
	});
	$('commandeValid').addEvent('click',function(e){
		if(!$('cgv').checked==true){
			$('cgv').className='error';
			alert('Vous devez avoir pris connaissance des conditions générales de vente !!!');
		}else{
			if($('fac_nom').value==""){
				document.getElementById('usererror').style.left=getX(document.getElementById('fac_nom'))+150+ "px";;
				document.getElementById('usererror').style.top=getY(document.getElementById('fac_nom'))-3+ "px";;
				$('usererror').style.visibility='';
				$('usererror2').innerHTML='<br />le nom ne peut être vide.';
				errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
			}
			else if($('fac_adresse').value==""){
				document.getElementById('usererror').style.left=getX(document.getElementById('fac_adresse'))+150+ "px";;
				document.getElementById('usererror').style.top=getY(document.getElementById('fac_adresse'))-3+ "px";;
				$('usererror').style.visibility='';
				$('usererror2').innerHTML='<br />l\'adresse ne peut être vide.';
				errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
			}
			else if($('fac_zip').value==""){
				document.getElementById('usererror').style.left=getX(document.getElementById('fac_zip'))+150+ "px";;
				document.getElementById('usererror').style.top=getY(document.getElementById('fac_zip'))-3+ "px";;
				$('usererror').style.visibility='';
				$('usererror2').innerHTML='<br />le code postal ne peut être vide.';
				errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
			}
			else if($('fac_ville').value==""){
				document.getElementById('usererror').style.left=getX(document.getElementById('fac_ville'))+150+ "px";;
				document.getElementById('usererror').style.top=getY(document.getElementById('fac_ville'))-3+ "px";;
				$('usererror').style.visibility='';
				$('usererror2').innerHTML='<br />la ville ne peut être vide.';
				errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
			}
			else if($('liv_nom').value==""){
				document.getElementById('usererror').style.left=getX(document.getElementById('liv_nom'))+150+ "px";;
				document.getElementById('usererror').style.top=getY(document.getElementById('liv_nom'))-3+ "px";;
				$('usererror').style.visibility='';
				$('usererror2').innerHTML='<br />le nom ne peut être vide.';
				errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
			}
			else if($('liv_adresse').value==""){
				document.getElementById('usererror').style.left=getX(document.getElementById('liv_adresse'))+150+ "px";;
				document.getElementById('usererror').style.top=getY(document.getElementById('liv_adresse'))-3+ "px";;
				$('usererror').style.visibility='';
				$('usererror2').innerHTML='<br />l\adresse ne peut être vide.';
				errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
			}
			else if($('liv_zip').value==""){
				document.getElementById('usererror').style.left=getX(document.getElementById('liv_zip'))+150+ "px";;
				document.getElementById('usererror').style.top=getY(document.getElementById('liv_zip'))-3+ "px";;
				$('usererror').style.visibility='';
				$('usererror2').innerHTML='<br />le code postal ne peut être vide.';
				errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
			}
			else if($('liv_ville').value==""){
				document.getElementById('usererror').style.left=getX(document.getElementById('liv_ville'))+150+ "px";;
				document.getElementById('usererror').style.top=getY(document.getElementById('liv_ville'))-3+ "px";;
				$('usererror').style.visibility='';
				$('usererror2').innerHTML='<br />la ville ne peut être vide.';
				errorTimer=window.setTimeout("$('usererror').style.visibility='hidden'",5000);
			}
			else {
			$('cgv').className='';
			var req = new Request({url:'command.php',
				onSuccess:function(reponse) {
					$('command_number').innerHTML=reponse;
					$('commande_div').style.visibility='hidden';
					  var myWidth = 0;
					  var myHeight= 0;
					  if( typeof( window.innerWidth ) == 'number' ) {
					    //Non-IE
					    myWidth = window.innerWidth;
					    myHeight = window.innerHeight;
					  } else if( document.documentElement && document.documentElement.clientWidth ) {
					    //IE 6+ in 'standards compliant mode'
					    myWidth = document.documentElement.clientWidth;
					    myHeight = document.documentElement.clientHeight;
					  } else if( document.body && document.body.clientWidth ) {
					    //IE 4 compatible
					    myWidth = document.body.clientWidth;
					    myHeight = document.body.clientHeight;
					  }
					 $('commande_response_div').style.left=(myWidth/2)-300+'px';
					 $('commande_response_div').style.top=(myHeight/2)-100+'px';
					 $('commande_response_div').style.visibility='';
				},
				onFailure:function() {alert('Erreur de connexion au server');}
			});
			req.send("userkey="+$('userkey').value+"&cmd1="+$('cmd1').value+"&cmd2="+$('cmd2').value+"&cmd3="+$('cmd3').value+"&cmd4="+$('cmd4').value+"&fac_societe="+$('fac_societe').value+"&fac_nom="+$('fac_nom').value+"&fac_prenom="+$('fac_prenom').value+"&fac_adresse="+$('fac_adresse').value+"&fac_zip="+$('fac_zip').value+"&fac_ville="+$('fac_ville').value+"&liv_societe="+$('liv_societe').value+"&liv_nom="+$('liv_nom').value+"&liv_prenom="+$('liv_prenom').value+"&liv_adresse="+$('liv_adresse').value+"&liv_zip="+$('liv_zip').value+"&liv_ville="+$('liv_ville').value);		
			}
		}
	});
	function calculopen(){
		var req = new Request({url:'user.php',
			onSuccess:function(reponse) {
				var a=reponse.split('|');
				$('usererror').style.visibility='hidden';
				$('parametre_mail').value=a[1];
				$('parametre_nom').value=a[2];
				$('parametre_prenom').value=a[3];
				$('parametre_societe').value=a[4];
				$('parametre_tel').value=a[5];
				$('parametre_mobile').value=a[6];
				$('parametre_fax').value=a[7];
				$('parametre_adresse').value=a[8];
				$('parametre_zip').value=a[9];
				$('parametre_ville').value=a[10];
				$('fac_societe').value=$('parametre_societe').value;
				$('fac_nom').value=$('parametre_nom').value;
				$('fac_prenom').value=$('parametre_prenom').value;
				$('fac_adresse').value=$('parametre_adresse').value;
				$('fac_zip').value=$('parametre_zip').value;
				$('fac_ville').value=$('parametre_ville').value;
				$('liv_societe').value=$('parametre_societe').value;
				$('liv_nom').value=$('parametre_nom').value;
				$('liv_prenom').value=$('parametre_prenom').value;
				$('liv_adresse').value=$('parametre_adresse').value;
				$('liv_zip').value=$('parametre_zip').value;
				$('liv_ville').value=$('parametre_ville').value;
			},
			onFailure:function() {alert('Erreur de connexion au server');}
		});
		req.send("do=compte&userkey="+$('userkey').value);
	}
});
