//------------------------------------------------------------------------------------
// analisi del browser
var ns4 = (navigator.appName == 'Netscape' && parseInt(navigator.appVersion) == 4);
var ns6 = (document.getElementById)? true:false;
var ie4 = (document.all)? true:false;
if (ie4) var docRoot = 'document.body';
var ie5 = false;

//------------------------------------------------------------------------------------
if (ie4) 
{
	if ((navigator.userAgent.indexOf('MSIE 5') > 0) || (navigator.userAgent.indexOf('MSIE 6') > 0)) 
	{
		if(document.compatMode && document.compatMode == 'CSS1Compat') docRoot = 'document.documentElement';
		ie4 = false;
		ie5 = true;
	}
	if (ns6) 
	{
		ns6 = false;
	}
}

//------------------------------------------------------------------------------------
function verificaSeVisibile(obj)
{
  if(obj==null) 
  {
   window.status = "verificaSeVisibile() - oggetto non valido";
   return false;
  }
	
	if (ns4)
	{
	 if(obj.visibility=="show") return true;
	}
	
	if (ie4) 
	{
	 if(obj.visibility=="visible") return true;
	}
	
	if (ie5)
	{
	 if(obj.style.visibility=="visible") return true;
	}
	
	if (ns6)
	{
	 if(obj.style.visibility=="visible") return true;
	}
	
	// oggetto non visibile o non trovato
	return false;
}

//------------------------------------------------------------------------------------
// visualizza un oggetto
function visualizza(obj) 
{
  if(obj==null) 
  {
   window.status = "visualizza() - oggetto non valido";
   return;
  }
	
	if (ns4) obj.visibility = "show";
	else if (ie4) obj.visibility = "visible";
	else if (ie5) obj.style.visibility = "visible";
	else if (ns6) obj.style.visibility = "visible";
	else window.status = "visualizza() - browser non supportato";
}

//------------------------------------------------------------------------------------
// nasconde un oggetto
function nascondi(obj) 
{
  if(obj==null) 
  {
   window.status = "nascondi() - oggetto non valido";
   return;
  }
  
	if (ns4) obj.visibility = "hide";
	else if (ie4) obj.visibility = "hidden";
	else if (ie5) obj.style.visibility = "hidden";
	else if (ns6) obj.style.visibility = "hidden";
  else window.status = "nascondi() - browser non supportato";
}
//------------------------------------------------------------------------------------
function settaVisibilita(objref,stato)
{
 if(stato==1) visualizza(objref);
 else	nascondi(objref); 
}
//------------------------------------------------------------------------------------
// restituisce un oggetto in base all'ID
function getOggettoPerID(nome) 
{
 if (ns4) return document.elements[nome];
 if (ie4) return document.all[nome];
 if (ie5) return document.all[nome];
 if (ns6) return document.getElementById(nome);
}

//------------------------------------------------------------------------------------
// muove un layer
function spostaLayer(obj,xL,yL)
{
 spostaLeftLayer(obj,xL);
 spostaTopLayer(obj,yL);
}
//------------------------------------------------------------------------------------
// muove un layer
function spostaLeftLayer(obj,xL)
{
	if((ns4) || (ie4))
	{
		obj.left = (ie4 ? xL + 'px' : xL);
	} 
	else 
	if(ns6||ie5)
	{
		obj.style.left = xL + "px";
	}
}
//------------------------------------------------------------------------------------
// muove un layer
function spostaTopLayer(obj,yL)
{
	if((ns4) || (ie4))
	{
		obj.top = (ie4 ? yL + 'px' : yL);
	} 
	else 
	if(ns6||ie5)
	{
		obj.style.top = yL+ "px";
	}
}

//----------------------------------------------------------------------
function settaVisibilitaActiveXPagina(stato)
{
 var appoStato = stato;
 
 // controlla se un layer di attesa è visualizzato
 var layerDiAttesa = getOggettoPerID("layerDiAttesa");
 if(layerDiAttesa)
 {
  var layVis = verificaSeVisibile(layerDiAttesa);
  if(layVis==true) appoStato = 0; // il layer di attesa è visualizzato, mantiene nascosti gli oggetti
 }
  
 // imposta lo stato corretto
 settaVisibilitaOggettiLista(document.getElementsByTagName("select"),appoStato);
 settaVisibilitaOggettiLista(document.getElementsByTagName("object"),appoStato); 
}

