window.addEvent('domready', function(){
//-----------------------**************************-------------------------------
	 Element.extend({
	    effect: function(property, options){
	        return new Fx.Style(this, property, options);
	    }
	});
	
	new Asset.images([

		'img/menusituation_on.png',

		'img/menufuture_on.png', 

		'img/menuinfos_on.png', 

		'img/menumaison_on.png', 

		'img/menuregion_on.png'

	]);
//new Asset.javascript('/pngfix.js', {id: 'pngfix'});
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+11;
var hauteur = 20+11;
var haut2 = 65+11;
var haut3 = 55+11;
var haut4 = 50+11;
var haut5 = 45+11;
//----------------
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"){
	$('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();
	//new Asset.image('/images/fond_accueil.jpg');
	(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);
	break;
case('un'):
	//alert(haut);
	//new Asset.images(['images/fond_1.jpg']);
	$('img1').setProperty("src","images/menu1_on.png");
	$('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'):
	//alert('deux');
	$('img2').setProperty("src","images/menu2_on.png");
	(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'):
	//alert('trois');
//	new Asset.images(['images/fond_3.jpg']);
	$('img3').setProperty("src","images/menu3_on.png");
	(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'):
	//alert('et quatre');
	$('img4').setProperty("src","images/menu4_on.png");
	(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'):
	//alert('cinq');
	$('footer').setStyle("margin-top",689);
	$('investir').setStyle('display','none');
	$('habiter').setStyle('display','none');
	$('liens_bas').setStyle("margin-top",178);
	$('logo_bouygues').setStyle("margin-top",178);
	$('contenu').setStyle("height",780);
	$('img5').setProperty("src","images/menu5_on.png");
	//
	$('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);
	//
	 // Teste si le mail a une forme correcte
      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) {
		//				
		new Event(e).stop();
		if($('chkBrochure').checked == false && $('chkContact').checked == false){
			alert("merci de spécifier au moins un souhait \n(demande de rendez vous ou/et de plaquette)");
			$('vous_souhaitez').setStyle('color','#ff0000');
		}else{		
			var retour="";
			$('lblCivilite').setStyle('color','#000000');
			if($('rblCivilite_0').checked == false && $('rblCivilite_1').checked == false && $('rblCivilite_2').checked==false){
				retour +='Civilité\n';
				$('lblCivilite').setStyle('color','#ff0000');
			};
			$$('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');
					}else if(el.id=="tbEmail" && !checkmail(el.value)) {
						retour += "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');
			}else{
				$('lblprojet').setStyle('color','#000');
			}
			if($('rblRaison_0').checked == false && $('rblRaison_1').checked == false){
				retour +="Vous cherchez pour ...\n";
				$('lblRaison').setStyle('color','#ff0000');
			}else{
				$('lblRaison').setStyle('color','#000');
				if($('rblRaison_0').checked == true){ //HABITER
					if($('projets').checked == false && $('opportunite').checked == false && $('retraite').checked==false){
						retour +='Proposition dont vous vous sentez le plus proche\n';
						$('de_quelle_propo2').setStyle('color','#ff0000');
					}else{
						$('de_quelle_propo2').setStyle('color','#000');
					}
				}else if($('rblRaison_1').checked == true){ //INVESTIR
					if($('patrimoine').checked == false && $('rentabilite').checked == false && $('locatif').checked==false){
						retour +='Proposition dont vous vous sentez le plus proche\n';
						$('de_quelle_propo').setStyle('color','#ff0000');
					}else{
						$('de_quelle_propo').setStyle('color','#000');
					}
				}
			};
			if($('rblInfo_0').checked == false && $('rblInfo_1').checked == false){
				retour +="Informations commerciales\n";
				$('lblInfo').setStyle('color','#ff0000');
			}else{
				$('lblInfo').setStyle('color','#000');
			}
			if($('rblInfoAutre_0').checked == false && $('rblInfoAutre_1').checked == false){
				retour +="informations commerciales partenaires\n";
				$('lblInfoAutre').setStyle('color','#ff0000');
			}else{
				$('lblInfoAutre').setStyle('color','#000');
			}			
			if(retour!=""){
				alert('merci de remplir correctement le(s) champ(s) : \n' + retour);
				return false;
			}else{
				/**
				 * Prevent the submit event
				 */
				 
				 //  page merci.php pour "Chechu Castro" :-) 
				//window.location.href = "merci.php";
				//swindow.location.href = "informations_2.php";

				//new Event(e).stop();
			 
				/**
				 * This empties the log and shows the spinning indicator
				 */
				var log = $('retour')
				log.setHTML('envoi de votre message en cours...');
				log.addClass('ajax-loading');
				/**
				 * send takes care of encoding and returns the Ajax instance.
				 * onComplete removes the spinner from the log.
				 */
				 /**/
				this.send({
					update: log,
					onComplete: function() {
						log.removeClass('ajax-loading');
					}
				})
				
			}
		}
	});
break;
default:
;
}
//--
//-----------------------**************************-------------------------------
});
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();
}



