HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.34
System: Linux atalantini.com 3.10.0-1127.13.1.el7.x86_64 #1 SMP Tue Jun 23 15:46:38 UTC 2020 x86_64
User: root (0)
PHP: 7.2.34
Disabled: NONE
Upload Files
File: //opt/plugins/atalantini/js/elettrotecafunctions.js
function random(min, max) {
	var randomnumber=Math.floor(Math.random()*max);
	return randomnumber;
}

function salvaUtente() {
	if (validateFormUtente()) {
		var azione = "INSERT";
		if (jQuery('#utenteId').val() != "") {
			azione = "UPDATE";
		}
		jQuery.post("../wp-content/plugins/elettroteca/data/service_utente.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
			"nome": jQuery('#nome').val() , 
			"cognome": jQuery('#cognome').val(), 
        	        "email": jQuery('#email').val(),        
        	        "password": jQuery('#password').val(),        
        	        "societa": jQuery('#societa').val(),        
        	        "tipo_utente": jQuery('#tipo_utente').val(),        
        	        "indirizzo": jQuery('#indirizzo').val(),        
        	        "attivo": jQuery('#attivo').val(),        
        	        "sottoscrizione_bacheca": jQuery('#sottoscrizione_bacheca').val(),        
        	        "invia_password": jQuery('#invia_password').val(),
			"promozione": jQuery('#promozione').val(),
			"id": jQuery('#utenteId').val()
		}, function(data) {
			idUtente = "";
			if (data != "false") {
				alert("salvataggio effettuato");
				listaUtente(1);
			} else {
				alert("Attenzione. Ricontrolla i campi, la username e' gia in uso");
			}
        	});
	}
}

function cancellaUtente(id) {
        var azione = "DELETE";
        jQuery.post("../wp-content/plugins/elettroteca/data/service_utente.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
                "id": id
        }, function(data) {
                idUtente = "";
		listaUtente(1);
                alert("Cancellazione effettuata");
        });
}

function listaUtente(page) {
	html = "";
	paginator = "";
	if (page > 1) {
		paginator += "<a href=\"#\" onClick=\"listaUtente(" + (page - 1) + ");\">Precedente</a> | ";
	}
	jQuery('#lista_utente').html('');
	jQuery.getJSON("../wp-content/plugins/elettroteca/data/service_utente.php?rand=" + random(0, 999) + "&viewmode=off&azione=LIST&pageSize=" + pageSize + "&pageNo=" + page + "&searchkey=" + jQuery('#search_utente').val(),
		function(data) {
			jQuery.each(data.lista, function(i,ts){
                                if (ts.promozione == 'N') {
                                        showPromozione = "block";
                                        hidePromozione = "none";
                                } else {
                                        showPromozione = "none";
                                        hidePromozione = "block";
                                }
				html += "<tr>";
				html += "<td>" + ts.id + "</td>";
				html += "<td>" + ts.cognome + "</td>";
                                html += "<td>" + ts.nome + "</td>";
                                html += "<td>" + ts.societa + "</td>";
                                html += "<td>" + ts.email + "</td>";
                                html += "<td>" + ts.tipo_utente + "</td>";
				html += "<td>";
                                html += "<div id='addPromozione' style='display:" + showPromozione + "'><a href=\"#\" onClick=\"setPromozione(" + ts.id + ");\">Disabilitato a promozione</a></div>";
                                html += "<div id='delPromozione' style='display:" + hidePromozione + "'><a href=\"#\" onClick=\"delPromozione(" + ts.id + ");\">Abilitato a promozione</a></div>";
				html += "<a href=\"#\" onClick=\"modificaUtente(" + ts.id + ");\">Modifica</a> | <a href=\"#\" onClick=\"cancellaUtente(" + ts.id + ");\">Cancella</a>";
				html += "</td>";
				html += "</tr>";
			});
		        numPages = Math.round(data.totaleValori/pageSize);
        		if (((numPages * pageSize) > data.totaleValori) && (page < numPages)) {
                		paginator += "<a href=\"#\" onClick=\"listaUtente(" + (page + 1) + ");\">Successivo</a>";
        		}
                        jQuery('#paginator').html(paginator);
			jQuery('#grigliaUtente').css('display', 'block');
                        jQuery('#formUtente').css('display', 'none'); 
			jQuery('#lista_utente').html(html);
	});
}

