{
debug = false;
var continuaCaricamento = true;
var browserError = false;
var osError = false;
var helpexpress1x = true;
dominioMail = new Array(4);
dominioMail[0] = "@tin.it";
dominioMail[1] = "@virgilio.it";
dominioMail[2] = "@tim.it";
dominioMail[3] = "@alice.it";
serverPOP3 = new Array(5);
serverPOP3[0] = "box.tin.it";
serverPOP3[1] = "box.clubnet.tin.it";
serverPOP3[2] = "in.virgilio.it";
serverPOP3[3] = "box.posta.tim.it";
serverPOP3[4] = "in.alice.it";
serverSMTP = new Array(5);
serverSMTP[0] = "mail.tin.it";
serverSMTP[1] = "mail.clubnet.tin.it";
serverSMTP[2] = "out.virgilio.it";
serverSMTP[3] = "mail.posta.tim.it";
serverSMTP[4] = "out.alice.it";
messaggioInstallaHE = "<strong>HELP<font color=\"#f77310\">Express 2.x</font></strong> non installato.<br><br><form action='/helpexpress2/files/he2lth.zip' method='get' onsubmit=\"alert('Dopo aver scaricato il file di installazione, chiudere Internet Explorer prima di installare HelpExpress.'); return true;\"><center><input type='submit' value='Installa Ora!' class='testo11' style='width: 100px;height: 20px; font-weight: bold;'></center></form>";
messaggioAggiornaHE = "Per sfruttare le nuove funzionalita' presenti sul sito devi aggiornare <strong>HELP<font color=\"#f77310\">Express</font></strong> alle versione <b>2.x</b>.<br><br><form action='/helpexpress2/files/he2lthup.zip' method='get' onsubmit=\"alert('Dopo aver scaricato il file di aggiornamento, chiudere Internet Explorer prima di aggiornare HelpExpress.'); return true;\"><center><input type='submit' value='Aggiorna ora!' class='testo11' style='width: 100px;height: 20px; font-weight: bold;'></center></form>";
messaggioBrowserHE = "Browser non supportato.<br>Le nuove funzionalitą di <strong>HELP<font color=\"#f77310\">Express</font></strong> integrate con il sito richiedono l'uso di Internet Explorer versione 5.5 o superiore.<br><br>";
messaggioSOHE = "<strong>S</strong>istema <strong>O</strong>perativo non supportato.<br>Le nuove funzionalitą di <strong>HELP<font color=\"#f77310\">Express</font></strong> integrate con il sito sono compatibili con Windows 98SE/ME/NT/2000/XP.<br><br>";
var posizioneX = 0;
var posizioneY = -200;
var posizioneDiPartenza = -200;
var fermaBanner = false;
}

function erroreFatale(messaggio, avviso, messaggioDebug, statisticheLayer)
{
	try
	{
		var messaggioVisualizzato = messaggio
		if ( (helpexpress1x) && (!osError) && (!browserError) && (messaggioInstallaHE == messaggio) )
		{
			messaggioVisualizzato = messaggioAggiornaHE;
		}
		if (statisticheLayer != null)
		{
			if ((messaggioVisualizzato != null) && (messaggioVisualizzato != ""))
				statisticheLayer.innerHTML = messaggioVisualizzato;
			else
				statisticheLayer.innerHTML = "Errore durante l'elaborazione";
		}
//		alert("avviso: " + avviso);
//		alert("continuaCaricamento: " + continuaCaricamento);
//		alert("osError: " + osError);
//		alert("browserError: " + browserError);
//		alert("(messaggioInstallaHE == messaggio): " + (messaggioInstallaHE == messaggio));
//		alert("messaggioInstallaHE: " + messaggioInstallaHE);
//		alert("messaggio: " + messaggio);
		if ( (avviso) && (!continuaCaricamento) && (!osError) && (!browserError) && (messaggioInstallaHE == messaggio) )
		{
			if (helpexpress1x)
				alert("HelpExpress non aggiornato.");
			else
				alert("HelpExpress non installato.");
		}
		else
		{
			if (avviso)
				alert("Si č verificato un errore.");
		}
		if ( (debug) && (messaggioDebug != null) && (messaggioDebug != "") )
			alert(messaggioDebug);
	}
	catch (e)
	{
		if (debug)
			alert("Exception erroreFatale(messaggio, avviso, messaggioDebug, statisticheLayer): [" + e.message + "]");
	}
}

