function check_frm_ricerca(redirect, tiporicerca)
{
	switch (tiporicerca)
	{
	case "1":
		var testo=""; 
		try	{ testo=document.frm_menu.strRicerca1.value;}
		catch (e){testo="";}
		window.location = redirect+"&tiporicerca=1&strRicerca1="+testo + "&RicInt1=1";			
		break;	
	case "2":
		var frm=document.frmCambio
		termine1=frm.strRicerca1.value
		termine2=frm.strRicerca2.value
		termine3=frm.strRicerca3.value
		sel1 = frm.sel1[frm.sel1.selectedIndex].value 
		sel2 = frm.sel2[frm.sel2.selectedIndex].value		
		frm.RicInt[0].checked ? Ric1=1 : Ric1=0; 
		frm.RicInt[1].checked ? Ric2=1 : Ric2=0; 
		frm.RicInt[2].checked ? Ric3=1 : Ric3=0; 
		//if (!vuoto(termine1) || !vuoto(termine2) || !vuoto(termine3))
		//{
			window.location = redirect	+ "&tiporicerca=2" + "&strRicerca1=" + termine1 + "&strRicerca2=" + termine2 + "&strRicerca3=" + termine3 + "&sel1=" + sel1 + "&sel2=" + sel2 + "&RicInt1=" + Ric1 + "&RicInt2=" + Ric2 + "&RicInt3=" + Ric3
		//}	
		break;
	}
}

function MM_openBrWindow(theURL, winName, features, width, height, bReturnObject)
{ 
	var window_width;
	var window_height;

	if(!width) 
			window_width = (screen.width/2)+150;
	else
		window_width = width;

	if(!height) 
		window_height = (screen.height/2)+130;
	else
		window_height = height;
			
	var window_top = (screen.height-window_height)/2;
	var window_left = (screen.width-window_width)/2;
	var newfeatures = features+",width="+window_width+",height="+window_height+",top="+window_top+",left="+window_left
	objWindow = window.open(theURL,winName,newfeatures);
	if(typeof(objWindow)=='object') { 
		objWindow.focus(); 
	} else {
		alert('Attenzione! Attivare popup!');
	}
	if (bReturnObject)
	{
		return objWindow;
	}
}

function BrowserSniff(){
	if (document.layers) return "NS";
	if (document.all) return "IE";
	if (document.getElementById) return "MOZ";
	return "OTHER";
}

function printit(){ 
	var Browser = BrowserSniff();
	switch( Browser ) {
		case 'NS':
			return; 
			break;
		case 'IE':
			var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
			document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
			WebBrowser1.ExecWB(6, 2);   
			WebBrowser1.outerHTML = "";  
			break;
		case 'MOZ':
			window.print(); 
			break;
		case 'OTHER':
			return;
			break;
	}
}

function addBookmark(title,url) {
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}

function homepage(url) { 
	if(document.all) {
		try
		{
			document.body.style.behavior='url(#default#homepage)';
			document.body.setHomePage(url);
		}
		catch (e)
		{
			var testo = "";
			testo += "Per Internet Explorer fino alla versione 4: \n";
			testo += "- Dal menu 'Visualizza' andare su 'Opzioni Internet'\n";
			testo += "- Nella cartella 'Generale' premere il pulsante 'Pagina Corrente'\n\n";
			testo += "PER NETSCAPE versione 4 o superiore, seguire questi passi: \n";
			testo += "- Dal menu 'Modifica' andare a 'Preferenze'\n";
			testo += "- Nella finestra di dialogo selezionare 'Navigator'\n";
			testo += "- Premere il pulsante 'Usa pagina corrente'";
			alert(testo);
		}
	}
} 

function mailThisUrl(){
   u = window.location;
   m = "Ti segnalo questo sito";
   campo=prompt("Inserisci l'e-mail:","")
   if(campo) window.location = "mailto:"+campo+"?subject="+m+"&body="+document.title+" "+u;
}

var _sLinkOver;
function LinkOver() {
	status=_sLinkOver; 
	return true;
}

function LinkOut() {
	status='';
}

function impostaPaginaWeb(sLinkText) {
	var thelinks = document.links;

	_sLinkOver = sLinkText;
	status =_sLinkOver;
	for (var j = 0; j < thelinks.length; j++) {
			if(document.links[j].name!='NORESET') {
				//thelinks[j].onmouseover = LinkOver;  	//modificato da Simone
				//thelinks[j].onmouseout = LinkOut;		//modificato da Simone
			}
		}
}

function vuoto (stringa) {
  return ((stringa == null)||(stringa.length==0))
}

function compatta (stringa) {
  s = new String('');
  for (i = 0; (stringa.charAt(i)==' ')&&(i<stringa.length); i++);
  for (j = stringa.length-1; (stringa.charAt(j)==' ')&&(j>=0); j--);
  s = stringa.substr(i,j-i+1);  
  return s;
}


function is_email_lingua(campo,label) {
	if (window.RegExp) {
		s = campo.value;
		var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)|(')";
		var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
		var regnv = new RegExp(nonvalido);
		var regv = new RegExp(valido);
		if (!regnv.test(s) && regv.test(s)) {
			return true;
		}
		else {
		  alert(label);
		  return errore(campo);
		}
	}
	else {
	  s = compatta(campo.value);
	  if (!vuoto(s)) {
		h = s.indexOf('@');
		if (h==-1) {
		  alert(label);
		  return errore(campo);
	  }
	  else {
		i = s.length
		if ((i==h) || (h==0)) {          /* se è stata omessa la user */
		  alert(label); 
		  return errore(campo);
		}
		else {
		  dominio = compatta(s.substr(h+1,i-(h+1)));
		  k = dominio.indexOf('.');
		  if (k == -1) {                 /* dominio non valido */
			alert(label);  /* non rispetta il    */ 
			return errore(campo);        /* formato "yyyy.xx"  */
		  }
		  else
			if (k == 0) {                      /* dominio di secondo */
			  alert(label);   /* livello non valido */
			  return errore(campo);         /* manca "yyyy."       */
			}
			else { 
			  dominio2 = compatta(dominio.substr(k+1,dominio.length-(k+1)));
			  
			  if (dominio2.length < 2) {        /* dominio non valido */
				alert(label);     /* manca ".xxx"       */
				return errore(campo);
			  }
			}
		  }
		}
	  }
	  return true;
	}
}

function ctrl_obbl(campo, label)
{
    s = compatta(campo.value);
    if (vuoto(s)) 
    {
      alert('Il campo '+label+' non puo\' essere lasciato vuoto');
      return errore(campo);
    }
    return true;
}

function ctrl_obbl_lingua(campo, label)
{
    s = compatta(campo.value);
    if (vuoto(s)) 
    {
      alert(label);
      return errore(campo);
    }
    return true;
}

