
//	APERTURE POP-UP

function popUpStatuto() {
	 window.open("public/user/statuto.asp", "popUpStatuto", "menubar=no, status=no, scrollbars=yes, location=no, toolbar=no, resizable=yes, width=600, height=700");
}
function popUpStatuto_uk() {
	 window.open("public/user/statuto_uk.asp", "popUpStatuto_uk", "menubar=no, status=no, scrollbars=yes, location=no, toolbar=no, resizable=yes, width=600, height=700");
}
function popUpScritti(id) {
	 window.open("public/user/vediScritto.asp?idScritto=" + id, "popUpScritti", "menubar=no, status=no, scrollbars=yes, location=no, toolbar=no, resizable=yes, width=540, height=700");
}
function popUpMusica(doc, tit) {
	 window.open("public/user/playMusica.asp?docMusica=" + doc + "&titoloMusica=" + tit, "popUpMusica", "menubar=no, status=no, scrollbars=no, location=no, toolbar=no, resizable=no, width=280, height=202, left=370, top=380");
}
function popUpVideo(id) {
	 window.open("public/user/playVideo.asp?idVideo=" + id, "popUpVideo", "menubar=no, status=no, scrollbars=no, location=no, toolbar=no, resizable=no, width=500, height=400, left=260, top=150");
}
function popUpFoto(id1, id2) {
	 window.open("public/user/vediFoto.asp?idCatFoto=" + id1 + "&idFoto=" + id2, "popUpFoto", "menubar=no, status=no, scrollbars=yes, location=no, toolbar=no, resizable=yes, width=700, height=700");
}

// VALIDAZIONE FORM SCRIVICI

function validaScrivici(x) {

	if (strip(x.testoScrivici.value) == "") {
		alert("Introduci il testo.");
		x.testoScrivici.focus();
		return false;
	}
	if (strip(x.emailScrivici.value) != '') {
		if ((x.emailScrivici.value.indexOf("@") < 0) || (x.emailScrivici.value.indexOf(".") < 0) || !(x.emailScrivici.value.indexOf("@") > 0) || !(x.emailScrivici.value.indexOf(".") > 0)) {
			alert("Verificare email.");
			x.emailScrivici.focus(); 
			return false; 
		}
	}
}

// VALIDAZIONE FORM NEWSLETTER

function validaNewsLett(x) {
	
	if (strip(x.nomeNewsLett.value) == "") {
		alert("Introduci il nome.");
		x.nomeNewsLett.focus();
		return false;
	}
	if (strip(x.emailNewsLett.value) == "") {
		alert("Introduci email.");
		x.emailNewsLett.focus();
		return false;
	}

	if ((x.emailNewsLett.value.indexOf("@") < 0) || (x.emailNewsLett.value.indexOf(".") < 0) || !(x.emailNewsLett.value.indexOf("@") > 0) || !(x.emailNewsLett.value.indexOf(".") > 0)) {
		alert("Verificare email.");
		x.emailNewsLett.focus(); 
		return false; 
	}
	
	if (x.confermaNewsLett[1].checked == true) {
		alert("Non hai ancora accettato i termini indicati. Clicca su 'Sė' se vuoi sottoscrivere le condizioni esposte.");
		return false;
	}

	x.nomeNewsLett.value = x.nomeNewsLett.value.replace(/'/g, "´");
	x.cognomeNewsLett.value = x.cognomeNewsLett.value.replace(/'/g, "´");
	x.emailNewsLett.value = strip(x.emailNewsLett.value.replace(/'/g, "´"));
	x.attivitaNewsLett.value = x.attivitaNewsLett.value.replace(/'/g, "´");
	x.cittaNewsLett.value = x.cittaNewsLett.value.replace(/"/g, "´");
	x.nomeNewsLett.value = x.nomeNewsLett.value.replace(/"/g, "´");
	x.cognomeNewsLett.value = x.cognomeNewsLett.value.replace(/"/g, "´");
	x.emailNewsLett.value = x.emailNewsLett.value.replace(/"/g, "´");
	x.attivitaNewsLett.value = x.attivitaNewsLett.value.replace(/"/g, "´");
	x.cittaNewsLett.value = x.cittaNewsLett.value.replace(/"/g, "´");
	
}

//	FUNZIONI COMUNI

function campoLett(y, valid) {	//  	CONTROLLA VALIDITA' CARATTERI IN STRINGA 'y'

	for (i=0; i < y.value.length; i++) {
		for (j=0; j < valid.length; j++) {
			if (y.value.charAt(i) == valid.charAt(j)) break;
		}
		if (j == valid.length)  return false;	
	}
	return true;
}

function ISdata(stringa) { 	// Funzione di validazione della data nel formato gg/mm/aaaa
  var data = stringa; 
  if (data.length > 0) { 
    var ok = true; 
    var first = false; 
    var second = false; 
    var g = 0; 
    var m = 0; 
    var giorno; 
    var mese; 
    var anno; 
    for(i=0;i<data.length;i++) { 
      if (data.charAt(i) != '/' && (data.charAt(i) < '0') || (data.charAt(i) > '9')) ok = false; 
    } 
    if (!ok){
      return false;
    }    
	for(i=0;i<data.length;i++) { 
      if (data.charAt(i) == '/' && !first) {; 
        first = true;
        g = i;
      } 
      else if (data.charAt(i) == '/' && first) { 
        second = true;
        m = i;
      } 
    } 
    if (!first || !second) ok = false; 
    if (!ok){
      return false;
    }
    giorno = data.substring(0,g); 
    mese   = data.substring(g+1,m); 
    anno   = data.substring(m+1,data.length); 
    if (anno < 1000) ok = false;     
    if (mese < 1 || mese > 12) ok = false;     
    if (giorno < 1 || giorno > 31) ok = false; 
    if (giorno > 30 && mese == 4) ok = false; 
    if (giorno > 30 && mese == 6) ok = false; 
    if (giorno > 30 && mese == 9) ok = false; 
    if (giorno > 30 && mese == 11) ok = false; 
    if (giorno > 29 && mese == 2) ok = false; 
    if (giorno == 29 && mese == 2) {
      if (anno % 4 == 0) {
        if (anno % 100 == 0) { 
          if (anno % 400 != 0) ok = false; 
        }
      }
      else ok = false;
    } 
    if (!ok){
      return false;
    }
  }
  return true;
}

function strip(stringa) {	//	 ELIMINA TUTTI GLI SPAZI DA UNA STRINGA

	var s_tmp;
	var s_output='';
	var lunghezza=0;
	
	s_tmp= new String(stringa);
	lunghezza=s_tmp.length;

	for(i=0;i<(lunghezza);i++)
 		if(s_tmp.charAt(i)!=' ') s_output+=s_tmp.charAt(i);

	return(s_output);
}

function campoLett(y, valid) {	//  	CONTROLLA VALIDITA' CARATTERI IN STRINGA 'y'

	for (i=0; i < y.value.length; i++) {
		for (j=0; j < valid.length; j++) {
			if (y.value.charAt(i) == valid.charAt(j)) break;
		}
		if (j == valid.length)  return false;	
	}
	return true;
}