function Trim(s)
{
	var risposta = "";
	try
	{
		if (s.length < 1)
		{
			risposta = "";
		}
		risposta = RTrim(s);
		risposta = LTrim(s);
	}
	catch (e)
	{
		if (debug)
			alert("Exception: verificaHE2(): [" + e.message + "]");
	}
	return risposta;
}

function verificaHE2()
{
	var risposta = false;
	try
	{
		//debug=true;
		var os = navigator.platform;
		
		if(os!="Win32" && os!="win16")
		{
			osError = true;
		}
		if ( (navigator.userAgent.indexOf("MSIE 6.") < 0) && (navigator.userAgent.indexOf("MSIE 5.") < 0) )
		{
			browserError = true;
		}
		if (navigator.userAgent.indexOf("Opera") != -1)
		{
			browserError = true;
		}
//		alert("mcciSM.IsCurrentSiteTrusted()" + mcciSM.IsCurrentSiteTrusted());
//		alert("APPKEY" + MotivePClient.GetVendorValue("GlobalSettings/APPKEY"));
//		alert("Server" + MotivePClient.GetVendorValue("ContactInfo_TinItHE/Server"));
		if ( (continuaCaricamento) && (!osError) && (!browserError) && (mcciSM.IsCurrentSiteTrusted()) && (MotivePClient.GetVendorValue("GlobalSettings/APPKEY") == "TinItHE") && ( (MotivePClient.GetVendorValue("ContactInfo_TinItHE/Server") == "helpexpress.virgilio.it") || (MotivePClient.GetVendorValue("ContactInfo_TinItHE/Server") == "motivecont1.ca.tin.it") || (MotivePClient.GetVendorValue("ContactInfo_TinItHE/Server") == "tinlab.motivedev.tin.it") ) )
		{
			risposta = true;
		}
//		alert("risposta: " + risposta);
	}
	catch (e)
	{
		if (debug)
			alert("Exception: verificaHE2(): [" + e.message + "]");
	}
	return risposta;
}
function onSecurityManagerLoadError()
{
	continuaCaricamento = false;
	if (debug)
		alert("Impossibile caricare Security Manager (McciSMX) ActiveX Control");
}

function onMailClientConfigHelperLoadError()
{
	continuaCaricamento = false;
	if (debug)
		alert("Impossibile caricare MailClientConfigHelper parte di McciAppsX ActiveX Control");
}

function onMailNewsAccountParametersLoadError()
{
	continuaCaricamento = false;
	if (debug)
		alert("Impossibile caricare MailNewsAccountParameters parte di McciAppsX ActiveX Control");
}

function onMailClientTypesLoadError()
{
	continuaCaricamento = false;
	if (debug)
		alert("Impossibile caricare MailClientTypes parte di McciAppsX ActiveX Control");
}

function onMcciNetSMTPLoadError()
{
	continuaCaricamento = false;
	if (debug)
		alert("Impossibile caricare IMcciNetSMTP parte di McciNetX ActiveX Control");
}

function onMcciNetMessageDataLoadError()
{
	continuaCaricamento = false;
	if (debug)
		alert("Impossibile caricare IMcciNetMessageData parte di McciNetX ActiveX Control");
}
function onMcciNetPOP3LoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare IMcciNetPOP3 parte di McciNetX ActiveX Control");
}

