function zoom(img, desc, x, y, scroll)
{
 var str="<img id=\"picture\" src=\"";
 str += img;
 str += "\"/>";

 var options = "scrollbars=no,resizable=no,status=no";
 if (scroll==1)
 {
  options = "scrollbars=yes,resizable=yes,status=no";
 }

 var w=window.open('','',options);

 if (navigator.appName=="Netscape")
 {
  w.name="Immagini";
  w.locationbar.visible=false;
  w.personalbar.visible=false;
  w.statusbar.visible=false;
  w.toolbar.visible=false;

  if (scroll==1)
   {
    w.scrollbars.visible=true;
    w.setResizable(true);
   }
   else
   {
    w.scrollbars.visible=false;
   }
  w.setResizable(false);
 }

 w.document.open();
 w.document.images.picture = new Image();
 w.document.images.picture.src = img;
 w.document.writeln("<html><head><title>Kosmos Club: immagini</title></head>");
 w.document.writeln("<body style=\"text-align:center;background-color:#efefef;overflow-y:scroll;\" onBlur=\"window.close()\";>");
 w.document.writeln(str);
 w.document.writeln("<hr width = 50% />");
 w.document.writeln("<p>"+desc+"</p>");
 w.document.writeln("</body></html>");

 if ((x < 1000) || (y < 800))
 {
  w.resizeTo(x + 30, y + 150);
 }
 else
 {
  w.resizeTo(800,600);
  w.scrollbars.visible=true;
  w.setResizable(true);
 }
 w.document.close();
}

function zoomVideo(szVideoPath, szDesc, bIsExternalStreaming)
{
  var w=window.open('', '', 'scrollbars=no,resizable=no,status=no');
  var szRealPath="";

  w.document.open();
  w.resizeTo(525, 500);

  w.document.writeln("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"); 
  w.document.writeln("<html xmlns=\"http://www.w3.org/1999/xhtml\">"); 
  w.document.writeln("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"); 
  w.document.writeln("<head><title>Kosmos Club - Video</title></head>");
  
  // Generazione della cornice
  w.document.writeln("<style type='text/css'>");
  w.document.writeln("#contenitore{");
  w.document.writeln("width:450px;");
  w.document.writeln("height:350px;");

  w.document.writeln("padding:25px;");
  w.document.writeln("}");
  w.document.writeln("</style>");
  
  w.document.writeln("<body style='text-align:center;background-color:#efefef;'>");
  w.document.writeln("<div id=\"contenitore\">");
  
  szRealPath = /*"/kosmos/video/" + */szVideoPath; // Da usarsi in locale
  // szRealPath = "http://www.kosmosclub.it/video/" + szVideoPath; // Versione online
  
  // Generazione dell'oggetto a seconda della sorgente di streaming
  if (bIsExternalStreaming == 1)
  {
    // Video presente su qualche servizio esterno, come YouTube
    // szVideoPath contiene semplicemente l'embed string al video
  }
  else
  {
    // Determiniamo l'estensione del file in base al tipo di browser
	// e creiamo l'ambiente relativo al player multimediale
    szRealPath += '.flv';
	
    w.resizeTo(525, 550);
	w.document.writeln("<object type=\"application/x-shockwave-flash\" data=\"player_flv_maxi.swf\" width=\"400\" height=\"300\">");
	w.document.writeln("<param name=\"movie\" value=\"player_flv_maxi.swf\" />"); // Versione locale

	//w.document.writeln("<object type=\"application/x-shockwave-flash\" data=\"http://www.kosmosclub.it/player_flv_maxi.swf\" width=\"400\" height=\"300\">");
	//w.document.writeln("<param name=\"movie\" value=\"http://www.kosmosclub.it/player_flv_maxi.swf\" />"); // Versione online

	w.document.writeln("<param name=\"allowFullScreen\" value=\"true\" />");
	w.document.writeln("<param name=\"FlashVars\" value=\"flv="+szRealPath+"\" />");
	w.document.writeln("</object>");
  }

  w.document.writeln("<hr width = 50% />");
  w.document.writeln("<p>" + szDesc + "</p>");

  w.document.writeln("<a href=\"" + szRealPath + "\">Scarica / apri questo file</a>");
  w.document.writeln("</div>");

  w.document.writeln("</body></html>");
  w.document.close();
}