function creaUtente() {
	jQuery('#utenteId').val('');
	jQuery('#nome').val('');
        jQuery('#cognome').val('');
        jQuery('#email').val('');
        jQuery('#password').val('');
        jQuery('#societa').val('');
        jQuery('#tipo_utente').val('');
        jQuery('#indirizzo').val('');
        jQuery('#attivo').val('');
        jQuery('#sottoscrizione_bacheca').val('');
	jQuery('#promozione').val('');
        jQuery('#grigliaUtente').css('display', 'none');
        jQuery('#formUtente').css('display', 'block');
}

function modificaUtente(id) {
        html = "";
        jQuery('#lista_utente').html('');
        jQuery.getJSON("../wp-content/plugins/elettroteca/data/service_utente.php?rand=" + random(0, 999) + "&viewmode=off&azione=DETAIL&id=" + id,
                function(data) {
                        jQuery.each(data.dettaglio, function(i,ts){
                                jQuery('#utenteId').val(ts.id);
                                jQuery('#nome').val(ts.nome);
                                jQuery('#cognome').val(ts.cognome);
                                jQuery('#email').val(ts.email);
                                jQuery('#password').val(ts.password);
                                jQuery('#societa').val(ts.societa);
                                jQuery('#tipo_utente').val(ts.tipo_utente);
                                jQuery('#indirizzo').val(ts.indirizzo);
                                jQuery('#attivo').val(ts.attivo);
                                jQuery('#sottoscrizione_bacheca').val(ts.sottoscrizione_bacheca);
                                jQuery('#promozione').val(ts.promozione);
                        });
                        jQuery('#grigliaUtente').css('display', 'none');
                        jQuery('#formUtente').css('display', 'block');
        });
}

function salvaNews() {
	if (validateFormNews()) {
        	var azione = "INSERT";
        	if (jQuery('#newsId').val() != "") {
        	        azione = "UPDATE";
        	}
		var htmlTesto = "";
		if( jQuery('#testo').is(':visible') ) {
			htmlTesto = jQuery('#testo').val();
		} else {
			var editor = tinyMCE.get("testo");
			htmlTesto = editor.getContent();   
		}
        	jQuery.post("../wp-content/plugins/elettroteca/data/service_news.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
        	        "data": jQuery('#data').val() ,
        	        "titolo": jQuery('#titolo').val(),
        	        "abstract": jQuery('#abstract').val(),
        	        "testo": htmlTesto,
        	        "tipo_accesso": jQuery('#tipo_accesso').val(),
        	        "tipo_target": jQuery('#tipo_target').val(),
        	        "id": jQuery('#newsId').val()
        	}, function(data) {
        	        idNews = "";
        	        alert("salvataggio effettuato");
        	        listaNews(1);
        	});
	}
}

function cancellaNews(id) {
        var azione = "DELETE";
        jQuery.post("../wp-content/plugins/elettroteca/data/service_news.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
                "id": id
        }, function(data) {
                idNews = "";
                listaNews(1);
                alert("Cancellazione effettuata");
        });
}


