function initMenu() {
  l = location.href;
  l = l.substr(l.lastIndexOf("/")+1).split(/[?#]/)[0];

  
  $('#menu ul').hide();
  $('#menu li a').click(
    function() {
        $(this).next().slideToggle('normal');	
      }
    );
  if(idivisione) {
    $('#menu li.'+ idivisione +' ul').show();
    $('#menu li.'+ idivisione +' ul li.ucat ul').hide();
    if(idcategoria) $('#menu li.'+ idivisione +' ul li#'+ idcategoria +' ul').show();
  }
  
  $('#fatture ul').hide();
  $('#fatture li a').click(
    function() {
        $(this).next().slideToggle('normal');	
      }
    );
}

function lookup(inputString) {
    if(inputString.length == 0) {
        $('#suggestions').hide();
		document.getElementById('suggestedImg').style.visibility = 'Hidden'; // MOSTRA IL LIVELLO
    } else {
        $.post("rpc.php", {queryString: ""+inputString+"", tvcc: ""+document.getElementById('tvcc').checked+"", rotor: ""+document.getElementById('rotor').checked+"", power: ""+document.getElementById('power').checked+""}, function(data){
            if(data.length >0) {
                $('#suggestions').show();
                $('#autoSuggestionsList').html(data);
            }
			else {
				$('#suggestions').hide();
				document.getElementById('suggestedImg').style.visibility = 'Hidden'; // MOSTRA IL LIVELLO
			}
        });
    }
} // lookup
function fill(thisValue) {
	$('#search').val(thisValue);
	$('#suggestions').hide();
}

function showImg(testo) {
	document.getElementById('suggestedImg').innerHTML = "<img src=\"images/products/"+ testo +".jpg\" />"; // IMPOSTA IL TESTO NEL LIVELLO
	document.getElementById('suggestedImg').style.visibility = 'Visible'; // MOSTRA IL LIVELLO
}
function hideImg() {
	document.getElementById('suggestedImg').style.visibility = 'Hidden'; // NASCONDE IL LIVELLO
}

$(document).ready(function() {initMenu();});
