
function KeyWordInit()
{ 

	//var victim = document;
	var victim = parent.victimsite.document;
	
  //  Create an XML document object reference to our XML data island
  //var oXMLDoc = window.document.all("xmlkeywords");
	var oXMLDoc = window.document.getElementById("xmlkeywords");
 //var oXMLDoc = victim.all("xmlkeywords");  
  // Create an XML document list of all keywords
	try{
	
  var oXMLList = oXMLDoc.selectNodes("//KEYWORDS/KEYWORD");
	}
	catch(error){alert("Sorry you need to downgrade your browser! \n AutoThink only works with Internet Explorer\nGood enough for Google, good enough for Dougal!")}
  // 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  tags
  var oLinksHTML = new Array();
 
  var nLinks = victim.all.tags('A').length;

  // Store our current links in their proper arrays.
  for (i=0;i<nLinks;i++) { oLinks[i] = victim.all.tags('A')[i].href; oLinksHTML[i] = victim.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 = victim.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('<a style="text-decoration:underline;color:#ee0000" target="_new" title="Dougals recommendation for:' + oRange.text + '" href="'+sKeyURL+'">' + oRange.text + '</a>');
				//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++) {  victim.all.tags('A')[i].href = oLinks[i];  victim.all.tags('A')[i].innerHTML = oLinksHTML[i]; }
 
}

/*
function GotoSite()
{
	parent.victimsite.document.location=document.getElementById("SiteUrl").value;
}
*/
