var mySlideTween = '';
var myThanksTween = '';
var myMenuSlide = '';
var myTimer = '';
var barLogoOffset = -40;
var nbOfSections = 1; //Check page.php for the init of this variable. Default 1 for the blog.
var barLogoTweenArr = new Array();
var currentMode = 'set';
var minMenuHeight = '';

window.addEvent('domready', function() {
	
	//minMenuHeight = 250; //document.getElementById('merciDiv').offsetHeight + 15; -->remplacé par 250 qui correspond au bas du menu
	
	//mySlideTween = new Fx.Tween('overlayDiv');
	//myMenuSlide = new Fx.Tween('navigationDiv');
	myThanksTween = new Fx.Tween('merciDiv');
	
	//slideMenuInit();	
	
	window.addEvent('resize', function() {
		//currentMode = 'start';
		//slideMenuInit();
	});
	
	window.addEvent('scroll', function() {
		//postionVerticalElements();
	});
	
	currentMode = 'start';
	myTimer = slideMenuInit.periodical(100);
	
});

function bringMenuTop() {
	mySlideTween.start('top', '10px');
}

function bringMenuBottom() {
	mySlideTween.start('bottom', '60px');
}

function slideMenuInit() {

/*
	var windowDim = getWindowInnerHeight();
	var innerHeight = windowDim['height'];
	
	var myGoto = '';
	var overlayDiv = document.getElementById('overlayDiv');
	var footerDiv = document.getElementById('footer');
	var menuHeight = (innerHeight / 2) - (overlayDiv.offsetHeight / 2);
	var barreHeight = Math.max((innerHeight / 12), 60);//La barre a au moins 60 pixels
	
	if(menuHeight + overlayDiv.offsetHeight >= innerHeight - footerDiv.offsetHeight) {
		menuHeight = menuHeight - ((menuHeight + overlayDiv.offsetHeight) - (innerHeight - footerDiv.offsetHeight));
		
		if(menuHeight < minMenuHeight) {
			if(currentMode == 'start') {
				mySlideTween.set('left', '0px');
				mySlideTween.set('height', barreHeight+'px');
				mySlideTween.start('top', minMenuHeight+'px');
				
			}else {
				mySlideTween.set('left', '0px');
				mySlideTween.set('height', barreHeight+'px');
				mySlideTween.set('top', minMenuHeight+'px');
			}			
		}else {
			if(currentMode == 'start') {
				myGoto = menuHeight+'px';
				mySlideTween.set('left', '0px');
				mySlideTween.set('height', barreHeight+'px');
				mySlideTween.start('top', myGoto);
			}else {
				myGoto = menuHeight+'px';
				mySlideTween.set('left', '0px');
				mySlideTween.set('height', barreHeight+'px');
				mySlideTween.set('top', myGoto);
			}		
		}
	}else {
		if(currentMode == 'start') {
			myGoto = menuHeight+'px';
			mySlideTween.set('left', '0px');
			mySlideTween.set('height', barreHeight+'px');
			mySlideTween.start('top', myGoto);			
		}else {			
			myGoto = menuHeight+'px';
			mySlideTween.set('left', '0px');
			mySlideTween.set('height', barreHeight+'px');
			mySlideTween.set('top', myGoto);
		}
	}
	
	postionVerticalElements();
*/
}

function postionVerticalElements() {	
	
	var windowDim = getWindowInnerHeight();
	var innerHeight = windowDim['height'];
	var myGoto = '';
	var scrollHeight = getYScrollingPosition();
	//var overlayDiv = document.getElementById('overlayDiv');
	var footerDiv = document.getElementById('footer');
	//var menuHeight = (innerHeight / 2) - (overlayDiv.offsetHeight / 2);
	//var newLogoHeight = 0;	
	
	/*
	if(menuHeight + overlayDiv.offsetHeight >= innerHeight - footerDiv.offsetHeight) {
		menuHeight = menuHeight - ((menuHeight + overlayDiv.offsetHeight) - (innerHeight - footerDiv.offsetHeight));
		if(menuHeight < minMenuHeight) {
			newLogoHeight = minMenuHeight;				
		}else {
			newLogoHeight = menuHeight;	
		}
	}else {
		newLogoHeight = menuHeight;
	}
	*/
	
	//myGoto = ((scrollHeight + newLogoHeight) - document.getElementById('merciDiv').offsetHeight) + 'px';
	myThanksTween.set('left', '0px');
	myThanksTween.set('top', myGoto);
	
}

function getYScrollingPosition()
{
	var position = 0;
	if (typeof window.pageYOffset != 'undefined') {
		position = window.pageYOffset;
	}
	else if (typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0) {
		position = document.documentElement.scrollTop;
	}
	else if (typeof document.body.scrollTop != 'undefined') {
		position = document.body.scrollTop;
	}
	return position;
}


function getWindowInnerHeight() {
	
	var w = 0;
	var h = 0;

	//IE
	if(!window.innerWidth)
	{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};
}

