function reg_vote(id_sondaggio,opzioni) {
function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}
var http = createRequestObject();

	for (x=1; x<=opzioni; x++){
		indice = 'opt'+x;
		if(document.getElementById(''+indice+'').checked){
			my_scelta = document.getElementById(''+indice+'').value;
		}
	}
		
	var url ='http://www.barsportrimini.com/admin/p.php?act=reg_voto&scelta='+my_scelta+'&sondaggio='+id_sondaggio;

http.open('get', url);
    http.onreadystatechange = function () {
									if(http.readyState == 4){
										var response = http.responseText;
										document.getElementById('risultato').innerHTML = response;
										
									}
								}
    http.send(null);
}


function vis_ris_sond(act, id_sondaggio) {

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}
var http = createRequestObject();

		var url ='http://www.barsportrimini.com/admin/p.php?act='+act+'&id_sondaggio='+id_sondaggio;

http.open('get', url);
    http.onreadystatechange = function () {
									if(http.readyState == 4){
										var response = http.responseText;
										document.getElementById('risultati_voto').innerHTML = response;
										
									}
								}
    http.send(null);
}

function show_ris(id)
{
	div_risultati = document.getElementById(id);
	divRisultatiStyle = div_risultati.style.display;
	(divRisultatiStyle == "none") ? div_risultati.style.display = "block" : div_risultati.style.display = "none";
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function ApriImmagini(file)
{
	if (typeof win1 != "undefined") 
	win1.close();
	var prop = "top=10, left=10, width=10, height=10";
	win1 = window.open(file, null, prop);
}

function crlf_to_br(text)
{
		
		var el_html = ""
		var div = "" 
		var el = text ;
				
		if(navigator.userAgent.indexOf('Linux') != -1){ div = "\n" }		
		 else if (navigator.userAgent.indexOf('Win') != -1) { div = "\r\n" }		
		  else if(navigator.userAgent.indexOf('Mac') != -1){ div = "\r" }	
		   else { div = "\n" }
		   
		   if(navigator.userAgent.indexOf("Firefox")!=-1){
			var versionindex=navigator.userAgent.indexOf("Firefox")+8
			if (parseInt(navigator.userAgent.charAt(versionindex))>=1)
				div = "\n"
		   }
		   

		//alert(navigator.userAgent.indexOf("Firefox"))
		
		//document.write(el)
		var el_div =  el.split(div)
		
		if (el_div) {
			for (i = 0; i <= (el_div.length - 1); i++){
				
				el_html += el_div[i] 
				if (i < (el_div.length - 1)) el_html += '<br>' 
			}
		}
		
		
		//alert(navigator.userAgent.indexOf('Win'))
		//document.write(el_html_ita)
		//alert(el_html)
		return el_html
		
		//alert(el_html)

}









// Controllo inserimento dati nei moduli #####################################################


function cpi_notif()
{
	
   var d = document.notif
   var error = ""
   
   if (!d.mail.value) alert ("Inserire l'indirizzo e. mail del destinatario.")
    else d.submit()
   
   
	
}



function cpi_order()
{

   var d = document.order_ris
   
    d.submit()   
	
}





function cpi_search()
{

   var d = document.search_hotel
   var error = ""
   var plus = 0
   
   if (!d.param.value)  error += "Selezionare la tipologia di ricerca.\n";
   else 
     {
		 if (d.param.value == "tutti") plus++ 
	 }
   
   if (!plus)  {  if (!d.search_param.value) error += "Inserire il parametro di ricerca.\n"  }
   
   
   if (error) alert("Errore! Impossibile inviare il modulo.\n\n" + error)
   else d.submit()
	
}




function cpi_new_user()
{
	
  var d = window.document.nuovo_cliente
  var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
  var error = ""
  
  if (!d.idagente.value)  error += "Selezionare l'agente \n"
  if (!d.rag_sociale.value)  error += "Inserire la ragione sociale. \n"
  //if (!d.referente.value)  error += "Inserire il referente. \n"
  if (!d.piva.value)  error += "Inserire la partita iva \n"
  if (!d.indirizzo.value)  error += "Inserire l'indirizzo \n"
  if (d.cap.value)  { if (isNaN(d.cap.value) || (d.cap.value < 1))  error += "Il cap inserito non è valido.\n"  }
  if (!d.provincia.value)  error += "Inserire la provincia. \n"
  if (!d.tel.value) error += "Il numero di telefono inserito non è valido.\n" 
  if (!d.email.value)  error += "Inserire l'indirizzo e-mail. \n"
  else { if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test( d.email.value ))  { error += "L'indirizzo e-mail inserito non è valido.\n" } }

  

  if (error) {
	 alert(title_error + error); 
	 
  } else {
	  d.submit()
  }
	
	
}