function listaNews(page) {
        html = "";
        paginator = "";
        if (page > 1) {
                paginator += "<a href=\"#\" onClick=\"listaNews(" + (page - 1) + ");\">Precedente</a> | ";
        }
        jQuery('#lista_news').html('');
        jQuery.getJSON("../wp-content/plugins/elettroteca/data/service_news.php?rand=" + random(0, 999) + "&viewmode=off&azione=LIST&pageSize=" + pageSize + "&pageNo=" + page + "&searchkey=" + jQuery('#search_news').val(),
                function(data) {
                        jQuery.each(data.lista, function(i,ts){
                                html += "<tr>";
                                html += "<td>" + ts.id + "</td>";
                                html += "<td>" + ts.data + "</td>";
                                html += "<td>" + ts.titolo + "</td>";
                                html += "<td><a href=\"#\" onClick=\"modificaNews(" + ts.id + ");\">Modifica</a> | <a href=\"#\" onClick=\"cancellaNews(" + ts.id + ");\">Cancella</a></td>";
                                html += "</tr>";
                        });
                        numPages = Math.round(data.totaleValori/pageSize);
                        if (((numPages * pageSize) > data.totaleValori) && (page < numPages)) {
                                paginator += "<a href=\"#\" onClick=\"listaNews(" + (page + 1) + ");\">Successivo</a>";
                        }
                        jQuery('#paginator').html(paginator);
                        jQuery('#grigliaNews').css('display', 'block');
                        jQuery('#formNews').css('display', 'none');
                        jQuery('#lista_news').html(html);
        });
}

function listaNewspublic(page) {
        html = "";
        paginator = "";
        if (page > 1) {
                paginator += "<a href=\"#\" onClick=\"listaNewspublic(" + (page - 1) + ");\">Precedente</a> | ";
        }
	var showPublicNews = "none";
	var hidePublicNews = "none";
        jQuery('#lista_newspublic').html('');
        jQuery.getJSON("../wp-content/plugins/elettroteca/data/service_newspublic.php?rand=" + random(0, 999) + "&viewmode=off&azione=LIST&pageSize=" + pageSize + "&pageNo=" + page + "&searchkey=" + jQuery('#search_newspublic').val(),
                function(data) {
                        jQuery.each(data.lista, function(i,ts){
				if (ts.conteggio == 0) {
				        showPublicNews = "block";
				        hidePublicNews = "none";
				} else {
				        showPublicNews = "none";
				        hidePublicNews = "block";
				}
                                html += "<tr>";
                                html += "<td>" + ts.id + "</td>";
                                html += "<td>" + ts.data + "</td>";
                                html += "<td>" + ts.titolo + "</td>";
                                html += "<td>" + ts.categoria + "</td>";
                                html += "<td>";
				html += "<div id='addPublicNew' style='display:" + showPublicNews + "'><a href=\"#\" onClick=\"setPublicNews(" + ts.id + ");\">Metti in homepage</a></div>";
                                html += "<div id='delPublicNew' style='display:" + hidePublicNews + "'><a href=\"#\" onClick=\"delPublicNews(" + ts.id + ");\">togli da homepage</a></div>";
				html += "</td>";
                                html += "</tr>";
                        });
                        numPages = Math.round(data.totaleValori/pageSize);
                        if (((numPages * pageSize) > data.totaleValori) && (page < numPages)) {
                                paginator += "<a href=\"#\" onClick=\"listaNewspublic(" + (page + 1) + ");\">Successivo</a>";
                        }
                        jQuery('#paginator').html(paginator);
                        jQuery('#grigliaNewspublic').css('display', 'block');
                        jQuery('#lista_newspublic').html(html);
        });
}

function creaNews() {
        jQuery('#newsId').val('');
        jQuery('#data').val('');
        jQuery('#titolo').val('');
        jQuery('#abstract').val('');
        jQuery('#testo').val('');
        jQuery('#tipo_accesso').val('');
        jQuery('#tipo_target').val('');
        jQuery('#grigliaNews').css('display', 'none');
        jQuery('#formNews').css('display', 'block');
	if( jQuery('#testo').is(':visible') ) {
	    jQuery('#testo').val('');
	} else {
	    var editor = tinyMCE.get("testo");
	    editor.setContent('');           
	}       
        jQuery('#azione').val('INSERT');
}

