
	ELEMENT_NODE = 1;
	ATTRIBUTE_NODE = 2;
	TEXT_NODE = 3;
	

//--------- TEST-----------

function postCommonVersion()
{	alert ('common functions - version : 0.1');
}

//---------  Fonctions de Navigation  (from MamelonVert) -------------------
		
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function open_info (url,window,features) {
	window.open('url','window','features')
}

function NewWindow(theURL,winName,features) {
	nw = window.open(theURL,winName,features);
	nw.focus();
}

//------- pré-chargement des images du choix des options ----------

function preloadOptionsSLIcons( oneIconDir) 
{
MM_preloadImages(
	oneIconDir + 'iconMarchandisesHome.gif',
	oneIconDir + 'iconMarchandisesHomeHover.gif',
	oneIconDir + 'iconCommissionHome.gif',
	oneIconDir + 'iconCommissionHomeHover.gif',
	oneIconDir + 'iconVoyageursHome.gif',
	oneIconDir + 'iconVoyageursHomeHover.gif',
	oneIconDir + 'iconLegerHome.gif',
	oneIconDir + 'iconLegerHomeHover.gif',
	oneIconDir + 'iconExamHome.gif',
	oneIconDir + 'iconExamHomeHover.gif'
)
}


// ---------------- fonctions communes multiPages ------------------

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function MM_openBrWindow(theURL,winName,features) 
{
  if   ( features != null)  oneWIndow = window.open(theURL,winName,features);
  else						oneWIndow = window.open(theURL,winName);
  oneWIndow.focus();
  return oneWIndow;
}

function goBack(){
	history.go(-1);
}

function closeWin(){
	window.close();
}

//-- openFAQWindow & openPopUpWindow are equivalent
function openFAQWindow(urlString,winName,width,height) 
{	return openPopUpWindow(urlString,winName,width,height);
}
//-- openFAQWindow & openPopUpWindow are equivalent
function openPopUpWindow(urlString,winName,width,height) 
{
	posx = (screen.width/2) - (width/2)
	posy = (screen.height/2) - (height/2)
	if(posx < 0) { posx = 0; }
	if(posy < 0) { posy = 0; }
		  
	onePopUp = MM_openBrWindow(urlString, winName,' width=' + width + ', height=' + height 
			 +', scrollbars=yes,status=no,toolbar=yes,resizable=yes,left=' + posx + ',top=' + posy);
	return onePopUp;
	
}

// popUp is common to FAQ & Help, with fixed length
function openPopUp(urlString, popupTitle) 
{	return openPopUpWindow(urlString, popupTitle, 520, 580);
} 

//----------------------------- contentMenu -------------------------------


// contentForm is defined in the calling window (e.g. contentMenu)
// contentForm has contentPage as target
// parameters are transmitted thru POST
function  openContentWindow (oneContentURL, oneContentTitle)
{
	myContentForm = document.getElementById("contentForm");
	for ( var j=0; j < myContentForm.length; j++)
		{
		  if   ( myContentForm.elements[j].name == 'contentURL')
			   { myContentForm.elements[j].value = oneContentURL;
			   }
		  if   ( myContentForm.elements[j].name == 'contentTitle')
			   { myContentForm.elements[j].value = oneContentTitle;
			   }
		}
	// submit form
	myContentForm.submit();
}




//----------------------------------- Validations --------------------------------------

function  isCheckBoxIDChecked (oneCBID) 
{
	thisCheckBox = document.getElementById(oneCBID);
	if   ( thisCheckBox.checked == true ) return true;
	return false;
}