function cpi_new_attivita(categ)
{
	
  var d = window.document.nuova_attivita
  var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
  var error = ""
  if(categ!='1'){
  	if ((!d.categoria.value)&&(!d.categoria.disabled))  error += "Selezionare la categoria dell'attività \n"
  }
  //if ((!d.rag_sociale.value)&&(!d.rag_sociale.disabled))  error += "Inserire la ragione sociale. \n"
  if ((!d.nome_attivita.value)&&(!d.nome_attivita.disabled))  error += "Inserire il nome dell'azienda. \n"
  //if ((!d.piva.value)&&(!d.piva.disabled))  error += "Inserire la partita iva \n"
  if ((!d.indirizzo.value)&&(!d.indirizzo.disabled))  error += "Inserire l'indirizzo \n"
  if ((d.cap.value)&&(!d.cap.disabled))  { if (isNaN(d.cap.value) || (d.cap.value < 10000))  error += "Il cap inserito non è valido.\n"  }
  if ((!d.provincia.value)&&(!d.provincia.disabled))  error += "Inserire la provincia. \n"
  if ((!d.tel.value)&&(!d.tel.disabled)) error += "Il numero di telefono inserito non è valido.\n" 
  if (!d.email.value)  error += "Inserire l'indirizzo e-mail. \n"
  else { if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test( d.email.value ))  { error += "L'indirizzo e-mail inserito non è valido.\n" } }
  
  if (!d.usr.value)  error += "Inserire la username \n"
  if (!d.psw.value)  error += "Inserire la password \n"
  if (!d.hosting.value)  error += "Inserire l'hosting \n"
  //if (!d.logo.value)  error += "Inserire il logo \n"

  

  if (error) {
	 alert(title_error + error); 
	 return(false);
  } else {
	  //return(true);
  }
	
	
}


function cpi_modif_attivita()
{
	
  var d = window.document.nuova_attivita
  var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
  var error = ""
  
  //if ((!d.tipologia.value)&&(!d.tipologia.disabled))  error += "Selezionare la tipologia del cliente \n"
  //if ((!d.rag_sociale.value)&&(!d.rag_sociale.disabled))  error += "Inserire la ragione sociale. \n"
  //if ((!d.nome_attivita.value)&&(!d.nome_attivita.disabled))  error += "Inserire il nome dell'azienda. \n"
  //if ((!d.piva.value)&&(!d.piva.disabled))  error += "Inserire la partita iva \n"
  //if ((!d.indirizzo.value)&&(!d.indirizzo.disabled))  error += "Inserire l'indirizzo \n"
  //if ((d.cap.value)&&(!d.cap.disabled))  { if (isNaN(d.cap.value) || (d.cap.value < 10000))  error += "Il cap inserito non è valido.\n"  }
  //if ((!d.provincia.value)&&(!d.provincia.disabled))  error += "Inserire la provincia. \n"
  if ((!d.tel.value)&&(!d.tel.disabled)) error += "Il numero di telefono inserito non è valido.\n" 
  if (!d.email.value)  error += "Inserire l'indirizzo e-mail. \n"
  else { if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test( d.email.value ))  { error += "L'indirizzo e-mail inserito non è valido.\n" } }
  
  if (!d.usr.value)  error += "Inserire la username \n"
  if (!d.psw.value)  error += "Inserire la password \n"
  if (!d.hosting.value)  error += "Inserire l'hosting \n"
  //if (!d.logo.value)  error += "Inserire il logo \n"

  

  if (error) {
	 alert(title_error + error); 
	 return(false);
  } else {
	  return(true);
  }
	
	
}

