//****** JS Portefolio 1.2 || Scripted and Performed by Benoît Dietrich with Jquery©******/

$(document).ready(function(){

	//NAVIGATION PROFIL
	$('#profilContent div').hide();
	$('#message').show();
	$('#navProfil a').hover(function(){
		var categorie = $(this).attr('title');
		$('#profilContent div').hide();
		$('#'+categorie).show();
	});

	//Survoler les icones de jobs
	$('.jobsIcone').hover(function(){
		$(this).css({"cursor" : "pointer"});
		$(this).children('.jobDetail').animate({
			marginTop : "44px"
		}, 200);
	}, function(){
		$(this).children('.jobDetail').animate({
			marginTop : "130px"
		}, 200);
	});
	
	
	$('#importAjax').load('job/showreel/showreel.php');
	
	//AJAX Tampax
	$('.jobsIcone').click(function(){
		var flex = $(this).attr('id');
		var title = $(this).children().children('h2').text();
		
		$('#jobPresentation').show();
		
		$('#titreJob').children('h2').html(title);
		
		$('#importAjax').load('job/'+flex+'/'+flex+'.php', function(){
			$('#jobs').animate({
				marginTop : "0"
			}, 200);
			//Fait tourner //Scrpited only by Benoît Dietrich ©
			//Si c'est un job flash
			if($('#imageJob').attr("class") == 'flash'){
				//SWFOBJECT
 		   		//pageExterne
    			var largeure = $('#imageJob').width();
    			var hauteure = $('#imageJob').height();
    			var title = $('#imageJob').attr('title');
    			
    			$('#imageJob').flash({
        			swf: 'job/'+title+'/'+title+'.swf',
       		 		width: largeure,
       		 		height: hauteure
    			});
    			$('#imageJob').css({"background-color" : "#000"});
    		
    		}else{
				var nombreNumero = $('#numero div').length;	
				var lalongueure = nombreNumero*690;
				
				$('#numero div').css({opacity: "0.35"});
			
				$('#numero div').hover(function(){
					$(this).css({"cursor" : "pointer"});
				});
			
				$('#numero div:first').css({opacity: "1", "background-color": "#acd5ee"});
			
				$('#numero div').click(function(){
					var jason = $(this);
					$('#numero div').css({opacity: "0.35", "padding-top" : "5px","padding-bottom" : "5px", "background-color" : "#33221b"});
					jason.css({opacity: "1", "background-color" : "#acd5ee"});
					var increment = (jason.text()-1)*(-690);
					$('#labarre').animate({marginLeft : increment}, 200);
				});
				
				$('#imageJob div').hover(function(){
					$(this).css({"cursor" : "pointer"});
				});
				
				$('#imageJob div div').click(function(){
					if($(this).attr("class") == 'flashObj'){
					}else{
						var margeActuelle = $('#labarre').css('margin-left').slice(0,-2);
						var leBonNombre = (margeActuelle/-690) + 1;	
						$('#numero div').css({opacity: "0.35", "padding-top" : "5px","padding-bottom" : "5px", "background-color" : "#33221b"});
						if(nombreNumero==leBonNombre){//si c'est le dernier
							$('#numero div:first').css({opacity: "1", "background-color": "#acd5ee"});
							$('#labarre').animate({marginLeft : 0}, 200);
						}else{
							var newMarge = margeActuelle-690;
							$('#labarre').animate({marginLeft : newMarge}, 200);//avance de un
							$('#numero div:eq('+leBonNombre+')').css({opacity: "1", "background-color" : "#acd5ee"});
						}						
					}
				});
    		}
    	});
		
   		$('html,body').animate({scrollTop:20},800);
	
	});
	
	//Footer Ancre
	$('#footerBTN').hover(function(){
		$(this).css({'cursor' : 'pointer'});
	});
	$('#footerBTN').click(function(){
		$('html, body').animate({scrollTop:0}, 1000);
	});
});