function modificaNews(id) {
        html = "";
        jQuery('#lista_news').html('');
        jQuery.getJSON("../wp-content/plugins/elettroteca/data/service_news.php?rand=" + random(0, 999) + "&viewmode=off&azione=DETAIL&id=" + id,
                function(data) {
                        jQuery.each(data.dettaglio, function(i,ts){
                                jQuery('#newsId').val(ts.id);
                                jQuery('#data').val(ts.data);
                                jQuery('#titolo').val(ts.titolo);
                                jQuery('#abstract').val(ts.abstract);
                                if( jQuery('#testo').is(':visible') ) {
                                        jQuery('#testo').val(ts.testo);
                                } else {
                                        var editor = tinyMCE.get("testo");
                                        editor.setContent(ts.testo);
                                }
                                jQuery('#spotNewsImmagine').html('<img src="../wp-content/news/' + ts.immagine+ '" border=0>');
                                jQuery('#tipo_accesso').val(ts.tipo_accesso);
                                if (ts.tipo_accesso == "P") {
                                        jQuery('#idPrivatePanel').css('display','none');
                                        jQuery('#idPublicPanel').css('display','block');
                                } else {
                                        jQuery('#idPrivatePanel').css('display','block');
                                        jQuery('#idPublicPanel').css('display','none');
                                }
                                jQuery('#tipo_target').val(ts.tipo_target);
                                jQuery('#wp_page').val(ts.wp_page);
                                jQuery('#azione').val('UPDATE');
                                //tinyMCE.activeEditor.setContent(testo);
                        });
                        jQuery('#grigliaNews').css('display', 'none');
                        jQuery('#formNews').css('display', 'block');
        });
}

function salvaEventi() {
        if (validateFormEventi()) {
                var azione = "INSERT";
                if (jQuery('#eventiId').val() != "") {
                        azione = "UPDATE";
                }
                var htmlTesto = "";
                if( jQuery('#testo_evento').is(':visible') ) {
                        htmlTesto = jQuery('#testo_evento').val();
                } else {
                        var editor = tinyMCE.get("testo_evento");
                        htmlTesto = editor.getContent();
                }
                jQuery.post("../wp-content/plugins/elettroteca/data/service_eventi.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
                        "data_evento": jQuery('#data_evento').val() ,
                        "titolo_evento": jQuery('#titolo_evento').val(),
                        "testo_evento": htmlTesto,
                        "id": jQuery('#eventiId').val()
                }, function(data) {
                        idEventi = "";
                        alert("salvataggio effettuato");
                        listaEventi(1);
                });
        }
}

function cancellaEventi(id) {
        var azione = "DELETE";
        jQuery.post("../wp-content/plugins/elettroteca/data/service_eventi.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
                "id": id
        }, function(data) {
                idEventi = "";
                listaEventi(1);
                alert("Cancellazione effettuata");
        });
}

function listaEventi(page) {
        html = "";
        paginator = "";
        if (page > 1) {
                paginator += "<a href=\"#\" onClick=\"listaEventi(" + (page - 1) + ");\">Precedente</a> | ";
        }
        jQuery('#lista_eventi').html('');
        jQuery.getJSON("../wp-content/plugins/elettroteca/data/service_eventi.php?rand=" + random(0, 999) + "&viewmode=off&azione=LIST&pageSize=" + pageSize + "&pageNo=" + page + "&searchkey=" + jQuery('#search_eventi').val(),
                function(data) {
                        jQuery.each(data.lista, function(i,ts){
                                html += "<tr>";
                                html += "<td>" + ts.id + "</td>";
                                html += "<td>" + ts.data_evento + "</td>";
                                html += "<td>" + ts.titolo_evento + "</td>";
                                html += "<td><a href=\"#\" onClick=\"modificaEventi(" + ts.id + ");\">Modifica</a> | <a href=\"#\" onClick=\"cancellaEventi(" + ts.id + ");\">Cancella</a></td>";
                                html += "</tr>";
                        });
                        numPages = Math.round(data.totaleValori/pageSize);
                        if (((numPages * pageSize) > data.totaleValori) && (page < numPages)) {
                                paginator += "<a href=\"#\" onClick=\"listaEventi(" + (page + 1) + ");\">Successivo</a>";
                        }
                        jQuery('#paginator').html(paginator);
                        jQuery('#grigliaEventi').css('display', 'block');
                        jQuery('#formEventi').css('display', 'none');
                        jQuery('#lista_eventi').html(html);
       });
}