function no_view(){
	
	
	var i;
	var d = window.document.nuova_attivita;
	
	 for(i=3; i<=6; i++)
	 {
		 d.elements[i].disabled  = true;	 
	 }
}

function no_view_modif(){
	
	
	var i;
	var d = window.document.nuova_attivita;
	
	 for(i=3; i<=7; i++)
	 {
		 d.elements[i].disabled = true	 
	 }
}

function no_view_modif2(){
	
	
	var i;
	var d = window.document.nuova_attivita;
	
	 for(i=1; i<=6; i++)
	 {
		 d.elements[i].disabled = true	 
	 }
}

function view(){
	
	
	var i;
	var d = window.document.nuova_attivita;
	
	 for(i=1; i<=10; i++)
	 {
		 d.elements[i].disabled = false	 
	 }
}

function reloadpage(){		
	var d = window.document.nuova_attivita;
	d.submit()
}

function cpi_categoria(){
	var d = window.document.search_clienti;
	d.submit()	
}

function copyvaluelink(valore){
	var d = window.document.insert_servizi;
	d.LINK_url.value = valore
}

function copyvaluebanner(valore){
	var d = window.document.insert_servizi;
	d.BANNER_urlsito.value = valore
}

function view_banner(file,portale)
{	
   open("view_banner.php?file="+file+"&portale="+portale,"","width=600,height=200,scrollbars=no")	
}

function view_notifiche(id_cliente)
{	
   var x = document.body.offsetWidth
   var y = document.body.offsetHeight
   TheNewWin = window.open("notifica.php?id_cliente="+id_cliente,"","width=650,height=690,scrollbars=yes")
   TheNewWin.moveTo((x-650)/2,((y-750)/2)-50);
}

function view_logo(file)
{	
   open("view_logo.php?file="+file,"","width=90,height=90,scrollbars=no")	
}


function erase_service(url){
	var x=window.confirm("Vuoi eliminare il servizio definitivamente?")
	if (x)
	document.location=url;
	else
	window.alert("Azione annullata")
}

function no_logo(url){
	var x=window.confirm("Impossibile inserire questo servizo poichè l'attivita non ha un logo!\r\nInserire un logo adesso?")
	if (x)
	document.location=url;
	
}

function disattiva_service(url){
	var x=window.confirm("Vuoi disattivare questo servizio senza eliminarne i dati?")
	if (x)
	document.location=url;
	else
	window.alert("Azione annullata")
}

function attiva_service(url){
	var x=window.confirm("Vuoi attivare questo servizio?")
	if (x)
	document.location=url;
	else
	window.alert("Azione annullata")
}

function modify(id_attivita,id_cliente){
		//alert(id_attivita)
		//alert(id_cliente)
		document.location.href="index.php?go=modif_attivita&id_cliente="+ id_cliente +"&id_attivita="+id_attivita
}

function cpi_new_link()
{
	
   var d = document.insert_servizi
   var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
   var error = ""
   
   if (!d.url.value) error += "Inserire l'URL da linkare \n"
   if (!d.nomelink.value) error += "Inserire il nome del link \n"
   //if (!d.descrizione.value) error += "Inserire una descrizione \n"
   
   
   if (error) {
	 alert(title_error + error); 
  } else {
	  d.submit()
  }

}

function cpi_new_banner()
{
	
   var d = document.insert_servizi
   var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
   var error = ""

   
   if (!d.url.value) error += "Inserire l'URL da linkare \n"
   if ((!d.file.value)&&(d.sel_old_file.value==0)) error += "Inserire il file del banner \n"
   //if (!d.nomelink.value) error += "Inserire l' ALT immagine\n"
   
   
   if (error) {
	 alert(title_error + error); 
  } else {
	  d.submit()
  }

}

function view_all(id_attivita,id_cliente){
		//alert(id_attivita)	
		document.location="index.php?go=view_all&id_cliente="+ id_cliente +"&id_attivita="+id_attivita
}

function del_cliente(id_cliente){
		
	var x=window.confirm("Vuoi eliminare tutta l'anagrafica generale e le attività correlate?")
	if (x){
		document.location="index.php?&action=erase&type=anag_gen&id_cliente="+id_cliente
	}else{
		window.alert("Azione annullata")
	}

	
}