function HintString(nIndex)
{
 // Stampa una breve descrizione di suggerimento in un box sotto il menu principale
 var Hint = new Array (14);
 Hint[0]="";
 Hint[1]="Pagina principale del sito: presentazione e alcuni cenni storici.";
 Hint[2]="L'archivio delle notizie relative all'Associazione, ordinate a partire dal 2003";
 Hint[3]="L'offerta delle arti marziali e delle discipline di combattimento";
 Hint[4]="Le offerte relative al fitness, alla danza, alla pesistica e all'allenamento in genere";
 Hint[5]="L'archivio fotografico e una raccolta di filmati relativi all'Associazione";
 Hint[6]="Gli orari dei corsi di Arti marziali, Fitness e Danza";
 Hint[7]="Il Direttore Tecnico G. Tucci, lo staff tecnico e l'organigramma del Kosmos Club e dell'A.R.T.U.";
 Hint[8]="Come raggiungere la sede dell'Associazione da Pisa, Lucca e Livorno";
 Hint[9]="Articoli scritti dai soci e recensioni sulle opere editoriali attinenti alle offerte dell'Associazione Kosmos Club";
 Hint[10]="Introduzione all'Associazione Reikika/Reikija Toscani, metodo Usui";
 Hint[11]="La mappa sensibile delle sezioni del sito, indicazioni per contattare la dirigenza";
 Hint[12]="Firmate il libro degli ospiti e consultate altri siti relativi ad arti marziali, sport di combattimento, danza e fitness";
 Hint[13]="";

 self.status = Hint[nIndex];
}

//domCorners by Alessandro Fulciniti - http://pro.html.it

function DomCheck()
{
 return(document.createElement && document.getElementById)
}

function DomCorners(id,bk,h,tries)
{
var el=document.getElementById(id);
if(el==null)
{
 if(tries==null) tries=200;
 if(tries>0)
  setTimeout("DomCorners('"+id+"','"+bk+"',"+h+","+(--tries)+")",50);
 return;
}

var c=new Array(4);
for(var i=0;i<4;i++)
{
 c[i]=document.createElement("b");
 c[i].style.display="block";
 c[i].style.height=h+"px";
 c[i].style.fontSize="1px";
 if(i%2==0)
  c[i].style.background="url("+bk+") no-repeat 0 -"+ i*h + "px";
 else
  c[i].style.background="url("+bk+") no-repeat 100% -"+ i*h + "px";
}
c[0].appendChild(c[1]);
c[2].appendChild(c[3]);
el.style.padding="0";
el.insertBefore(c[0],el.firstChild);
el.appendChild(c[2]);
}

