<!--
ruotafoto = true

function cambiafoto(variabile,cartella) {
	if (variabile == "stop") {
		ruotafoto = false;
	} else if (ruotafoto == true) {
		mygallery.picture.options[Math.round(Math.random()*(foto.length - 1))].selected = true;
		setTimeout("cambiafoto('','" + cartella + "')",4000);
	}
	//aggiorna immagine
	document.getElementById("blendimage").src = cartella + "pixel.jpg"; 
	blendimage('blenddiv','blendimage', cartella + foto[document.mygallery.picture.selectedIndex][1],200);
}

//IsDate
function isDate(dateStr) {
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) {
		alert("Per favore inserisci una data nel formato dd/mm/yyyy o dd-mm-yyyy.");
		return false;
	}
	month = matchArray[3]; // p@rse date into variables
	day = matchArray[1];
	year = matchArray[5];
	if (month < 1 || month > 12) { // check month range
		alert("Il mese deve essere tra 1 e 12.");
		return false;
	}
	if (day < 1 || day > 31) {
		alert("il giorno deve essere tra 1 e 31.");
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("Il mese di "+month+" non ha 31 giorni!")
		return false;
	}
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day > 29 || (day==29 && !isleap)) {
			alert("Febbraio " + year + " non ha " + day + " giorni!");
			return false;
		}
	}
	return true; // date is valid
}

// Funzioni per effetto fade su immagini-----------------------------------------------------------------------
function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function blendimage(divid, imageid, imagefile, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
     
    //set the current image as background 
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
     
    //make image transparent 
    changeOpac(0, imageid); 
     
    //make new image 
    document.getElementById(imageid).src = imagefile; 

    //fade in image 
    for(i = 0; i <= 100; i++) { 
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    } 
} 
// Fine funzioni per effetto fade su immagini------------------------------------------------------------------

// Funzioni per rotazione sfondi su tabella in home------------------------------------------------------------
square = 9;
vertical = 6;
horizontal = 7;

function setproperty(layername, property, value){
	layerRef="document.all";
	styleSwitch=".style";
	
	eval(layerRef + '["' + layername + '"]' + styleSwitch + '.' + property + "=\"" + value + "\"");
}