function onMotivePClientLoadError()
{
	continuaCaricamento = false;
	helpexpress1x = false;
	if (debug)
	    alert("Impossibile caricare MotivePClient Motive Client Control");
}

function onMotiveCommunicationsLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare MotiveCommunications Motive Client Control");
}

function onRegManagerLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare RegManager Motive Client Control");
}

function onWebBrowserConfigHelperLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare WebBrowserConfigHelper Motive Client Control");
}

function onIESecurityZonesLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare IESecurityZones Motive Client Control");
}


function onIESecuritySettingsLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare IESecuritySettings Motive Client Control");
}

function onIESecuritySettingValuesLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare IESecuritySettingValues Motive Client Control");
}

function onWebBrowserTypesLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare BrowserTypes Motive Client Control");
}

function onProxyServerProtocolsLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare ProxyServerProtocols Motive Client Control");
}

function onIEPrivacySettingTemplatesLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare IEPrivacySettingTemplates Motive Client Control");
}

function OnSysNetNetworkLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare OnSysNetNetworkLoadError Motive Client Control");
}

function onMcciSysNetAdapterCriteriaConstantError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare onMcciSysNetAdapterCriteriaConstantError Motive Client Control");
}

function onMcciSysNetHardwareStatusConstantError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare onMcciSysNetHardwareStatusConstantError Motive Client Control");
}

function onMcciNetPingLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare onMcciNetPingLoadError Motive Client Control");
}

function onMcciDialLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare onMcciDialLoadError Motive Client Control");
}

function onMcciPhoneBookLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare onMcciPhoneBookLoadError Motive Client Control");
}

function onMcciPhoneBookEntryLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare onMcciPhoneBookEntryLoadError Motive Client Control");
}

function onMcciSysProcessLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare onMcciSysProcessLoadError Motive Client Control");
}

function onMcciUtilsFileProcessorLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare onMcciUtilsFileProcessorLoadError Motive Client Control");
}

function onMcciUtilsFile2LoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare onMcciUtilsFile2LoadError Motive Client Control");
}

function onMcciUtilsSpecialFolderLoadError()
{
	continuaCaricamento = false;
	if (debug)
	    alert("Impossibile caricare onMcciUtilsSpecialFolderLoadError Motive Client Control");
}

function apriTestSpeed()
{
	if (continuaCaricamento)
		document.location.href = "velox.jsp";
	else
		alert("Impossibile aprire la pagina.");
}

function apriTestPosta()
{
	if (continuaCaricamento)
		document.location.href = "posta.jsp";
	else
		alert("Impossibile aprire la pagina.");
}

function apriAltreImpostazioni()
{
	if (continuaCaricamento)
		document.location.href = "altreImpostazioni.jsp";
	else
		alert("Impossibile aprire la pagina.");
}

function apriElencoIncident()
{
	if (continuaCaricamento)
		document.location.href = "incidentList.jsp";
	else
		alert("Impossibile aprire la pagina.");
}

function verificaArray(s, a)
{
	risposta = false;
	var i=0;
	while ( (i<a.length) && (!risposta) )
	{
		risposta = (a[i] == s);
		i++;
	}
	return risposta;
}

function GetMailClientName(mailClientID)
{
	try
	{
	    if (mailClientID == mailclients.OUTLOOK)
	        return "Outlook";
	    else if (mailClientID == mailclients.OE)
	        return "Outlook Express";
	    else if (mailClientID == mailclients.MSN)
	        return "MSN Explorer";
	    else if (mailClientID == mailclients.NS4)
	        return "Netscape 4.x";
	    else if (mailClientID == mailclients.NS6)
	        return "Netscape 6.x";
	    else if (mailClientID == mailclients.NS7)
	        return "Netscape 7.x";
	    else
	        return "Unknown";
	}
	catch (e)
	{
		if (debug)
			alert("Exception GetMailClientName(mailClientID): [" + e.message + "]");
	}
}

