window.addEvent('domready', function(){
//-----------------------**************************-------------------------------
	 Element.extend({
	    effect: function(property, options){
	        return new Fx.Style(this, property, options);
	    }
	});
	
var menu1 =  $('menu1').effect('margin-top', {duration: 400});
var menu2 =  $('menu2').effect('margin-top', {duration: 400});
var menu3 =  $('menu3').effect('margin-top', {duration: 400});
var menu4 =  $('menu4').effect('margin-top', {duration: 400});
var menu5 =  $('menu5').effect('margin-top', {duration: 400});
//---------------------
var haut = 88;
var hauteur = 20;
var haut2 = 65;
var haut3 = 55;
var haut4 = 50;
var haut5 = 45;
//----------------
if(page!="un"){
	$('menu1').addEvent('mouseenter',function(e){
		menu1.stop();
		menu1.start(haut, haut+hauteur);
		$('img1').setProperty("src","images/menu1_on.png");
	});
	$('menu1').addEvent('mouseleave',function(e){
		menu1.stop();
		menu1.start(haut+hauteur,haut);
		$('img1').setProperty("src","images/menu1_off.png");
	});
}
if(page!="deux"){
	$('menu2').addEvent('mouseenter',function(e){
		menu2.stop();
		menu2.start(haut2, haut2+hauteur);
		$('img2').setProperty("src","images/menu2_on.png");
	});
	$('menu2').addEvent('mouseleave',function(e){
		menu2.stop();
		menu2.start(haut2+hauteur,haut2);
		$('img2').setProperty("src","images/menu2_off.png");
	});
}
if(page!="trois"){
	$('menu3').addEvent('mouseenter',function(e){
		menu3.stop();
		menu3.start(haut3, haut3+hauteur);
		$('img3').setProperty("src","images/menu3_on.png");
	});
	$('menu3').addEvent('mouseleave',function(e){
		menu3.stop();
		menu3.start(haut3+hauteur,haut3);
		$('img3').setProperty("src","images/menu3_off.png");
	});
}
if(page!="quatre"){
	$('menu4').addEvent('mouseenter',function(e){
		menu4.stop();
		menu4.start(haut4, haut4+hauteur);
		$('img4').setProperty("src","images/menu4_on.png");
	});
	$('menu4').addEvent('mouseleave',function(e){
		menu4.stop();
		menu4.start(haut4+hauteur,haut4);
		$('img4').setProperty("src","images/menu4_off.png");
	});
}
if(page!="cinq" && page !='six'){
	$('menu5').addEvent('mouseenter',function(e){
		menu5.stop();
		menu5.start(haut5, haut5+hauteur);
		$('img5').setProperty("src","images/menu5_on.png");
	});
	$('menu5').addEvent('mouseleave',function(e){
		menu5.stop();
		menu5.start(haut5+hauteur,haut5);
		$('img5').setProperty("src","images/menu5_off.png");
	});
}
if(page=="accueil"){
	//MySlide.toggle();
}

//alert(page);
switch(page){
case('accueil'):
	var mySlide = new Fx.Slide('content_droite',{mode:'horizontal'});
	$('content_droite').setStyle('visibility','hidden');
	mySlide.hide();
	(function(){menu1.start(0,haut)}).delay(1000);
	(function(){menu2.start(0,haut2)}).delay(1200);
	(function(){menu3.start(0,haut3)}).delay(1400);
	(function(){menu4.start(0,haut4)}).delay(1500);
	(function(){menu5.start(0,haut5)}).delay(1600);
	(function(){$('content_droite').setStyle('visibility','visible');mySlide.toggle()}).delay(1900);
	(function(){ $('flash').setStyle('display',"block")}).delay(2400);
	break;
case('un'):
	$('footer').setStyle("margin-top",519);
	$('liens_bas').setStyle("margin-top",8);
	$('logo_bouygues').setStyle("margin-top",8);
	$('contenu').setStyle("height",610);
	(function(){
	menu1.start(0,haut+hauteur);
	menu2.start(0,haut2);
	menu3.start(0,haut3);
	menu4.start(0,haut4);
	menu5.start(0,haut5)}).delay(900);
	break;
case('deux'):
	(function(){menu1.start(0,haut);
	menu2.start(0,haut2+hauteur);
	menu3.start(0,haut3);
	menu4.start(0,haut4);
	menu5.start(0,haut5)}).delay(900);
	break;
case('trois'):
	(function(){menu1.start(0,haut);
	menu2.start(0,haut2);
	menu3.start(0,haut3+hauteur);
	menu4.start(0,haut4);
	menu5.start(0,haut5)}).delay(900);
	break;
case('quatre'):
	(function(){menu1.start(0,haut);
	menu2.start(0,haut2);
	menu3.start(0,haut3);
	menu4.start(0,haut4+hauteur);
	menu5.start(0,haut5)}).delay(900);
break;
case('cinq'):
	$('footer').setStyle("margin-top",721);
	$('investir').setStyle('display','none');
	$('habiter').setStyle('display','none');
	$('liens_bas').setStyle("margin-top",210);
	$('logo_bouygues').setStyle("margin-top",210);
	$('contenu').setStyle("height",810);
	//
	$('rblRaison_0').addEvent("click",function(e){
		$('investir').setStyle('display','none');
		$('habiter').setStyle('display','block');
	});
	//
	$('rblRaison_1').addEvent("click",function(e){
		$('investir').setStyle('display','block');
		$('habiter').setStyle('display','none');
	});
	//
	(function(){menu1.start(0,haut);
	menu2.start(0,haut2);
	menu3.start(0,haut3);
	menu4.start(0,haut4);
	menu5.start(0,haut5+hauteur)}).delay(900);
	//
	function checkmail(email) {
       var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,4}$/
       return (reg.exec(email)!=null)
     }
	$('demandeInfo').addEvent('submit', function(e) { 
		//				
		var retour="";
		var format ="";
		$('vous_souhaitez').setStyle('color','#000');
		if($('chkBrochure').checked == false && $('chkContact').checked == false){
			//$('erreur').setText("Attention : Les champs suivis d’un (*) sont obligatoires, veuillez les remplir, SVP.");
			$('vous_souhaitez').setStyle('color','#ff0000');
			new Event(e).stop();
			var retour="chkBrochure";
		}
		$('lblCivilite').setStyle('color','#000000');
		if($('rblCivilite_0').checked == false && $('rblCivilite_1').checked == false && $('rblCivilite_2').checked==false){
			retour +='Civilité\n';
			$('lblCivilite').setStyle('color','#ff0000');
			new Event(e).stop();
		};
		$$('input[type=text]').each(function(el){
			if(el.id=="tbNom" || el.id=="tbEmail" || el.id=="tbCodePostal" || el.id=="tbPrenom" || el.id=="tbTelephone"){
			$('lbl'+el.id.substring(2,el.id.length)).setStyle('color','#000000');
				if(el.value == ""){
					if(el.id=="tbCodePostal"){
						retour+='Code Postal\n';
					}else{
						retour+=el.id.substring(2,el.id.length)+'\n';
					}
					$('lbl'+el.id.substring(2,el.id.length)).setStyle('color','#ff0000');
					new Event(e).stop();
				}else if(el.id=="tbEmail" && !checkmail(el.value)) {
					format = "Mail : le format n'est pas correct\n";
				}
			}
		})
		
		
		if($('prj0').checked == false && $('prj1').checked == false && $('prj2').checked == false){
			retour += 'Vous avez un projet ŕ ...\n';
			$('lblprojet').setStyle('color','#ff0000');
			new Event(e).stop();
		}else{
			$('lblprojet').setStyle('color','#000');
		}
		$('lblRaison').setStyle('color','#000000');
		if($('rblRaison_0').checked == false && $('rblRaison_1').checked == false){
			retour +="Vous cherchez pour ...\n";
			$('lblRaison').setStyle('color','#ff0000');
			new Event(e).stop();
		}else{
			$('lblRaison').setStyle('color','#000');
			if($('rblRaison_0').checked == true){ //HABITER
				if($('4').checked == false && $('5').checked == false && $('6').checked==false){
					retour +='Proposition dont vous vous sentez le plus proche\n';
					$('lblChoixRaison').setStyle('color','#ff0000');
					new Event(e).stop();
				}else{
					$('lblChoixRaison').setStyle('color','#000');
				}
			}else if($('rblRaison_1').checked == true){ //INVESTIR
				if($('1').checked == false && $('2').checked == false && $('3').checked==false){
					retour +='Proposition dont vous vous sentez le plus proche\n';
					$('lblChoixRaison2').setStyle('color','#ff0000');
					new Event(e).stop();
				}else{
					$('lblChoixRaison2').setStyle('color','#000');
				}
			}
		};
		if($('rblInfo_0').checked == false && $('rblInfo_1').checked == false){
			retour +="Informations commerciales\n";
			$('lblInfo').setStyle('color','#ff0000');
			new Event(e).stop();
		}else{
			$('lblInfo').setStyle('color','#000');
		}
		if($('rblInfoAutre_0').checked == false && $('rblInfoAutre_1').checked == false){
			retour +="informations commerciales partenaires\n";
			$('lblInfoAutre').setStyle('color','#ff0000');
			new Event(e).stop();
		}else{
			$('lblInfoAutre').setStyle('color','#000');
		}			
		if(retour!=""){
			$('erreur').setText('Attention : Les champs suivis d’un (*) sont obligatoires, veuillez les remplir, SVP.');
			new Event(e).stop();
			return false;
		}else if(format !=""){
				$('erreur').setText('Un ou plusieurs champs ne sont pas au bon format, veuillez les vérifier avant de valider le formulaire.');
				$('tbEmail').setStyle('color','#ff0000');
				new Event(e).stop();
				return false;
		}else{
			return true;				
		}
	});
break;
case "photos":
(function(){menu1.start(0,haut);
	menu2.start(0,haut2);
	menu3.start(0,haut3);
	menu4.start(0,haut4);
	menu5.start(0,haut5)}).delay(900);
break;
case('six'):
(function(){menu1.start(0,haut);
	menu2.start(0,haut2);
	menu3.start(0,haut3);
	menu4.start(0,haut4);
	menu5.start(0,haut5+hauteur)}).delay(900);
	$('footer').setStyle("margin-top",721);
	$('liens_bas').setStyle("margin-top",210);
	$('logo_bouygues').setStyle("margin-top",210);
	$('contenu').setStyle("height",810);
default:
break;
}
//--
//-----------------------**************************-------------------------------
});
function montrer_image(param,w,h){
	//alert(param);
	var reg1=new RegExp("[MSIE]","g");
	var chaine = navigator.appVersion;
	if (chaine.match(reg1)) {
		w = w + 30;
		h = h +30;
	}
	var fenetre = window.open("pop.html", "popup", "width="+w+",height="+h+",scrollbars");
	fenetre.document.write('<html>'+
	'<head>' +
	'<title>imprimer</title>' + 
	'<style>' +
	'*{font-size:12px;text-align:center;margin-right:15px;font-family:arial;color:#000000;}'+
	'</style>'+
	'</head>'+
	'<body>' +
	'<img src="images/'+param+'" /><br/>' +
	'<a href="javascript:window.print();">Imprimer</a>'+ 
	'<a>  |  </a>'+
	'<a href="javascript:window.close();">fermer</a> '+
	'</body>'+
	'</html>');
	fenetre.document.close();
	fenetre.focus();
}

function cacher_flash(){
	$('flash').setStyle('display',"none");
}




