window.addEvent('domready', function(){
//-----------------------**************************-------------------------------
	 Element.extend({
	    effect: function(property, options){
	        return new Fx.Style(this, property, options);
	    }
	});
	
	new Asset.images([

		'images/menusituation_on.png',

		'images/menufuture_on.png', 

		'images/menuinfos_on.png', 

		'images/menumaison_on.png', 

		'images/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 = 85;
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" && 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");
	});
}

//alert(page);
switch(page){
case('accueil'):
	//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);
	var acc =  $('content_droite').effect('margin-left', {duration: 600});
	(function(){
	$('content_droite').setStyle('visibility','visible');
	acc.start(971,431);
	}).delay(2100);
	(function(){$('mask').setStyle('display','none')}).delay(2700);
	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",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);
//	$('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();
		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');
			}
			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($('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');
						new Event(e).stop();
					}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');
						new Event(e).stop();
					}else{
						$('de_quelle_propo').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');
				return false;
			}else{
				/**
				 * Prevent the submit event
				 */
			 
				/**
				 * This empties the log and shows the spinning indicator
				 */
				/*var log = $('retour')
				log.setHTML('envoi de votre message en cours...');
				log.addClass('ajax-loading');
				
				
				this.send({
				
					update: $('formulaire'),
					onComplete: function() {
							
						//log.removeClass('ajax-loading');
					}
				})*/
				return true;
				
			}
	});
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);
	$('img5').setProperty("src","images/menu5_on.png");
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();
}



