﻿$(document).ready(function(){	   
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	order = "designgraphique,designobjet,webdesign,lab";
	page = "accueil"; // accueil
	
	$.sifr({
		path: 'fonts/',
		font: 'replica',
		save: true
	});	

	$("#lab_retour").hide();
	$("#retour").hide();	
	
	iPhoneDetect();
	img_keyboard(); // lance la fonction clavier dans le projet
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	$("#liste").sortable({ axis: 'y', opacity: 0.6, cursor: 'move', update: function(){  // liste pour le choix de l'ordre														
		$("#sorthelp").animate({ 
		opacity: 0				
		}, 1500 );
		order = $(this).sortable("toArray");
		afficheblocks(order,"non","oui"); // affiche les blocks
		}				  
	}); //sortable		
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	var str = "" + window.location; // passage en chaine de caractères
	var reg0=new RegExp("#(/)+","g");	// "#" suivi de "/"
	var reg1=new RegExp("[_]","g");		// séparateur "_"
	if (str.match(reg0)) { // si on est dans un permalien
		if (str.match(reg1)) { // si on est dans un projet
			var  reg2=new  RegExp("[0-9]*(_)+", "g");
			var permalink = "" + str.match(reg2);
			var permalink_id = permalink.replace('_', '');
			$.get("permalink.php?permalink_id="+permalink_id, function(data){ // petite fonction ajax des copains
				affiche_projet_viapermalink(permalink_id,2,data); // hop on récupère le nombre d'images dans le projet selectionné et on l'affiche
				backspace_return_permalink();
			});	
		}
		else {
			if (str.indexOf("contact") != -1) { // si le permalien pointe vers contact
			affiche("contact");
			}
			else if (str.indexOf("a-propos") != -1) { // si le permalien pointe vers a propos
			affiche("a-propos");
			}
			else if (str.indexOf("lab") != -1) { // si le permalien pointe vers lab
			affiche("lab");
			}
		}
	}
	else { // sinon c'est le site par défaut qui s'affiche
		afficheblocks("designgraphique,designobjet,webdesign,lab","oui","non"); // par default on affiche les blocks + les permanants
		backspace_return();
	}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	$(".blocknav").hover(// hover() prend en argument deux fonctions, over puis out.
		function() // over
		{
			$(this).children(".titres").animate({ 
				opacity: 1.0				
			}, 200 );
		}, // DFTFC!
		function() //out
		{
			$(this).children(".titres").animate({ 
				opacity: 0.6				
			}, 200 );
		}
	);	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	$(".titre_9ko").click(function () {
		if(page!="accueil") {
			affiche("accueil");
		}
	});	
	$(".titre_a-propos").click(function (){
	//fonction au clic de a propos
		if(page!="a-propos") {
			affiche("a-propos");
		}
	});
	$(".titre_contact").click(function (){
	//fonction au clic de a propos
		if(page!="contact") {
			affiche("contact");
		}
	});
	$(".titre_lab").click(function (){
		if(page!="lab") {
			affiche("lab");
		}
	});
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
});
