Is_NS = window.navigator.appName == "Netscape"
Is_IE = window.navigator.appName == "Microsoft Internet Explorer"
Redir   = '..';
MailWeb = "webmaster@liceofoscarini.it";
OrarioOra = '../orariodin/'

function GetElement(nome){
//	if (Is_IE) {
//		return document.all[nome];
//	} else {
		return document.getElementById(nome);
//	}
}

function IntRandom(hi){
	var ind = Math.floor(hi*Math.random());
	if (ind == hi) --ind;
	return ind;
}

Array.prototype.Set = function(ind){
	GetElement('Scelta').value = ind;
	GetElement('Foto').src = this[ind][0];
	GetElement('Legenda').innerHTML = this[ind][1];
}

Array.prototype.Random = function(hi){
	this.Set(IntRandom(hi));
}

Array.prototype.Change = Array.prototype.Set;

Array.prototype.Next = function(){
	var ind = GetElement('Scelta').value;
	if (ind < this.length - 1) ++ind; else ind = 0;
	this.Set(ind);
}

Array.prototype.Prev = function(){
	var ind = GetElement('Scelta').value;
	if (ind > 0) --ind; else ind = this.length -1;
	this.Set(ind);
}

Array.prototype.MMSet = function(ind){
	var media = GetElement('Media');
	var html = '<';
	posext  = this[ind][0].indexOf('.');
	var ext = this[ind][0].substr(posext+1, 7);
	if ((ext  == 'jpeg') || (ext == 'jpg') || (ext == 'png') || (ext == 'gif')) {
		html += "img src= '" + this[ind][0] +"'";
//		alert(html);
	} else if ((ext == 'wma') ||(ext == 'mp3') || (ext == 'mpg') || (ext == 'mpeg')){
		html += "embed src='" + this[ind][0] +"'";
	} else if (ext == 'GoogleM') {
		sorg = 'http://maps.google.com/staticmap?center' + this[ind][0].substr(8, 255);
		html += "img src= '" + sorg +"'";
//		alert(html);
	} else if (ext == 'YouTube') {
		sorg = 'http://www.youtube.com/v/' + this[ind][0].substr(7, 255) + '&hl=it&rel=0&fs=1&color2=0x700000';
		html += "embed type='application/x-shockwave-flash' src='" + sorg + "'";
	} else {
		sorg = 'http://video.google.com/googleplayer.swf?docid=' + this[ind][0].substr(6, 255) + '&amp;hl=it&amp;fs=true';
		html += "embed type='application/x-shockwave-flash' src='" + sorg + "'";
	}
	if (this[ind][2]) html += "width= " + this[ind][2] + " style='width:" + this[ind][2] + ";'";
	if (this[ind][3]) html += "height= " + this[ind][3] + " style='height:" + this[ind][3] + ";'";
	html += '>';
	media.innerHTML = html;
	GetElement('Legenda').innerHTML = this[ind][1];
	GetElement('Scelta').value = ind;
}

Array.prototype.MMNext = function(){
	var ind = GetElement('Scelta').value;
	if (ind < this.length - 1) ++ind; else ind = 0;
	this.MMSet(ind);
}

Array.prototype.MMPrev = function(){
	var ind = GetElement('Scelta').value;
	if (ind > 0) --ind; else ind = this.length -1;
	this.MMSet(ind);
}

Array.prototype.MMRandom = function(hi){
	this.MMSet(IntRandom(hi));
}

function CambiaFoto(fname){
	GetElement('Scelta').value = fname;
	GetElement('Foto').src = fname;
}

function ColOrdina(chiave){
	ord = document.forms[0].Ordine;
	ord.value = chiave;
	tip = document.forms[0].Tipo;
	if (tip.value == 'ASC'){
		tip.value = 'DESC';
	} else {
		tip.value = 'ASC';
	}
	document.forms[0].submit()
}

function Person(Nome, Cognome, Classe, EMail){
   this.Cognome = Cognome;
   this.Nome    = Nome;
   this.Classe  = Classe;
   this.EMail   = EMail;
}