function bannerHE2()
{
	try
	{
//		continuaCaricamento = false;
//		helpexpress1x = true;
//		osError = true;
//		browserError = true;
		
//		if (verificaIpADSL())
		if (false)
		{
			if (verificaHE2())
			{
				var listaIncidenti = MotivePClient.GetIncidentList();
				var arrayIncidenti = listaIncidenti.toArray();
				var numIncAperti = 0;
//				setCookie("VerificaHelpExpress","1");
				for(var i=0; i < arrayIncidenti.length; i++)
				{
					if ( (arrayIncidenti[i].state < 6) && (arrayIncidenti[i].state > 2) )
					{
						numIncAperti++;
					}
				}
				if (numIncAperti > 0)
				{
					if (numIncAperti == 1)
						statisticheLayer.innerHTML = "Hai <b>" + numIncAperti + "</b> segnalazione aperta.<br><br><a href='/helpexpress2/objIncidentList.jsp' class='testo11'><b>Vai all'elenco delle segnalazioni</b></a>.<br><br>";
					else
						statisticheLayer.innerHTML = "Hai <b>" + numIncAperti + "</b> segnalazioni aperte.<br><br><a href='/helpexpress2/objIncidentList.jsp' class='testo11'><b>Vai all'elenco delle segnalazioni</b></a>.<br><br>";
					var txtObj = document.all ? document.all["divStatisticheLayer"] : null;
					txtObj.style.visibility = "visible";
					avanzaBanner();
				}	
			}
			else
			{
				if (helpexpress1x)
					messaggioErroreHome = "Per sfruttare le nuove funzionalita' presenti sul sito devi aggiornare <strong>HELP<font color=\"#f77310\">Express</font></strong> alle versione <b>2.x</b>.<br><br><form action='/helpexpress2/files/he2lthup.zip' method='get' onsubmit=\"alert('Dopo aver scaricato il file di aggiornamento, chiudere Internet Explorer prima di aggiornare HelpExpress.'); chiudiBanner(); return true;\"><center><input type='submit' value='Aggiorna ora!' class='testo11' style='width: 100px;height: 20px; font-weight: bold;'></center></form>";
				else
				messaggioErroreHome = "<B>Installa subito</B> il software di assistenza per poter sfruttare tutto le potenzialitą del sito Help.<br><br><form action='/helpexpress2/files/he2lth.zip' method='get' onsubmit=\"alert('Dopo aver scaricato il file di installazione, chiudere Internet Explorer prima di installare HelpExpress.'); chiudiBanner(); return true;\"><center><input type='submit' value='Installa ora!' class='testo11' style='width: 100px;height: 20px; font-weight: bold;'></center></form>";
				if ( (!continuaCaricamento) && (!osError) && (!browserError) )
				{
					erroreFatale(messaggioErroreHome, false, "", statisticheLayer);
					var txtObj = document.all ? document.all["divStatisticheLayer"] : null;
					txtObj.style.visibility = "visible";
//					setCookie("VerificaHelpExpress","0");
					avanzaBanner();
				}
				else
				{
//					setCookie("VerificaHelpExpress","-1");
				}
			}
		}
	}
	catch (e)
	{
		erroreFatale("", true, "Exception bannerHE2(): [" + e.message + "]", statisticheLayer);
	}
}

function avanzaBanner()
{
	try
	{
		var txtObj = document.all ? document.all["divStatisticheLayer"] : null;
		if (posizioneY == posizioneDiPartenza)
		{
			posizioneX = parseInt(document.body.clientWidth / 2) - 85;
			txtObj.style.top = posizioneY + "px";
			txtObj.style.left = posizioneX + "px";
		}
		if ((posizioneY < 50) && (!fermaBanner) )
		{
			posizioneY = posizioneY + 3;
			txtObj.style.top = posizioneY + "px";
			setTimeout("avanzaBanner()", 20);
		}
		else
		{
			if (!fermaBanner)
				setTimeout("chiudiBanner()", 20000);
		}
	}
	catch (e)
	{
		erroreFatale("", true, "Exception avanzaBanner(): [" + e.message + "]", statisticheLayer);
	}
}