function creaEventi() {
        jQuery('#eventiId').val('');
        jQuery('#data_evento').val('');
        jQuery('#titolo_evento').val('');
        jQuery('#testo_evento').val('');
        jQuery('#grigliaEventi').css('display', 'none');
        jQuery('#formEventi').css('display', 'block');
        if( jQuery('#testo_evento').is(':visible') ) {
            jQuery('#testo_evento').val('');
        } else {
            var editor = tinyMCE.get("testo_evento");
            editor.setContent('');
        }
}

function modificaEventi(id) {
        html = "";
        jQuery('#lista_eventi').html('');
        jQuery.getJSON("../wp-content/plugins/elettroteca/data/service_eventi.php?rand=" + random(0, 999) + "&viewmode=off&azione=DETAIL&id=" + id,
                function(data) {
                        jQuery.each(data.dettaglio, function(i,ts){
                                jQuery('#eventiId').val(ts.id);
                                jQuery('#data_evento').val(ts.data_evento);
                                jQuery('#titolo_evento').val(ts.titolo_evento);
                                if( jQuery('#testo_evento').is(':visible') ) {
                                        jQuery('#testo_evento').val(ts.testo_evento);
                                } else {
                                        var editor = tinyMCE.get("testo_evento");
                                        editor.setContent(ts.testo_evento);
                                }
                                //tinyMCE.activeEditor.setContent(testo);
                        });
                        jQuery('#grigliaEventi').css('display', 'none');
                        jQuery('#formEventi').css('display', 'block');
        });
}

function salvaBacheca() {
	if (validateFormBacheca()) {
        	var azione = "INSERT";
        	if (jQuery('#bachecaId').val() != "") {
        	        azione = "UPDATE";
        	}
        	jQuery.post("../wp-content/plugins/elettroteca/data/service_bacheca.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
        	        "testo_bacheca": jQuery('#testo_bacheca').val(),
        	        "attivo": jQuery('#attivo').val(),
        	        "data_inserimento": jQuery('#data_inserimento').val(),
        	        "id": jQuery('#bachecaId').val()
        	}, function(data) {
        	        idBacheca = "";
        	        alert("salvataggio effettuato");
        	        listaBacheca(1);
        	});
	}
}

function cancellaBacheca(id) {
        var azione = "DELETE";
        jQuery.post("../wp-content/plugins/elettroteca/data/service_bacheca.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
                "id": id
        }, function(data) {
                idBacheca = "";
                listaBacheca(1);
                alert("Cancellazione effettuata");
        });
}

function listaBacheca(page) {
        html = "";
        paginator = "";
        if (page > 1) {
                paginator += "<a href=\"#\" onClick=\"listaBacheca(" + (page - 1) + ");\">Precedente</a> | ";
        }
        jQuery('#lista_bacheca').html('');
        jQuery.getJSON("../wp-content/plugins/elettroteca/data/service_bacheca.php?rand=" + random(0, 999) + "&viewmode=off&azione=LIST&pageSize=" + pageSize + "&pageNo=" + page + "&searchkey=" + jQuery('#search_bacheca').val(),
                function(data) {
                        jQuery.each(data.lista, function(i,ts){
                                html += "<tr>";
                                html += "<td>" + ts.id + "</td>";
                                html += "<td>" + ts.testo_bacheca + "</td>";
                                html += "<td>" + ts.attivo + "</td>";
                                html += "<td><a href=\"#\" onClick=\"modificaBacheca(" + ts.id + ");\">Modifica</a> | <a href=\"#\" onClick=\"cancellaBacheca(" + ts.id + ");\">Cancella</a></td>";
                                html += "</tr>";
                        });
                        numPages = Math.round(data.totaleValori/pageSize);
                        if (((numPages * pageSize) > data.totaleValori) && (page < numPages)) {
                                paginator += "<a href=\"#\" onClick=\"listaBacheca(" + (page + 1) + ");\">Successivo</a>";
                        }
                        jQuery('#paginator').html(paginator);
                        jQuery('#grigliaBacheca').css('display', 'block');
                        jQuery('#formBacheca').css('display', 'none');
                        jQuery('#lista_bacheca').html(html);
        });
}