/*-------------------- additional DOM functions (No XML Script ! ) ------------------------

//----------  process Elements -------------

// imported from rico
function getDirectChildrenByTag (oneElement, tagName) 
{
      var kids = new Array();
      var allKids = oneElement.childNodes;
      for  ( var i = 0 ; i < allKids.length ; i++ )
		   {
			  if ( allKids[i] && allKids[i].tagName && allKids[i].tagName == tagName )
                   kids.push(allKids[i]);
			}
      return kids;
}

function getChildWithTag (oneElement, oneTag) 
{       
	childElement = null;
	allChildren = oneElement.childNodes;
	for   ( j=0; j < allChildren.length; j++ )
		  { currentItem = allChildren.item(j);
			// consider elements only
			if   ( currentItem.nodeType != ELEMENT_NODE ) continue;
			if   ( currentItem.getTagName() == oneTag )
			     { childElement = currentItem;
				   break;
				 }
		  }
	return  childElement;
}

function getChildWithTagAndID (oneElement, oneTag, oneID) 
{       
	childElement = null;
	allChildren = oneElement.childNodes;
	for   ( j=0; j < allChildren.length; j++ )
		  { currentItem = allChildren.item(j);
			// consider elements only
			if   ( currentItem.nodeType != ELEMENT_NODE ) continue;
			if   ( currentItem.getTagName() == oneTag )
			     { // tag has been found
				   currentItemID = currentItem.getAttribute('ID');
				   if   ( currentItemID == oneID )
						{ childElement = currentItem;
						  break;
						}
				 }
		  }
	return  childElement;
}

function getElementTitle (oneElement) 
{       
	titleElement = getChildWithTag (oneElement, 'title');
	if   ( titleElement == null ) return 'NO TITLE';
	return  getTextTrimmedValue(titleElement);
}

// get text value of Node, even with '/n' and blanks
function getTextTrimmedValue (oneNode) 
{       
	if   ( oneNode == null ) return '';
	currentTextNode = oneNode.firstChild;
	if   ( currentTextNode.nodeType != TEXT_NODE ) return 'NO TEXT_NODE AVAILABLE';
	textValue = currentTextNode.nodeValue;
	return textValue;
}
--------------------------------*/
	
//----------------------------------- additional XML Script DOM functions --------------------------------------

// imported from rico
function getDirectChildrenByTag (oneElement, tagName) 
{
      var kids = new Array();
      var allKids = oneElement.childNodes;
      for  ( var i = 0 ; i < allKids.length ; i++ )
		   {
			  if ( allKids[i] && allKids[i].tagName && allKids[i].tagName == tagName )
                   kids.push(allKids[i]);
			}
      return kids;
}

function getChildWithTag (oneElement, oneTag) 
{       
	childElement = null;
	allChildren = oneElement.childNodes;
	for   ( j=0; j < allChildren.length; j++ )
		  { currentItem = allChildren.item(j);
			// consider elements only
			if   ( currentItem.nodeType != ELEMENT_NODE ) continue;
			if   ( currentItem.getTagName() == oneTag )
			     { childElement = currentItem;
				   break;
				 }
		  }
	return  childElement;
}

function getChildWithTagAndID (oneElement, oneTag, oneID) 
{       
	childElement = null;
	allChildren = oneElement.childNodes;
	for   ( j=0; j < allChildren.length; j++ )
		  { currentItem = allChildren.item(j);
			// consider elements only
			if   ( currentItem.nodeType != ELEMENT_NODE ) continue;
			if   ( currentItem.getTagName() == oneTag )
			     { // tag has been found
				   currentItemID = currentItem.getAttribute('ID');
				   if   ( currentItemID == oneID )
						{ childElement = currentItem;
						  break;
						}
				 }
		  }
	return  childElement;
}

function getElementTitle (oneElement) 
{       
	titleElement = getChildWithTag (oneElement, 'title');
	if   ( titleElement == null ) return 'NO TITLE FOUND';
	return  getTextTrimmedValue(titleElement);
}

// get text value of Node, even with '/n' and blanks
function getTextTrimmedValue (oneNode) 
{       
	if   ( oneNode == null ) return '';
	currentTextNode = oneNode.firstChild;
	if   ( currentTextNode.nodeType != TEXT_NODE ) return 'NO TEXT_NODE AVAILABLE';
	textValue = currentTextNode.nodeValue;
	// unescape XML for HTML
	textValue.replace('&#xa;', '<br/>');
	return textValue;
}

//</script>
