var key_wl = new Array();
var title_wl = new Array();
var desc_wl = new Array();	
var tot_link =0;
var domainn = "http://" + window.location.toString().split("//")[1].split("/")[0] + "/";
function parseWORDLIVE()
{
try //Internet Explorer
  {
	  xmlDoc_wl=new ActiveXObject("Microsoft.XMLDOM");
	  var brow='IE';
	  xmlDoc_wl.async=false;
	  xmlDoc_wl.load(domainn+"cms/wl/biozio.xml");
  }
catch(e)
  {
  try //Firefox, Mozilla, Opera, etc.
    {
		var xmlhttp_wl = new window.XMLHttpRequest();
		xmlhttp_wl.open("GET",domainn+"cms/wl/biozio.xml",false);
		xmlhttp_wl.send(null);
		var xmlDoc_wl = xmlhttp_wl.responseXML.documentElement;
    }
  catch(e)
    {
		alert(e.message);
		return;
	}
  }
	var value_wl = xmlDoc_wl.getElementsByTagName("keyword");
	//alert(value_wl.length);
		
	for(var i=0; i < value_wl.length; i++)
	{
		key_wl[i] = xmlDoc_wl.getElementsByTagName("key")[i].childNodes[0].nodeValue;
		title_wl[i] = xmlDoc_wl.getElementsByTagName("title")[i].childNodes[0].nodeValue;
		desc_wl[i] = xmlDoc_wl.getElementsByTagName("description")[i].childNodes[0].nodeValue;
		//alert(key_wl[i]+"\n"+title_wl[i]+"\n"+desc_wl[i]);
	}
}

function doHighlight_wl(bodyText, searchTerm, highlightStartTag, highlightEndTag,index)
{
  // the highlightStartTag and highlightEndTag parameters are optional
  //alert(index);
  if ((!highlightStartTag) || (!highlightEndTag)) {
	  //alert (title_wl[index]+"\n"+desc_wl[index]);
    highlightStartTag = "<a href='javascript:;' onmouseover='menuLayers.show(\""+escape(title_wl[index])+"\",\""+escape(desc_wl[index])+"\",event);' onmouseout='menuLayers.hide();'><font style='color:red; text-decoration:underline;'>";
    highlightEndTag = "</font></a>";
  }
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
  var alm, almm, leng, ll, lll;
  var found=0;
  
  while (bodyText.length > 0) {
	i = lcBodyText.indexOf(lcSearchTerm, i+1);
	//alert(i);
	if (i < 0) {
	  newText += bodyText;
	  bodyText = "";
	} else {
	  // skip anything inside an HTML tag
	  if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
		  // skip anything inside an a tag
		   if (bodyText.lastIndexOf("/a>", i) >= bodyText.lastIndexOf("<a", i)) {
			   //stip anything inside an table tag
			    if (bodyText.lastIndexOf("/table>", i) >= bodyText.lastIndexOf("<table", i)) {
		// skip anything inside a <script> block
		if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
		  alm = bodyText.substr(i-1, searchTerm.length);
		  almm = bodyText.substr(i+1, searchTerm.length);
		  //var nmm = bodyText.substring(0, i);
		  leng = alm.length;
		  ll = alm.charAt(0);
		  lll = almm.charAt(leng-1);
		    var txt = bodyText.substring(0, i);
		  var mid_worda = txt.split(" ");
		  var tot_midl_worda = mid_worda.length;
		  //alert(lll);
		  if((ll == ' ' && lll == ' ' || ll == '>' || lll == ',' || lll == '.' || lll == '\n' || lll == '&nbsp;' || lll == '&quot;' || lll == '&lt;' || lll == '&acute;' || lll == ';') && (found < 5) && (tot_link < 25) && tot_midl_worda > 40)
		  {
				newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
				bodyText = bodyText.substr(i + searchTerm.length);
				lcBodyText = bodyText.toLowerCase();
				i = -1;
				found++; tot_link++;
				//alert(found);
		  }
		 
		}
		   }
	   }
	  }
	}
  }
  return newText;
}

function highlightSearchTerms_wl(warnOnFailure, highlightStartTag, highlightEndTag)
{
	//alert(warnOnFailure);
	
 if (!document.body || typeof(document.body.innerHTML) == "undefined") {
	  //alert(searchText);
    if (warnOnFailure) {
      alert("Sorry, for some reason the text of this page is unavailable. Searching will not work.");
    }
    //return false;
  }
 
  var bodyText = document.getElementById('entry').innerHTML;
  for (var i = 0; i < key_wl.length; i++) {
    bodyText = doHighlight_wl(bodyText, key_wl[i], highlightStartTag, highlightEndTag,i);
  }
  
  document.getElementById('entry').innerHTML = bodyText;
  return true;
}

document.writeln('<div class="menu_karthi" id="badd"><div class="rbroundboxgg">');
document.writeln('<div class="rbtopgg"><div></div></div><div class="rbcontentgg">');
document.writeln('<table bgcolor=#FFFFFF width=100% height=100% cellpadding="2" cellspacing="0"><tr  style="background:#9bb143; color:#2a2a2a; font-family:cursive; font-weight:bold; font-size:15px;"><td colspan="2" align="center"><a href="http://www.biozio.com/ref/services/consulting.html" id="an"><span id="div_title">Biofuel Consulting & Research</span></a>&nbsp;<span id="rr"><a href="javascript:;" onclick="closs();" style="border:none;"><img src="http://www.biozio.com/cms/img/close_icon_g.png"></a></span></td></tr>');
document.writeln('<tr>');
document.writeln('<td align="center"><a href="http://www.biozio.com/ref/services/consulting.html" title="Biodiesel, Ethanol Business Strategy, Research, Investment Advice" id="an"><img src="http://www.biozio.com/cms/img/r.png" /></a></td><td><a href="http://www.biozio.com/ref/services/consulting.html" id="ann"><font color="#2a2a2a" size="2"><b><span id="div_desc">Biodiesel, Ethanol Business Strategy, Research, Investment Advice</span></b></font></a><br><br><h4 align="center"><a href="http://www.biozio.com/ref/services/consulting.html">Read More</a></h4>');
document.writeln('</td></tr></table></div><div class="rbbotgg"><div></div></div></div></div>');
parseWORDLIVE();
highlightSearchTerms_wl(false);