function creaBacheca() {
        jQuery('#bachecaId').val('');
        jQuery('#attivo').val('');
        jQuery('#testo_bacheca').val('');
        jQuery('#data_inserimento').val('');
        jQuery('#grigliaBacheca').css('display', 'none');
        jQuery('#formBacheca').css('display', 'block');
        jQuery('#azione').val('INSERT');
}

function modificaBacheca(id) {
        html = "";
        jQuery('#lista_bacheca').html('');
        jQuery.getJSON("../wp-content/plugins/elettroteca/data/service_bacheca.php?rand=" + random(0, 999) + "&viewmode=off&azione=DETAIL&id=" + id,
                function(data) {
                        jQuery.each(data.dettaglio, function(i,ts){
                                jQuery('#bachecaId').val(ts.id);
                                jQuery('#attivo').val(ts.attivo);
                                jQuery('#testo_bacheca').val(ts.testo_bacheca);
                                jQuery('#data_inserimento').val(ts.data_inserimento);
				jQuery('#spotImmagine').html('<img src="../wp-content/bacheca/' + ts.immagine+ '" border=0>'); 
 	 	 	        jQuery('#azione').val('UPDATE');
                        });
                        jQuery('#grigliaBacheca').css('display', 'none');
                        jQuery('#formBacheca').css('display', 'block');
        });
}

function salvaMappatrattanti() {
        var azione = "INSERT";
        if (jQuery('#mappatrattantiId').val() != "") {
                azione = "UPDATE";
        }
        jQuery.post("../wp-content/plugins/elettroteca/data/service_mappatrattanti.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
                "nome_azienda": jQuery('#nome_azienda').val() ,
                "recapito": jQuery('#recapito').val(),
                "marchio_trattato": jQuery('#marchio_trattato').val(),
                "famiglia": jQuery('#famiglia').val(),
                "ordinamento": jQuery('#ordinamento').val(),
                "regione": jQuery('#regione').val(),
                "fatturato": jQuery('#fatturato').val(),
                "id": jQuery('#mappatrattantiId').val()
        }, function(data) {
                idMappatrattanti = "";
                alert("salvataggio effettuato");
                listaMappatrattanti(1);
        });
}

function cancellaMappatrattanti(id) {
        var azione = "DELETE";
        jQuery.post("../wp-content/plugins/elettroteca/data/service_mappatrattanti.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
                "id": id
        }, function(data) {
                idMappatrattanti = "";
                listaMappatrattanti(1);
                alert("Cancellazione effettuata");
        });
}

function cancellaAllMappa(id) {
        var azione = "DELETEALL";
        jQuery.post("../wp-content/plugins/elettroteca/data/service_mappatrattanti.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
                "id": -1
        }, function(data) {
                idMappatrattanti = "";
                listaMappatrattanti(1);
                alert("Cancellazione effettuata");
		window.location = window.location.href;
        });
}

function listaMappatrattanti(page) {
        html = "";
        paginator = "";
        if (page > 1) {
                paginator += "<a href=\"#\" onClick=\"listaMappatrattanti(" + (page - 1) + ");\">Precedente</a> | ";
        }
        jQuery('#lista_mappatrattanti').html('');
        jQuery.getJSON("../wp-content/plugins/elettroteca/data/service_mappatrattanti.php?rand=" + random(0, 999) + "&viewmode=off&azione=LIST&pageSize=" + pageSize + "&pageNo=" + page + "&searchkey=" + jQuery('#search_mappa').val(),
                function(data) {
                        jQuery.each(data.lista, function(i,ts){
                                html += "<tr>";
                                html += "<td>" + ts.id + "</td>";
                                html += "<td>" + ts.nome_azienda + "</td>";
                                html += "<td>" + ts.recapito + "</td>";
                                html += "<td>" + ts.marchio_trattato + "</td>";
                                html += "<td>" + ts.famiglia + "</td>";
                                html += "<td><a href=\"#\" onClick=\"modificaMappatrattanti(" + ts.id + ");\">Modifica</a> | <a href=\"#\" onClick=\"cancellaMappatrattanti(" + ts.id + ");\">Cancella</a></td>";
                                html += "</tr>";
                        });
                        numPages = Math.round(data.totaleValori/pageSize);
                        if (((numPages * pageSize) > data.totaleValori) && (page < numPages)) {
                                paginator += "<a href=\"#\" onClick=\"listaMappatrattanti(" + (page + 1) + ");\">Successivo</a>";
                        }
                        jQuery('#paginator').html(paginator);
                        jQuery('#grigliaMappatrattanti').css('display', 'block');
                        jQuery('#formMappatrattanti').css('display', 'none');
                        jQuery('#lista_mappatrattanti').html(html);
        });
}

