//////////////////////////////////////////////////////////////////////////////////////
// Fonctions standards
/////////////////////////////////////////////////////////////////////////////////////
var oAjax;
var bProcessing=0;
var oPopupMessage;

function getTopPos(oObjet)
{	
  var returnValue = oObjet.offsetTop;
  while((oObjet = oObjet.offsetParent) != null) returnValue += oObjet.offsetTop;
  return returnValue;
}

function getLeftPos(oObjet)
{
  var returnValue = oObjet.offsetLeft;
  while((oObjet = oObjet.offsetParent) != null) returnValue += oObjet.offsetLeft;
  return returnValue;
}

function select_ligne_table( maLigne )
{
	sClasse=maLigne.getAttribute("class");
	if(!sClasse) sClasse=maLigne.getAttribute("className");
	nLen=sClasse.length -5;
	if(sClasse.substring(nLen,100) == "_over") sClasse=sClasse.substring(0,nLen);else sClasse=sClasse.concat('_over');
	maLigne.setAttribute("className", sClasse);maLigne.setAttribute("class", sClasse);
}
// Pour bug du replace
function remplace( sCherche, sRemplace, sTexte)
{
	while(sTexte.indexOf(sCherche,0) >=0) sTexte=sTexte.replace(sCherche,sRemplace);
	return sTexte;
}

///////////////////////////////////////////////////////////////////////////////
// CONTROLE DE SAISIE
///////////////////////////////////////////////////////////////////////////////

function controle_saisie(oForm)
{
	for(i=0; i< oForm.elements.length; i++)
	{
		oElem=oForm.elements[i];
		if( oElem.getAttribute("obligatoire")=="1")
		{
			if(remplace(" ","",oElem.value) == "")
			{
				alert("Cette donnée doit être renseignée !");
				oElem.focus();
				return false;
			}
		}
	}
	oForm.submit();
}

///////////////////////////////////////////////////////////////////////////////
// BOITES SURGISSANTES
///////////////////////////////////////////////////////////////////////////////

function centrer_popup(oPopup)
{
	oPopup.style.left=document.body.scrollLeft + Math.floor((screen.width - oPopup.clientWidth)/2);
	oPopup.style.top=document.body.scrollTop + Math.floor((screen.height - oPopup.clientHeight)/2)-100;
}

function scroll_popup(sId,nPos,nStopY)
	{
		oPopup=document.getElementById(sId);
		if(!nPos) nY=screen.height; else nY=nPos-20;
		oPopup.style.top=nY;
		if(oPopup.style.display != "block")
		{
			oPopup.style.display="block";
			nLargeur=oPopup.clientWidth;
			oPopup.style.left=(screen.width-nLargeur)/2;
		}
		
		if(nY > nStopY) setTimeout("scroll_popup('"+sId+"',"+nY+","+nStopY+")",5);
	}
	
function fermer_scroll_popup(sId,nPos)
	{
		oPopup=document.getElementById(sId);
		if(!nPos) nY=oPopup.style.top.replace("px",""); else nY=nPos+20;
		oPopup.style.top=nY;	
		if(nY > screen.height) oPopup.style.display="none"; 
		else setTimeout("fermer_scroll_popup('"+sId+"',"+nY+")",5);
	}
	
function popup_gauche(sId,nPos)
{
	oBoite=document.getElementById(sId);
	if(!nPos) 
	{
		oBoite.style.top=document.body.scrollTop;
		oBoite.style.display="block";
		nX=-(oBoite.clientWidth);
	}
	else nX=nPos+10; 
	oBoite.style.left=nX;
	if(nX < 0) setTimeout("popup_gauche('"+sId+"',"+nX+")",5);
}
function fermer_popup_gauche(sId,nPos)
{
	oBoite=document.getElementById(sId);
	nX=nPos-10;
	oBoite.style.left=nX;
	if(nX > -(oBoite.clientWidth)) setTimeout("fermer_popup_gauche('"+sId+"',"+nX+")",5);
	else oBoite.style.display="none";
}

function afficher_section(objetNotice)
{
	visible = document.getElementById(objetNotice).style.display;
	oImg=document.getElementById("I" + objetNotice);
	if( visible == "block" ) 
		{
			if(oImg != null) oImg.setAttribute("src", imagesUrl+ "plus_carre.gif");
			document.getElementById(objetNotice).style.display="none";
			return false;
		}
	else
		{
			if(oImg != null) oImg.setAttribute("src", imagesUrl+ "moins_carre.gif");
			oNotice=document.getElementById(objetNotice);
			oNotice.style.display="block";
			return true;
		}
}

/*
v1.03 Copyright (c) 2006 Stuart Colville
http://muffinresearch.co.uk/archives/2006/04/29/getelementsbyclassname-deluxe-edition/

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial 
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
IN THE SOFTWARE.
*/
  
function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;    
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = new Array();                              
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';   
  var arrClass = strClass.split(delim);    
  for (var i = 0, j = objColl.length; i < j; i++) {                         
    var arrObjClass = objColl[i].className.split(' ');   
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if ((delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]); 
          break comparisonLoop;
        }
      }
    }
  }
  return arr; 
}

// To cover IE 5 Mac lack of the push method
Array.prototype.push = function(value) {this[this.length] = value; };

function showCmsAvis(idCmsAvis) {

	avis = document.getElementById(idCmsAvis);
	avis.style.display = 'block';
}

function hideCmsAvis(idCmsAvis) {

	avis = document.getElementById(idCmsAvis);
	avis.style.display = 'none';
}
