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+"plant/wl/oilgae.xml");
  }
catch(e)
  {
  try //Firefox, Mozilla, Opera, etc.
    {
		var xmlhttp_wl = new window.XMLHttpRequest();
		xmlhttp_wl.open("GET",domainn+"plant/wl/oilgae.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" id="badd"><div align="right"><a href="javascript:;" onclick="closs();">Close</a></div>');
document.writeln('<table bgcolor=#FFFFFF width=100% height=100%><tr  style="background:#2a2a2a; color:#FFFFFF; font-family:cursive; font-weight:bold; font-size:14px;"><td colspan="2" align="center"><a href="http://www.plantoils.in/portal/jatropha/report/jatropha_report___market__opportunity_and_trends_in_jatropha.html" id="an"><span id="div_title">Jatropha Digest</span></a></td></tr>');
document.writeln('<tr>');
document.writeln('<td align="center"><a href="http://www.plantoils.in/portal/jatropha/report/digest/jatropha_digest.html" title="The Jatropha Digest" id="an"><img src="/plant/images/jatropha_d.jpg" /></a></td><td><a href="http://www.plantoils.in/portal/jatropha/report/jatropha_report___market__opportunity_and_trends_in_jatropha.html" id="ann"><span id="div_desc">The Only Available Comprehensive Jatropha Report - from Plantoils.in</span></a><br><br><h2 align="center"><a href="http://www.plantoils.in/portal/jatropha/report/jatropha_report___market__opportunity_and_trends_in_jatropha.html">See More</a></h2>');
document.writeln('</td></tr></table></div>');
parseWORDLIVE();
highlightSearchTerms_wl(false);