

window.addEvent('domready',function(){ 
	Arrive();
	AddCss();
	Navigation();
	Formulaire();
	Modalbox()
	Projet();
		
	});

function AddCss() {

if(Browser.Platform.win) {

	
var myCSS = new Asset.css('css/generalPC.css');
var myCSS2 = new Asset.css('css/squeezbox/SqueezeBox.css');
	}else{
var myCSS2 = new Asset.css('css/squeezbox/SqueezeBox.css');
	}
}

function Modalbox(){
	    /**
     * Set default options, overrideable from later calls.
     */
    SqueezeBox.initialize({
        size: {x: 350, y: 400}
    });
 
    /**
     * Assign SqueezeBox to all links with rel="boxed" attribute, the class then reads the "href".
     */
    SqueezeBox.assign($$('a[rel=boxed]'));
	
	SqueezeBox.assign($$('a.boxed'), {
		parse: 'rel'
	});

	
}

function Projet(){ 

$('webdesign').setStyle('color', '#cc33cc').setStyle('text-decoration', 'none').setStyle('cursor', 'default');




$('autres').addEvent('click', function(event) {
$('webdesign').setStyle('color', '').setStyle('text-decoration', '').setStyle('cursor', '');
$('autres').setStyle('color', '#cc33cc').setStyle('text-decoration', 'none').setStyle('cursor', 'default');
	$$('.hide').fade('hide').removeClass('hide');
	$('web').addClass('hide');
	
	$('autres_supports').set('tween', {duration:1600}).fade('in');
	event.stop()
	})


$('webdesign').addEvent('click', function(event) {
$('autres').setStyle('color', '').setStyle('text-decoration', '').setStyle('cursor', '');
$('webdesign').setStyle('color', '#cc33cc').setStyle('text-decoration', 'none').setStyle('cursor', 'default');
	$$('.hide').fade('hide').removeClass('hide');
	$('autres_supports').addClass('hide');
	$('web').set('tween', {duration:1600}).fade('in');
	event.stop()
	})





	  var totIncrement		= 0;
	  var increment			= 690;
	  var maxRightIncrement	= increment*(-7);
	  var fx = new Fx.Tween('projetbande', {
				duration: 1600,
				transition: Fx.Transitions.Back.easeInOut,
				wait: true
	   });
	 
	$('previous').setStyle('visibility', 'hidden');
	  
	   //-------------------------------------
	  // EVENTS for the button "previous"
	  $('previous').addEvents({ 
          'click' : function(event){ 
		  if(totIncrement<0){
					totIncrement = totIncrement+increment;
					
					fx.start('margin-left',totIncrement);
					$('next').setStyle('visibility', 'visible');
					
					
				}
				if(totIncrement==0){
				   $('previous').setStyle('visibility', 'hidden');
				   
				   }
			}
			
			
      }); 
	 
       //-------------------------------------
	  // EVENTS for the button "next"
  	  $('next').addEvents({ 
          'click' : function(event){ 
			 if(totIncrement>maxRightIncrement){
				 totIncrement = totIncrement-increment;
		    	
				fx.start('margin-left',totIncrement);
				$('previous').setStyle('visibility', 'visible');
			
				
			 }
			 if(totIncrement==-4830){
				   $('next').setStyle('visibility', 'hidden');
			 }
			}
      })
	  
	    var totIncrement2		= 0;
	  var increment2			= 690;
	  var maxRightIncrement2	= increment2*(-4);
	  
	  var fx2 = new Fx.Tween('projetbande2', {
				duration: 1600,
				transition: Fx.Transitions.Back.easeInOut,
				wait: true
	   });
	 
	$('previous2').setStyle('visibility', 'hidden');
	  
	   //-------------------------------------
	  // EVENTS for the button "previous"
	  $('previous2').addEvents({ 
          'click' : function(event){ 
		  if(totIncrement2<0){
					totIncrement2 = totIncrement2+increment2;
					
					fx2.start('margin-left',totIncrement2);
					$('next2').setStyle('visibility', 'visible');
					
					
				}
				if(totIncrement2==0){
				   $('previous2').setStyle('visibility', 'hidden');
				   
				   }
			}
			
			
      }); 
	 
       //-------------------------------------
	  // EVENTS for the button "next"
  	  $('next2').addEvents({ 
          'click' : function(event){ 
			 if(totIncrement2>maxRightIncrement2){
				 totIncrement2 = totIncrement2-increment2;
		    	
				fx2.start('margin-left',totIncrement2);
				$('previous2').setStyle('visibility', 'visible');
			
				
			 }
			 if(totIncrement2==-2760){
				   $('next2').setStyle('visibility', 'hidden');
			 }
			}
      })
	  
	  

	 
};




// Script géneral de navigation 

