/****************************************************************************************************/
/* FOUS */ 
/****************************************************************************************************/

var presentFouId = 0;
var presentFouName = '';
var transition = true;

// Fou Menu -> Desactivate all buttons by css style
function clearFouBts() {
	for (i = 0; i < fous.length; i++) {
		$(fous[i] + '_bt').className = 'off';
	}
}

// Fou Menu -> Replace fou name and animation
function changeFou(fouPath, fouName, fouAbbr) {
	
	if ((transition == false) && (presentFouName != fouName)) {
		
		transition = true;
		presentFouName = fouName;
		
		clearFouBts();
		$(fouName + '_bt').className = 'on';
		
		fouNameMaj = fouName.charAt(0).toUpperCase() + fouName.substr(1).toLowerCase();
		$('fou_name').innerHTML = fouNameMaj + ' Fou';
		
		fouPathName = fouPath + fouName;
		$('flash').sendChosenFou(fouPathName, fouAbbr);
		
		if ((document.location.href == 'http://www.doctorfou.com/') || (document.location.href == 'http://doctorfou.com/')) {
			loadRequest('library/php/include/session.inc.php?fouName=' + fouName, 'ajax_call');
		} else {
			loadRequest('../library/php/include/session.inc.php?fouName=' + fouName, 'ajax_call');
		}
	}
}

function transitionEnded() {
	 transition = false;
}

// Fou Page -> Present Fou
function presentFou(fouId) {
	
	if ((presentFouId != fouId) && (transition == false)) {
		
		function FadeEffect(element) {
			new Effect.Fade(element, { duration:0.5});
		}
		
		FadeEffect('picture_' + presentFouId);
		FadeEffect('description_' + presentFouId);
		
		function ShowEffect(element) {
			new Effect.Appear(element, {duration:0.5});
		}
		
		ShowEffect('picture_' + fouId);
		ShowEffect('description_' + fouId);
		
		if ($('bt_' + presentFouId).className.indexOf('left') >= 1) {
			$('bt_' + presentFouId).className = 'off left';
		} else {
			$('bt_' + presentFouId).className = 'off';
		}
		
		if ($('bt_' + fouId).className.indexOf('left') >= 1) {
			$('bt_' + fouId).className = 'on left';
		} else {
			$('bt_' + fouId).className = 'on';
		}
		
		transition = true;
		setTimeout('transitionEnd()', 500)
		
		presentFouId = fouId;
	}
}

function transitionEnd() {
	
	transition = false;
}