//Global  variables
var xmlDoc;
//////////////////////////////////////////////////////////////////////////// for Mozilla index
function getprod(varNodeValue,browserIE)
{//si browserIE=true donc IE sinon firefox

	var NomElementNode =varNodeValue.getElementsByTagName("Nom")[0];
	var TextElementNode =varNodeValue.getElementsByTagName("Text")[0];
	var PhotoElementNode =varNodeValue.getElementsByTagName("Photo")[0];
	var lienElementNode =varNodeValue.getElementsByTagName("lien")[0];



	(browserIE)?Nom=NomElementNode.text:Nom=NomElementNode.textContent;
	(browserIE)?Text =TextElementNode.text:Text =TextElementNode.textContent;
	(browserIE)?Photo =PhotoElementNode.text:Photo =PhotoElementNode.textContent;
	(browserIE)?lien =lienElementNode.text:lien =lienElementNode.textContent;
	contentCode="";
	
	// for Mozilla index  reading first xml child
	
contentCode+='<table border="0" cellpadding="0" cellspacing="0" width="525">';
  contentCode+='<tr>';
   contentCode+='<td colspan="3" width="355" height="27"><h4>' + Nom+ '</h4></td>';
   contentCode+='<td rowspan="3" width="170" height="149" class="bord"><a  href="fiches_prod/' + lien + '.htm"><img border="0" src="' + Photo+ '" width="170" height="149" border="0" /></a></td>';
  contentCode+='</tr>';
  contentCode+='<tr>';
   contentCode+='<td colspan="3" width="355" height="79" >' + Text+ '</td>';
  contentCode+='</tr>';
  contentCode+='<tr>';
   contentCode+='<td><a href="fiches_prod/' + lien + '.htm"><img name="pesage_r3_c1" src="img/pesage_r3_c1.png" width="40" height="43" border="0" id="pesage_r3_c1" alt="" /></a></td>';
   contentCode+='<td width="159" height="43"><a href="pdf_prod/' + lien + '.pdf" target="_blank">Fiche technique en Pdf</a></td>';
   contentCode+='<td width="156" height="43"><a href="fiches_prod/' + lien + '.htm">En savoir plus>></a></td>';
  contentCode+='</tr>';
contentCode+='</table>';
contentCode+='<br />';
   contentCode+='<hr>';
   
   contentCode+='<br />';
   
   
   	return contentCode
}  // end function



////////////////////////////////////////////////////////////////////////////
function getspec()
{   // for IE index    read all childs 
	var y = xmlDoc.getElementsByTagName("PROD");
	var contentCode="";
	for (j=0;j<y.length;j++)
	{
		contentCode+=getprod(y[j],true);
			
	} 
	document.getElementById("content").innerHTML=contentCode;
}  // end function

////////////////////////////////////////////////////////////////////////////
function getspe()
{   // for Mozilla    read all childs 
	var y = xmlDoc.getElementsByTagName("PROD");
	var contentCode="";
	for (j=0;j<y.length;j++)
	{
		contentCode+=getprod(y[j],false);
			} 
	document.getElementById("content").innerHTML=contentCode;
}  // end function


///////////////////////////////////////////////////////////////////////////
function getmenu(s)
{   // for IE index    create dynamic menu from xml
	var y = xmlDoc.getElementsByTagName(s);
	var x = xmlDoc.getElementsByTagName('PROD');
	for (j=0;j<y[0].childNodes.length;j++)
	{
		document.writeln('<a href="' +x[j].childNodes[3].firstChild.nodeValue + '.htm"> >> ' +x[j].childNodes[0].firstChild.	nodeValue + '</a>');
		document.writeln('<br>');
			} 
}  // end function

////////////////////////////////////////////////////////////////////////////
function getmen(s)
{   // for Mozilla index    create dynamic menu from xml
	var y = xmlDoc.getElementsByTagName(s);
	var x = xmlDoc.getElementsByTagName('PROD');
	for (j=0;j<y[0].childNodes.length;j++)
	{
		document.writeln('<a href="' +x[j].childNodes[3].firstChild.nodeValue + '.htm">' +x[j].childNodes[0].firstChild.nodeValue + '</a>');
		document.writeln('<br>');
	} 
}

//////////////////////////////////////////////////////////////////////////////
function init(url)
{
	//load xml file
	if (window.ActiveXObject)
	{
		 xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		 xmlDoc.async=false; //Enforce download of XML file first. IE only.
	}
	else if (document.implementation && document.implementation.createDocument)
   			 xmlDoc= document.implementation.createDocument("","doc",null);
	
	if (typeof xmlDoc!="undefined")
		xmlDoc.load(url);

	if (typeof xmlDoc!="undefined")
	{
		if (window.ActiveXObject) //if IE, simply execute script (due to async prop).
		getspec();
		else //else if NS6, execute script when XML object has loaded
		xmlDoc.onload=getspe
	}
}

// end function
//////////////////////////////////////////////////////////////////////////////// Fireworks functions

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_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 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];}}
}





////////////////////////////////////////////////////// NEWS CODE //////////////////////////////////////////////////////////////////////

function getonenews(varNodeValue,browserIE)
{//si browserIE=true donc IE sinon firefox

	var titleElementNode =varNodeValue.getElementsByTagName("title")[0];
	var descriptionElementNode =varNodeValue.getElementsByTagName("description")[0];
	var lienElementNode =varNodeValue.getElementsByTagName("lien")[0];
	

	(browserIE)?title=titleElementNode.text:title=titleElementNode.textContent;
	(browserIE)?description =descriptionElementNode.text:description =descriptionElementNode.textContent;
	(browserIE)?lien =lienElementNode.text:lien =lienElementNode.textContent;
	
	contentCode="";
	// for Mozilla index  reading first xml child
	contentCode+='<div>';
	contentCode+='<a style="border-style: none" target="_self" href="' + lien + '"><h1>' + title+ '</h1></a>';
	contentCode+='<a style="border-style: none" target="_self" href="' + lien + '">' + description+ '</a>';
	contentCode+='</div>';
	contentCode+='<br>';
	contentCode+='<br>';
	
	
	return contentCode
}  // end function

////////////////////////////////////////////////////////////////////////////
 function getnews()
{   // for IE index    read all childs 
	var y = xmlDoc.getElementsByTagName("item");
	var contentCode="";
	for (j=0;j<y.length;j++)
	{
		contentCode+=getonenews(y[j],true);
	
	} 
	document.getElementById("contentnews").innerHTML=contentCode;
}  // end function

////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
function getnew()
{   // for Mozilla    read all childs 
	var y = xmlDoc.getElementsByTagName("item");
	var contentCode="";
	for (j=0;j<y.length;j++)
	{
		contentCode+=getonenews(y[j],false);
	} 
	document.getElementById("contentnews").innerHTML=contentCode;
}  // end function


////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
function initnews(url)
{
	//load xml file
	if (window.ActiveXObject)
	{
		 xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		 xmlDoc.async=false; //Enforce download of XML file first. IE only.
	}
	else if (document.implementation && document.implementation.createDocument)
   			 xmlDoc= document.implementation.createDocument("","doc",null);
	
	if (typeof xmlDoc!="undefined")
		xmlDoc.load(url);

	if (typeof xmlDoc!="undefined")
	{
		if (window.ActiveXObject) //if IE, simply execute script (due to async prop).
		getnews();
		else 
		xmlDoc.onload=getnew
	}
}

// end function

// END news code.....................................................................................................................