function Navigation() {

	$('btn_refe').setStyle('color', '#FFFFFF').setStyle('text-decoration', 'none').setStyle('cursor', 'default');;
	var scroll = new Fx.Scroll('prevu', {
	wait: false,
	duration: 1000,
	offset: {'x': -0, 'y': -0},
	transition: Fx.Transitions.Quad.easeInOut
	
});
	
	scroll.toElement('portefolio');
 
$('btn_pres').addEvent('click', function(event) {
	event = new Event(event).stop();
	scroll.toElement('presentation');
	$('btn_pres').setStyle('color', '#FFFFFF').setStyle('text-decoration', 'none').setStyle('cursor', 'default');
	$$('#btn_refe', '#btn_cont').setStyle('color', '').setStyle('text-decoration', '').setStyle('cursor', '');
	$('presentation').set('tween', { duration: 1 }).fade('hide'); $('presentation').set('tween', { duration: 1200}).fade('in');
	$$('#portefolio','#contact').set('tween', {duration:800}).fade('out');
});
 

$('btn_refe').addEvent('click', function(event) {
	event = new Event(event).stop();
	scroll.toElement('portefolio');
	$('btn_refe').setStyle('color', '#FFFFFF').setStyle('text-decoration', 'none').setStyle('cursor', 'default');
	$$('#btn_cont','#btn_pres').setStyle('color', '').setStyle('text-decoration', '').setStyle('cursor', '');
	$('portefolio').set('tween', { duration: 1 }).fade('hide'); $('portefolio').set('tween', { duration: 1200}).fade('in');
	$$('#presentation','#contact').set('tween', {duration:800}).fade('out');
});

$('btn_cont').addEvent('click', function(event) {
	event = new Event(event).stop();
	scroll.toElement('contact');
		$('btn_cont').setStyle('color', '#FFFFFF').setStyle('text-decoration', 'none').setStyle('cursor', 'default');
	$$('#btn_refe', '#btn_pres').setStyle('color', '').setStyle('text-decoration', '').setStyle('cursor', '');
		$('contact').set('tween', { duration: 1 }).fade('hide'); $('contact').set('tween', { duration: 1200}).fade('in');
		$$('#portefolio','#presentation').set('tween', {duration:800}).fade('out');
});


}

function Style(){ 

}


function Arrive(){ 

$('presentation').set('tween', { duration: 1 }).fade('hide'); $('presentation').set('tween', { duration: 1500}).fade('in');
$('contact').set('tween', { duration: 1 }).fade('hide'); $('contact').set('tween', { duration: 1500}).fade('in');

$('menu').set('tween', { duration: 1 }).fade('hide'); $('menu').set('tween', { duration: 500}).fade('in');


var myEffect = new Fx.Morph('menu_bg', {duration: 1200, transition: Fx.Transitions.Bounce.easeOut});
 
myEffect.start({
    'top': [-32, 0] 
});

var myEffect2 = new Fx.Morph('menu', {duration: 1200, transition: Fx.Transitions.Bounce.easeOut});
 
if(Browser.Engine.trident) {

myEffect2.start({
    'top': [-32, 10] 
});
} else if((Browser.Platform.win) && (Browser.Engine.gecko)) {
	
myEffect2.start({
    'top': [-32, 0] 
});	

}else{
myEffect2.start({
    'top': [-32, -3] 
});	}

}

// Script page contact

function Formulaire(){

// Arrivée bandeau réponse
var Effet = new Fx.Slide('log_res');
Effet.slideOut();

// Suppression bandeau réponse
var Effet2 = new Fx.Slide('log_res');

// Vide le formulaire
var viderFormulaire = function() {
			$$('textarea', 'input').setProperty('value','');
			
			}

// Aller retour Formulaire
var myFx = new Fx.Slide('formulaire', {
	mode: 'horizontal',
								
    duration: 2000,
    transition: Fx.Transitions.Pow.easeOut
});


	
		// fValidator test les champs du formulaire
		var myFormValidator = new fValidator('myForm', {language: "fr"});
		
		// AJAX Form		
		$('myForm').addEvent('submit', function(e) {
											
		if(myFormValidator._onSubmit(e)){
			//myFx.toggle().chain(myFx.toggle);	
			$('formulaire').slide('out','horizontal');

			new Event(e).stop();
	
			var log = $('log_res').empty().addClass('ajax-loading');
			
			this.set('send', {onComplete: function(response) { 
			log.removeClass('ajax-loading');
			log.setStyle('display', 'block');
			log.addClass('accuse');
			log.set('html', response);
			(function(){ viderFormulaire(); }).delay(500);
			(function(){ Effet.slideIn(); }).delay(1000);
				
	(function(){ Effet2.slideOut(); }).delay(8000);
		
	(function(){	$('formulaire').slide('in','horizontal'); }).delay(8500);
			
			
		}});
		//Send the form.
		this.send();

	
			
	
		
		// Reset
		$('myForm').addEvent('reset', function(e) {
			var log = $('log_res').empty();
			
		});	
}

})}
		
		

