function view(param)
{
	window.open('./foto_admin.php?id='+param,'Annuncio','scrollbars=yes,resizable=no,width=550,height=500,status=no,location=no,toolbar=no');
}
function view_squadre(param)
{
	window.open('./foto_squadre.php?id='+param,'Squadre','scrollbars=yes,resizable=yes,width=550,height=500,status=no,location=no,toolbar=no');
}
function view_partec(param,variab)
{
	window.open('./foto_squadre.php?id='+param+'&part='+variab,'PartecipantiSquadre','scrollbars=yes,resizable=yes,width=550,height=500,status=no,location=no,toolbar=no');
}

function foto_admin(param)
{
	window.open('../foto_admin.php?id='+param,'Foto','scrollbars=yes,resizable=no,width=550,height=500,status=no,location=no,toolbar=no');
}

function foto(param)
{
	window.open('./foto_admin.php?id='+param,'Foto','scrollbars=yes,resizable=no,width=550,height=500,status=no,location=no,toolbar=no');
}
function foto_gallery(param)
{
	window.open('./foto_gallery.php?id='+param,'Foto','scrollbars=yes,resizable=no,width=550,height=500,status=no,location=no,toolbar=no');
}
function dett(param)
{
	window.open('./dettagli.php?id=' + param,'Iscritto','scrollbars=yes,resizable=no,width=550,height=500,status=no,location=no,toolbar=no');
}
function squadra(manif,code)
{
	window.open('./stampa_squadra.php?id_manif=' + manif+ '&view_squadra=' +code,'Stampa','scrollbars=yes,resizable=yes,width=800,height=500,status=no,location=no,toolbar=no');
}
function iscritti(manif)
{
	window.open('./stampa_iscritti.php?id_manif=' + manif,'Iscritti','scrollbars=yes,resizable=yes,width=800,height=500,status=no,location=no,toolbar=no');
}
function news(param)
{
	window.open('./dettagli_news.php?id=' + param,'news'+ param,'scrollbars=yes,resizable=yes,width=650,height=500,status=no,location=no,toolbar=no');
}

function lettersOnly(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 65 || charCode > 90) && 
        (charCode < 97 || charCode > 122)) {
        alert("Puoi inserire solo lettere!");
        return false;
    }
    return true;
}

function numeralsOnly(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        alert("Puoi inserire solo numeri!");
        return false;
    }
    return true;
}


// richiamata per verificare che abbia immesso i dati nel form codice cliente di cash.php per completare l'ordine
function cod_validate(form)
{
	if (form.cod_utente.value.length == 0)
		{
			alert('Nessun codice inserito!');
			return false;
		}
}

// richiamata per verificare che abbia immesso i dati nel form
function valid(form)
{

	titolo = form.titolo.value;
	testo_ann = form.testo_ann.value;
	
	if (titolo == '' || testo_ann=='')
		{
			alert('Attenzione, dati mancanti nella compilazione!');
			return false;
		}
}
// richiamata per verificare che abbia immesso i dati nel form
function valid2(form)
{

	tipo_ann = form.tipo_ann.value;
	
	if (tipo_ann=='')
		{
			alert('Attenzione, dati mancanti nella compilazione!');
			return false;
		}
}
// richiamata per verificare che abbia immesso i dati nel form
function valid3(form)
{

	nome = form.nome.value;
	msg = form.msg.value;
	email = form.email.value;
	
	if (nome=='' || msg=='' || email =='')
		{
			alert('Attenzione, dati mancanti nella compilazione!');
			return false;
		}
}
function valid_torneo(form)
{

	nome = document.form.nome.value;
	cognome =  document.form.cognome.value;
	data_nascita =  document.form.data_nascita.value;
	circolo =  document.form.circolo.value;
	classifica =  document.form.classifica.value;
	cellulare =  document.form.cellulare.value;
	email =  document.form.email.value;
	
	if (nome=='' || cognome=='' || email ==''|| classifica ==''|| circolo =='' || data_nascita =='' || cellulare =='')
		{
			alert('Attenzione, dati mancanti nella compilazione!');
			return false;
		}
}
function y2k(number)
   {
   return (number < 1000) ? number + 1900 : number;
   }

function explodeArray(item,delimiter) {
  tempArray=new Array(1);
  var Count=0;
  var tempString=new String(item);

  while (tempString.indexOf(delimiter)>0) {
    tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
    tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1); 
    Count=Count+1
  }

  tempArray[Count]=tempString;
  return tempArray;
}

function ver_form(form)
{
	if(form.nome.value == '')
	{
		alert("Nome non inserito!!");
		return false;
	}
	if(form.cognome.value == '')
	{
		alert("Cognome non inserito!!");
		return false;
	}
	if(!verData(form.data_nascita.value))
		return false;
	if(form.indirizzo.value == '')
	{
		alert("Indirizzo non inserito!!");
		return false;
	}
	
	if(form.citta.value == '')
	{
		alert("Citta' non inserita!!");
		return false;
	}
	if(form.cap.value == '')
	{
		alert("Cap non inserita!!");
		return false;
	}
	if(form.prov.value == '')
	{
		alert("Provincia non inserita!!");
		return false;
	}
	
	if(form.cellulare.value == '')
	{
		alert("Cellulare non inserito!!");
		return false;
	}
	if(form.telefono.value == '')
	{
		alert("Telefono non inserito!!");
		return false;
	}
	if(form.email.value == '')
	{
		alert("Email non inserita!!");
		return false;
	}
	
	
	// verifico che abbia checcato l'autorizzazione
	if(form.autorizzo.checked==true)
		return true;
	else
	{
		alert("Attenzione: è necessario autorizzare il trattamento dei dati inseriti\nper proseguire nell'iscrizione!");
		return false;
	}
	
}

