/*
### Shrink And Expand Module
### V1.0
### the next version'll use class ans prototype
### Author : Jean-Frédéric Nault 2008
*/

actif = 'no';
onWait = "no";
current	 = '';
function resizea(div,operand){
	
	if (actif != 'no'){
		actif = 'no';
		
		if(current == div){
			onWait = "no";
			resizea(div,'fermer')
		
		}else{
			 onWait = div;
			 resizea(current,'fermer');
		}
	}
	
	else{
		selectedDiv = document.getElementById('content_'+div); 
		currentHeight = selectedDiv.offsetHeight; 
		maxHeight = document.getElementById('content_s'+div).offsetHeight; 
		resize2a(operand);
		current = div;
	}
}

function resize2a(operand){
	
	if (operand == "ouvrir"){ 
	
		if (currentHeight <= maxHeight){
	
			if ((currentHeight - maxHeight) <= 20 ){
				selectedDiv.style.height=currentHeight+10+"px"
				currentHeight = selectedDiv.offsetHeight;
				window.setTimeout("resize2a('ouvrir')",1);
			}
		}
		
		else{
			actif = current ;
		}
	}
	
	else{ 
	
		if (currentHeight > 10){
			selectedDiv.style.height=currentHeight-10+"px"
			currentHeight = selectedDiv.offsetHeight;
			window.setTimeout("resize2a('fermer')",1);
		}
		
		else{
			selectedDiv.style.height=1+"px"
		
			if (onWait != "no"){
				actif = 'no';
				resizea(onWait, 'ouvrir')
			}
		}
	}
}


/*  Browser WIDTH AND HEIGHT  */
    function getPageSize() {
	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight];
	}
	
	
	
	function getScrollXY() {
		  var scrOfX = 0, scrOfY = 0;
		  if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		  }
		  return [ scrOfX, scrOfY ];
     }





/*
### Sup Layer Fade
### V1.0
### the next version'll use class ans prototype
### Author : Jean-Frédéric Nault 2008
*/

currentopa = 0;
currentdiv = '';
function showOver($id){
	currentdiv = $id
	fadeOff($id);
	document.getElementById('shadowWrapper').style.visibility = 'visible';
	$('shadowWrapper').setStyle({
			  height: getPageSize()[1]+'px'
	});
	
}
function fadeOff($id){	
	document.getElementById('shadowWrapper').style.opacity = 0 //ff
	document.getElementById('shadowWrapper').style.filter='alpha(opacity='+(0)+')' //ie
	fade('shadowWrapper');
	$($id).setStyle({ marginTop: (getScrollXY()[1]+300)+'px'}); 
	$($id).setStyle({display: 'block'}); 
}


function fade($id){

	currentopa = currentopa + .05;
	
	
	if (currentopa < '.95'){
		document.getElementById('shadowWrapper').style.opacity = currentopa
		document.getElementById('shadowWrapper').style.filter='alpha(opacity='+(currentopa*100)+')'	
		anime =  window.setTimeout("fade('shadowWrapper')",0.1);
	}
	else{
		
	}
}

function closing(){

	currentopa = 0;
	
	$(currentdiv).setStyle({ marginTop: (0)+'px'}); 
	$(currentdiv).setStyle({display: 'none'}); 
		document.getElementById('shadowWrapper').style.opacity = currentopa
		document.getElementById('shadowWrapper').style.filter='alpha(opacity='+(currentopa*100)+')'	
		document.getElementById('shadowWrapper').style.height= 1 + 'px';	
	


}