function CreaLeftContent (szDisabled, bAddMenu)
{
  // Crea il menu di sinistra in base all'array preso dal file degli array (js)
  // Nel file sono contenuti gli array
  // rgMenuEntries - testo dei menu
  // rgMenuLinks   - collegamenti
  // rgMenuNot     - voci da non inserire
  // rgMenuTitles  - voci dei capitoli del menu (Articoli, Discipline ecc...)
  // szDisabled è il testo della voce da non inserire nella colonna, es. Il nome di una disciplina
  // quando siamo nella pagina della disciplina stessa
  // bAddMenu indica di aggiungere al menu la sezione delle ultime aggiunte
  // La variabile con suffisso N, omonima degli array (rg), contiene sempre il numero di elementi dell'array
  // Javascript by Dr. Ing. Mentore Siesto, settembre 2008

  var szPreamble = "<p class='leftcontent'><a href='";
  var szLinkEnd = "'>";
  var szEnd = "</a></p>";
  var szCommentStart = "<!-- ";
  var szCommentEnd = "-->";
  var szDirective = "";

  var nCount = 0;

  // Primo ciclo - argomenti della pagina
  szDirective = "<h2 class='leftcontent'>";
  szDirective += rgMenuTitles[1];
  szDirective += "</h2>";
  document.writeln (szDirective);

  for (nCount = 1; nCount <= rgMenuEntriesN; nCount ++)
  {
    if ((rgMenuEntries[nCount] != szDisabled) && (rgMenuNot[nCount] != 1))
    {
      // La voce di menu è fra quelle da abilitare
      szDirective = szPreamble;
      szDirective += rgMenuLinks[nCount];
      szDirective += szLinkEnd;
      szDirective += rgMenuEntries[nCount];
      szDirective += szEnd;

      // Inserimento della direttiva nel DIV
      document.writeln(szDirective);
    }
  }

  // Secondo ciclo (facoltativo) - ultime aggiunte
  if ((rgLastAddN > 0) && (bAddMenu == 1))
  {
    document.writeln ("<hr />");
    szDirective = "<h2 class='leftcontent'>";
    szDirective += rgMenuTitles[2];
    szDirective += "</h2>";
    document.writeln (szDirective);

    for (nCount = 1; nCount <= rgLastAddN; nCount ++)
    {
      // Non vi sono voci da disabilitare qui
      szDirective = szPreamble;
      szDirective += rgLastLinks [nCount];
      szDirective += szLinkEnd;
      szDirective += rgLastAdd [nCount];
      szDirective += szEnd;
      // Inserimento della direttiva nel DIV
      document.writeln(szDirective);
    }
  }

  // Terzo ciclo (facoltativo) - Notizie significative
  if ((rgExtraN > 0))
  {
    document.writeln ("<hr />");
    szDirective = "<h2 class='leftcontent'>";
    szDirective += rgMenuTitles[3];
    szDirective += "</h2>";
    document.writeln (szDirective);

    for (nCount = 1; nCount <= rgExtraN; nCount ++)
    {
      // Non vi sono voci da disabilitare qui
      szDirective = szPreamble;
      szDirective += rgExtraLinks [nCount];
      szDirective += szLinkEnd;
      szDirective += rgExtra [nCount];
      szDirective += szEnd;
      // Inserimento della direttiva nel DIV
      document.writeln(szDirective);
    }
  }
}

function CreaMenu (szCurrentSection)
{
  // Crea il menu principale della pagina, considerando la sezione per sapere cosa disabilitare
  // dinamicamente. Javascript by Dr. Ing. Mentore Siesto, settembre 2008

  // Elementi costanti da scegliere a seconda del tipo di tasto
  var szMenuStart = "<button class=\"menu\" onmouseover=\"HintString(";
  var szAppendActive = ");\" onmouseout=\"HintString(0);\" onclick=\"document.location=\'";
  var szEndActive = "\';\">";

  var szAppendDisabled = ");\" disabled>";
  var szRed = "Site_Images/red.gif";
  var szGreen = "Site_Images/green.gif";
  var szLed = "<img align='left' src = '";
  var szLedEnd = " '/>";
  var szMenuEnd = "</button>";
  var szPrefixD = ""; // Prefisso per le directory inferiori
  var szPrefixU = "../"; // Prefisso per la directory superiore

  var szDirective = "";
  var i = 1;


  for (i = 1; i <= nMenuEntries; i++)
  {
    szDirective = szMenuStart;
    szDirective += i;
    if (szCurrentSection == rgMenuLinks [i])
    {
      // Bottone da disabilitare
      szDirective += szAppendDisabled;
      szDirective += szLed;
      if (szCurrentSection != "Default.html")
        szDirective += "../";

      szDirective += szGreen;
      szDirective += szLedEnd;
      szDirective += rgMenuText[i];
      szDirective += szMenuEnd;
    }
    else
    {
      // Bottone attivo - decidere percorsi e varie
      szDirective += szAppendActive;
      if (szCurrentSection != "Default.html")
        szDirective += "../";

      szDirective += rgMenuLinks[i];
      szDirective += szEndActive;
      szDirective += szLed;
      if (szCurrentSection != "Default.html")
        szDirective += "../";

      szDirective += szRed;
      szDirective += szLedEnd;
      szDirective += rgMenuText[i];
      szDirective += szMenuEnd;
    }
    document.writeln (szDirective);
  }
}

