/*********************** Search engine *************************************/
function createXHR() 
{
	if(window.XMLHttpRequest) // Firefox 
	   return new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
 	   return new ActiveXObject("Microsoft.XMLHTTP");
	else { // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); }
}



function getBody(content) 
{
   test = content.toLowerCase();    // to eliminate case sensitivity
   var x = test.indexOf("&lt;body");
   if(x == -1) return "";

   x = test.indexOf("&gt;", x);
   if(x == -1) return "";

   var y = test.lastIndexOf("&lt;/body&gt;");
   if(y == -1) y = test.lastIndexOf("&lt;/html&gt;");
   if(y == -1) y = content.length;    // If no HTML then just grab everything till end

   return content.slice(x + 1, y);   
} 

/**
	Loads a HTML page
	Put the content of the body tag into the current page.
	Arguments:
		url of the other HTML page to load
		id of the tag that has to hold the content
*/		

function loadHTML(url, fun, storage, param)
{
	var xhr = createXHR();
	xhr.onreadystatechange=function()
	{ 
		if(xhr.readyState == 4)
		{
			//if(xhr.status == 200)
			//{
				//storage.innerHTML = getBody(xhr.responseText);
				storage.innerHTML = xhr.responseText;
				//fun(storage, param);
			//}
		} 
	}; 

	xhr.open("GET", url , true);
	xhr.send(null); 

} 

	/**
		Callback
		Assign directly a tag
	*/		


	function processHTML(temp, target)
	{
		target.innerHTML = temp.innerHTML;
	}

	function loadWholePage(url,storage)
	{
		var y = document.getElementById("storage");
		var x = document.getElementById("displayed");
		loadHTML(url, processHTML, storage, storage);
	}	





function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "text/html; charset=ISO-8859-1");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

function HONETNav(what)
{
HONETsearch(what.substring(1,what.length));
}

function HONETsearch(what)
{
	var myDIV = document.getElementById('searchresult');
	var mysearchlink = "http://www.fromm-pack.lu/Search.aspx?what="+escape(what)+"&xsl="+escape("http://www.fromm-pack.lu/fr/FROMMFR.xsl");
	loadWholePage(mysearchlink,myDIV);
}

