window.addEvent("domready", function(){									 
	
		
	if($("contact_form")){
		new FormCheck("contact_form");	 
	}
	
	
	
	$$("form").each(function(F){		
		new FormCheck(F);
	});	
	
	
	if($('box2')){
	var nS2 = new noobSlide({
			box: $('box2'),
			items: $$('#box2 span'),
			interval: 3000,
			size: 269,
			fxOptions: {
				duration: 1000,
				transition: Fx.Transitions.Bounce.easeOut,
			 	wait: false
			    
			},
			addButtons: {
				previous: $('prev1'),
				next: $('next1')
			}
		});
	}
	
	
	$$("#loginform input[type=text").each(function(el){			
			el.addEvent("click", function(){										  
				if(this.value == "Identifiant")
					this.value = "";
			});
	});
	
	
	
	// MENU HOVER ...
	
	$$('#menu a').each(function(a, i){
		var myFx = new Fx.Tween('banner-box', {duration : 1500, wait:false, transition : Fx.Transitions.Expo.easeOut});
		
		var current = $('banner-box').getStyle('left');
		
		a.addEvents({
			click : function(){
				var from = $('banner-box').getStyle('left');
				var to = i*825*(-1);
				myFx.cancel();
				myFx.start("left" , [from , to]);
			}			
			/*mouseenter : function(){
				var from = $('banner-box').getStyle('left');
				var to = i*825*(-1);
				myFx.cancel();
				myFx.start("left" , [from , to]);
				//$('banner-box').setStyle('left', i*825*(-1))
			},*/
			/*mouseleave : function(){
				
				var from = $('banner-box').getStyle('left');
						
				myFx.cancel();
				myFx.start("left" , [from , current]);
			}*/
		})
		
	});
	
	var mask = new Mask($("content"));	
		$$("#menu ul li a").each(function(a,index){
			
			a.addEvent("click", function(event){	
				event.stop();					
				var pageId = this.getProperty("href");
				var requette_ajax = new Request.HTML({
					url : pageId,
					method :"post",
					update : "content",
					onRequest:function(){
						mask.show();
					},
					onSuccess:function(){
						mask.hide();
					}				
				});
				requette_ajax.send();
				$$("#menu ul li a.active").removeClass("active");
				this.addClass("active");	
				return false;		
			});
		});
	$$("input[type=text]").each(function(input){
		input.setProperty("ovalue", input.get("value"));
		input.addEvents({
			"focus": function(){
				if(this.get("value").trim() == this.getProperty("ovalue"))	
					this.set("value", "");
			},
			"blur":function(){
				if(this.get("value").trim() == "")	
					this.set("value", this.getProperty("ovalue"));
			}
		});
	});
	$$("input[type=password]").each(function(input){
		input.setProperty("ovalue", input.get("value"));
		input.addEvents({
			"focus": function(){
				if(this.get("value").trim() == this.getProperty("ovalue"))	
					this.set("value", "");
			},
			"blur":function(){
				if(this.get("value").trim() == "")	
					this.set("value", this.getProperty("ovalue"));
			}
		});
	});
	$$("textarea").each(function(input){
		input.setProperty("ovalue", input.get("value"));
		input.addEvents({
			"focus": function(){
				if(this.get("value").trim() == this.getProperty("ovalue"))	
					this.set("value", "");
			},
			"blur":function(){
				if(this.get("value").trim() == "")	
					this.set("value", this.getProperty("ovalue"));
			}
		});
	});

});