function del_attivita(id_attivita){
	
	var x=window.confirm("Vuoi eliminare questa l'attività?")
		if (x){
			document.location="index.php?action=erase&type=attivita&id_attivita="+id_attivita
		}else{
			window.alert("Azione annullata")
		}
	
}

function del_cliente2(id_cliente){
	
	//alert(id_attivita);
	//alert(id_cliente);
	//alert(a.substring(0,9))
		
	
	var x=window.confirm("Vuoi eliminare tutta l'anagrafica generale e le attività correlate?")
	if (x){
		document.location="index.php?&action=erase&type=anag_gen&id_cliente="+id_cliente
	}else{
		window.alert("Azione annullata")
	}
		
		
		
		
	
	
}

function goinsertattivita(){		
	var d = window.document.nuova_attivita;
	d.submit()
}

function select_localita(url,provincia,categ){

		var d = document.nuova_attivita
		var nomeattivita = escape(d.nome_attivita.value)
		var id_attivita = d.id_attivita.value
		var indir = escape(d.indirizzo.value)
		var cap = d.cap.value
		var tel = d.tel.value
		var fax = d.fax.value
		var sito1 = d.sito1.value
		var sito2 = d.sito2.value
		var sito3 = d.sito3.value
		var sito4 = d.sito4.value
		var sito5 = d.sito5.value
		var usr = escape(d.usr.value)
		var psw = escape(d.psw.value)
		if(categ!=1){
			var categoria = d.categoria.options[d.categoria.selectedIndex].value
			var endquery = "&categoria="+categoria
		}else{
			var endquery = '';	
		}
		//var hosting = d.hosting.options[d.hosting.selectedIndex].value
		var email = d.email.value	
		
		document.location=url+provincia+"&nome_attivita="+nomeattivita+"&indirizzo="+indir+"&cap="+cap+"&tel="+tel+"&fax="+fax+"&sito1="+sito1+"&sito2="+sito2+"&sito3="+sito3+"&sito4="+sito4+"&sito5="+sito5+"&usr="+usr+"&psw="+psw+"&id_attivita="+id_attivita+"&email="+email+endquery
}


function select_localita_anaggen(url,provincia){

		var d = document.nuovo_cliente
		var rag_sociale = escape(d.rag_sociale.value)
		var referente = d.referente.value
		var recapito_referente = escape(d.recapito_referente.value)
		var piva = d.piva.value
		var indirizzo = escape(d.indirizzo.value)
		var cap = d.cap.value
		var tel = d.tel.value
		var fax = d.fax.value
		var mobile = d.mobile.value
		var email = d.email.value
		var idagente = d.idagente.options[d.idagente.selectedIndex].value

		
		document.location=url+provincia+"&rag_sociale="+rag_sociale+"&referente="+referente+"&recapito_referente="+recapito_referente+"&piva="+piva+"&indirizzo="+indirizzo+"&cap="+cap+"&tel="+tel+"&fax="+fax+"&mobile="+mobile+"&email="+email+"&idagente="+idagente
}


function gest_servizi(id_attivita,id_cliente){
		//alert(id_attivita)
		
		var str = new String(id_attivita)

        str = str.slice(0,9)
		if(str=='generale_'){
			alert('Selezionare un\'attivita')
		}else{
			document.location="index.php?go=select_services&id_attivita="+id_attivita+"&id_cliente="+id_cliente	
		}
		
		//alert(id_cliente)
		//document.location.href="index.php?go=modif_attivita&id_cliente="+ id_cliente +"&id_attivita="+id_attivita
}


function CopyFormObject(srcobj, destobj) {
	val=MM_findObj(srcobj)
	val2=MM_findObj(destobj);

	if(val != null && val2 !=null)
	{
		val2.value = val.value;
	}
}

function MM_findObj(n, d) {
  var p,i,x;
  if(!d) d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
  	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all){
  	 x=d.all[n];
  }
  for (i=0;!x&&i<d.forms.length;i++) {
  	x=d.forms[i][n];
  }
  for(i=0;!x&&d.layers&&i<d.layers.length;i++){
  	 x=MM_findObj(n,d.layers[i].document);
  }
  return x;
}

function copia(campo1, campo2, campo3, campo4) {

	CopyFormObject(campo1, campo2);
	CopyFormObject(campo3, campo4);
}