//----------------------------------------------------------------------
function settaVisibilitaOggettiLista(lista,stato)
{
 if(lista!=null)
 {
  for(var i=0;i<lista.length;i++)
  { 
   settaVisibilita(lista[i],stato);   
  }
 }
}

//------------------------------------------------------------------------------------
// dimensiona un layer
function ridimensionaLayer(obj,larghezza,altezza)
{
 ridimensionaLarghezzaLayer(obj,larghezza);
 ridimensionaAltezzaLayer(obj,altezza);
}

//------------------------------------------------------------------------------------
// dimensiona un layer
function ridimensionaLarghezzaLayer(obj,larghezza)
{
	if((ns4) || (ie4))
	{
		obj.width = (ie4 ? larghezza + 'px' : larghezza);
	} 
	else 
	if(ns6||ie5)
	{
		obj.style.width = larghezza + "px";
	}
}
//------------------------------------------------------------------------------------
// dimensiona un layer
function ridimensionaLarghezzaPercentualeLayer(obj,larghezza)
{
	if((ns4) || (ie4))
	{
		obj.width = (ie4 ? larghezza + '%' : larghezza);
	} 
	else 
	if(ns6||ie5)
	{
		obj.style.width = larghezza + "%";
	}
}
//------------------------------------------------------------------------------------
// dimensiona un layer
function ridimensionaAltezzaLayer(obj,altezza)
{
	if((ns4) || (ie4))
	{
		obj.height = (ie4 ? altezza + 'px' : altezza);
	} 
	else 
	if(ns6||ie5)
	{
		obj.style.height = altezza+ "px";
	}
}

//------------------------------------------------------------------------------------
// Carica un'immagine in un DIV
function caricaImmagineInDIV(over,pic)
{
	if(pic == "") 
	{
		if (ns4) over.background.src = null;
		if (ie4) over.backgroundImage = "none";
		if (ns6) over.style.backgroundImage = "none";
	} 
	else 
	{
		if(ns4)
		{
			over.background.src = pic;
		} 
		else 
		 if(ie4)
		 {
	 		over.backgroundImage = "url("+pic+")";
 		 }
		 else
		  if(ns6 || ie5) 
		  {
			 over.style.backgroundImage = "url("+pic+")";
		  }
	} 
}
//------------------------------------------------------------------------------------
// Carica un'immagine in un DIV
function scriviInLayer(over,testo)
{
 if(over) over.innerHTML = testo;
}


//------------------------------------------------------------------------------------
function lanciaAttesa(nomeLayer,nomeBarra)
{
 var titolettoAttesa = "NINJACROSS WEB ENGINE INFO";
 var contenutoTabella = "...PROCESSING REQUEST...<br>"+getCodiceHTMLBarraIncrementale(nomeBarra,"90%","20","ColEstBordoBarraTimeOut","ColEstBarraTimeOut","ColIntBordoBarraTimeOut","ColIntBarraTimeOut","barraAttesa")+"<br><table><tr><td class=\"CellaAzioneTabellaGenerica\"><a href=\"JavaScript:var appo=settaLayerDiAttesa(0);\">STOP !</a></td></tr></table>";
 var desc = "<table class=\"LayerDiAttesa\" cellspacing=\"4\" cellpadding=\"4\" border=\"0\" width=\"100%\" height=\"100%\">"+
	           "<tr><td height=\"20\" class=\"TitoloTabellaGenerica\"><span class=\"DescrizioneDescrittore\">"+titolettoAttesa+"</span></td><td width=\"20\" class=\"TitoloTabellaGenerica\" align=\"center\"><table><tr><td class=\"CellaAzioneTabellaGenerica\"><a href=\"JavaScript:var appo=settaLayerDiAttesa(0);\">X</a></td></tr></table></td></tr>"+
	           "<tr><td colspan=\"2\" height=\"100%\" class=\"CellaTestoTabellaGenerica\" align=\"center\"><span class=\"DescrizioneDescrittore\">"+contenutoTabella+"</span></td></tr>"+
             "</table>";

 scriviInLayer(layerDiAttesa,desc);
 var larg1 = screen.width/3; 
 var alt1 = 200;
 ridimensionaLayer(layerDiAttesa,larg1,alt1);
 spostaLayer(layerDiAttesa,larg1,55);
 settaVisibilitaActiveXPagina(0);
 settaVisibilita(getOggettoPerID(nomeLayer),1);
 // lancia l'animazione della barra di progressione
 var barra1 = new BarraIncrementale(getOggettoPerID(nomeBarra),100,20000);
 barra1.start();
}
//------------------------------------------------------------------------------------
function settaLayerDiAttesa(mode)
{
 if(isNaN(mode)) return;
 var layerDiAttesa = getOggettoPerID("layerDiAttesa");
 // prosegue solo se trova un layer
 if(layerDiAttesa) 
 {
	// se voglio chiuderlo, lo faccio subito
  if(mode==0) 
  {
   settaVisibilita(layerDiAttesa,0);
   scriviInLayer(layerDiAttesa,"");
   settaVisibilitaActiveXPagina(1);
  }
  else // se voglio visualizzarlo, aspetto il tempo di delay
  {
   //window.setTimeout("lanciaAttesa('layerDiAttesa','barraAttesa');",2000);
lanciaAttesa('layerDiAttesa','barraAttesa');
  }
 }
}