Pers = new Array()

function RegistroVis(){
	if (location.host == 'www.liceofoscarini.it') {
		return '/orariodin/registro.phtml'
	}else if (location.host == 'critto.liceofoscarini.it') {
		return '/registro.phtml'
	}else if (location.host == 'astro.liceofoscarini.it') {
		return '/registro.phtml'
	}else{
		return 'http://www.liceofoscarini.it/orariodin/registro.phtml'
	};
}

Pers[ 0] = new Person('Paolo', 'Bonavoglia', 'prof.', 'paolo.bonavoglia@liceofoscarini.it');

function Persona(Nome, Cognome, tit_it, tit_en, tit_de, tit_fr){
   this.Cognome  = Cognome;
   this.Nome     = Nome;
   this.Titolo   = new Array(tit_it, tit_en, tit_de, tit_fr, '');
}

Presidenza = new Array()
Presidenza[0] = new Persona("Rocco", "Fiano", "Preside-Rettore", "Headmaster", "Leiter", "Proviseur")


Persone    = new Array()
Persone[0] = new Persona("Anna Luisa", "Montagner", 
	"Responsabile amministrativo", "Chief", "Chef", 	"Secr&eacute;taire")

function Personale(person, lingua){
	document.write(person.Titolo[lingua], "<EM> ");
	document.write(person.Nome, " ");
	document.write(person.Cognome, "</EM>");
}

function UffPresidenza(lingua){
	for (numero = 1; numero< Presidenza.length; numero++) {
		Personale(Presidenza[numero], lingua);
		document.writeln("<BR>");
	}
}


OrarioOra = Redir + '/orario2/'
LibriOra  = Redir + '/libri01-02/';
EstLibri = '.html'

function ScriviAncora(path, label){
	document.write('<A HREF="', Redir, path, '">', label, '</A>');	
}

function NewOrario(){
	return('../orario1/')
}

function ReplaceURL(nuovo, repdir, homefile){
	newProv = nuovo;
	local = location.pathname.toLowerCase();
	cerca = /\\/gi
	local = local.replace(cerca, '/');
	prov  = local.indexOf(repdir);
	if (prov >= 0){
        	newProv = newProv + local.substr(prov+repdir.length);
	} else {
		newProv = newProv + homefile;
	}
	return(newProv)
}

function NewURL(){
	return (ReplaceURL(OrarioOra, '/orario2/', 'home.htm'));
}

function NewLibriURL(){
	nuovo = ReplaceURL(LibriOra, '/libri/', 'index.htm');
	extpos = nuovo.indexOf('.html');
	if (extpos < 0) {
		nuovo += 'l';
	}
	return (nuovo);
}


function Figura(foto, testo){
	this.Foto = foto
	this.Testo = testo
}


WebMaster    = 0;
Informatica  = 0;
Fisica       = 1;
MailRettore  = "preside@liceofoscarini.it";
MailScuola   = "segreteria@liceofoscarini.it";
MailWebMaster = "webmaster@liceofoscarini.it";
NomeScuola   = "Convitto Nazionale &ldquo;Marco Foscarini&rdquo; Venezia";
NomeScuolaW  = "Convitto Nazionale &ldquo;Marco Foscarini&rdquo; Venezia";
Indirizzo    = "Cannaregio 4941 - 30121 VENEZIA";
Telefono     = "0415221970";
Fax          = "0415239698";
CodMeccan    = "VEVC010004";

function ScrivIndirizzo(){
	document.write(NomeScuola + '<br>')
	document.write(Indirizzo, '<br>');
	document.write('Tel: ', Telefono, '<br>');
	document.write('Fax: ', Fax, '<br>');
	document.write('Codice Meccanografico: ', CodMeccan);
}

function ScriviMail(aMail){
	document.write('<A HREF="mailto:', aMail, '">', aMail, '</A>')
}

function ScriviWebMaster(){
	ScriviPersona(WebMaster)
}

