function menuderoul(divid)
{
	this.div = document.getElementById(divid);
	if( this.div )
	{
	   this.lis = this.div.getElementsByTagName("LI");
	   for(var i=0; i<this.lis.length ; i++ )
	   {
		   this.lis[i].onmouseover =
			   function()
			   {
				   this.className+=" over";
			   }
		   this.lis[i].onmouseout =
			   function()
			   {
				   this.className=this.className.replace(" over", "");
			   }
	   }
	}
}
//=======================================================================================
// Affiche les bordures des divs --- Utile en DEV.
function fnShowDivIds()
{
	var d = document;
	for (var i=0; i<d.getElementsByTagName("DIV").length; i++)
	{
		var oDiv = d.getElementsByTagName("DIV")[i];
		if("DIV" == oDiv.parentNode.tagName)
		{
			oDiv.style.border = "1px dotted aqua";
		}
		else
		{
			oDiv.style.border = "1px solid lime";
		}

		if(oDiv.id)
		{
			var oSpan = d.createElement("SPAN");
				oSpan.setAttribute("style","background : #CCCCCC;");
				oSpan.innerHTML=""+oDiv.id;
			 oDiv.appendChild(oSpan);
		}
		// alert(oDiv.id)
	}
}

//============================================================
function fnLinkEmploi()
{
	// rProjets srProjets pProjets
	var oLi =  document.getElementById("MOD_EMPLOI");
	if(oLi)
	{
		var oLink = oLi.getElementsByTagName("A")[0];
		if(oLink)
		{
			oLink.setAttribute("href","/app/mod-emploi/4front/");		
		} 
	}
}

//============================================================
function fnLinkPhototheque()
{
	// rProjets srProjets pProjets
	var oLi =  document.getElementById("MOD_PHOTOTHEQUE");
	if(oLi)
	{
		var oLink = oLi.getElementsByTagName("A")[0];
		if(oLink)
		{
			oLink.setAttribute("href","/app/mod-catdoc/php/4front/");		
		} 
	}
}

//============================================================
function fnLinkBaseDocumentaire()
{
	// rProjets srProjets pProjets
	var oLi =  document.getElementById("MOD_BASE_DOCUMENTAIRE");
	if(oLi)
	{
		var oLink = oLi.getElementsByTagName("A")[0];
		if(oLink)
		{
			oLink.setAttribute("href","/app/mod-catdoc-file/php/4front/");		
		} 
	}
}

//============================================================
function fnLinkGmap()
{
	// rProjets srProjets pProjets
	var oLi =  document.getElementById("mod_map");
	if(oLi)
	{
		var oLink = oLi.getElementsByTagName("A")[0];
		if(oLink)
		{
			oLink.setAttribute("href","/app/mod-map/php/4front/index2.php");		
		} 
	}
}

//============================================================
function fnAnnuEntreprise()
{
	// rProjets srProjets pProjets
	var oLi =  document.getElementById("ANNUAIRE_ENTREPRISES");
	if(oLi)
	{
		var oLink = oLi.getElementsByTagName("A")[0];
		if(oLink)
		{
			oLink.setAttribute("href","/app/mod-annuaire-entreprise/php/4front/index.php");		
		} 
	}
}

//============================================================
function fnAnnuMandat()
{
	// rProjets srProjets pProjets
	var oLi =  document.getElementById("ANNUAIRE_MANDATS");
	if(oLi)
	{
		var oLink = oLi.getElementsByTagName("A")[0];
		if(oLink)
		{
			oLink.setAttribute("href","/app/mod-annuaire-mandat/php/4front/index.php");		
		} 
	}
}

//=======================================================================================
var vgMsg = new Array();