function selectCSS (iLevel, iCol)
{
  // Seleziona il CSS da caricare e l'immagine di sfondo
  // determina il livello di annidamento per recuperare l'URI dell'immagine
  // Javascript by Dr. Ing. Mentore Siesto, sept 2010
  
  var szStagione;
  var szBrowser;
  var szRelPath;
  var szColonne;
  
  dToday = new Date ();
  var szMese = dToday.getMonth ();
  var szGiorno = dToday.getDate ();
  var szFirstColor, szLastColor;
  
  // Definizione dello sfondo in base alla stagione
  if ((szMese > 2) && (szMese < 5))
  {
    szStagione = "primavera";
  }  
  else if ((szMese >= 5) && (szMese < 8))
  {
    szStagione = "estate";
  }  
  else if ((szMese >= 8) && (szMese < 11))
  {
    szStagione = "autunno";
  }  
  else
  {
    szStagione = "inverno";
  }
  
  // Determiniamo il tipo di browser tramite user agent
  var ua = navigator.userAgent.toLowerCase();
  
  if ( ua.indexOf( "opera" ) != -1 ) 
  {
    szBrowser = "opera";
  }
  else if ( ua.indexOf( "msie" ) != -1 ) 
  {
    szBrowser = "ie";
  } 
  else if ( ua.indexOf( "safari" ) != -1 ) 
  {
    szBrowser = "safari";
  }
  else if ( ua.indexOf( "chrome" ) != -1 ) 
  {
    szBrowser = "chrome";
  }
  else
  {
    szBrowser = "mozilla";
  }
  
  // Determinazione directory dell'immagine di sfondo in base alla posizione del file
  switch (iLevel)
  {
    case 0:
      szRelPath = "./";
    break;
    case 1:
      szRelPath = "../";
    break;
    case 2:
      szRelPath = "../../";
    break;
    case 3:
      szRelPath = "../../../";
    break;
  }
  
  if (iCol == 1)
    szColonne = "1colonna";
  else
    szColonne = "2colonne";
    
  // Creazione dinamica del nome del CSS da caricare
  var szCSSPath = szRelPath + "css/" + szBrowser + "_" + szColonne + "_" + szStagione + ".css";
  
  document.writeln('<link type="text/css" rel="stylesheet" href="' + szCSSPath + '"/>');
}

// Tooltip in javascript
var tooltip=function(){
 var id = 'tt';
 var top = 3;
 var left = 3;
 var maxw = 300;
 var speed = 10;
 var timer = 20;
 var endalpha = 95;
 var alpha = 0;
 var tt,t,c,b,h;
 var ie = document.all ? true : false;
 return{
  show:function(v,w){
   if(tt == null){
    tt = document.createElement('div');
    tt.setAttribute('id',id);
    t = document.createElement('div');
    t.setAttribute('id',id + 'top');
    c = document.createElement('div');
    c.setAttribute('id',id + 'cont');
    b = document.createElement('div');
    b.setAttribute('id',id + 'bot');
    tt.appendChild(t);
    tt.appendChild(c);
    tt.appendChild(b);
    document.body.appendChild(tt);
    tt.style.opacity = 0;
    tt.style.filter = 'alpha(opacity=0)';
    document.onmousemove = this.pos;
   }
   tt.style.display = 'block';
   c.innerHTML = v;
   tt.style.width = w ? w + 'px' : 'auto';
   if(!w && ie){
    t.style.display = 'none';
    b.style.display = 'none';
    tt.style.width = tt.offsetWidth;
    t.style.display = 'block';
    b.style.display = 'block';
   }
  if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
  h = parseInt(tt.offsetHeight) + top;
  clearInterval(tt.timer);
  tt.timer = setInterval(function(){tooltip.fade(1)},timer);
  },
  pos:function(e){
   var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
   var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
   tt.style.top = (u - h) + 'px';
   tt.style.left = (l + left) + 'px';
  },
  fade:function(d){
   var a = alpha;
   if((a != endalpha && d == 1) || (a != 0 && d == -1)){
    var i = speed;
   if(endalpha - a < speed && d == 1){
    i = endalpha - a;
   }else if(alpha < speed && d == -1){
     i = a;
   }
   alpha = a + (i * d);
   tt.style.opacity = alpha * .01;
   tt.style.filter = 'alpha(opacity=' + alpha + ')';
  }else{
    clearInterval(tt.timer);
     if(d == -1){tt.style.display = 'none'}
  }
 },
 hide:function(){
  clearInterval(tt.timer);
   tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
  }
 };
}();

