function cherche_navigateur_simple() {
	// on crée la variable qui accueillera le message relatif au navigateur
	var navigateur = "";
	// Attention, l'ordre de recherche est important !! Parce que IE reprend la mention 'Mozilla' et Opera reprend la mention 'MSIE' !!
	// on teste si on trouve la mention 'Opera...' dans le nom du navigateur
	if ( navigator.userAgent.indexOf('Opera 5') != -1 ) { navigateur = 'inc'; }
	// on teste si on trouve la mention 'MSIE' dans le nom du navigateur
	else if ( navigator.userAgent.indexOf('MSIE 6.0') == 25 ) { navigateur = 'mie'; }
	else if ( navigator.userAgent.indexOf('Mozilla') != -1 ) { navigateur = 'net'; }
	// si rien n'a été reconnu...
	else { navigateur = 'inc'; }
	// on affecte la variable 'navigateur' au formulaire
	return navigateur;
}

function randOrd() {
	return (Math.round(Math.random())-0.6);
}

function appearback2() {
	$('.backhome2').fadeIn(500);
}

function appearCpt() {
	for (i=1; i<10; i++) {
		$('#competence'+i).fadeIn({duration:300,queue:"global"});
	}
}

function cpt(e) {
	/*backArray = new Array('0','-35px','-70px','-105px');
	backArray.sort( randOrd );
	dureArray = new Array(500,700,900,1100,1300,1500,1700);
	dureArray.sort( randOrd );
	var j=Math.floor(Math.random()*3);*/
	//$('.competence'+e+' a img').css('top',backArray[j]).fadeIn({duration:500,queue:"cpt"+e});
	//$('.competence'+e+' a img').eq(0).fadeOut({duration:500,queue:"cpt"+e});
	var j = e-1;
	backArray = new Array('fade','fadeZoom','fade','fadeZoom','fade','fadeZoom','fade');
	//backArray.sort( randOrd );
	dureArray = new Array(300,400,500,600,700,800,900);
	dureArray.sort( randOrd );
	speedArray = new Array(300,400,500,600,700,800,900);
	speedArray.sort( randOrd );
	$('.competence'+e+' a img:first').fadeIn(500,function() { $(this).addClass('cpta') });
	//$('.competence'+e+' a').cycle({fx:'fade',timeout:dureArray[j],speed:speedArray[j],delay:1500});
	//$('.competence'+e+' a').cycle({fx:''+backArray[j]+'',timeout:dureArray[j],speed:500,delay:1500});
	//$('.competence'+e+' a').show("drop",{direction: "down",duration:dureArray[e],queue:"cpt"+e});
	//$('.competence'+e+' a').hide("drop",{direction: "up",duration:dureArray[e],queue:"cpt"+e});
	//setTimeout("cpt("+e+")",new Number(dureArray[e]+600));
}

/*function cpt(e) {
	backArray = new Array('0','-35px','-70px','-105px');
	backArray.sort( randOrd );
	dureArray = new Array(500,600,700,800,900,1000,1100);
	dureArray.sort( randOrd );
	var j=Math.floor(Math.random()*3);
	$('.competence'+e+' a img').css('top',backArray[j]).show('blind',{duration:100,queue:"cpt"+e});
	$('.competence'+e+' a').show("drop",{direction: "down",duration:dureArray[e],queue:"cpt"+e});
	$('.competence'+e+' a').hide("drop",{direction: "up",duration:dureArray[e],queue:"cpt"+e});
	setTimeout("cpt("+e+")",new Number(dureArray[e]+500));
}*/

function cas() {
	var scas = $('.cas').size();
	for (x=1; x<=scas; x++) {
		var y = x*200;
		$('#cas'+x).show(y,function() {
			$(this).animate({top:"0"},1000,"easeOutQuad",function() { $('#castitre'+$(this).attr('id').replace('cas','')).fadeIn(200); });
		});
		if(x==scas) {
			$('#timer').fadeIn(y+600,function() {
				if($('.open').size()==1) {
					var mnc = $('.open').css('z-index');
					setTimeout("showcas("+mnc+")",600);
				}
				$('#cas-presentation #prez').fadeIn(1500);
			});
		}
	}
}

/*for (i=1; i<8; i++) {
	timeArray = new Array(1500,1900,2300,2700,3100,3500,3900);
	timeArray.sort( randOrd );
	setTimeout("cpt("+i+")",timeArray[i-1]);
*/