function stripLeadingZeroes(input){
	  if((input.length > 1) && (input.substr(0,1) == "0"))
			return input.substr(1);
	  else
			return input;
 } 

function cpi_new_lastminute(maxgiorni)
{
	
   var d = document.insert_servizi
   var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
   var error = ""
   
   if (!d.titolo_it.value) error += "Inserire il titolo del last minute in italiano\n"
   if (!d.descrizione_it.value) error += "Inserire la descrizione del last minute in italiano\n"

   if (d.descrizione_it.value!='') d.descrizione_it.value = crlf_to_br(document.insert_servizi.descrizione_it.value)
   if (d.descrizione_en.value!='') d.descrizione_en.value = crlf_to_br(document.insert_servizi.descrizione_en.value)
   if (d.descrizione_fr.value!='') d.descrizione_fr.value = crlf_to_br(document.insert_servizi.descrizione_fr.value)
   if (d.descrizione_de.value!='') d.descrizione_de.value = crlf_to_br(document.insert_servizi.descrizione_de.value)

	//alert(document.insert_servizi.descrizione_it.value)

   
	var humDate1 = new Date(Date.UTC(document.getElementById("anno_start").value,(stripLeadingZeroes(document.getElementById("mese_start").value)-1),stripLeadingZeroes(document.getElementById("giorno_start").value),1, 1, 1));
	tempo1 = (humDate1.getTime()/1000.0);
	//tempo2
	var humDate2 = new Date(Date.UTC(document.getElementById("anno_end").value,           (stripLeadingZeroes(document.getElementById("mese_end").value)-1), stripLeadingZeroes(document.getElementById("giorno_end").value),           1, 1, 1));
	tempo2 = (humDate2.getTime()/1000.0);
	//86400 = un giorno
	//5184000 = 60 giorni 
	var tempotot = maxgiorni * 86400
	if((tempo2 - tempo1) > tempotot) error +="Attenzione, il divario tra la data d'inizio e la data della fine non deve superare "+maxgiorni+" giorni"  
   
	if (error) {
	 alert(title_error + error); 
	 return false
	} else {
	  d.submit()
	}

}

function cpi_modif_lastminute(maxgiorni)
{
	
   var d = document.insert_servizi
   var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
   var error = ""
   
   if (!d.titolo_it.value) error += "Inserire il titolo del last minute in italiano\n"
   if (!d.descrizione_it.value) error += "Inserire la descrizione del last minute in italiano\n"
   
   if (d.descrizione_it.value!='') d.descrizione_it.value = crlf_to_br(document.insert_servizi.descrizione_it.value)
   if (d.descrizione_en.value!='') d.descrizione_en.value = crlf_to_br(document.insert_servizi.descrizione_en.value)
   if (d.descrizione_fr.value!='') d.descrizione_fr.value = crlf_to_br(document.insert_servizi.descrizione_fr.value)
   if (d.descrizione_de.value!='') d.descrizione_de.value = crlf_to_br(document.insert_servizi.descrizione_de.value)

   //alert(d.descrizione_it.value);return false
   
	var humDate1 = new Date(Date.UTC(document.getElementById("anno_start").value,(stripLeadingZeroes(document.getElementById("mese_start").value)-1),stripLeadingZeroes(document.getElementById("giorno_start").value),1, 1, 1));
	tempo1 = (humDate1.getTime()/1000.0);
	//tempo2
	var humDate2 = new Date(Date.UTC(document.getElementById("anno_end").value,           (stripLeadingZeroes(document.getElementById("mese_end").value)-1), stripLeadingZeroes(document.getElementById("giorno_end").value),           1, 1, 1));
	tempo2 = (humDate2.getTime()/1000.0);
	//86400 = un giorno
	//5184000 = 60 giorni 
	var tempotot = maxgiorni * 86400
	if((tempo2 - tempo1) > tempotot) 
	{
		error +="Attenzione, il divario tra la data d'inizio e la data della fine non deve superare "+maxgiorni+" giorni"
		
	}
	   
   
   
   
   
	if (error) {
	 alert(title_error + error); 
	 return false
	} else {
	  return true
	}
	

}

