$(function(){

	
	speed = 1;

	$('.down-list').width($('.dropdown-menu').width()-2);

    $('.dropdown-menu').hover(
    		function () {
	    			$('.menu-first', this).addClass('slide-down'); 
	    			$('.down-list', this).css({'display' : 'block'});
    		}, 
    		function () {
    			obj = this;
    			$('.menu-first', obj).removeClass('slide-down'); 
    			$('.down-list', this).css({'display' : 'none'});
    		}
    	);
	
	$('.menu-first').hover(
		function () {
				$('.down-list-child').css({'display' : 'none'});
		}
	);	
	
	$('.down-list .parentList').hover(
		function () {
			$('.down-list-child').css({'display' : 'none'});
			$(this).toggleClass('menuOver');
			if($(this).hasClass('lastLI'))	{
				$(this).parent().toggleClass('down-list-lastLI');
			}
			if($(this).hasClass('parent'))	{
				var top = $(this).offset().top - 126;
				$('.down-list-child', this).attr("style", "top:"+top+"px").slideDown(1);
			}
		}, 
		function () {
			$(this).toggleClass('menuOver');
			if($(this).hasClass('lastLI'))	{
				$(this).parent().toggleClass('down-list-lastLI');
			}
		}
	);
	
	
	$('.down-list-child li').hover(
		function () {
				$(this).toggleClass('menuOver');
				if($(this).hasClass('lastLI'))	{
					$(this).parent().toggleClass('down-list-lastLI');
				}		
		}, 
		function () {
			$(this).toggleClass('menuOver');
			if($(this).hasClass('lastLI'))	{
				$(this).parent().toggleClass('down-list-lastLI');
			}
		}
	);
	
	$('.down-list-child li').css({'list-style' : 'none'});
	$('.down-list li').css({'list-style' : 'none'});
	
	$("#cerca").autocomplete({
			source: availableTags
	});
});

function checkEnter(e){
	var characterCode;
	if(e && e.which){ 
		e = e
		characterCode = e.which 
	}
	else{
		e = event
		characterCode = e.keyCode
	}
	if(characterCode == 13 && $("#cerca").attr('value')!="Cerca all'interno del sito" && $("#cerca").attr('value')!=""){
		$("#doc_ricerca").submit();			
	}
}

function chk_ricerca(){
	if($("#cerca").attr('value')=="Cerca all'interno del sito")
		$("#cerca").attr('value','');
}

function checkRicerca(){
	if($("#cerca").attr('value')!="" && $("#cerca").attr('value')!="Cerca all'interno del sito")
		$("#doc_ricerca").submit();
}

function banner_click(parametro_click){
	_gaq.push(["_trackEvent", "AbbonatiInfostrada", parametro_click]);
	}