function ruota_background(oggetto) {
	if (navigator.appName != "Netscape"){
		tipo = oggetto.substr(0, oggetto.length - 2);

		if (tipo == "square") {
			valoremassimo = square;
			nome = "sbandieratori";
		} else if (tipo == "vertical") {
			valoremassimo = vertical;
			nome = "lanceursdedrapeaux";
		} else if (tipo == "horizontal") {
			valoremassimo = horizontal;
			nome = "flagwavers";
		}
		
		valore = "0" + Math.round(Math.random()*(valoremassimo));
		valore = valore.substr(valore.length - 2, 2);
		
		setproperty(oggetto,"background","url(images_home/" + nome + valore + ".jpg)");
		
		tempo = Math.round(Math.random()* 8000) + 2000;

	setTimeout("ruota_background(\"" + oggetto + "\")", tempo);
	}
}
// Fine funzioni per rotazione sfondi su tabella in home-------------------------------------------------------
function chat_window() {
	var winl = (screen.width - 709) / 2;
	var wint = (screen.height - 481) / 2;
	
	window.open('http://www.gruppostorico.com/chat/default.asp','ChatWindow2', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=1,width=700,height=460,top='+wint+',left='+winl)
}
function showimage() {
	if (!document.images)
	return
	document.images.pictures.src = "images/" + foto[document.mygallery.picture.selectedIndex][1];
}
function leapto(form) {
	var myindex=form.dest.selectedIndex
	window.open(form.dest.options[myindex].value,"popDialog","height=420,width=400,scrollbars=no")
}
function leapto2(form) {
	var myindex=form.dest.selectedIndex
	window.open(form.dest.options[myindex].value,"popDialog","height=420,width=400,scrollbars=yes")
}
function popup_user(id) {
	window.open("http://www.gruppostorico.com/users/utente.asp?id=" + id,"popDialog","height=420,width=400,scrollbars=yes")
}
function streaming(filmato) {
	window.open("http://www.gruppostorico.com/movies/streaming.asp?movie=" + filmato,"popDialog","height=470,width=390,scrollbars=no")
}

function PopFoto(Foto) {
  FotoUrl = "popfoto.html?a=" + Foto;
  FotoCar = "width=670 height=520";
  window.open(FotoUrl,"",FotoCar);
}

function PopFotoVer(Foto) {
  FotoUrl = "popfoto.html?a=" + Foto;
  FotoCar = "width=520 height=670";
  window.open(FotoUrl,"",FotoCar);
}

var width=100;
var pos=1-width;
function scorrevole(len) {
	if (len=='ita'){
		var scrtxt="Gruppo Storico e Sbandieratori Città di Castiglion Fiorentino";
	}
	else if (len=='deu'){
		var scrtxt="die Historische Gruppe der Fahnenträger von Castiglion Fiorentino";
	}
	else if (len=='esp'){
		var scrtxt="Grupo Històrico y Abanderados de Castiglion Fiorentino";
	}
	else if (len=='fra'){
		var scrtxt="Groupe Historique et Lanceurs de Drapeaux de Castiglion Fiorentino";
	}
	else if (len=='por'){
		var scrtxt="Castiglion Fiorentino Grupo Histórico e seu Bandeira-oscila";
	}
	else if (len=='tur'){
		var scrtxt="Castiglion Fiorentino Tarihi Grubu ve Bayrak Dansçilarinin";
	}
	else if (len=='slo'){
		var scrtxt="Historicna skupina Castiglion Fiorentino in njeni Vihralci zastav";
	}
	else if (len=='ces'){
		var scrtxt="Historické uskupení Castiglion Fiorentino a jeho Vlajkonosi";
	}
	else if (len=='pol'){
		var scrtxt="Historyczna grupa Castiglion Fiorentino i ich Powiewajacy flagami";
	}
	else if (len=='fin'){
		var scrtxt="Castiglion Fiorentinon Historiallinen Ryhmä ja sen lipunheiluttajat";
	}
	else if (len=='rom'){
		var scrtxt="Grupul Istoric Castiglion Fiorentino si Mânuitorii Drapelelor";
	}
	else if (len=='sve'){
		var scrtxt="Castiglion Fiorentino Fanbärare";
	}
	else if (len=='shq'){
		var scrtxt="Grupit Historik të Flamurmbajtësve të Castiglion Fiorentino";
	}
	else {
		var scrtxt="The Castiglion Fiorentino Historical Group and its Flag-Wavers";
	}
	
	var lentxt=scrtxt.length;
	pos++;
	var scroller="";
	if (pos==lentxt) {
	pos=1-width;
	}
	if (pos<0) {
	for (var i=1; i<=Math.abs(pos); i++) {
	  scroller=scroller+" ";}
	scroller=scroller+scrtxt.substring(0,width-i+1);
	}
	else {
	scroller=scroller+scrtxt.substring(pos,width+pos);
	}
	window.status = scroller;
	setTimeout("scorrevole('" + len + "')",170);
}

colors = new Array(14)
colors[0]="0"
colors[1]="1"
colors[2]="2"
colors[3]="3"
colors[4]="4"
colors[5]="5"
colors[5]="6"
colors[6]="7"
colors[7]="8"
colors[8]="9"
colors[9]="a"
colors[10]="b"
colors[11]="c"
colors[12]="d"
colors[13]="e"
colors[14]="f"

digit = new Array(5)

function genHex() {
	color = ""
	for (i=0; i<6; i++) {
		digit[i] = colors[Math.round(Math.random() * 14)]
		color = color + digit[i]
	}
	return color;
}

function TestoLampeggiante() {
	var testo = document.getElementById("blink");
	testo.style.color = genHex();

	//if (testo.style.color == "#000000") {
		//testo.style.color = "#ff0000";
	//} else {
		//testo.style.color = "#000000";
	//}
}

function ControllaMail() {
	if (document.mailinglist.email.value.length < 1) {
		alert("Inserisci la tua mail!");
		return false;
	}
	if (document.mailinglist.email.value.indexOf("@") < 0) {
		alert("Inserisci un indirizzo e-mail valido!");
		return false;
	}
	return true;
}

function ControllaFormLogin() {
	if (document.login.nome.value.length < 1) {
		alert("Inserisci il tuo nome!");
		return false;
	}
	if (document.login.cognome.value.length < 1) {
		alert("Inserisci il tuo cognome!");
		return false;
	}
	if (document.login.password.value.length < 1) {
		alert("Inserisci la tua password!");
		return false;
	}
	return true;
}

// Gestione mouse animato---------------------------------------
var nDots = 7;
var Xpos = 0;
var Ypos = 0;
var DELTAT = .01;
var SEGLEN = 10;
var SPRINGK = 10;
var MASS = 1;
var GRAVITY = 50;
var RESISTANCE = 10;
var STOPVEL = 0.1;
var STOPACC = 0.1;
var DOTSIZE = 11;
var BOUNCE = 0.75;
var isNetscape = navigator.appName=="Netscape";
var followmouse = true;
var dots = new Array();
function animatedmouse() {
var i = 0;
for (i = 0; i < nDots; i++) {
dots[i] = new dot(i);
}
if (!isNetscape) {
// I only know how to read the locations of the 
// <LI> items in IE
//skip this for now
// setInitPositions(dots)
}
for (i = 0; i < nDots; i++) {
dots[i].obj.left = dots[i].X;
dots[i].obj.top = dots[i].Y;
}
if (isNetscape) {
startanimate();
} else {
// let dots sit there for a few seconds
// since they're hiding on the real bullets
setTimeout("startanimate()", 3000);
   }
}
function dot(i) {
this.X = Xpos;
this.Y = Ypos;
this.dx = 0;
this.dy = 0;
if (isNetscape) {	
this.obj = eval("document.dot" + i);
} else {
this.obj = eval("dot" + i + ".style");
   }
}
function startanimate() {	
setInterval("animate()", 20);
}
function setInitPositions(dots) {
var startloc = document.all.tags("LI");
var i = 0;
for (i = 0; i < startloc.length && i < (nDots - 1); i++) {
dots[i+1].X = startloc[i].offsetLeft
startloc[i].offsetParent.offsetLeft - DOTSIZE;
dots[i+1].Y = startloc[i].offsetTop +
startloc[i].offsetParent.offsetTop + 2*DOTSIZE;
}
dots[0].X = dots[1].X;
dots[0].Y = dots[1].Y - SEGLEN;
}
function MoveHandler(e) {
Xpos = e.pageX;
Ypos = e.pageY;	  
return true;
}
function MoveHandlerIE() {
Xpos = window.event.x + document.body.scrollLeft;
Ypos = window.event.y + document.body.scrollTop;	  
}
if (isNetscape) {
document.captureEvents(Event.MOUSEMOVE);
document.onMouseMove = MoveHandler;
} else {
document.onmousemove = MoveHandlerIE;
}
function vec(X, Y)
{
this.X = X;
this.Y = Y;
}
function springForce(i, j, spring)
{
var dx = (dots[i].X - dots[j].X);
var dy = (dots[i].Y - dots[j].Y);
var len = Math.sqrt(dx*dx + dy*dy);
if (len > SEGLEN) {
var springF = SPRINGK * (len - SEGLEN);
spring.X += (dx / len) * springF;
spring.Y += (dy / len) * springF;
   }
}
function animate() {	
var start = 0;
if (followmouse) {
dots[0].X = Xpos;
dots[0].Y = Ypos;	
start = 1;
}
for (i = start ; i < nDots; i++ ) {
var spring = new vec(0, 0);
if (i > 0) {
springForce(i-1, i, spring);
}
if (i < (nDots - 1)) {
springForce(i+1, i, spring);
}
var resist = new vec(-dots[i].dx * RESISTANCE, -dots[i].dy * RESISTANCE);
var accel = new vec((spring.X + resist.X)/ MASS, (spring.Y + resist.Y)/ MASS + GRAVITY);
dots[i].dx += (DELTAT * accel.X);
dots[i].dy += (DELTAT * accel.Y);
if (Math.abs(dots[i].dx) < STOPVEL &&
Math.abs(dots[i].dy) < STOPVEL &&
Math.abs(accel.X) < STOPACC &&
Math.abs(accel.Y) < STOPACC) {
dots[i].dx = 0;
dots[i].dy = 0;
}
dots[i].X += dots[i].dx;
dots[i].Y += dots[i].dy;
var height, width;
if (isNetscape) {
height = window.innerHeight + document.scrollTop;
width = window.innerWidth + document.scrollLeft;
} else {	
height = document.body.clientHeight + document.body.scrollTop;
width = document.body.clientWidth + document.body.scrollLeft;
}
if (dots[i].Y >=  height - DOTSIZE - 1) {
if (dots[i].dy > 0) {
dots[i].dy = BOUNCE * -dots[i].dy;
}
dots[i].Y = height - DOTSIZE - 1;
}
if (dots[i].X >= width - DOTSIZE) {
if (dots[i].dx > 0) {
dots[i].dx = BOUNCE * -dots[i].dx;
}
dots[i].X = width - DOTSIZE - 1;
}
if (dots[i].X < 0) {
if (dots[i].dx < 0) {
dots[i].dx = BOUNCE * -dots[i].dx;
}
dots[i].X = 0;
}
dots[i].obj.left = dots[i].X;			
dots[i].obj.top =  dots[i].Y;		
   }
}

//-->

//gestore del calendarietto--------------------------------------------------------------------------------------
<!--
function show_calendar(str_target, str_datetime) {
	var arr_months = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno",
		"Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"];
	var week_days = ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa"];
	var n_weekstart = 1; // day week starts from (normally 0 or 1)

	var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt(str_datetime));
	var dt_prev_month = new Date(dt_datetime);
	dt_prev_month.setMonth(dt_datetime.getMonth()-1);
	var dt_next_month = new Date(dt_datetime);
	dt_next_month.setMonth(dt_datetime.getMonth()+1);
	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);
	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	var dt_lastday = new Date(dt_next_month);
	dt_lastday.setDate(0);
	
	// html generation (feel free to tune it for your particular application)
	// print calendar header
	var str_buffer = new String (
		"<html>\n"+
		"<head>\n"+
		"	<title>Calendar</title>\n"+
		"</head>\n"+
		"<body bgcolor=\"White\">\n"+
		"<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
		"<tr><td bgcolor=\"#4682B4\">\n"+
		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
		"<tr>\n	<td bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar('"+
		str_target+"', '"+ dt2dtstr(dt_prev_month)+"'+document.cal.time.value);\">"+
		"<img src=\"../icons/prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"previous month\"></a></td>\n"+
		"	<td bgcolor=\"#4682B4\" colspan=\"5\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
		+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+
		"	<td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('"
		+str_target+"', '"+dt2dtstr(dt_next_month)+"'+document.cal.time.value);\">"+
		"<img src=\"../icons/next.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"next month\"></a></td>\n</tr>\n"
	);

	var dt_current_day = new Date(dt_firstday);
	// print weekdays titles
	str_buffer += "<tr>\n";
	for (var n=0; n<7; n++)
		str_buffer += "	<td bgcolor=\"#87CEFA\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
		week_days[(n_weekstart+n)%7]+"</font></td>\n";
	// print calendar table
	str_buffer += "</tr>\n";
	while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
		dt_current_day.getMonth() == dt_firstday.getMonth()) {
		// print row heder
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
				if (dt_current_day.getDate() == dt_datetime.getDate() &&
					dt_current_day.getMonth() == dt_datetime.getMonth())
					// print current date
					str_buffer += "	<td bgcolor=\"#FFB6C1\" align=\"right\">";
				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
					// weekend days
					str_buffer += "	<td bgcolor=\"#DBEAF5\" align=\"right\">";
				else
					// print working days of current month
					str_buffer += "	<td bgcolor=\"white\" align=\"right\">";

				if (dt_current_day.getMonth() == dt_datetime.getMonth())
					// print days of current month
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
					"<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
				else 
					// print days of other months
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
					"<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		// print row footer
		str_buffer += "</tr>\n";
	}
	// print calendar footer
	str_buffer +=
		"" +
		"<form name=\"cal\">\n<tr><td colspan=\"7\" bgcolor=\"#87CEFA\">" +