function showhidedata(objct){
	var hosting = objct.options[objct.selectedIndex].value
	if(hosting==0){
		window.document.nuova_attivita.scad_hosting_1.disabled  = true;
		window.document.nuova_attivita.scad_hosting_2.disabled  = true;
		window.document.nuova_attivita.scad_hosting_3.disabled  = true;
	}
	if(hosting==1){
		window.document.nuova_attivita.scad_hosting_1.disabled  = false;
		window.document.nuova_attivita.scad_hosting_2.disabled  = false;
		window.document.nuova_attivita.scad_hosting_3.disabled  = false;
	}
	
}






























// #############################################################################################





function open_win(rif,wi,he,dwn)
{
   	open(rif,"","width="+wi+", height="+he+", scrollbars="+dwn)
}


function open_foto(foto,wFoto,hFoto)
{	
   open("view_foto.php?foto="+foto,"","width="+wFoto+",height="+hFoto+",scrollbars=no")	
}



function sel_hotel()
{
   var d = document.search_hotel
   
   if (d.param.value == "tutti") d.search_param.disabled = true
   else d.search_param.disabled = false
   
   if (d.param.value == "datascadenza") d.search_param.value = "gg/mm/aaaa"
   else d.search_param.value = ""
}



function do_sel(name_form)
{
   var d = document
   
   alert(name_form)
   
}



function ins_citta()
{
   var d = document.nuovo
   
   if (document.nuovo.boxcitta.value) document.nuovo.citta.value = document.nuovo.boxcitta.value 
}

function cpi_notifiche()
{
	
   var d = document.notifica
   var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
   var error = ""
   
   if (!d.tipo_notifica.value) error += "Selezionare la tipologia di notifica \n"	
   if (!d.email_invio.value) error += "Inserire l'indirizzo e-mail al quale inviare i dati \n"
   
   
   
   if (error) {
	 alert(title_error + error);
	 return (false);
  } else {
	  return (true);
  }

}

function cpi_new_banner_pagina()
{
	
   var d = document.insert_servizi
   var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
   var error = ""

   
   //if (!d.file.value) error += "Inserire il file del banner\n"
   if ((!d.file.value)&&(d.sel_old_file.value==0)) error += "Inserire il file del banner \n"
   if (!d.nomelink.value) error += "Inserire l' ALT immagine\n"
   if (!d.descrizione_it.value) error += "Inserire un breve descrizione della struttura\n"
   if (d.descrizione_it.value.length > 100) error += "La breve descrizione supera i 100 caratteri\n"
   if (!d.logo.value) error += "Inserire il logo dell'azienda per la pagina interna\n"
   if (!d.descrizione_struttura.value) error += "Inserire la descrizione della struttura\n"
   if (!d.foto1.value) error += "Inserire la foto 1\n"
   if (!d.foto2.value) error += "Inserire la foto 2\n"
   if (!d.foto3.value) error += "Inserire la foto 3\n"
   if (!d.foto4.value) error += "Inserire la foto 4\n"
   if (!d.foto5.value) error += "Inserire la foto 5\n"
   if (!d.foto6.value) error += "Inserire la foto 6\n"
   
   var totale = 0;
   if (d.usa_foto1.checked==true) totale++
   if (d.usa_foto2.checked==true) totale++
   if (d.usa_foto3.checked==true) totale++
   if (d.usa_foto4.checked==true) totale++
   if (d.usa_foto5.checked==true) totale++
   if (d.usa_foto6.checked==true) totale++
   
  
   
   if(totale >3) error += "Non si possono selezionare più di 3 foto\n"
  
   
   
   if (error) {
	 alert(title_error + error); 
  } else {
	  d.submit()
  }

}

