var OP_InstallSoftware_msg  = "Verifica aggiornamenti software in corso...";
var OP_TimeAlign_msg        = "Allineamento data e ora...";
var OP_DotNetCheck_msg		= "Verifica versione .Net Framework...";
//  
//  INSTALAZIONE ACROBAT READER
//  
function OP_InstallAcrobat()
{
	window.showModalDialog("dshpg_stuff/omnistation/op_acroinst.htm","","dialogWidth:600px;dialogHeight:400px;resizable:yes;status:no;titlebar:no"); 
}
//  
//  INSTALAZIONE .NET
//  
function OP_InstallNET()
{
	window.showModalDialog("dshpg_stuff/omnistation/op_netinst.htm","","dialogWidth:600px;dialogHeight:400px;resizable:yes;status:no;titlebar:no"); 
}
//  
//  INSTALLAZIONE JVM
//  
function OP_InstallJVM()
{
	location = "dshpg_stuff/omnistation/op_msjavx86.exe";
}
//  
//  INSTALLAZIONE GRIGLIA SHERIDAN
//  
function OP_InstallGrid()
{
	location = "dshpg_stuff/omnistation/op_grid.exe";
}
//  
//  INSTALAZIONE CERTIFICATO 
//  
function OP_InstallCertificate()
{
	location = "dshpg_stuff/omnistation/" + window.CertificateName;
}
//  
//  CONTROLLA AGGIORNAMENTI CIRIO
//  
function OP_NeedSWUpdate()
{
    try{
		var p = new ActiveXObject("CIRIO.KeyManager.1");
		var v = p.GetVersion();
		debug( "CIRIO.GetVersion retcode: " + v );
		return v != window.CirioVersion;
	}
	catch(e){
	    debug( "CIRIO.GetVersion exception: " + e.description );
		return true;
	}
}
//  
//  VERIFICA VERSIONE .NET
//  
function OP_CheckDotNetFramework()
{
	var s = window.navigator.userAgent.toUpperCase();
	var i=-1;

	while( (i = s.indexOf(".NET CLR",i+1)) >= 0 )
	{
		try
		{
			var version = Number(s.substr(i+9,3));
			debug( "OP_CheckDotNetFramework.version: " + version );
			if ( version > 1 )
				return true;
		}
		catch(e)
		{
			debug( "OP_CheckDotNetFramework.version error: " + s.substr(i+9,3) );
		}
	}
	debug( "OP_CheckDotNetFramework.failed." );
	return false;
}
//  
//  INSTALLA CIRIO
//  
function OP_InstallSoftware()
{
	location = "dshpg_stuff/omnistation/op_swupd.exe";
	Init();
}
//
// CANVASS GIUGNO 2006: INSTALLA LETTORE PINPAD
//
//  
function OP_InstallLettoreCarta()
{
	location = "dshpg_stuff/omnistation/openpad.exe";
	Init();
}


//  
//  ALLINEAMENTO DATA/ORA
//  
function OP_TimeAlign()
{
    try{
		var p = new ActiveXObject("CIRIO.KeyManager.1");					
		p.SetDateTime( window.ServerTime.getUTCFullYear(), window.ServerTime.getUTCMonth()+1, window.ServerTime.getUTCDate(), window.ServerTime.getUTCHours(), window.ServerTime.getUTCMinutes(), window.ServerTime.getUTCSeconds() );
		return true;
	}
	catch(e){
	    debug( "CIRIO.SetDateTime exception: " + e.description );
	    return false;
	}
}
//
//  ACCESSO X OMNISTATION
//
function OP_AccessControls()
{
    //  check software update
    opupgrade_txt.style.display="";
    if ( OP_NeedSWUpdate() )
    {
        opupgrade_alert.style.display="";
        accessfail_div.style.display = "";
        return;
    }
    else opupgrade_txt.innerText += "OK";

    //  time align
    optmalign_txt.style.display="";
    optmalign_txt.innerText += OP_TimeAlign() ? "OK" : "KO";
    
    //	dotnet check
    optdotnetcheck_txt.style.display="";
    if ( !OP_CheckDotNetFramework() )
    {
	    optdotnetcheck_txt.innerText = "Attenzione: non è possibile accedere ad OPEN in quanto non è installato il software .Net. Per installarlo seguire le istruzioni presenti nella welcome page al link SOFTWARE .NET";
	    //accesswarn_div.style.display = "";
	    accessfail_div.style.display = "";
	     return;
    }
    else optdotnetcheck_txt.innerText += "OK";

	Enter();
}
function OP_Enter()
{
	if ( window.IsDebug )
		Enter();

    //  mostra pagina 
    default_div.style.display="none";
    op_access_div.style.display="";

    opupgrade_txt.innerText = OP_InstallSoftware_msg;
    optmalign_txt.innerText = OP_TimeAlign_msg;
    optdotnetcheck_txt.innerText = OP_DotNetCheck_msg;

    //  tardo un secondo x permettere refresh video
    setTimeout("OP_AccessControls()",1000);
}