function creaMappatrattanti() {
        jQuery('#mappatrattantiId').val('');
        jQuery('#nome_azienda').val('');
        jQuery('#recapito').val('');
        jQuery('#marchio_trattato').val('');
        jQuery('#famiglia').val('');
        jQuery('#ordinamento').val('');
        jQuery('#regione').val('');
        jQuery('#fatturato').val('');
        jQuery('#grigliaMappatrattanti').css('display', 'none');
        jQuery('#formMappatrattanti').css('display', 'block');
}

function modificaMappatrattanti(id) {
        html = "";
        jQuery('#lista_mappatrattanti').html('');
        jQuery.getJSON("../wp-content/plugins/elettroteca/data/service_mappatrattanti.php?rand=" + random(0, 999) + "&viewmode=off&azione=DETAIL&id=" + id,
                function(data) {
                        jQuery.each(data.dettaglio, function(i,ts){
                                jQuery('#mappatrattantiId').val(ts.id);
                                jQuery('#nome_azienda').val(ts.nome_azienda);
                                jQuery('#recapito').val(ts.recapito);
                                jQuery('#marchio_trattato').val(ts.marchio_trattato);
                                jQuery('#famiglia').val(ts.famiglia);
                                jQuery('#ordinamento').val(ts.ordinamento);
                                jQuery('#regione').val(ts.regione);
                                jQuery('#fatturato').val(ts.fatturato);
                        });
                        jQuery('#grigliaMappatrattanti').css('display', 'none');
                        jQuery('#formMappatrattanti').css('display', 'block');
        });
}

function validateFormNews() {
        var ritorno = true;
	if (jQuery('#tipo_accesso').val() == "N") {
        	if (isEmpty(jQuery('#data').val())) {
        	        alert("Il campo data  non puo' essere vuoto.");
        	        return false;
        	}
        	if (isEmpty(jQuery('#titolo').val())) {
        	        alert("Il campo titolo non puo' essere vuoto.");
        	        return false;
        	}
        	if (isEmpty(jQuery('#abstract').val())) {
        	        alert("Il campo abstract non puo' essere vuoto.");
        	        return false;
        	}
        	var htmlTesto = "";
        	if( jQuery('#testo').is(':visible') ) {
		        htmlTesto = jQuery('#testo').val();
        	} else {
		        var editor = tinyMCE.get("testo");
		        htmlTesto = editor.getContent();
        	}
        	if (isEmpty(htmlTesto)) {
        	        alert("Il campo testo non puo' essere vuoto.");
        	        return false;
        	}
	}
        if (jQuery('#tipo_accesso').val() == "P") {
                if (isEmpty(jQuery('#wp_page').val())) {
                        alert("Il link alla news di wordpress  non puo' essere vuoto.");
                        return false;
                }
	}
        var htmlTesto = "";
        if( jQuery('#testo').is(':visible') ) {
                htmlTesto = jQuery('#testo').val();
        } else {
                var editor = tinyMCE.get("testo");
                htmlTesto = editor.getContent();
        }
 	jQuery('#testo').val(htmlTesto);
        return ritorno;
}