function verData(tempString)
{
//	alert("str " + );
//	tempString = form.data_nascita.value;
	tempArray=explodeArray(tempString,"-");
	if(tempString.length <10)
	{
		alert('Data Errata!');
		return false;
	}
   gg=tempArray[0];
   mm=tempArray[1];
   yyyy=tempArray[2];
   if (gg=="")
   {
      alert('Inserire Data!');
	  return false;
   }
   else
   {
      if(mm=="")
	  {
         alert('Inserire Data!');
		 return false;
	  }
      else
	     if(yyyy=="")
		 {
            alert('Inserire Data!');
			return false;
		 }
   }
    var today = new Date();
    
	yyyy = ((!yyyy) ? y2k(today.getYear()):yyyy);
    mm = ((!mm) ? today.getMonth():mm-1);
	
    if (!gg) 
		return false;
		
    var test = new Date(yyyy,mm,gg);
    if ( (y2k(test.getYear()) == yyyy) && (mm == test.getMonth()) && (gg == test.getDate()) )
	{
       // return true; 
	}
    else
	{
        alert(tempString + ': data errata!!');
		return false;
	}
	

	return true;
}
function SelectFilter (theKind, theSelect, source, theSelIndex)
{
		//alert('Source: '+source);
	if (source)
	{
		if (theSelIndex == '')	theSelIndex = 0;
		theComList = (document.getElementById(theKind + 'data').value).match (new RegExp ('#' + source + '[^#]*'));
		
		if (theComList)
		{
			theComItems = theComList[0].split ('|');
			with (theSelect.form[theKind])
			{
				options.length = 0;
				options[0] = new Option( '', '')
				
				for ( theIndex = 1; theIndex < theComItems.length -1; theIndex++) 
				{
					options[theIndex] = new Option( theComItems[theIndex], theComItems[theIndex])
					if (theComItems[theIndex] == theSelIndex)	
					{
						options.selectedIndex=theIndex;
					}
				}
			}
		}
		else
			theSelect.form[theKind].options.length = 0;
	}
	else
		theSelect.form[theKind].options.length = 0;
}
	
function ca(var1,var2)
{ 
	//alert("entrato"+provincia+ " "+ comune);
//	document.getElementById('provinc_ann').selectedIndex = provincia;
	SelectFilter('man', document.getElementById('sez_manif'), var1,var2);
}
function colore1(class1,class2)
{
	document.getElementById("testo_news").className = class1;
	attesa = window.setTimeout("colore2('"+class1+"','"+class2+"')",500);
}

function colore2(class1,class2)
{
	document.getElementById("testo_news").className = class2;
	attesa = window.setTimeout("colore1('"+class1+"','"+class2+"')",500)
}
function avvia(class1,class2)
{
	attesa = window.setTimeout("colore1('"+class1+"','"+class2+"')",500);
}

// per lampeggiare iscrizione
function colore11(ogg,class1,class2)
{
	document.getElementById("iscr"+ogg).className = class1;
	attesa = window.setTimeout("colore22('"+ogg+"','"+class1+"','"+class2+"')",500);
}

function colore22(ogg,class1,class2)
{
//	alert("iscr"+ogg);
	document.getElementById("iscr"+ogg).className = class2;
	
	attesa = window.setTimeout("colore11('"+ogg+"','"+class1+"','"+class2+"')",500)
}
function avvia_iscrivi(ogg,class1,class2)
{
	attesa = window.setTimeout("colore11('"+ogg+"','"+class1+"','"+class2+"')",500);
}
function stop(){
	//alert("fermo");
	document.getElementById("sound_back").src="";
	document.getElementById("logo_music").src="img/no_music.jpg";
}

function suona(nome){
	if (document.getElementById("sound_back").src != nome)
	{
	//	alert("SUONO");
		document.getElementById("sound_back").src= nome;
		document.getElementById("logo_music").src="img/music.jpg";
	}
	else
	{
		stop();
	}
}


var slideShowSpeed = 2000

var crossFadeDuration = 100
var dir = "img_gallery/";
var Pic = new Array();
var t;
var j = 0;
var p = 17;
var r=0;
var r2=3;

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image();
   preLoad[i].src = dir+i+".jpg";
}

function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=100)";
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
      document.images.SlideShow.filters.blendTrans.Apply(); 
	  
	  document.images.SlideShow2.style.filter="blendTrans(duration=10)";
      document.images.SlideShow2.style.filter="blendTrans(duration=crossFadeDuration)";
      document.images.SlideShow2.filters.blendTrans.Apply();      
   }
   r = Math.round(Math.random()*16);
   
   if(r<13)
	{ 
		r2 = r+3;
   	}
	else
	{
		r2 = Math.round(Math.random()*5);
	}

	if(preLoad[r].src!= null)
   		document.images.SlideShow.src = preLoad[r].src;
	if(preLoad[r2].src!= null)
 	  document.images.SlideShow2.src = preLoad[r2].src;
	 
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play();
	  document.images.SlideShow2.filters.blendTrans.Play()
   }
   j = j + 1;
   if (j > (p-1)) j=0;
   t = setTimeout('runSlideShow()', slideShowSpeed)
   
}