//STRINGHE PER AUTOCOMPLETAMENTO FORM REGISTRAZIONE -->
function lookup(citta) {
		if(citta.length == 0) {
			// nascondo il DIV senza caratteri
			$('#suggestions').hide();
		} else {
			$.post("autocomp.php", {queryString: ""+citta+""}, function(data){
				if(data.length >0) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
				}
			});
		}
	} 

	function carica(citta,cap,pr) {
	var stringa = citta;
		$('#citta').val(stringa.replace("_"," "));
		$('#cap').val(cap);
		$('#pr').val(pr);
		setTimeout("$('#suggestions').hide();", 100);
	}	

	function chiudi() {
	  setTimeout("$('#suggestions').hide();", 1);
	}	

	
	//STRINGHE PER SUGGERIMENTO RICERCA AVANZATA ARTICOLI
function cercaava(stringa) {
			$.post("cerca_avanzata.php", {queryString: ""+stringa+""}, function(data){
				if(data.length >0) {
					$('#autoList').html(data);
				}
			});
		}
	
//slide
$(document).ready(function(){
	$(".freccia").click(function(){
	   $("#ricerca").slideToggle("slow");
		$(this).toggleClass("active"); 
		return false;
		 		
   });
});


//Bottoni Animati
$(document).ready(function () {
$("#azienda").mouseover(function () {
$(this).stop().animate({ marginTop: "-50px" }, 100 );
});
$("#azienda").mouseout(function () {
$(this).stop().animate({ marginTop: "-45px" }, 100 );
});
});

$(document).ready(function () {
$("#prodotti").mouseover(function () {
$(this).stop().animate({ marginTop: "-50px" }, 100 );
});
$("#prodotti").mouseout(function () {
$(this).stop().animate({ marginTop: "-45px" }, 100 );
});
});

$(document).ready(function () {
$("#contatti").mouseover(function () {
$(this).stop().animate({ marginTop: "-50px" }, 100 );
});
$("#contatti").mouseout(function () {
$(this).stop().animate({ marginTop: "-45px" }, 100 );
});
});

$(document).ready(function () {
$("#offerte").mouseover(function () {
$(this).stop().animate({ marginTop: "-50px" }, 100 );
});
$("#offerte").mouseout(function () {
$(this).stop().animate({ marginTop: "-45px" }, 100 );
});
});

//DIV
function Esegui(ID)   {

document.getElementById("popup").style.visibility = "hidden";
document.getElementById("pop_ric").style.visibility = "hidden";


		for (i=1; i<=11; i++) {
			document.getElementById("D"+i).style.visibility = "hidden";
			document.getElementById("D"+i).style.position = "absolute";
		}
		
		switch (ID)  { 
				case 1: 
					document.body.style.overflow="hidden";
				break; 	
				case 2: 
					document.body.style.overflow="auto";
				break;
				case 3: 
					document.body.style.overflow="hidden";
				break;
				case 4: 
					document.body.style.overflow="hidden";
				break;
				case 5: 
					document.body.style.overflow="auto";
				break;
				case 6: 
					document.body.style.overflow="hidden";
				break;
				case 7: 
					document.body.style.overflow="auto";
					document.getElementById("carrel").src = 'carrello.php';
				break; 
				case 8: 
					document.body.style.overflow="hidden";
				break; 
				case 9: 
					document.body.style.overflow="auto";
				break; 
				case 10: 
					document.body.style.overflow="hidden";
				break; 
				case 11: 
					document.body.style.overflow="hidden";
				break;
			default: 
				document.body.style.overflow="hidden"; 

		}		
			
	document.getElementById("D" + ID).style.visibility = "visible";
}


//gestione CATALOGO
function catalogo(pag)  { 
NewWin=window.open(['catalogo/'+pag+'_catalogo.pdf#navpanes=0&toolbar=0&statusbar=0&location=0'] ,"Catalogo","resizable=yes,scrollbars=yes,location=0,top=0,left=0,width=800,height=600,toolbar=0,status=0,title=0")
} 

//funzione solo numeri aggiunta nella pagina del catalogo per inserire solo cifre nel campo qta
function soloNumeri(vnt)  { 
var tasto,carattereTasto;
if (window.event) //Modello ad eventi IE
tasto = window.event.keyCode;
else 
if (vnt) //Modello ad eventi NN
tasto = vnt.which;
else 
return true;

carattereTasto = String.fromCharCode(tasto);

if ((tasto==null) || (tasto==0) || (tasto==8) ||(tasto==9) || (tasto==13) || (tasto==27) )
return true;
else 
if ((('0123456789').indexOf(carattereTasto) > -1))
{
window.status = ""; 
return true;
}
else
{
window.status = 'Il campo accetta solo numeri';
return false; 
}
}

function toppage()   {
window.location.hash = "#top";

}

function centra(div)  {
var timeout = null;
	
	var DIVwidth = $(div).width();	
	var DIVheight = $(div).height();
	var SCREENwidth = $(document).width();
	var SCREENheight = $(window).height();	
	var SCREENscrolltop = $(window).scrollTop();
	$(div).animate({   
		top: (SCREENheight-DIVheight)/2+SCREENscrolltop+"px",
		left: (SCREENwidth-DIVwidth)/2+"px"
	},90);
	timeout = setTimeout("centra('"+div+"')",100);
	
}

function top_index()  {
	//funzione che porta al top della pagina principale. Viene richiamata dalla index.php in <body onload="centra('#popup');top_index();">
	//e' stata usta anche in opera.php per rimanere in top quando si sceglie il pagamento o le varie funzioni varia/elimina
	setTimeout('window.scrollTo(0, 0)',1);

}
	
function chiudi_form()  {
parent.document.getElementById('D2').style.visibility = 'visible';
parent.document.getElementById('pop_ric').style.visibility = 'hidden';
}


function AutoCompleteDate_DDMMAAAA(obj)
	{
		// controlla se vengono inseriti solo numeri
		var sKeyPressed;
		sKeyPressed = new String(event.keyCode);
		if (event.keyCode < 48 || event.keyCode > 57)
		{
			event.keyCode = 0;
		}
		else
		{
			if (obj.value.length == 2)
			{
				obj.value += "/";
			}
			else if (obj.value.length == 5)
			{
				obj.value += "/";
			}
			else if (obj.value.length > 9)
			{
			var selText = (document.all) ? document.selection.createRange().text : document.getSelection();
				if( selText.length == 0 )
				{
					// lunghezza max del campo
					event.keyCode = 0;
				}
			}
		}
	}