function showcas(nmc) {
	var prv = $('a[name=cas'+nmc+']').prevAll('.cas').size();
	var nxt = $('a[name=cas'+nmc+']').nextAll('.cas').size();
	if(prv>0) {
		for(i=0;i<prv;i++) {
			var newl = new Number(i*41+41);
			var newrel = $('a[name=cas'+nmc+']').prevAll('.cas').eq(i).css('left');
			//alert(newl);
			$('a[name=cas'+nmc+']').prevAll('.cas').eq(i).attr('rel',newrel).animate({left:'-'+newl+'px'},{duration:1000,easing:"easeOutQuad"});
		}
	}
	if(nxt>0) {
		for(j=0;j<nxt;j++) {
			var newr = new Number(j*41+898);
			var newrer = $('a[name=cas'+nmc+']').nextAll('.cas').eq(j).css('left');
			$('a[name=cas'+nmc+']').nextAll('.cas').eq(j).attr('rel',newrer).animate({left:newr+'px'},{duration:1000,easing:"easeOutQuad"});
		}
	}
	$('.castitre').not($('#castitre'+$('a[name=cas'+nmc+']').attr('id').replace('cas',''))).fadeOut(1000);
	$('#logoandmenu').animate({left:"-1300px"},{duration:500,easing:"easeOutQuad"});
	$('#prez'+$('a[name=cas'+nmc+']').attr('id')).fadeIn(500);
	$('a[name=cas'+nmc+']').attr('rel',$('a[name=cas'+nmc+']').css('left')).animate({width:"898px",left:"0"},{duration:1000,easing:"easeOutQuad"});
	$('a[name=cas'+nmc+'] span img').animate({left:"0"},{duration:1000,easing:"easeOutQuad"});
	$('a[name=cas'+nmc+']').next('.castitre').children('p').fadeIn();
}

function cacheteam() {
	var wdtr = Math.round(new Number($("#slider").slider("value")*898/100));
	//$('body').prepend(wdtr);
	$('#teamrelative').css('width',wdtr+'px');
}