//con l'ora
//		"<font color=\"White\" face=\"tahoma, verdana\" size=\"2\">" +
//		"Time: <input type=\"text\" name=\"time\" value=\"" + dt2tmstr(dt_datetime) +
//		"\" size=\"8\" maxlength=\"8\"></font></td></tr>\n" +
//senza l'ora
		"<input name=\"time\" type=\"hidden\" value=\"\">\n" +

		"</form>\n" +
		"</table>\n" +
		"</tr>\n</td>\n</table>\n" +
		"</body>\n" +
		"</html>\n";

	var vWinCal = window.open("", "Calendar", 
		"width=200,height=215,status=no,resizable=yes,top=200,left=200");
	vWinCal.opener = self;
	var calc_doc = vWinCal.document;
	calc_doc.write (str_buffer);
	calc_doc.close();
}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt (str_datetime) {
//	var re_date = /^(\d+)\/(\d+)\/(\d+)\s+(\d+)\:(\d+)\:(\d+)$/;
	var re_date = /^(\d+)\/(\d+)\/(\d+)$/;
	if (!re_date.exec(str_datetime))
		return alert("Invalid Datetime format: "+ str_datetime);
	return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}
function dt2dtstr (dt_datetime) {
	giorno = "0" + dt_datetime.getDate();
	mese = "0" + (dt_datetime.getMonth()+1);
	anno = dt_datetime.getFullYear() + "";
	giorno = giorno.substr(giorno.length - 2,2);
	mese = mese.substr(mese.length - 2,2);
	return (new String (giorno + "/" + mese + "/" + anno));
}
function dt2tmstr (dt_datetime) {
	return (new String (
			dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds()));
}

//regola la larghezza in base alla risoluzione del browser
function resize_max() {
  var myWidth = 0, myHeight = 0;
  if (typeof(window.innerWidth ) == 'number') {
    //Non-IE
    myWidth = window.innerWidth;
	myWidth = myWidth - 24;
    //myHeight = window.innerHeight;
  } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    //myHeight = document.documentElement.clientHeight;
  } else if (document.body && ( document.body.clientWidth || document.body.clientHeight)) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    //myHeight = document.body.clientHeight;
  } else if (screen.availWidth > 0 || screen.availHeight > 0) {
    //IE 9
    myWidth = screen.availWidth;
    //myHeight = screen.availheight;
  }
  
  max_larghezza = 1300;
  if (myWidth < max_larghezza) {
	  larghezza = myWidth;
  } else {
	  larghezza = max_larghezza;
  }
  //alert("max_larghezza: " + max_larghezza + " , myWidth: " + myWidth + " , larghezza: " + larghezza);
  document.getElementById('pag_sbandieratori').style.width = larghezza + "px";
}

//-->