function cpi_new_pagina()
{
	
   var d = document.insert_servizi
   var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
   var error = ""

   
   if (!d.logo.value) error += "Inserire il logo dell'azienda\n"
   //if (!d.mappa.value) error += "Inserire il file della mappa stradale\n"
   
   if (!d.descr_struttura_ita.value) error += "Inserire almeno una descrizione della struttura in italiano\n"

   if (!d.foto1.value) error += "Inserire la foto 1\n"
   if (!d.foto2.value) error += "Inserire la foto 2\n"
   if (!d.foto3.value) error += "Inserire la foto 3\n"
   //if (!d.foto4.value) error += "Inserire la foto 4\n"
   //if (!d.foto5.value) error += "Inserire la foto 5\n"
   //if (!d.foto6.value) error += "Inserire la foto 6\n"
   //if (!d.foto7.value) error += "Inserire la foto 7\n"
   //if (!d.foto8.value) error += "Inserire la foto 8\n"
   
   var totale = 0;
   if (d.usa_foto1.checked==true) totale++
   if (d.usa_foto2.checked==true) totale++
   if (d.usa_foto3.checked==true) totale++
   if (d.usa_foto4.checked==true) totale++
   if (d.usa_foto5.checked==true) totale++
   if (d.usa_foto6.checked==true) totale++
   if (d.usa_foto7.checked==true) totale++
   if (d.usa_foto8.checked==true) totale++
   if (d.usa_foto9.checked==true) totale++
   if (d.usa_foto10.checked==true) totale++

   if(totale >8) error += "Non si possono selezionare più di 8 foto\n"

   if (error) {
	 alert(title_error + error); 
  } else {
	  d.submit()
  }

}


function cpi_modif_pagina_abcrn()
{
	
   var d = document.insert_servizi
   var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
   var error = ""


   
   if (!d.descr_struttura_ita.value) error += "Inserire almeno una descrizione della struttura in italiano\n"

   var totale = 0;
   if (d.usa_foto1.checked==true) totale++
   if (d.usa_foto2.checked==true) totale++
   if (d.usa_foto3.checked==true) totale++
   if (d.usa_foto4.checked==true) totale++
   if (d.usa_foto5.checked==true) totale++
   if (d.usa_foto6.checked==true) totale++
   if (d.usa_foto7.checked==true) totale++
   if (d.usa_foto8.checked==true) totale++
   if (d.usa_foto9.checked==true) totale++
   if (d.usa_foto10.checked==true) totale++

   if(totale >8) error += "Non si possono selezionare più di 8 foto\n"

   if (error) {
	 
	 alert(title_error + error); 
	 return (false)
	 
  } 

}


function cpi_modif_banner_pagina()
{
	
   var d = document.insert_servizi
   var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
   var error = ""

   

   if (!d.nomelink.value) error += "Inserire l' ALT immagine\n"
   if (!d.descrizione_it.value) error += "Inserire un breve descrizione della struttura\n"
   if (d.descrizione_it.value.length > 100) error += "La breve descrizione supera i 100 caratteri\n"
   if (!d.descrizione_struttura.value) error += "Inserire la descrizione della struttura\n"
   
   
   
   var totale = 0;
   if (d.usa_foto1.checked==true) totale++
   if (d.usa_foto2.checked==true) totale++
   if (d.usa_foto3.checked==true) totale++
   if (d.usa_foto4.checked==true) totale++
   if (d.usa_foto5.checked==true) totale++
   if (d.usa_foto6.checked==true) totale++
   
  
   
   if(totale >3) error += "Non si possono selezionare più di 3 foto\n"
   
  
   
   
   if (error) {
	 alert(title_error + error); 
	 return false
  } else {
	  return true
  }

}

function cpi_new_gestionale()
{
	
   var d = document.insert_servizi
   var title_error = "ERRORE! Impossibile inviare il modulo. \n\n"
   var error = ""


   
   if (error) {
	 alert(title_error + error); 
  } else {
	  d.submit()
  }

}

function verifica_data(primadatalibera){

	var humDate1 = new Date(Date.UTC(document.getElementById("anno_start").value,(stripLeadingZeroes(document.getElementById("mese_start").value)-1),stripLeadingZeroes(document.getElementById("giorno_start").value),1, 1, 1));
	dataimpostata = (humDate1.getTime()/1000.0);
	
	if(dataimpostata < primadatalibera){
		alert("La data di inizio servizio è errata!!");	
	}
	
}

function open_close(miotag,nome_check){
	if(nome_check.checked){
		MM_changeProp(miotag,'','style.display','block','DIV')
	}
	if(!nome_check.checked){
		MM_changeProp(miotag,'','style.display','none','DIV')
	}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function conferma_login(url,messaggio){
	var x=window.confirm(messaggio)
	if (x)
	document.location=url;
	

}