// JavaScript Document
$(document).ready(function() {

	$('.hide').hide();
	$("a[rel$='external']").attr('target','_blank');
	$("a[href$='#']").attr('href','javascript:void(0);');

	$("img[src$='.png']").ifixpng();
	
	$('.cycle').cycle();
	
	if(cherche_navigateur_simple()=='mie') {
		$(".maindata img").fullsize({shadow: false});
	}else{
		$(".maindata img").fullsize();
	}
	
	/*$('#words #relative div a img').each(function() {
		if($(this).attr('src').indexOf('1-')!=-1){
			$(this).fadeIn(3500);
		}
	});*/

	if($('#words').size()==1) {
		appearCpt();
	}
	
	if($('#cyclephilo').size()==1) {
		$('#cyclephilo').show('blind',{direction:"vertical",duration:4000},function(){
			$(this).cycle();
		});
		//$('#textphilo').css('margin-top',(450-$('#textphilo').height())/2+"px");
	}
	
	if($('.backhome2').size()==1) {
		setTimeout("appearback2()",2000);
		$('.backhome2').hover(function(){
			$('img',this).toggle();
		},function(){
			$('img',this).toggle();
		});
	}

	/*if($('#words').size()==1) {
		//
		$('#words #relative div').hoverIntent(function() {
			if($('a',this).attr('rel')>0) {
				var newtop1 = new Number($(this).css('top').replace('px',''))-Math.abs($('a',this).attr('rel'));
			}else{
				var newtop1 = new Number($(this).css('top').replace('px',''))+Math.abs($('a',this).attr('rel'));
			}
			$('a em',this).show("blind",{direction:"vertical",duration:500});
			//$('.competence'+i+' a').animate({height:"90px"},timeArray[j]);
			$(this).animate({top:newtop1+"px"},500);
		 },function(){
		 	if($('a',this).attr('rel')>0) {
				var newtop2 = new Number($(this).css('top').replace('px',''))+Math.abs($('a',this).attr('rel'));
			}else{
				var newtop2 = new Number($(this).css('top').replace('px',''))-Math.abs($('a',this).attr('rel'));
			}
			$('a em',this).hide("blind",{direction:"vertical",duration:500});
			//$('.competence'+i+' a').animate({height:"90px"},timeArray[j]);
			$(this).animate({top:newtop2+"px"},500);
		 });
	}*/

	$('.hideshow:first a.link').css('background','url(medias/core/imgs/puce-moins.gif) no-repeat left center');
	$('.hideshow:first .hsdata').animate({height:$('.hsheight',this).height()+10},1000);
	$('.hideshow a.link').click(function() {
		if($(this).next('.hsdata').css('height')=='0px') {
			var hsh = $(this).next('.hsdata:hidden').children('.hsheight').height();
			$('.hideshow a.link').not($(this)).css('background','url(medias/core/imgs/puce-plus.gif) no-repeat left center').next('.hsdata:visible').animate({height:'0px'},500);
			$(this).css('background','url(medias/core/imgs/puce-moins.gif) no-repeat left center').next('.hsdata:hidden').animate({height:hsh+10},1000);
		}
	});
	
	$('.swf').each(function(){
		swfobject.embedSWF($(this).metadata().url,$('div',this).attr('id'),$(this).metadata().width,$(this).metadata().height,"9.0.0",false,false,{wmode:"transparent"},false);
	});
	
	/* upper resolutioon spacer */
	if(screen.height>768) {
		$('#rezspacer').animate({height:"50px"},{duration:1000,easing:"easeOutQuad"});
	}
	
	/* main menu */
	$('#logoandmenu,#logoandmenu-black').animate({top:"470px"},{duration:500,easing:"easeOutQuad",queue:"first"});
	$('#logoandmenu,#logoandmenu-black').animate({left:"-900px"},{duration:1000,easing:"easeOutQuad",queue:"first"});
	$('.backlink').fadeIn({duration:500,easing:"easeOutQuad",queue:"first"});
	$('#logoandmenu a,#logoandmenu-black a').hover( function() {
		//$(this).children('img').effect("scale", { percent: 110, direction: 'both' }, 500);
		$('img.hide',this).fadeIn({duration:200});
		//$(this).next('.maintitle').animate({color:"#E1037A"},{duration:200});
	},function() {
		$('img.hide',this).fadeOut({duration:200});
		//$(this).next('.maintitle').animate({color:"#FFFFFF"},{duration:200});
		//$(this).children('img').effect("scale", { percent: 80, direction: 'both' }, 500);
	});
	/*$('#logoandmenu-black a').hover( function() {
		//$(this).children('img').effect("scale", { percent: 110, direction: 'both' }, 500);
		$('img.hide',this).fadeIn({duration:200});
		//$(this).next('.maintitle').animate({color:"#E1037A"},{duration:200});
	},function() {
		$('img.hide',this).fadeOut({duration:200});
		//$(this).next('.maintitle').animate({color:"#000000"},{duration:200});
		//$(this).children('img').effect("scale", { percent: 80, direction: 'both' }, 500);
	});*/
	$('#logoandmenu a,#logoandmenu-black a').click( function() {
		window.location.replace($(this).attr('href'));
	});
	
	/* flash object */
	$('#dialog').animate({top:"80px"},{duration:500,easing:"easeOutBounce",queue:"first"});
	swfobject.embedSWF("medias/public/flash/anim_intro.swf","animintro","850","450","9.0.0",false,{urlhome:$('.backhome').attr('href'),snd:"on"},{wmode:"transparent"},false);
	swfobject.embedSWF("medias/public/flash/anim_hiphop.swf","dancer","160","175","9.0.0",false,false,{wmode:"transparent"},false);
	swfobject.embedSWF("medias/public/flash/anim_sound.swf","snds","60","20","9.0.0",false,false,{wmode:"transparent"},false);
	//swfobject.embedSWF("medias/public/flash/anim_ventilo.swf","cooler","898","523","9.0.0",false,false,{wmode:"transparent"},false);
	//swfobject.embedSWF("medias/public/flash/anim_ventilo.swf","preload","1","1","9.0.0",false,false,{wmode:"transparent"},false);
	
	if($('#flv').size()==1) {
		swfobject.embedSWF("medias/public/flash/player.swf?file=intro.flv&controlbar=none","flv","270","153","9.0.0",false,false,{wmode:"transparent"},false);
	}
	
	if($('#voeux2010').size()==1) {
		swfobject.embedSWF("2010bis.swf","voeux2010","900","603","9.0.0",false,false,{wmode:"transparent"},false);
	}
	
	$('#video').mouseenter(function() {
		swfobject.embedSWF("medias/public/flash/anim_sound.swf","snds","60","20","9.0.0",false,{snd:"off"},{wmode:"transparent"},false);
		var player2 = document.getElementById("flv");
		player2.sendEvent("PLAY","true");
		//$('#snds a').toggle();
	});

	//$('#snds').show("slide",{direction:"down"},2000);
		
	/* home */
	//$('#words a').cycle({fx:'fade',speed:500});
	//$('#words a:visible').hover( function() {
	$('#words a').hover( function() {
		//$('img',this).animate({"opacity": "toggle"},200);
		//$('.'+$(this).parent().attr('id')).show();
		$(this).animate({color:'#e1037a'},300);
	},function() {
		//$('img',this).animate({"opacity": "toggle"},200);
		//$('.'+$(this).parent().attr('id')).hide();
		$(this).animate({color:'#b8babc'},200);
	});
	
	/* case studies */	
	$('#cas1').show(1500,function() {
		cas();
	});
	
	$('.cas').click( function() {
		var prv = $(this).prevAll('.cas').size();
		var nxt = $(this).nextAll('.cas').size();
		if($(this).width()==40 && $(this).css('top')=='0px') {
			if(prv>0) {
				for(i=0;i<prv;i++) {
					var newl = new Number(i*41+41);
					var newrel = $(this).prevAll('.cas').eq(i).css('left');
					//alert(newl);
					$(this).prevAll('.cas').eq(i).attr('rel',newrel).animate({left:'-'+newl+'px'},{duration:1000,easing:"easeOutQuad"});
				}
			}
			if(nxt>0) {
				for(j=0;j<nxt;j++) {
					var newr = new Number(j*41+898);
					var newrer = $(this).nextAll('.cas').eq(j).css('left');
					$(this).nextAll('.cas').eq(j).attr('rel',newrer).animate({left:newr+'px'},{duration:1000,easing:"easeOutQuad"});
				}
			}
			$('.castitre').not($('#castitre'+$(this).attr('id').replace('cas',''))).fadeOut(1000);
			$('#logoandmenu').animate({left:"-1300px"},{duration:500,easing:"easeOutQuad"});
			$('#prez'+$(this).attr('id')).fadeIn(500);
			$(this).attr('rel',$(this).css('left')).animate({width:"898px",left:"0"},{duration:1000,easing:"easeOutQuad"});
			$('span img',this).animate({left:"0"},{duration:1000,easing:"easeOutQuad"});
			$(this).next('.castitre').children('p').fadeIn();
		}
		if($(this).width()==898 && $(this).css('top')=='0px') {
			if(prv>0) {
				for(i=0;i<prv;i++) {
					var newl = $(this).prevAll('.cas').eq(i).attr('rel');
					//alert(newl);
					$(this).prevAll('.cas').eq(i).animate({left:newl},{duration:1000,easing:"easeOutQuad"}).removeAttr('rel');
				}
			}
			if(nxt>0) {
				for(j=0;j<nxt;j++) {
					var newr = $(this).nextAll('.cas').eq(j).attr('rel');
					//alert(newr);
					$(this).nextAll('.cas').eq(j).animate({left:newr},{duration:1000,easing:"easeOutQuad"}).removeAttr('rel');
				}
			}
			$('.cas img').not('.first').fadeOut();
			$('.castitre').fadeIn(1000);
			$('#logoandmenu').animate({left:"-900px"},{duration:1000,easing:"easeOutQuad"});
			$('#prez'+$(this).attr('id')).fadeOut(500);
			$(this).animate({width:"40px",left:$(this).attr('rel')},{duration:1000,easing:"easeOutQuad"}).removeAttr('rel');
			$('span img',this).animate({left:'-'+$('span img',this).css('z-index')+'px'},{duration:1000,easing:"easeOutQuad"});
			$(this).next('.castitre').children('p').fadeOut();
		}
	});
	
	$('.linkimg').click(function(){
		$('.cas img').not('.first').fadeOut();
	});
	$('.linkimgs').click(function(){
  		$('.cas img').not('.first').fadeOut();
		$('.'+$(this).attr('rel')).fadeIn();
	});
	
	/* team 
	$('#team').show('drop',{direction:'up'},2000);
	$("#slider").slider({max:100,orientation:"horizontal",slide:cacheteam,change:cacheteam});*/
	$('.teamid').attr('title','');
	$('.teamid').hoverIntent(function(){
		$('#teamtitle h1').hide();
		$('.'+$(this).attr('href').replace('#','')).show(100,function() { $('#whitecache').fadeOut(500); });
	},function(){
		$('#teamtitle h1').hide();
		$('#whitecache').show();
	});
	
});
