/*var hexa1 = 0;
var hexa2 = 0;
var hexa3 = 0;
var hexa4 = 0;
var hexa5 = 0;
var hexa6 = 0;

$("#a_accueil").mouseOver = function(){
	$("#a_accueil").css("background-color", "#"+hexa1+hexa2+hexa3+hexa4+hexa5+hexa6);
}*/
/*************************LIGHTBOX*************************/
var lightboxHeight = 400;
var lightboxWidth = 450;
var scrOfY = 0;
var scrOfX = 0;
var winW = "";
var winH = "";
var fWinW = "";
var fWinH = "";
var varNombre = 0;
/*************************LIGHTBOX*************************/


var secs = 0;
var timerID = null;
var timerRunning = false;
var delay = 3;
var speed = 10;
var currentPos = new Array;
var curHeight = 0;
var direction = 1;
var backupPage = "";
var openPage = "";
var closing = false;
var currentRealTest = "infographie";
function init(){
	currentPos[0] = 0;
	currentPos[1] = 0;
	currentPos[2] = 0;
	currentPos[3] = 0;
	
	curHeight = 0;
	direction = 1;
	clearTimeout(timerID);
	
	/*************************LIGHTBOX*************************/
	if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName=="Netscape") {
		winW = window.innerWidth;
		winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
		winW = document.body.offsetWidth;
		winH = document.documentElement.clientHeight;
		}
		else	{
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		fWinW = winW/2-(lightboxWidth/2);
		fWinH = winH/2-(lightboxHeight/2);
	}
	//document.getElementById("lightbox").style.left=fWinW+"px";
	//document.getElementById("lightbox").style.height=lightboxHeight+"px";
	//document.getElementById("lightbox").style.width=lightboxWidth+"px";
	$("#lightbox").css("left",fWinW+"px");
	$("#lightbox").css("height",lightboxHeight+"px");
	$("#lightbox").css("width",lightboxWidth+"px");
	cacher();
	/*************************LIGHTBOX*************************/
}
init();

function preAff(page){
	backupPage = page;
	enterFrame("aff", page)
}

function aff(page){	
	if(currentPos[0] != 0 || currentPos[1] != 0 || currentPos[2] != 0 || currentPos[3] != 0)
	{
		if(currentPos[0] != 0) page = "accueil";
		if(currentPos[1] != 0) page = "realisations";
		if(currentPos[2] != 0) page = "cv";
		if(currentPos[3] != 0) page = "contact";
		
		if(curHeight > 0)
		{
			curHeight -= speed;
			$("#"+page).css("height", curHeight);
			clearTimeout(timerID);
			enterFrame("aff", page);
		}
		else	{
			closingTest(page);
			init();
			if(closing != true) {aff(backupPage);}
			else{$("#arrow").css("display", "none");}
		}
	}
	else{
		$("#"+page).css("display", "block");
		if(curHeight < 450 && direction == 1)
		{
			curHeight += speed;
			$("#"+page).css("height", curHeight);
			clearTimeout(timerID);
			enterFrame("aff", page);
		}
		else
		{
			if(curHeight == 450)
			{
				direction = -1;
				if(page == "accueil") currentPos[0] = curHeight;
				if(page == "realisations") currentPos[1] = curHeight;
				if(page == "cv") currentPos[2] = curHeight;
				if(page == "contact") currentPos[3] = curHeight;
				openPage = page;
				
				if(openPage=="accueil") $("#arrow").css("left", "310px");
				if(openPage=="realisations") $("#arrow").css("left", "460px");
				if(openPage=="cv") $("#arrow").css("left", "610px");
				if(openPage=="contact") $("#arrow").css("left", "760px");
				$("#arrow").css("display", "block");
				
				clearTimeout(timerID);
			}
			else
			{
				clearTimeout(timerID);
			}
		}
	}
}

function closingTest(cible){
	if(backupPage == openPage){
		closing = true;
	}
	else{
		closing = false;
	}
}

function enterFrame(fonction, cible){
	timerID = self.setTimeout(fonction+"('"+cible+"')", delay);
}

function onglet(realType){
	$(".prog").css("display", "none");
	$(".prog").css("height", "0");
	$(".prog").css("width", "0");
	$(".info").css("display", "none");
	$(".info").css("height", "0");
	$(".info").css("width", "0");
	
	$("."+realType).css("display", "block");
	$("."+realType).css("height", "");
	$("."+realType).css("width", "");
	
	if(realType== "info"){
		currentRealTest = "infographie";
	}
	else{
		if(realType== "prog"){
			currentRealTest = "programmation";
		}
		else{
			if(realType== "video"){
				currentRealTest = "video";
			}
			else{
				if(realType== "d3"){
					currentRealTest = "d3";
				}
			}
		}
	}
	$("#infographieInput").css("background-image", "url(images/infographie.png)");
	$("#programmationInput").css("background-image", "url(images/programmation.png)");
	$("#videoInput").css("background-image", "url(images/video.png)");
	$("#d3Input").css("background-image", "url(images/d3.png)");
	$("#"+currentRealTest+"Input").css("background-image", "url(images/"+currentRealTest+"2.png)");
}

function ongletOver(overType){
	$("#"+overType+"Input").css("background-image", "url(images/"+overType+"2.png)");
}

function ongletOut(outType){
	if(currentRealTest != outType){
	$("#"+outType+"Input").css("background-image", "url(images/"+outType+".png)");
	}
	else {
		$("#"+outType+"Input").css("background-image", "url(images/"+outType+"2.png)");
	}
}