function cl_messagederoulant( idObj, sIdUl )
{
	window.message = this;
	this.msgName = "message_"+idObj;

	vgMsg.push( this );

	var cpt = (vgMsg.length -1);

	this.divDeroul= document.getElementById( idObj );
	this.ulDeroul =  document.getElementById(sIdUl);
	/* --- */
  if(! this.ulDeroul)
	{
    var oUl = this.divDeroul.getElementsByTagName("UL")[0]
		if(!oUl)
		{
			oUl = document.createElement("UL");
	    this.divDeroul.appendChild( oUl );
		}
			var oNewsUl = oUl.cloneNode(true);
	        oNewsUl.setAttribute("id", sIdUl );

	  	var oDivSticker = document.createElement("DIV");
	        oDivSticker.appendChild( oNewsUl );

	  	this.divDeroul.removeChild( oUl );
	    this.divDeroul.appendChild( oDivSticker );

	    this.ulDeroul =  document.getElementById( sIdUl )
  }
  /* --- */
	 this.divDeroul.style.display = 'block';
   // this.divDeroul.innerHTML = vgMsg[cpt].msgName + this.divDeroul.innerHTML;
  /* --- */
	this.defil =
	function cl_messagederoulant_defil()
	{
    //if( (this.ulDeroul.offsetLeft + this.ulDeroul.offsetWidth) <= 0)
    if( (this.ulDeroul.offsetLeft + this.ulDeroul.offsetWidth) <= 0)
		{
      this.ulDeroul.style.left = "0%"
		}
		this.ulDeroul.style.left=this.ulDeroul.offsetLeft-2+"px";
		clearTimeout(this.timer);
		// this.timer = setTimeout("window.message.defil()",13);
		this.timer = setTimeout( "vgMsg["+cpt+"].defil()" ,50);
	}
	/* --- */
	this.deroul =
	function cl_messagederoulant_deroul()
	{
    if( (this.ulDeroul.offsetTop + this.ulDeroul.offsetHeight) <= 0)
		{
      this.ulDeroul.style.top = "100%"
		}
		this.ulDeroul.style.top=this.ulDeroul.offsetTop-2+"px";
		clearTimeout(this.timer);
		// this.timer = setTimeout("window.message.deroul()",90);
		this.timer = setTimeout( "vgMsg["+cpt+"].deroul()" ,90);
	}
	/* --- */
	this.pause =
	function cl_messagederoulant_pause()
	{
		clearTimeout(this.timer);
	}
	/* --- */
	this.restart =
	function cl_messagederoulant_restart( sAction )
	{
		switch( sAction )
		{
			case 'deroul' :
				this.deroul()
				break;

			case 'defil' :
				this.defil();
				break;
		}
	}
}
//============================================================
function fnDisplayMsgDeroul( idDiv, sIdUl,  sAction ) {
  var oDiv = document.getElementById( idDiv )
	if( oDiv )
  {
		switch( sAction )
		{
			case 'deroul' :
					var oMessage = new  cl_messagederoulant( idDiv, sIdUl );
					    oMessage.deroul();
					oDiv.attachEvent ( "onmouseover", function ()	{ oMessage.pause(); })
					oDiv.attachEvent ( "onmouseout", function () { oMessage.restart( 'deroul' );})
				break;

			case 'defil' :
					var oMessage2 = new  cl_messagederoulant( idDiv, sIdUl );
					    oMessage2.defil();
					oDiv.attachEvent ( "onmouseover", function ()	{ oMessage2.pause(); })
					oDiv.attachEvent ( "onmouseout", function () { oMessage2.restart( 'defil' );})
				break;
		}

  }
}
//============================================================
function _printPageContent(){
	var oContent = document.getElementById('front-content');
	if( oContent ){
		var oPrintBtn = document.createElement("DIV");
				oPrintBtn.setAttribute("ID", "divPrintPage");
				oPrintBtn.innerHTML = '<a href="#null" id="aPrintBtn"onclick="openPrintWindow();return false;">Version imprimable</a>';
		oContent.appendChild( oPrintBtn );
	}
	var oBtnPrint = document.getElementById('aPrintBtn');
}
function openPrintWindow(){
	oPrintWin = window.open("/print.htm", 'impression', 'scrollbars=yes,menubar=yes,width=640,height=560');
	return false;
}
function getParentContents(){
	var sPageTitle 		= document.getElementById("front-title").innerHTML;
	var sPageContent 	= document.getElementById("front-content").innerHTML;
	
	var oPopUpTitle 		= oPrintWin.document.getElementById('front-title');
	var oPopUpContener 	= oPrintWin.document.getElementById('front-content');

	var sTitle = document.getElementsByTagName("title")[0].text;
	
	oPrintWin.document.getElementsByTagName("title")[0].text = sTitle; 

	oPopUpTitle.innerHTML = sPageTitle;
	oPopUpContener.innerHTML = sPageContent;
}

//============================================================
if(DHTML && DOM)
{
	window.attachEvent
		(
		"onload",
			function ()
			{
				if(MS){
					menuderoul('navigation-menu');
		  	}
				if( -1 != String(document.body.className).indexOf("ACCUEIL") ){
					fnDisplayMsgDeroul( "actu-div","ulNews", "defil" );
				}
				if( -1 != String(document.body.className).indexOf("PLAN_DU_SITE") ){
					//fnHideProtectedRubsInSiteMap();
				}
				fnLinkEmploi();
			  fnLinkGmap();
			  fnLinkPhototheque();
			  fnLinkBaseDocumentaire();
			  fnAnnuEntreprise();
			  fnAnnuMandat();
				
				if( !/ACCUEIL/.test(document.body.className)){
					//_printPageContent();
				}
			}
		)
}
//============================================================
