/********* FUNZIONI PER LA GESTIONE DEI COOKIES ***********/
var strautore = "animazionefede";

//crea un cookie
function SetCookie(NameOfCookie, value, expiredays) 
{ 
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + escape(value) + 
	((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

//preleva un cookie
function GetCookie(sName)
{
  // i cookie sono separati da ;
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // una coppia nome valore è separata da =
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }
  // se il cookie non esiste
  return null;
}

//cancella un cookie mettendo una data nel passato
function DelCookie(sName)
{
	document.cookie = sName + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
/********* END FUNZIONI PER LA GESTIONE DEI COOKIES ***********/

//apre la pagina con animazione flash
function apriAnimazione(nomewin)
{
		var whatpage;
		
		whatpage = "/fede/flashchk.html"
		window.open(whatpage, // pagina con contenuto Flash
					nomewin,  // nome della finestra
					"width=770,height=440,hotkeys=no,toolbar=no,alwaysRaised,menubar=no");
}

//gestisce l'apertura dei macroconcetti dalla home page o dalla pagina di animazione flash
function openwindow(whatpage)
{
	//setta il cookie per determinare se ho aperto flash oppure no
	SetCookie(strautore, "true", 1);
	
	if (chebrows()=="NS")
	{
		pathURL = self.location.href + '';

		if (pathURL.indexOf('\\')>0) 
		{
			pathDir = pathURL.lastIndexOf ('\\', pathURL.length);
		} 
		else 
		{
			pathDir = pathURL.lastIndexOf ('/', pathURL.length);
		}

		pathBase = pathURL.substring (0, pathDir + 1);
	
		window.open(pathBase+whatpage, '', 'toolbar=yes,scrollbars,location=yes,status=yes,resizable=yes,menubar=yes,width=787,height=440');
	}
	
	else //IE
	{
		window.open(whatpage, '', 'toolbar=yes,scrollbars,location=yes,status=yes,resizable=yes,menubar=yes,width=786,height=440');
	}
}

// Gestisce il ritorno alla home page dalla root dall'agenda e dala bacheca
// in base al valore del parametro origine
function torna(winname, origine)
{
	var ck;
	var path;
	
	path = "";
	if (origine == "agenda")
		path = "../";
	else if (origine == "bacheca")
		path = "../../";
	
	ck = GetCookie(strautore);
	if (ck == "true") //navigazione dinamica
	{
		if (top.opener != null)
		{
			// mettendo il nome alla finestra se è gia aperta non ne apre una nuova ma la carica nella stessa
			window.open(path + "init.html", strautore, "hotkeys=no,scrollbars=no,toolbar=no,width=770,height=442");
		}
	
		window.close();		// chiusura della finestra corrente
		window.parent.close();  // se la finestra corrente è un frame, chiudo il suo frameset
	}
	
	// navigazione statica
	else
	{
		//apre e chiude la finestra di animazione (se gia aperta, ritorna su se stessa)
		win = window.open(path + "init.html", strautore, "hotkeys=no,scrollbars=no,toolbar=no,width=770,height=442");
		win.close();
		
		parent.location = path + "index.html";
	}
}

// gestisce l'apertura della mappa del sito
function aprimappa(page)
{
	//var features;
	
	//features = 'toolbar=no,scrollbars=yes,location=no,status=no,resizable=no,menubar=no,width=300,height=300';
	//window.open(page, 'mappa', features);
}

// gestisce il ritorno al macroconcetto, agenda e forum dalla mappa
function tornamappa(page)
{
	// apre la nuova pagina nella pagina genitore della mappa
	// uso parent perchè il genitore potrebbe essere un frameset
	//top.opener.parent.location = page;
	parent.location = page;
}