var texteReal = new Array;
texteReal[0] = "<h2>Site web de la Technique d'integration Multimédia du Cégep de Matane</h2><p>Ce travail se fesais a 3, je me suis occupé de la très grande majorité de la programmation, autant web que flash. Une administration de type &quot;back-office&quot; est disponible pour modifier l'entièreté du site (l'administration est aussi dynamique avec l'ajout de certains éléments). Travail de 600h réalisé durant la <span class='underline'>fin 2009</span></p><p class='last'>Travail : HTML, CSS, Javascript, MySQL, PHP, jQuery, Ajax, AS3</p>";
texteReal[1] = "<h2>Jeu ludo-éducatif pour enfants de 7 à 14 ans</h2><p>Ce travail se fesait en équipe de 2, je me suis occupé de la partie programmation. Un &quot;lag&quot; dans le jeu est apparu a la fin du projet, malgré la transformations de certains éléments en Bitmaps, il n'a pas été corrigé. <span class='underline'>Début 2009</span></p><p class='last'>Travail : AS2</p>";
texteReal[2] = "<h2>Changement du style graphique du journal municipal de la ville de Crolles</h2><p>Ce travail a été effectué lors de mon stage dans la compagnie Piment Rouge au début de <span class='underline'>l'été 2010</span>. J'ai eu beaucoup de liberté pour la conception de cette mise en page.</p><p class='last'>Travail : inDesign, Illustrator</p>";

function changeReal(realPrecis){
	if(realPrecis=="prog1")
	{
		varNombre = 0;
		$("#lightbox").html("<iframe src='http://prod.espacevacant.com/EFC/3/'></iframe>");
		lightboxHeight = 700;
		lightboxWidth = 950;
		fWinW = winW/2-(lightboxWidth/2);
		fWinH = winH/2-(lightboxHeight/2);
	}
	else{
		if(realPrecis=="prog2")
		{
			varNombre = 1;
			$("#lightbox").html("<object width='800' height='600'><param name='Flash' value='flash.swf'><embed src='flash/flash.swf' width='800' height='600'></embed></object>");
			lightboxHeight = 600;
			lightboxWidth = 800;
			fWinW = winW/2-(lightboxWidth/2);
			fWinH = winH/2-(lightboxHeight/2);
		}
		else{
			if(realPrecis=="info1")
			{
				varNombre = 2;
				$("#lightbox").html("<img src='images/gros/crolles.jpg' alt='Journal municipal de Crolles' />");
				lightboxHeight = 600;
				lightboxWidth = 870;
				fWinW = winW/2-(lightboxWidth/2);
				fWinH = winH/2-(lightboxHeight/2);
			}	
		}	
	}
	
	$("#grosseVersion").html("<a href='javascript:decacher(varNombre)'><img src='images/real/"+realPrecis+".jpg' alt='"+realPrecis+"' /></a>"+texteReal[varNombre]);
}

/*************************LIGHTBOX*************************/
function decacher(varContenu){
	document.getElementById("filter").style.display="block";
	document.getElementById("filter").style.height="";
	document.getElementById("filter").style.width="";
	document.getElementById("filter").style.visibility="visible";
	document.getElementById("filter").style.zIndex="10";
	document.getElementById("lightbox").style.display="block";
	document.getElementById("lightbox").style.height=lightboxHeight+"px";
	document.getElementById("lightbox").style.width=lightboxWidth+"px";
	document.getElementById("lightbox").style.visibility="visible";
	document.getElementById("lightbox").style.zIndex="11";
	
	if (navigator.appName=="Netscape") {
	scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
	}
	if (navigator.appName.indexOf("Microsoft")!=-1) {
	scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
	}
	else{
	scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
	}
	var windowHeight = scrOfY+fWinH;
	var windowWidth = scrOfX+fWinW;
	document.getElementById("lightbox").style.top = windowHeight+"px";
	document.getElementById("lightbox").style.left = windowWidth+"px";
}

window.onresize=function(){
	winW = "";
	winH = "";
	if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName=="Netscape") {
		winW = window.innerWidth;
		winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
		winW = document.body.offsetWidth;
		winH = document.body.offsetHeight;
		}
		fWinW = winW/2-(lightboxWidth/2);
		fWinH = winH/2-(lightboxHeight/2);
	}
	document.getElementById("lightbox").style.left=fWinW+"px";
	document.getElementById("lightbox").style.top=fWinH+"px";
}

window.onscroll=function(){
	if (navigator.appName=="Netscape") {
	scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
	}
	if (navigator.appName.indexOf("Microsoft")!=-1) {
	scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
	}
	else{
	scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
	}
	var windowHeight = scrOfY+fWinH;
	var windowWidth = scrOfX+fWinW;
	document.getElementById("lightbox").style.top = windowHeight+"px";
	document.getElementById("lightbox").style.left = windowWidth+"px";
	document.getElementById("filter").style.top = scrOfY+"px";
	document.getElementById("filter").style.left = scrOfX+"px";
}

function cacher(){
	$("#filter").css("display","none");
	$("#filter").css("height","0px");
	$("#filter").css("width","0px");
	$("#filter").css("visibility","hidden");
	$("#filter").css("zIndex","0");
	$("#lightbox").css("display","none");
	$("#lightbox").css("height","0px");
	$("#lightbox").css("width","0px");
	$("#lightbox").css("visibility","hidden");
	$("#lightbox").css("zIndex","0");
}
/*************************LIGHTBOX*************************/