//------------------------------------------------------------------------------------
function getCodiceHTMLBarraIncrementale(nomeOgg,larg,alt,stileColoreBordoEsterno,stileColoreEsterno,stileColoreBordoInterno,stileColoreInterno)
{
	var codiceTabella = "";
	codiceTabella += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\""+stileColoreBordoEsterno+"\" height=\""+alt+"\" width=\""+larg+"\"><tr><td class=\""+stileColoreEsterno+"\" align=\"center\">\n";
	codiceTabella += "<table border=\"0\" cellspacing=\"0\" id=\""+nomeOgg+"\" width=\"0\" height=\"100%\" class=\""+stileColoreBordoInterno+"\"><tr><td class=\""+stileColoreInterno+"\"></td></tr></table>\n";
	codiceTabella += "</td></tr></table>\n";  
	return codiceTabella;
}

//------------------------------------------------------------------------------------
function BarraIncrementale(refO,stepTempo,maxTempo)
{
 var tempo=0;
 
 function settalarghezzaPercentuale(valorePerc)
 {
   if(valorePerc<1)valorePerc=1;
   if(valorePerc>100)valorePerc=100;
   if(refO)
   {
    ridimensionaLarghezzaPercentualeLayer(refO,valorePerc);
   }
 }
 
 function step()
 {
 
  try
  {
   tempo+=stepTempo;
   if(tempo>=maxTempo) tempo=0;
   else 
   {
    var appoVal = tempo/maxTempo*100;
    settalarghezzaPercentuale(appoVal);
   }
  // window.status = appoVal;
   window.setTimeout(step,stepTempo);
  }
  catch(e)
  {
  }	
 }
  
  function start()
  {	 
   window.setTimeout(this.step,stepTempo);
  }	 
  
 this.settalarghezzaPercentuale = settalarghezzaPercentuale;
 this.step=step;
 this.start=start;
}

//------------------------------------------------------------------------------------
function visualizzaHelpDinamico(testo,xpos,ypos)
{
 if(testo) 
 {
  HelpMePlease(1,testo,xpos,ypos,200,100);
 }
}
//------------------------------------------------------------------------------------
function chiudiHelpDinamico()
{
  HelpMePlease(0,"",0,0,0,0);
}
 