function ScriviPersona(num){
	document.write('<EM>', Pers[num].Nome, ' ', Pers[num].Cognome, '</EM> ')
	if (Pers[num].EMail.length > 0){
		document.write('(<I>')
		ScriviMail(Pers[num].EMail);
		document.write('</I>) ')
	}
}

function ScriviLogo(){
	document.writeln('<IMG SRC="/logo.jpg"  USEMAP="#Logo">')
	document.write('<MAP NAME="Logo">');
	document.write('<AREA SHAPE="rect" COORDS="0,4,196,26" HREF="/index.html">');
	document.write('</MAP>');
}

function HomeDir(dir){
	if (location.protocol == 'http:') {
		return 'http://www.provincia.venezia.it/mfosc/'
	} else {
		return dir
	}
}

function PoloEstHREF(dir, href, titolo){
	document.write('<A HREF="', HomeDir(dir), href, '">', titolo, '</A>');
}

function ScriviUltimaData(){
	var datAgg = new Date(document.lastModified);
	with (datAgg) {
		var anno = getFullYear();
//		if (anno < 1980) {anno += 100}
		document.writeln(getDate(), '-', getMonth()+1, '-', anno);
	}
}

function ScriviCoda(dum, aut, tipo, aut2){
	document.writeln('<br style="clear: both">')
	if (aut >= 0) {
		if (tipo == 1) {
			document.write('<hr>Testo e foto di ');
		}else if (tipo == 2) {
			document.write('<hr>Testo di ');
		}else if (tipo == 3) {
			document.write('<hr>Fotografia di ');
		}else {
			document.write('<hr>Pagina a cura di ');
		}
		if (aut2 >0){
		}
		ScriviPersona(aut);
		if (aut2 >= 0){
			document.write('e di ');
			ScriviPersona(aut2);
		}
		document.write(' del ');
	} else {
		document.write('<HR>Pagina a cura del')
	}
	document.write('<dl>')
	document.write('<dt>', NomeScuolaW)
	document.write('<dd>E-Mail: '); ScriviMail(MailWeb);

	document.write('<dd><a href="http://www.liceofoscarini.it/index.phtml">Presentazione della scuola</a>')
	document.write('<dd><a href="', RegistroVis(), '">Registro visitatori</a>')
	document.write('<dd><a href="http://www.liceofoscarini.it/biglietto.html">Indirizzi, Numeri di telefono, E-Mail</a>')
	document.write('</dl>')
	document.write('<hr><div>Pagina aggiornata il ');ScriviUltimaData();
	document.write('</div>');
	document.write('<hr><div><em>@2010 Convitto Nazionale &ldquo;Marco Foscarini&rdquo; - Venezia</em> ');
	document.write('Testi e foto possono essere riprodotti liberamente a condizione che ');
	document.write('venga citata esplicitamente la fonte, con un link a questa pagina, e che la cosa non abbia fini di lucro.</DIV>');
}

Anno0   = 2000;
AnnoSQL = 2003;
AnnoU   = 2004;

function Sequenza(titolo, pre, post, inizio, escluso, fine){
	document.write(titolo);
	for (numero = inizio; numero<=fine; numero++) {
	   if (numero == escluso) {
		document.write('  <STRONG>', numero, "/", (numero+1)%100, "</STRONG>");
	   } else {
		document.write('  <A HREF="', pre, (numero+1)%100, post, '">', numero, '/', (numero+1)%100, '</A>');
	   }
	}
}

function Notizie(escluso, dir){
	if (typeof(dir) != "string"){dir=''}
	Sequenza('Notizie ', dir+'notizie', '.html', Anno0, escluso, AnnoU);
}

function Eventi(escluso, dir){
	if (typeof(dir) != "string"){dir=''}
	Sequenza('Eventi ', dir+'visite', '.html', Anno0, escluso, AnnoU);
}

function Accessi(escluso, dir){
	Sequenza('Statistiche A.S.', dir+'statistiche', '.html', Anno0+1, escluso-1, AnnoU-1);
}

function Orari(escluso, dir){
	Sequenza('Orari', '../orario', '/'+ dir, Anno0+1, escluso-1, 2001);
}


