$(function(){
	Cufon.replace('h1', {fontFamily: 'Futura-Condensed-Normal', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
	Cufon.replace('h2', {fontFamily: 'Futura-Condensed-Normal', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
	Cufon.replace('h3', {fontFamily: 'Arrus BT', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
	Cufon.replace('p', {fontFamily: 'Arrus BT', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
	Cufon.replace('h4', {fontFamily: 'Futura-Condensed-Normal', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
	Cufon.replace('h5', {fontFamily: 'Arrus BT', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
	Cufon.replace('h6', {fontFamily: 'Arrus BT', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' })
	Cufon.replace('nav ul li a', {fontFamily: 'Futura-Condensed-Normal', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });

var session=$('#session').val();
if(session==0){

  $('#logo a').fadeIn(600,function(){  
    	$('.nav_ico ul li').each(function(index) {
			$(this).delay(200*index).fadeIn(200,function(){
				if (index==4) {
					$.loader({
        className:"blue-with-image-2",
        content:''
    });
					$('#slogan').fadeTo(500,1,function(){
					$('nav ul li').each(function(index) {
						$(this).delay(200*index).fadeIn(300,function(){
						$("#ancre_carousel").fadeTo(500,1,function(){$.loader('close');});
						$("#ancre_project").fadeTo(500,1);
						$("#ancre_contact").fadeTo(400,1);
						
						/*	if(index==3){
							ancre="#ancre_carousel";
							var deplace=$(ancre).offset().top;
							deplace=deplace-30;
					$('html,body').animate({scrollTop:deplace},1000,'swing',function(){
          			$("#ancre_carousel").fadeTo(500,1,function(){
          			
          			    ancre="#ancre_project";
          			    	var deplace2=$(ancre).offset().top;
							deplace2=deplace2-30;
 		           $('html,body').animate({scrollTop:deplace2},1500,'swing',function(){
           			$("#ancre_project").fadeTo(500,1,function(){
           			
           			    ancre="#ancre_contact";
           			    	var deplace3=$(ancre).offset().top;
							deplace3=deplace3-30;
    		       $('html,body').animate({scrollTop:deplace3},1500,'swing',function(){
           			$("#ancre_contact").fadeTo(400,1,function(){
           			
           			 $('html,body').animate({scrollTop:$('body').offset().top},600,'swing' ,function(){  $.loader('close'); });
           			
           			
           			});
    		        $(ancre).attr('tabindex','-1');
    		        $(ancre).focus();
        		    $(ancre).removeAttr('tabindex');
           
       			 });
           			});
  		          $(ancre).attr('tabindex','-1');
   		         $(ancre).focus();
   		         $(ancre).removeAttr('tabindex');
      		 	 });
       			 });
       			  $(ancre).attr('tabindex','-1');
         		   $(ancre).focus();
       		     $(ancre).removeAttr('tabindex');
          			});
						}		*/				
						});  					
 					}); 	
        		   });           			          
 		        }
			}); 
	    });  		
 		$('.sep').fadeTo(1000,1);    
 		
  });
}else{
	$('#logo a, .nav_ico ul li, #slogan, nav ul li').show();
	$('#slogan, .sep, #ancre_contact, #ancre_carousel, #ancre_project ').css('opacity','1');
	

}

  
});

$(window).load(function(){
																						//$("body").css("background","#373737");
});


/*$(window).load(function(){
							Cufon.replace('h1', {fontFamily: 'Futura-Condensed-Normal', hover: true });
							Cufon.replace('h2', {fontFamily: 'Futura-Condensed-Normal', hover: true });
							Cufon.replace('h3', {fontFamily: 'Arrus BT', hover: true  });
							Cufon.replace('p', {fontFamily: 'Arrus BT', hover: true });
							Cufon.replace('h4', {fontFamily: 'Arrus BT', hover: true });
							Cufon.replace('h5', {fontFamily: 'Arrus BT', hover: true });
							Cufon.replace('nav ul li a', {fontFamily: 'Futura-Condensed-Normal', hover: true  });
							$("body").css("background","#FFFFFF");
});
*/


$(document).ready(function()
{
	$("#showcase").awShowcase(
	{
		content_width:			900,
		content_height:			500,
		hundred_percent:		false,
		auto:					false,
		interval:				3000,
		continuous:				false,
		loading:				true,
		tooltip_width:			200,
		tooltip_icon_width:		32,
		tooltip_icon_height:	32,
		tooltip_offsetx:		18,
		tooltip_offsety:		0,
		arrows:					true,
		buttons:				true,
		btn_numbers:			true,
		keybord_keys:			true,
		mousetrace:				false,
		pauseonover:			true,
		transition:				'vslide', /* hslide/vslide/fade */
		transition_delay:		0,
		transition_speed:		500,
		show_caption:			'onload', /* onload/onhover/show */
		thumbnails:				false,
		thumbnails_position:	'outside-last', /* outside-last/outside-first/inside-last/inside-first */
		thumbnails_direction:	'horizontal', /* vertical/horizontal */
		thumbnails_slidex:		1, /* 0 = auto / 1 = slide one thumbnail / 2 = slide two thumbnails / etc. */
		dynamic_height:			false,
		speed_change:			true,
		viewline:				false
	});
});



$(function(){
var $applications = $('#applications');
var	$data = $applications.clone();
function tri(categorie){
	if(categorie=="all"){
		var $filteredData = $data.find('li');
	}
	if(categorie=="webdesign"){
		var $filteredData = $data.find('li[data-categorie=1]' );
	}
	if(categorie=="photo"){
		var $filteredData = $data.find('li[data-categorie=2]' );
	}
	if(categorie=="timelapse"){
		var $filteredData = $data.find('li[data-categorie=3]' );
	}
	if(categorie=="film"){
		var $filteredData = $data.find('li[data-categorie=4]' );
	}
	if(categorie=="mobile"){
		var $filteredData = $data.find('li[data-categorie=5]' );
	}
	if(categorie=="school"){
		var $filteredData = $data.find('li[data-categorie=6]' );
	}
	
	// finally, call quicksand
	$applications.quicksand($filteredData, {
		duration: 1000,
		easing: 'easeInOutQuad',
		adjustHeight:  	'auto'
	}, function(){
	Cufon.replace('h1', {fontFamily: 'Futura-Condensed-Normal', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
							Cufon.replace('h2', {fontFamily: 'Futura-Condensed-Normal', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
							Cufon.replace('h3', {fontFamily: 'Arrus BT', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
							Cufon.replace('p', {fontFamily: 'Arrus BT', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
							Cufon.replace('h4', {fontFamily: 'Futura-Condensed-Normal', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
							Cufon.replace('h5', {fontFamily: 'Arrus BT', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
							Cufon.replace('h6', {fontFamily: 'Arrus BT', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' })
							Cufon.replace('nav ul li a', {fontFamily: 'Futura-Condensed-Normal', hover: true ,textShadow:'0px 1px 0px #4d4d4d;' });
						
	
	
	
	
	});
	}
		
		
		$('#categorie_all').click(function(){tri('all');});
		$('#categorie_webdesign').click(function(){tri('webdesign');});
		$('#categorie_photo').click(function(){tri('photo');});
		$('#categorie_timelapse').click(function(){tri('timelapse');});
		$('#categorie_film').click(function(){tri('film');});
		$('#categorie_mobile').click(function(){tri('mobile');});
		$('#categorie_school').click(function(){tri('school');});

	$(".project ul li div ").live('mouseover',function(){
	$("img", this).stop().animate({'opacity':"0"},{queue:false,duration:200});
	}); 
	$(".project ul li div ").live('mouseout',function() {
	$("img", this).stop().animate({'opacity':"1"},{queue:false,duration:200});
	});
	
	
	/* form contact */
	function file(url){
 // if(window.XMLHttpRequest) 
// xhr_object=new XMLHttpRequest();else if(window.ActiveXObject)
// xhr_object=new ActiveXObject("Microsoft.XMLHTTP");else 
// return(false);
 try {
   xhr_object = new ActiveXObject("Microsoft.XMLHTTP");    // Essayer Internet Explorer 
}
catch(e)   // Echec
{
  xhr_object = new XMLHttpRequest();  // Autres navigateurs
}
xhr_object.open("GET",url,false);xhr_object.send(null);if(xhr_object.readyState==4)
return(xhr_object.responseText);else
return(false);} 
	function bonmail(mailteste){
		var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i');
		if(reg.test(mailteste)){return(true);
		}else{return(false);}
	}

	function Remplace(expr,a,b) {
	  var i=0;
	  while (i!=-1) {
		 i=expr.indexOf(a,i);
		 if (i>=0){
			expr=expr.substring(0,i)+b+expr.substring(i+a.length);
			i+=b.length;
		 }
	  }
	  return expr;
	}
	$("#nom, #message").blur(function(){
		if($(this).val()==""){
			$(this).parent().find('div').css('background','url(img/dot_red.png) no-repeat');
		}else{
			$(this).parent().find('div').css('background','url(img/dot_green.png) no-repeat');
		}
	});
	$("#email").blur(function(){
		if($('#email').val()==""){
			$(this).parent().find('div').css('background','url(img/dot_red.png) no-repeat');
		}else{
			var email=$('#email').val();
			var verif_mail=bonmail(email);
			if(verif_mail==false){
				$(this).parent().find('div').css('background','url(img/dot_red.png) no-repeat');
			}else{
				$(this).parent().find('div').css('background','url(img/dot_green.png) no-repeat');
			}
		}
	});
	$('.list_contact h1').click(function() {
			
		var bReturn = true;	
		var email=document.getElementById("email").value;
		var verif_mail=bonmail(email);
		var nom=document.getElementById("nom").value;
		var message=document.getElementById("message").value;
		
	
		
        if(( nom=="" )||(nom=="NOM")) {
			$('.erreur_nom').css({'background': 'url(img/dot_red.png) no-repeat'});
            bReturn = false;
        }
		
		if (( jQuery.trim($("#email").val()).length==0 )) {
			$('.erreur_email').css({'background': 'url(img/dot_red.png) no-repeat'});
            bReturn = false;
        }
		
		if(verif_mail==false){
			$('.erreur_email').css({'background': 'url(img/dot_red.png) no-repeat'});
            bReturn = false; 
		}

        if (( jQuery.trim($("#message").val()).length==0 )) {
			$('.erreur_message').css({'background': 'url(img/dot_red.png) no-repeat'});
            bReturn = false;
        }
		
		if(bReturn==true){
			message=Remplace(message,"\n","<br/>");
			message=Remplace(message,"\r","<br/>");
			var envoi_form = file('contact_ajax.php?nom='+nom+'&email='+email+'&message='+message);		
			document.getElementById("nom").value="";
			document.getElementById("email").value="";
			document.getElementById("message").value="";
			document.getElementById("nom").focus();
			$('.erreur_contact').css({'background': 'none'});
		}
		return false;
    
		  // $('#form_contact').submit(function(){
			// alert("ok");
		  // });
	});
	
});