//------------------------------------------------------------------------------------
function HelpMePlease(mode,testo,xpos,ypos,Lwidth,Lheight)
{
 var layerDiHelp = getOggettoPerID("DynamicHelpLayer");
 if(!layerDiHelp) 
 {
  window.alert("Errore, help non trovato !");
  return;
 }   
// se voglio nascondere l'help, nascondo il layer e chiudo
if(mode==0) 
{ 
 nascondi(layerDiHelp);
 return;
}

 var desc = '';
 
 desc = desc + '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
 desc = desc + '<tr>';
 desc = desc + '<td width="1" height="1" valign="top" align="left"><img src="../../JS/frecsusx.gif" border="0"></td>';
 desc = desc + '<td align="left" valign="top">';
 desc = desc + '<table width="100%"  border="0" cellspacing="0" cellpadding="0">';
 desc = desc + '<tr>';
 desc = desc + '<td bgcolor="#ffffbb" width="1" height="1" style="border-top: 1px solid #666666;"><table border="0" width="100%" height="100%"><tr><td></td></tr></table></td>';
 //desc = desc + '<td bgcolor="#ffffbb"> </td>';
 desc = desc + '<td bgcolor="#ffffbb" width="1" height="1" style="border-top: 1px solid #666666;"><table border="0" width="100%" height="100%"><tr><td></td></tr></table></td>';
 desc = desc + '<td align="right" valign="top" height="1" width="1"><img src="../../JS/curvsudx.gif" border="0"></td>';
 desc = desc + '</tr>';
 desc = desc + '<tr>';
 desc = desc + '<td bgcolor="#ffffbb" width="1" height="1"><table width="100%" height="100%" style="border-left: 1px solid #666666;"><tr><td></td></tr></table></td>';
 desc = desc + '<td bgcolor="#ffffbb"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><b>';
 desc = desc + testo;
 desc = desc +'</b></font></td>';
 //desc = desc + '<td bgcolor="#ffffbb" width="1" height="1"> </td>';
 desc = desc + '<td bgcolor="#ffffbb" height="1" width="1" style="border-right: 1px solid #666666;"><table border="0" width="100%" height="100%"><tr><td></td></tr></table></td>';
 desc = desc + '</tr>';
 desc = desc + '<tr>';
 desc = desc + '<td valign="bottom" align="left" width="1" height="1"><img src="../../JS/curvgiusx.gif" border="0"></td>';
 //desc = desc + '<td bgcolor="#ffffbb"> </td>';
 desc = desc + '<td bgcolor="#ffffbb" width="1" height="1" style="border-bottom: 1px solid #666666;"><table border="0" width="100%" height="100%"><tr><td></td></tr></table></td>';
 desc = desc + '<td align="right" valign="bottom" height="1" width="1"><img src="../../JS/curvgiudx.gif" border="0"></td>';
 desc = desc + '</tr>';
 desc = desc + '</table>';
 desc = desc + '</td>';
 desc = desc + '</tr>';
 desc = desc + '</table>';
 

 scriviInLayer(layerDiHelp,desc);
 visualizza(layerDiHelp);
 ridimensionaLayer(layerDiHelp,Lwidth,Lheight);
 spostaLayer(layerDiHelp,xpos,ypos);
} 

//------------------------------------------------------------------------------------
// colori suddivisi per categoria
var coloreLinguaggio='#663399';
var coloreFramework='#009900';
var coloreDownload='#0000ff';
var coloreAPI='#ff9900';
var coloreAltro='#ff0000';

//------------------------------------------------------------------------------------
// LINGUE
function getBandieraItalianaParametrica(larghezza,altezza)
{
 return '<table width="'+larghezza+'" height="'+altezza+'" border="0" cellpadding="1" cellspacing="0" bgcolor="#FFFFFF"><tr><td><table height="100%" width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000"><tr><td bgcolor="#009900"></td><td bgcolor="#FFFFFF"></td><td bgcolor="#FF0000"></td></tr></table></td></tr></table>';
}

//------------------------------------------------------------------------------------
function getBandieraAmericanaParametrica(larghezza,altezza)
{
 return '<table width="'+larghezza+'" height="'+altezza+'" border="0" cellpadding="1" cellspacing="0" bgcolor="#FFFFFF"><tr><td height="20%"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000"><tr><td height="20%" rowspan="3" align="center" valign="middle" bgcolor="#0000FF"></td><td bgcolor="#FF0000" height="20%"></td></tr><tr><td bgcolor="#FFFFFF" height="20%"></td></tr><tr><td bgcolor="#FF0000" height="20%"></td></tr><tr><td colspan="2" bgcolor="#FFFFFF" height="20%"></td></tr><tr><td colspan="2" bgcolor="#FF0000" height="20%"></td></tr></table></td></tr></table>';
}

//------------------------------------------------------------------------------------
function getBandieraAmericana()
{
 return getBandieraAmericanaParametrica(40,18);
}

//------------------------------------------------------------------------------------
function getBandieraItaliana()
{
 return getBandieraItalianaParametrica(40,18);
}

