/* Resize */

if( window.attachEvent ) /* IE 6 */
{
	window.attachEvent('onresize', resize);
}
else if( window.addEventListener ) /* FireFox */
{
	window.addEventListener('resize', resize, false);
}
else /* IE and Opera */
{
	document.addEventListener('resize', resize, false);
}

function resize()
{

   var conteneur = document.getElementById('global');
   var heightConteneur = parseInt(conteneur.scrollHeight);
   var main = document.getElementById('contenu-principal');
   var heightMain = parseInt(main.scrollHeight);
   var colonneGauche = document.getElementById('contenu-gauche');
   var heightColonneGauche = parseInt(colonneGauche.scrollHeight);
   var colonneDroite = document.getElementById('contenu-droite');
   var heightColonneDroite = parseInt(colonneDroite.scrollHeight);

   var scroller = document.getElementById('scroller');
   if( scroller != null ) var heightScroller = parseInt(scroller.scrollHeight);
   var elevUp = document.getElementById('elevUp');
   if( elevUp != null ) var heightElevUp = parseInt(elevUp.scrollHeight);
   var elevDn = document.getElementById('elevDn');
   if( elevDn != null ) var heightElevDn = parseInt(elevDn.scrollHeight);
   var scrollbarGlobal = document.getElementById('scrollbarGlobal');
   if( scrollbarGlobal != null ) var heightScrollbarGlobal = parseInt(scrollbarGlobal.scrollHeight);
   var scrollbar = document.getElementById('scrollbar');
   if( scrollbar != null ) var heightScrollbar = parseInt(scrollbar.scrollHeight);
   var scrollerMo5Shim = document.getElementById('scrollerMo5Shim');
   var container = document.getElementById('container');
   if( container != null ) var heightContainer = parseInt(container.scrollHeight);
   var content = document.getElementById('content');
   if( content != null ) var heightContent = parseInt(content.scrollHeight);
	
   var heightBody = parseInt(document.body.clientHeight);
   height = heightBody;
	
   if( heightBody < 665 )
   {
      height = 665;
   }
	
   conteneur.style.height = height + 'px';
   //content.style.height = (height) + 'px';
   
   main.style.height = ( height - 221 ) + 'px';
   colonneGauche.style.height = ( height - 271 ) + 'px';
   colonneDroite.style.height = ( height - 251 ) + 'px';
	
	if( scrollbar != null && scrollerMo5Shim != null && container != null && content != null )
	{
		if( heightContent <= 444 ) // 354 = 673 - 319
		{
			scroller.style.height = '444px';
			scrollbarGlobal.style.display = 'none';
			elevUp.style.height = '444px';
			elevDn.style.height = '444px';
			scrollerMo5Shim.style.display = 'none';
			container.className = 'no-scroller';
			container.style.height = '444px';
			content.className = 'no-scroller';
		}
		else if( heightContent <= height - 221 )
		{
			scroller.style.height = heightContent + 'px';
			scrollbarGlobal.style.display = 'none';
			elevUp.style.height = '0px';
			elevDn.style.height = ( heightContent - 20 ) + 'px';
			scrollerMo5Shim.style.display = 'none';
			container.className = 'no-scroller';
			container.style.height = heightContent + 'px';
			content.className = 'no-scroller';
		}
		else
		{
			scroller.style.height = ( height - 221 ) + 'px';
			scrollbarGlobal.style.height = ( height - 251 ) + 'px';
			scrollbarGlobal.style.display = '';
			scrollbar.style.height = (scrollbarGlobal.scrollHeight-20) + 'px';
			elevUp.style.height = '0px';
			elevDn.style.height = ( height - 271 ) + 'px';
			scrollerMo5Shim.style.display = 'block';
			container.className = 'scroller';
			container.style.height = ( height - 245 ) + 'px';
			content.className = 'scroller';
		}
		var scroll = new Scroller('');
		scroll.init();
	}

}