function validateFormEventi() {
        var ritorno = true;
        if (isEmpty(jQuery('#data_evento').val())) {
                alert("Il campo data  non puo' essere vuoto.");
                return false;
        }
        if (isEmpty(jQuery('#titolo_evento').val())) {
                alert("Il campo titolo non puo' essere vuoto.");
                return false;
        }
        var htmlTesto = "";
        if( jQuery('#testo_evento').is(':visible') ) {
                htmlTesto = jQuery('#testo_evento').val();
        } else {
                var editor = tinyMCE.get("testo_evento");
                htmlTesto = editor.getContent();
        }
        if (isEmpty(htmlTesto)) {
                alert("Il campo testo non puo' essere vuoto.");
                return false;
        }
        return ritorno;
}

function validateFormBacheca() {
        var ritorno = true;
        if (isEmpty(jQuery('#data_inserimento').val())) {
                alert("Il campo data  non puo' essere vuoto.");
                return false;
        }
        if (isEmpty(jQuery('#testo_bacheca').val())) {
                alert("Il campo testo non puo' essere vuoto.");
                return false;
        }
        return ritorno;
}

function validateFormUtente() {
        var ritorno = true;
        if (isEmpty(jQuery('#nome').val())) {
                alert("Il campo nome  non puo' essere vuoto.");
                return false;
        }
        if (isEmpty(jQuery('#cognome').val())) {
                alert("Il campo cognome non puo' essere vuoto.");
                return false;
        }
        if (isEmpty(jQuery('#email').val())) {
                alert("Il campo email non puo' essere vuoto.");
                return false;
        }
        if (isEmailValid(jQuery('#email').val())) {
                alert("Il campo email non e' corretto.");
                return false;
        }
        if (isEmpty(jQuery('#password').val())) {
                alert("Il campo password non puo' essere vuoto.");
                return false;
        }
        if (isEmpty(jQuery('#societa').val())) {
                alert("Il campo societa' non puo' essere vuoto.");
                return false;
        }
        //if (isEmpty(jQuery('#indirizzo').val())) {
        //        alert("Il campo indirizzo non puo' essere vuoto.");
        //        return false;
        //}
        return ritorno;
}

function isEmpty(inputStr) { 
        if ( null == inputStr || "" == inputStr ) { 
                return true; 
        } 
        return false; 
}

function isEmailValid(strEmail){
	validRegExp = /^[^@]+@[^@]+.[a-z]{2,}jQuery/i;
	// search email text for regular exp matches
	if (strEmail.search(validRegExp) == -1) {
		return false;
	}
	return true;
}

function setAccesso() {
	if (jQuery('#tipo_accesso').val() == "P") {
		jQuery('#idPrivatePanel').css('display','none');
                jQuery('#idPublicPanel').css('display','block');
	} else {
                jQuery('#idPrivatePanel').css('display','block');
                jQuery('#idPublicPanel').css('display','none');
	}
}

function setPublicNews(id) {
        var azione = "SETPUBLICNEWS";
        jQuery.post("../wp-content/plugins/elettroteca/data/service_newspublic.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
                "id": id
        }, function(data) {
                idNews = "";
                listaNewspublic(1);
        });
}

function delPublicNews(id) {
        var azione = "DELPUBLICNEWS";
        jQuery.post("../wp-content/plugins/elettroteca/data/service_newspublic.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
                "id": id
        }, function(data) {
                idNews = "";
                listaNewspublic(1);
        });
}

function setPromozione(id) {
        var azione = "SETPROMOZIONE";
        jQuery.post("../wp-content/plugins/elettroteca/data/service_utente.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
                "id": id
        }, function(data) {
                idUtente = "";
                listaUtente(1);
        });
}

function delPromozione(id) {
        var azione = "DELPROMOZIONE";
        jQuery.post("../wp-content/plugins/elettroteca/data/service_utente.php?rand=" + random(0, 999) + "&viewmode=off&azione=" + azione, {
                "id": id
        }, function(data) {
                idUtente = "";
                listaUtente(1);
        });
}