 var xmlhttp=false;
 var _ai = 0;
  
  // -----> This method was provided from Jim Ley's website 
  /*@cc_on @*/
  /*@if (@_jscript_version >= 5)
  // JScript gives us Conditional compilation, we can cope with old IE versions.
  // and security blocked creation of the objects.
  try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
  try {
  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
  xmlhttp = false;
  }
  }
  /*@end @*/
  
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
  }
  // -->>>>>> End method
  
  
  // Over here we make a call back to our server side page and return the results from our query 
  // to a DIV tag sitting under the text box
  function methDataGet(strMethod,strValue,returnDiv)
  {
  xmlhttp.open("GET", "searchSuggest.php?search=" + strValue,true);
  
   xmlhttp.onreadystatechange=function() {
   if (xmlhttp.readyState==4) {
     document.getElementById(returnDiv).innerHTML = xmlhttp.responseText 
     if(document.getElementById(returnDiv).innerHTML == "none")
     {
       document.getElementById(returnDiv).style.visibility = 'hidden'
       document.getElementById(returnDiv).style.display = 'none'
     }
     else 
     {
       document.getElementById(returnDiv).style.visibility = 'visible'
       document.getElementById(returnDiv).style.display = 'inline'
     }
   }
   }
   xmlhttp.send(null)
  }
  
  function selectName(oName)
  {
   if(oName)
   {
    document.productsearch.searchstring.value = oName.innerHTML;
    
   }
   //lostfocus('theDiv');
  }
  
  function lookmeup(oElement,oDiv,evt)
  {
   //Detect if the user is using the down button
   if( document.productsearch.searchstring.value == "")
   {
    document.getElementById(oDiv).style.visibility = 'hidden';
	document.getElementById(oDiv).style.display = 'none';
	return;
   }
   if(detectKeyPress(evt)==38)
   {
    keyUpList()
   }
   else if(detectKeyPress(evt)==40)
   {
    keyDownList()
   }
   else if(detectKeyPress(evt)==13)
   {
    selectName(document.getElementById('ai'+_ai));
	url = document.getElementById('ai'+_ai).innerHTML;
	url = url.replace(" ","_");
	window.location = '03_'+url+'.html';
   }
   else
   {
   lostfocus(oDiv);
   methDataGet("methGetAddressName",oElement.value,oDiv)
   }
  }
  
  function keyDownList()
  {
   if(_ai!=0)
   {
    uhAddress(document.getElementById('ai'+_ai))
   }
   
   _ai = _ai +1;
   if(document.getElementById('ai'+_ai))
   {
    hAddress(document.getElementById('ai'+_ai))
    selectName(document.getElementById('ai'+_ai))
   }
   else
   {
    _ai = _ai -1;
    hAddress(document.getElementById('ai'+_ai))
    selectName(document.getElementById('ai'+_ai))
   }
  }
  
  function mouseOut(id)
  {
	  uhAddress(document.getElementById('ai'+id))
  }
  function mouseOver(id)
  {
    _ai = id;
    hAddress(document.getElementById('ai'+_ai))
    selectName(document.getElementById('ai'+_ai))
  }

  function mouseClick(id)
  {
    _ai = id;
    hAddress(document.getElementById('ai'+_ai))
    selectName(document.getElementById('ai'+_ai));
	document.productsearch.submit();
  }

  function keyUpList()
  {
   if(_ai!=0)
   {
    uhAddress(document.getElementById('ai'+_ai))
   }
   
   _ai = _ai -1;
   if(document.getElementById('ai'+_ai))
   {
    hAddress(document.getElementById('ai'+_ai))
    selectName(document.getElementById('ai'+_ai))
   }
   else
   {
    _ai = _ai +1;
    hAddress(document.getElementById('ai'+_ai))
    selectName(document.getElementById('ai'+_ai))
   }
  }
  
  //Highlights a div
  function hAddress(tobject)
  {
   if(tobject)
   {
    tobject.style.background = 'blue'
    tobject.style.color= "white"
   }
  }
  
  //unhighlights a div
  function uhAddress(tobject)
  {
   if(tobject)
   {
    tobject.style.color= "black"
    tobject.style.background = '#ffffff'
   }
  }
  
  //Detects what key was pressed
  function detectKeyPress(evt)
  {
   evt = (evt) ? evt : (window.event) ? event : null;
   if (evt)
   {
    var charCode = (evt.charCode) ? evt.charCode :
       ((evt.keyCode) ? evt.keyCode :
       ((evt.which) ? evt.which : 0));
    return charCode; 
   }
  }
  
  
  function lostfocus(oDiv)
  {
   if(document.getElementById(oDiv).style.visibility = 'visible')
   {
    document.getElementById(oDiv).style.visibility = 'hidden';
	document.getElementById(oDiv).style.display = 'none';
    _ai=0;
   } 
  }
/*

//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");
	}
}

//Our XmlHttpRequest object to get the auto suggest
var searchReq = getXmlHttpRequestObject();

//Called from keyup on the search textbox.
//Starts the AJAX request.
function searchSuggest() {
	if (searchReq.readyState == 4 || searchReq.readyState == 0) {
		var str = escape(document.getElementById('txtSearch').value);
		searchReq.open("GET", 'searchSuggest.php?search=' + str, true);
		searchReq.onreadystatechange = handleSearchSuggest; 
		searchReq.send(null);
	}		
}

//Called when the AJAX response is returned.
function handleSearchSuggest() {
	if (searchReq.readyState == 4) {
		var ss = document.getElementById('search_suggest')
		ss.innerHTML = '';
		var str = searchReq.responseText.split("\n");
		for(i=0; i < str.length - 1; i++) {
			//Build our element string.  This is cleaner using the DOM, but
			//IE doesn't support dynamically added attributes.
			var suggest = '<div onmouseover="javascript:suggestOver(this);" ';
			suggest += 'onmouseout="javascript:suggestOut(this);" ';
			suggest += 'onclick="javascript:setSearch(this.innerHTML);" ';
			suggest += 'class="suggest_link">' + str[i] + '</div>';
			ss.innerHTML += suggest;
		}
	}
}

//Mouse over function
function suggestOver(div_value) {
	div_value.className = 'suggest_link_over';
}
//Mouse out function
function suggestOut(div_value) {
	div_value.className = 'suggest_link';
}
//Click function
function setSearch(value) {
	document.getElementById('txtSearch').value = value;
	document.getElementById('search_suggest').innerHTML = '';
}
*/