var timer = null;
var id_objOut = null;
var id_objOut_child=null;

/* Les menus */
function survol_menu(id_elem){

    clearTimeout(timer);
    timer = null;
	var elem=document.getElementById(id_elem);
	if(elem.className=="menu-off-premier"){
		elem.className="menu-on-premier";
	}
	else if(elem.className=="menu-off-milieu"){
		elem.className="menu-on-milieu";
	}
	else if(elem.className=="menu-off-dernier"){
		elem.className="menu-on-dernier";
	}
	else if(elem.className=="menu-on-premier"){
		elem.className="menu-off-premier";
	}
	else if(elem.className=="menu-on-milieu"){
		elem.className="menu-off-milieu";
	}
	else if(elem.className=="menu-on-dernier"){
		elem.className="menu-off-dernier";
	}
	if (id_objOut!=elem && id_objOut!=null && id_elem!="menu-2") { hide_sub_menu(); }

}
 
function mouseOutTime(obj,id_child) {
	id_objOut = obj;
	id_objOut_child = id_child;
	clearTimeout(timer);
	timer = null;
	if (timer == null) timer = setTimeout("hide_sub_menu()","1000");
}

function survol_menu_top(elem){
	if(elem.className=="menu-top-off"){
		elem.className="menu-top-on";
	}
	else if(elem.className=="menu-top-on"){
		elem.className="menu-top-off";
	}
}
function show_sub_menu(id_elem,id_child){
	clearTimeout(timer);
	timer = null;
	var elem=document.getElementById(id_child);
	if (id_objOut!=elem && id_objOut!=null) { hide_sub_menu(); }	
	if (document.getElementById(id_elem).style.display!="block") {
		var elem=document.getElementById(id_child).className="menu-on-milieu";	
		document.getElementById(id_elem).style.display="block";
		document.getElementById('div-sub-'+id_child).style.display="block";
	}
}
function hide_sub_menu(){	
	var elem=document.getElementById(id_objOut_child).className="menu-off-milieu";	
	document.getElementById(id_objOut).style.display="none";
	document.getElementById('div-sub-'+id_objOut_child).style.display="none";
}

function containsDOM(aoContainer, aoContainee)
{
   var isParent = false;
   do
   {
      if ((isParent = aoContainer == aoContainee))
      {
         break;
      }
      aoContainee = aoContainee.parentNode;
   }
   while (aoContainee != null);
   return isParent;
}

function checkMouseEnter(aoContainer, aoEvt)
{
   if (aoContainer.contains && aoEvt.fromElement)
   {
      return !aoContainer.contains(aoEvt.fromElement);
   }
   else if (aoEvt.relatedTarget)
   {
      return !containsDOM(aoContainer, aoEvt.relatedTarget);
   }
}

function checkMouseLeave(aoContainer, aoEvt)
{
   if (aoContainer.contains && aoEvt.toElement)
   {
      return !aoContainer.contains(aoEvt.toElement);
   }
   else if (aoEvt.relatedTarget)
   {
      return !containsDOM(aoContainer, aoEvt.relatedTarget);
   }
}

/*Google plan*/

function openWindow(asPage, anWidth, anHeight)
{
   if (!anWidth)
   {
      anWidth = screen.width;
   }
   if (!anHeight)
   {
      anHeight = screen.height;
   }
   if (anHeight > screen.height)
   {
      anHeight = screen.height;
      anWidth += 24;
   }
   anPosX = (screen.width - anWidth) / 2;
   anPosY = (screen.height - anHeight) / 2;
   asName = 'window1';
   window1 = window.open(asPage,asName,"toolbar=no,location=no,dependent=yes,directories=no,status=yes,menubar=no,resizable=yes,scrollbars=yes,left="+anPosX+",screenX="+anPosX+",top="+anPosY+",screenY="+anPosY+",width="+anWidth+",height="+anHeight);
}