function chiudiBanner()
{
	try
	{
		var txtObj = document.all ? document.all["divStatisticheLayer"] : null;
		txtObj.style.visibility = "hidden";
		fermaBanner = true;
	}
	catch (e)
	{
		erroreFatale("", true, "Exception chiudiBanner(): [" + e.message + "]", statisticheLayer);
	}
}

function setCookie(name, value, days)
{
	var risposta = false;
	try
	{
		if (days == "0")
		{
			document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
		}
		else
		{
			var expire = new Date();
			expire.setTime(expire.parse() + (60*60*24*days*1000));
			document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
		}
		risposta = true;
	}
	catch(e)
	{
		risposta = false;
	}
	return risposta;
}

function getCookie(Name)
{
	var risposta = null;
	try
	{
		var search = Name + "="
		if (document.cookie.length > 0)
		{
			offset = document.cookie.indexOf(search);
			if (offset != -1)
			{
				offset += search.length;
				end = document.cookie.indexOf(";", offset);
				if (end == -1)
					end = document.cookie.length;
				risposta = unescape(document.cookie.substring(offset, end))			
			}
		}
	}
	catch(e)
	{
		risposta = null;
	}
	return risposta;
}

// ARRAY DEGLI INDIRIZZI DIALUP
var dialup_dx=new Array()
var dialup_sx=new Array()
dialup_sx[0] = '212.171.128.0';  dialup_dx[0] = '212.171.255.255';
dialup_sx[1] = '213.45.128.0';  dialup_dx[1] = '213.45.230.255';
dialup_sx[2] = '213.45.232.0';  dialup_dx[2] = '213.45.255.255';
dialup_sx[3] = '212.216.128.0';  dialup_dx[3] = '212.216.171.255'; 
dialup_sx[4] = '212.216.184.0';  dialup_dx[4] = '212.216.255.255';
dialup_sx[5] = '62.211.68.200';  dialup_dx[5] = '62.211.68.204';
// FINE ARRAY DEGLI INDIRIZZI DIALUP
// ARRAY DEGLI INDIRIZZI ADSL
var adsl_dx = new Array()
var adsl_sx = new Array()

