// JavaScript Document

var oTextbox;

function inizia()
{
	//AUTOCOMPLETAMENTO	
	oTextbox = new AutoSuggestControl(document.getElementById("key"), new StateSuggestions()); 

}

function ricerca()
{
	if (document.getElementById("key"))
	{
		if (document.getElementById("key").value != "")
		{
			if (location.search.length > 0)
			{
				//location.href = "pagina.asp" + location.search + "&q=" + escape(document.getElementById("key").value);
				location.href = "pagina.asp" + location.search + "&id=0&q=" + document.getElementById("key").value;
			}
			else
			{
				//location.href = "pagina.asp" + "?q=" + escape(document.getElementById("key").value);
				location.href = "pagina.asp" + "?id=0&q=" + document.getElementById("key").value;
			}
		}
		document.getElementById("key").value = "";
	}
}

function checkEnter(e)
{ //e is event object passed from function invocation
	var characterCode; //literal character code will be stored in this variable
	
	if(e && e.which)
	{ //if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	}
	else
	{
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13)
	{ //if generated character code is equal to ascii 13 (if enter key)
		document.getElementById('cercavi').innerHTML = "<br /><br /><br />... ricerca in corso ...";
		document.getElementById('key').style.visibility = "hidden";
		ricerca(); //submit the form
		return false
	}
	else
	{
		return true
	}
}

function mostra_altre_ricerche(pagina)
{
	if (parseInt(pagina) == 1)
	{
		document.getElementById('altre1').style.backgroundImage = "url(images/tab.gif)";
		document.getElementById('risultato_altre1').style.display = "block";
	}
	else
	{
		document.getElementById('altre1').style.backgroundImage = "none";
		document.getElementById('risultato_altre1').style.display = "none";
	}
	
	if (parseInt(pagina) == 2)
	{
		document.getElementById('altre2').style.backgroundImage = "url(images/tab.gif)";
		document.getElementById('risultato_altre2').style.display = "block";
	}
	else
	{
		document.getElementById('altre2').style.backgroundImage = "none";
		document.getElementById('risultato_altre2').style.display = "none";
	}	

	if (parseInt(pagina) == 3)
	{
		document.getElementById('altre3').style.backgroundImage = "url(images/tab.gif)";
		document.getElementById('risultato_altre3').style.display = "block";
	}
	else
	{
		document.getElementById('altre3').style.backgroundImage = "none";
		document.getElementById('risultato_altre3').style.display = "none";
	}	
	
	if (parseInt(pagina) == 4)
	{
		document.getElementById('altre4').style.backgroundImage = "url(images/tab.gif)";
		document.getElementById('risultato_altre4').style.display = "block";
	}
	else
	{
		document.getElementById('altre4').style.backgroundImage = "none";
		document.getElementById('risultato_altre4').style.display = "none";
	}

}

function accendi_altre_ricerche(pagina)
{
	if (parseInt(pagina) == 1)
	{
		document.getElementById('altre1').style.color = "#2396D0";
	}
	if (parseInt(pagina) == 2)
	{
		document.getElementById('altre2').style.color = "#2396D0";
	}
	if (parseInt(pagina) == 3)
	{
		document.getElementById('altre3').style.color = "#2396D0";
	}
	if (parseInt(pagina) == 4)
	{
		document.getElementById('altre4').style.color = "#2396D0";
	}			
}

function spegni_altre_ricerche(pagina)
{
	if (parseInt(pagina) == 1)
	{
		document.getElementById('altre1').style.color = "#EEEEEE";
	}
	if (parseInt(pagina) == 2)
	{
		document.getElementById('altre2').style.color = "#EEEEEE";
	}
	if (parseInt(pagina) == 3)
	{
		document.getElementById('altre3').style.color = "#EEEEEE";
	}
	if (parseInt(pagina) == 4)
	{
		document.getElementById('altre4').style.color = "#EEEEEE";
	}			
}

function nascondi_parametro(numero)
{
	if (parseInt(numero) == 1)
	{
		document.getElementById('parametro1').style.textDecoration = "line-through";
	}
	if (parseInt(numero) == 2)
	{
		document.getElementById('parametro2').style.textDecoration = "line-through";
	}
	if (parseInt(numero) == 3)
	{
		document.getElementById('parametro3').style.textDecoration = "line-through";
	}
	if (parseInt(numero) == 4)
	{
		document.getElementById('parametro4').style.textDecoration = "line-through";
	}
	if (parseInt(numero) == 5)
	{
		document.getElementById('parametro5').style.textDecoration = "line-through";
	}
	if (parseInt(numero) == 6)
	{
		document.getElementById('parametro6').style.textDecoration = "line-through";
	}
	if (parseInt(numero) == 7)
	{
		document.getElementById('parametro7').style.textDecoration = "line-through";
	}
	if (parseInt(numero) == 8)
	{
		document.getElementById('parametro8').style.textDecoration = "line-through";
	}
	if (parseInt(numero) == 9)
	{
		document.getElementById('parametro9').style.textDecoration = "line-through";
	}								
}

function mostra_parametro(numero)
{
	if (parseInt(numero) == 1)
	{
		document.getElementById('parametro1').style.textDecoration = "none";
	}
	if (parseInt(numero) == 2)
	{
		document.getElementById('parametro2').style.textDecoration = "none";
	}
	if (parseInt(numero) == 3)
	{
		document.getElementById('parametro3').style.textDecoration = "none";
	}
	if (parseInt(numero) == 4)
	{
		document.getElementById('parametro4').style.textDecoration = "none";
	}
	if (parseInt(numero) == 5)
	{
		document.getElementById('parametro5').style.textDecoration = "none";
	}
	if (parseInt(numero) == 6)
	{
		document.getElementById('parametro6').style.textDecoration = "none";
	}
	if (parseInt(numero) == 7)
	{
		document.getElementById('parametro7').style.textDecoration = "none";
	}
	if (parseInt(numero) == 8)
	{
		document.getElementById('parametro8').style.textDecoration = "none";
	}
	if (parseInt(numero) == 9)
	{
		document.getElementById('parametro9').style.textDecoration = "none";
	}								
}

function findPosX(obj)
{
var curleft = 0;
if(obj.offsetParent)
	while(1) 
	{
	  curleft += obj.offsetLeft;
	  if(!obj.offsetParent)
		break;
	  obj = obj.offsetParent;
	}
else if(obj.x)
	curleft += obj.x;
return curleft;
}
