/*
	CYBERPRESSE
	Auteur:	Luc Lespérance
	Date:	2007
*/
var currentNumero = "1";
var currentArticle = "article1";
var currentManchette = "manchette1";
var anim = false;

// fct initArticle() : Callé depuis le bloc mise en valeur pour instancier les manchettes
function initArticle() {
	
	document.getElementById(currentManchette).style.backgroundColor = "#fff";
	setOpacity(document.getElementById("article2"), 0, true);
	setOpacity(document.getElementById("article3"), 0, true);
	setOpacity(document.getElementById("article4"), 0, true);
};

// fct switchDiv() : Callé depuis les btns manchettes
function switchDiv(numero) {
	
	var article = "article"+numero;
	var manchette = "manchette"+numero;
	var img = "imgArticle"+numero;
	var article_str = article.toString();
	if(anim==false && article_str!=currentArticle) {
		anim = true;
		document.getElementById(article).style.display = "block";
		var imgSrc = document.getElementById(img).src.toString();
		var lastChar = imgSrc.charAt(imgSrc.length-1);
		// if lastChar == #, on doit loader l'img pour la 1ere fois
		if(lastChar=="#"){
			document.getElementById(img).src = imgArticle_array[numero-1];
		}
		fadeOut(currentArticle, 100, 0, 20);
		document.getElementById(article).style.visibility = "visible";
		fadeIn(article, 0, 100, 20);
		document.getElementById(manchette).style.backgroundColor = "#fff";
		document.getElementById(currentManchette).style.backgroundColor = "#f4f4f4";
		currentNumero = numero;
		currentArticle = article;
		currentManchette = manchette;
	}
};

// fct setOpacity()
function setOpacity(obj, opacity, notDisplay) {
	obj.style.filter = "alpha(opacity:"+opacity+")";
	obj.style.KHTMLOpacity = opacity/100;
	obj.style.MozOpacity = opacity/100;
	obj.style.opacity = opacity/100;
	if(notDisplay)
		obj.style.display = "none";
};

// fct fadeIn()
function fadeIn(objId, opacity, maxOpacity, transitionTime) {
	obj = document.getElementById(objId);
	if (opacity <= maxOpacity) {
		setOpacity(obj, opacity, false);
		opacity += transitionTime;
		window.setTimeout("fadeIn('"+objId+"',"+opacity+","+maxOpacity+","+transitionTime+")", 50);
	}
};

// fct fadeOut()
function fadeOut(objId, opacity, minOpacity, transitionTime) {
	obj = document.getElementById(objId);
	if (opacity >= minOpacity) {
		setOpacity(obj, opacity, false);
		opacity -= transitionTime;
		window.setTimeout("fadeOut('"+objId+"',"+opacity+","+minOpacity+","+transitionTime+")", 50);
	}else{
		obj.style.visibility = "hidden";
		obj.style.display = "none";
		anim = false;
	}
};