var xmlhttp;
var current_query;
var current;

function hide_hints_industries(id)
{
clear_selections_industries();
document.getElementById(id).style.display = 'none';
}


function showHint_industries(str,t,type)
{
	if(document.getElementById('toggle_type').checked)
	{
	var id = 'input-'+type;
	var suggest_id = 'suggest-'+type;
	
		if (str.length==0)
		{
		clear_search(id);
		clear_selections_industries();
		document.getElementById(suggest_id).style.display = 'none';
		document.getElementById(suggest_id).innerHTML="";
		return;
		} else {
		show_clear(id);
		}
	  
	xmlhttp=GetXmlHttpObject_industries();
	
		if (xmlhttp==null)
		{
		//  alert ("Your browser does not support XMLHTTP!");
		return;
		}
	  
		if(str !== current_query)
		{
		clear_selections_industries();
		current_query = str;
		var url="/ff_search/find_matches.php";
		url=url+"?q="+str;
		url=url+"&t="+t;
	
	
		//url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=stateChanged_industries;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
		}
	}
	
}

function stateChanged_industries()
{
if (xmlhttp.readyState==4)
  {
  	if(xmlhttp.responseText !== 'No suggestions.')
  	{
	document.getElementById("suggest-find").style.display = 'block';
	document.getElementById("suggest-find").innerHTML=xmlhttp.responseText;
	} else {
	document.getElementById("suggest-find").style.display = 'none';
	document.getElementById("suggest-find").innerHTML="";
	}
  }
}

function GetXmlHttpObject_industries()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}







function choose_suggestion_industries(suggestion)
	{
	var data = explode(';', suggestion);
		
//	document.getElementById("postcode").value = data[1];

	document.getElementById("suggest-find").style.display = 'none';
	document.getElementById("suggest-find").innerHTML="";
	document.getElementById('input-find').value = data[0];
	}
	
	
	
	
	
var selected_industry = 0;
	
function checkArrows_industries (field, evt) 
	{
	var keyCode = 
    document.layers ? evt.which :
    document.all ? event.keyCode :
    document.getElementById ? evt.keyCode : 0;

  
	  	if((keyCode == 40) || (keyCode == 38))
	  	{
	  	
			if(document.getElementById('industries-suggestions'))
			{
		  	
			var parent = document.getElementById('industries-suggestions');
			var childCount = parent.getElementsByTagName('li').length;
		  
				if (keyCode == 40) //down
				{
				n = selected_industry + 1;
			    } else if (keyCode == 38) { //up
				n = selected_industry - 1;
				}
				
				if(n < 1)
				{
				n = childCount;
				} else if(n > childCount) {
				n = 1;
				}
				
			highlight_selection_industries(n);
			}
			
		}
	
	}

function clear_selections_industries()
	{
	selected_industry = 0;
	
		if(document.getElementById('industries-suggestions'))
		{
		var parent = document.getElementById('industries-suggestions');
		var childCount = parent.getElementsByTagName('li').length;
		var n = 1;
		
			while (n <= childCount)
			{
			document.getElementById('industries-suggestion'+n).style.backgroundPosition = '0 0';
			n++;
			}

		
		}
	
	}


function highlight_selection_industries(n)
	{
	clear_selections_industries();

	selected_industry = n;
	document.getElementById('industries-suggestion'+n).style.backgroundPosition = '-165px 0';
	}