

function importXML()
{
	if (document.implementation && document.implementation.createDocument)
	{
		oXMLDoc = document.implementation.createDocument("", "", null);
		oXMLDoc.onload = createTable;
	}
	else if (window.ActiveXObject)
	{
		oXMLDoc = new ActiveXObject("Microsoft.XMLDOM");
		oXMLDoc.onreadystatechange = function () {
			if (oXMLDoc.readyState == 4) createTable()
		};
 	}
	else
	{
		alert('Your browser can\'t handle this script');
		return;
	}
	oXMLDoc.load("Keywordpro.xml");
}

function KeyWordInit()
{ 

  //  Create an XML document object reference to our XML data island
 var oXMLDoc = window.document.all("xmlkeywords");  
  // Create an XML document list of all keywords
  //var oXMLList = oXMLDoc.selectNodes("//KEYWORDS/KEYWORD");
  var oXMLList = oXMLDoc.selectNodes("//KEYWORDS/KEYWORD");
  // How many keywords do we have?
  var nTot = oXMLList.length;

  var sKeyURL='';
  var sKeyPhrase='';
  // This array stores the actual .href values of existing links.
  var oLinks = new Array();
  // This array stores the contents between the <A></A> tags
  var oLinksHTML = new Array();
 
  var nLinks = document.all.tags('A').length;
 
  // Store our current links in their proper arrays.
  for (i=0;i<nLinks;i++) { oLinks[i] = document.all.tags('A')[i].href; oLinksHTML[i] = document.all.tags('A')[i].innerHTML; }
   
 // Iterate through our XML document of keywords and replace them with links

   for(nCnt=0;nCnt<nTot;nCnt++)
   {
          var oXMLNode = oXMLList.nextNode();
          sKeyURL = oXMLNode.text;
         sKeyPhrase = oXMLNode.attributes(1).text;

       // Recreate the text range every other keyword to get around bug mentioned
       // above.

       if (nCnt % 2 == 0) {   var oRange = document.body.createTextRange();   }
       else{  oRange.collapse(true); }

     // Find each instance of the current keyword and process it.
   
      for (i=0;oRange.findText(sKeyPhrase)!=false; i++)
      { 
        try
        {  
  oRange.pasteHTML('<b KeyWordURL=' + sKeyURL + ' style="color:#6666CC;text-decoration:none" class=KeyWordHiliting >' + oRange.text + '</b>'); 
           oRange.collapse(false);
        }
        catch (e) {  oRange.collapse(false);   }				    
      }
    }

   // go through all of the links again and replace them with their original values just in case our processing
   // pasted invalid html in them.

     for (i=0;i<nLinks;i++) {  document.all.tags('A')[i].href = oLinks[i];  document.all.tags('A')[i].innerHTML = oLinksHTML[i]; }
 
}
