﻿/*----------------------------------------------------------------------------- 
UTILITEST Javascript 

version:   1.0 
date:      17/03/2010 
author:    Carl Servant / SÉQUENCE DIGITALE SENC 
email:     info@sequencedigitale.com 
website:   www.sequencedigitale.com/web/ 
version history: /_INCLUDES/js/script.css

-----------------------------------------------------------------------------*/

// Execution de cette fonction lorsque le DOM sera entièrement chargé  
var timer;
var i_counter = 0; //compteur temoignages

$(document).ready(function() { 

	//Liens externe nouvelle fenetre
		$("a[href^='http']").attr("target", "_blank");

	
	/* -----------------------------------------
		NAVIGATION PRINCIPALE
	-------------------------------------------- */
	
		$('#Navigation a')
			
			.mouseover( function(){
			
				$(this).animate({opacity: 1.0}, 250);
			
			})
			
			.mouseout( function(){
			
				$(this).animate({opacity: 0}, 250);
			
			});
			
			
	/* -----------------------------------------
		PAGE D'ACCUEIL - INDEX.PHP
	-------------------------------------------- */
	
		$('#SectionMenuIndex li a')
		
			.click( function(){
			
			
				clearTimeout(timer);
			
				$('#SectionMenuIndex li a').removeClass('menu_courrant');
				
				var position = $(this).parent().attr('class');
				
				$(this).addClass('menu_courrant');
			
				$('.animation').fadeOut('slow');
						
				$('.' + position).fadeIn('slow');

				return false;
				
			});
			
			timer = setTimeout('changeImage(1)', 10000);
			
		/* Clique sur boite */
		$('#PageContenu div.animation, .i_mobilite,	.i_temoignages')
		
			.click( function(){
			
				var url = $(this).find('a').attr('href');
				
				window.location.href = url;
			
				return false;
			
			});
		
		var temoignages = $('.i_temoignages_txt');			
			
		$('#NAV .suivant a')
			.click( function(){

				i_counter++;
							
				if( i_counter >= temoignages.length)
					i_counter = 0;
				
				temoignages.hide();								
				
				temoignages.eq(i_counter).fadeIn();

			});
		
		$('#NAV .precedent a')
			.click( function(){
				
				i_counter--;
				
				if( i_counter < 0)
					i_counter = (temoignages.length -1);
					
				temoignages.hide();	
				
				temoignages.eq(i_counter).fadeIn();
				
			});
			
		$('.i_temoignages_txt a')
			.click( function(){ 
				window.location.href = $(this).attr('href');
				return false; 
			});

	
	
	/* -----------------------------------------
		TEMOIGNAGES DE CLIENTS - /CLIENTS/
	-------------------------------------------- */	
	
		$('#clients #SectionMenu ul li')
			.click( function(){
			
				/* Retirer le pointer de la ligne */
				$('#clients #SectionMenu ul li a').removeClass('menu_courrant');
				
				/* Recuperer l'identifiant de la ligne */
				var position = $(this).attr('class').replace('t','');
				
				deplacement( position );
				
				return false;
				
			});
	
			


});


/* FUNCTION ACCUEIL */
function changeImage( x ){
		
	var array = new Array('utilisabilites', 'analyse', 'architecture');
	
		if(x >= array.length) x = 0;
			
	$('#SectionMenuIndex li a').removeClass('menu_courrant');
	
	var position = $('#SectionMenuIndex li').eq(x);
		
	$('.animation').fadeOut('slow');
				
	$('.' + position.attr('class') ).fadeIn('slow');
	position.find('a').addClass('menu_courrant');
	
	timer = setTimeout('changeImage(' + (x+1) +')', 10000);		
}

/* FUNCTION TEMOIGNAGNES */
function deplacement( x ){
			
	/* Attribuer le pointeur sur la ligne courrante */
	$('#clients #SectionMenu ul li a').removeClass('menu_courrant');
	$('#clients #SectionMenu ul li').eq(x).find('a').addClass('menu_courrant');
				
	if( x == null ){
			
		$('#PageContenu').animate({
			height: '620px'
		}, 800);
				
	}else{
			
		$('#PageContenu').animate({
			height: '500px'
		}, 800);
				
	}
			
	$('#SectionTemoignagesCarrousel')
		.animate({
			marginTop: "-" + ( 640 * x ) + "px"
		}, 800);
				
}

//Enlever Glitch IE sur Fade
function removeGlitch( obj ){
	obj.css('filter', 'filter');
}