//------------------------------------------------------------------------------------
function getRiquadroSimbolo(larghezza,altezza,testo,dimensioniTesto,coloreTesto,argomenti)
{
 var retStr = '';
 var testa = '<table width="'+larghezza+'" height="'+altezza+'" border="0" cellpadding="1" cellspacing="0" bgcolor="#FFFFFF"><tr><td><table height="100%" width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000"><tr><td align="center" valign="middle" bgcolor="#ffffff">';
 var corpo = '<font color="'+coloreTesto+'" size="'+dimensioniTesto+'" face="Verdana, Arial, Helvetica, sans-serif"><strong>'+testo+'</strong></font>';
 var coda = '</td></tr></table></td></tr></table>';

 retStr=retStr+testa;
 if(argomenti.length==0) retStr=retStr+'<a href="JavaScript:apriLegendaSimboli();">';
 retStr=retStr+corpo
 if(argomenti.length==0) retStr=retStr+'</a>';
 retStr=retStr+coda;
 
 return retStr;
}

//------------------------------------------------------------------------------------
// LINGUAGGI DI PROGRAMMAZIONE
function getSimboloCPP()
{
  return getRiquadroSimbolo(40,18,'CPP',1,coloreLinguaggio,getSimboloCPP.arguments);
}

//------------------------------------------------------------------------------------
function getSimboloCSharp()
{
  return getRiquadroSimbolo(40,18,'C#',1,coloreLinguaggio,getSimboloCSharp.arguments);
}

//------------------------------------------------------------------------------------
function getSimboloJS()
{
 return getRiquadroSimbolo(40,18,'JS',1,coloreLinguaggio,getSimboloJS.arguments);
}

//------------------------------------------------------------------------------------
// PIATTAFORME E FRAMEWORKS
function getSimboloWin32()
{
  return getRiquadroSimbolo(40,18,'W32',1,coloreFramework,getSimboloWin32.arguments);
}

//------------------------------------------------------------------------------------
function getSimboloDotNET()
{
  return getRiquadroSimbolo(40,18,'.NET',1,coloreFramework,getSimboloDotNET.arguments);
}

//------------------------------------------------------------------------------------
// RISORSE SCARICABILI/VISUALIZZABILI
function getSimboloDownload()
{
 return getRiquadroSimbolo(40,18,'[D]',1,coloreDownload,getSimboloDownload.arguments);
}

//------------------------------------------------------------------------------------
function getSimboloZIP()
{
  return getRiquadroSimbolo(40,18,'ZIP',1,coloreDownload,getSimboloZIP.arguments);
}

//------------------------------------------------------------------------------------
function getSimboloUML()
{
  return getRiquadroSimbolo(40,18,'UML',1,coloreDownload,getSimboloUML.arguments);
}

//------------------------------------------------------------------------------------
function getSimboloWMF()
{
  return getRiquadroSimbolo(40,18,'WMF',1,coloreDownload,getSimboloWMF.arguments);
}

//------------------------------------------------------------------------------------
function getSimboloPDF()
{
 return getRiquadroSimbolo(40,18,'PDF',1,coloreDownload,getSimboloPDF.arguments);
}

//------------------------------------------------------------------------------------
// API E LIBRERIE
function getSimboloOpenGL()
{
 return getRiquadroSimbolo(40,18,'OGL',1,coloreAPI,getSimboloOpenGL.arguments);
}

//------------------------------------------------------------------------------------
function getSimboloDX()
{
 return getRiquadroSimbolo(40,18,'DX',1,coloreAPI,getSimboloDX.arguments);
}

//------------------------------------------------------------------------------------
function getSimboloDInput()
{
 return getRiquadroSimbolo(40,18,'DIn',1,coloreAPI,getSimboloDInput.arguments);
}

//------------------------------------------------------------------------------------
function getSimboloD3D()
{
 return getRiquadroSimbolo(40,18,'D3D',1,coloreAPI,getSimboloD3D.arguments);
}

//------------------------------------------------------------------------------------
// ALTRO
function getSimboloWWW()
{
 return getRiquadroSimbolo(40,18,'WWW',1,coloreAltro,getSimboloWWW.arguments);
}

//------------------------------------------------------------------------------------
function getSimboloW3C()
{
 return getRiquadroSimbolo(40,18,'W3C',1,coloreAltro,getSimboloW3C.arguments);
}

//------------------------------------------------------------------------------------
function apriLegendaSimboli()
{
 window.open("Skin/legenda.htm","LEGENDA","width=750,height=380,resizable,scrollbars");
}

//------------------------------------------------------------------------------------
function apriDisclaimerCopyright()
{
 window.open("Skin/copyright.htm","COPYRIGHT_AND_INTELLECTUAL_PROPERTY","width=550,height=300,resizable,scrollbars");
}