adsl_sx[0] = '212.216.0.0';  adsl_dx[0] = '212.216.111.255'; 
adsl_sx[1] = '212.216.120.0';  adsl_dx[1] = '212.216.127.255';
adsl_sx[2] = '212.171.0.0';  adsl_dx[2] = '212.171.127.255';
adsl_sx[3] = '213.45.0.0';  adsl_dx[3] = '213.45.127.255';
adsl_sx[4] = '213.45.231.0';  adsl_dx[4] = '213.45.231.255';
adsl_sx[5] = '62.211.0.0';  adsl_dx[5] = '62.211.63.0';
adsl_sx[6] = '62.211.80.0';  adsl_dx[6] = '62.211.255.255';
adsl_sx[7] = '80.116.0.0';  adsl_dx[7] = '80.116.255.255';
adsl_sx[8] = '80.117.0.0';  adsl_dx[8] = '80.117.255.255';
adsl_sx[9] = '80.180.0.0';  adsl_dx[9] = '80.180.255.255';
adsl_sx[10] = '80.181.0.0';  adsl_dx[10] = '80.181.255.255';
adsl_sx[11] = '80.183.0.0';  adsl_dx[11] = '80.183.255.255';
adsl_sx[12] = '82.48.0.0';  adsl_dx[12] = '82.48.255.255';
adsl_sx[13] = '82.49.0.0';  adsl_dx[13] = '82.49.255.255';
adsl_sx[14] = '82.50.0.0';  adsl_dx[14] = '82.50.255.255';
adsl_sx[15] = '82.51.0.0';  adsl_dx[15] = '82.51.255.255';
adsl_sx[16] = '82.52.0.0';  adsl_dx[16] = '82.52.255.255';
adsl_sx[17] = '82.53.0.0';  adsl_dx[17] = '82.53.255.255';
adsl_sx[18] = '82.54.0.0';  adsl_dx[18] = '82.54.255.255';
adsl_sx[19] = '82.55.0.0';  adsl_dx[19] = '82.55.255.255';
adsl_sx[20] = '82.56.0.0';  adsl_dx[20] = '82.56.255.255';
adsl_sx[21] = '82.57.0.0';  adsl_dx[21] = '82.57.255.255';
adsl_sx[22] = '82.58.0.0';  adsl_dx[22] = '82.58.255.255';
adsl_sx[23] = '82.59.0.0';  adsl_dx[23] = '82.59.255.255';
adsl_sx[24] = '82.60.0.0';  adsl_dx[24] = '82.60.255.255';
adsl_sx[25] = '82.61.0.0';  adsl_dx[25] = '82.61.255.255';
adsl_sx[26] = '82.62.0.0';  adsl_dx[26] = '82.62.255.255';
adsl_sx[27] = '82.63.0.0';  adsl_dx[27] = '82.63.255.255';
adsl_sx[28] = '80.142.0.0';  adsl_dx[28] = '80.142.255.255';
adsl_sx[29] = '83.214.0.0';  adsl_dx[29] = '83.214.255.255';
adsl_sx[30] = '80.182.0.0';  adsl_dx[30] = '80.182.255.255';
adsl_sx[31] = '194.243.154.250';  adsl_dx[31] = '194.243.154.250';
// FINE ARRAY DEGLI INDIRIZZI ADSL

// FUNZIONE CONVERTE IN DECIMALE IP
function recupera_ip(ip)
{
	var risposta = false;
	try
	{
		Primopunto = ip.indexOf('.');
		Secondopunto = ip.indexOf('.',Primopunto + 1);
		Terzopunto = ip.indexOf('.',Secondopunto + 1);
		byte1 = ip.substring(0,Primopunto);
		byte2 = ip.substring(Primopunto+1,Secondopunto);
		byte3 = ip.substring(Secondopunto+1,Terzopunto);
		byte4 = ip.substring(Terzopunto+1,ip.length);
		var oct1=byte1;
		var oct2=byte2;
		var oct3=byte3;
		var oct4=byte4;
		risposta = eval(oct1*16777216) + eval(oct2*65536) + eval(oct3*256) + eval(oct4);
	}
	catch(e)
	{
		risposta = null;
	}
	return risposta;
}
// FUNZIONE CHECK RANGE
function controllarange (ipdx, ipsx, myip)
{
	risposta = false;	
	try
	{
		my_ip = recupera_ip (myip);
		ipdx = recupera_ip (ipdx);
		ipsx = recupera_ip (ipsx);
		if ((my_ip>=ipsx)&&(my_ip<=ipdx))
		{
			risposta = true;
		}
	}
	catch(e)
	{
		risposta = null;
	}
	return risposta;
}

function verificaIpDialUp()
{
	// Controlla se č dialup
	risposta = false;	
	try
	{
		for (var i=0;i<6;i++)
		{
			if (controllarange(dialup_dx[i], dialup_sx[i], myip))
			{
				risposta = true;
				break;
			}
		}
	}
	catch(e)
	{
		risposta = null;
	}
	return risposta;
}

function verificaIpADSL()
{
	//controlla se č adsl
	risposta = false;	
	try
	{
		for (var i=0;i<32;i++)
		{
			if (controllarange(adsl_dx[i], adsl_sx[i], myip))
			{
				risposta = true;
				break;
			}
		}
	}
	catch(e)
	{
		risposta = null;
	}
	return risposta;
}


