/*
**********************************************************************************
*                                                                                *
*                              FUNZIONI PER LE FOTO                              *
*                                                                                *
**********************************************************************************
*/

// variabile globale per le finestre
var f = null;

function zoomfoto(Img) {
	f = window.open("../documenti/" + Img, "popup", "scrollbars=yes left=1 top=1 toolbar=no  resizable");
//	f = window.open("gallery_zoom.asp?idfoto=" + Img, "popup", "scrollbars=yes left=1 top=1 toolbar=no width=530 height=405 resizable");
	f.focus();
}

/*
**********************************************************************************
*                                                                                *
*                            RIMUOVI FILE CARICATI                               *
*                                                                                *
**********************************************************************************
*/

function rimuoviDocMultipli(valore, i) {
	arrDell = new Array(1);
	arrDell[1] = 'txt_del_doc' + i;
	document.forms[0].elements[arrDell[1]].value = valore;
}

function rimuoviImgMultipli(valore, i) {
	arrDell = new Array(1);
	arrDell[1] = 'txt_del_img' + i;
	document.forms[0].elements[arrDell[1]].value = valore;
}


function rimuoviDoc(valore) {
	arrDell = new Array(1);
	arrDell[1] = 'txt_del_doc';
	document.forms[0].elements[arrDell[1]].value = valore;
}

function rimuoviFile(valore) {
	var nomeCampo;
	nomeCampo = "txt_del_doc";

	document.all[nomeCampo].value = valore;
}

function rimuoviImg(valore) {
	var nomeCampo;
	nomeCampo = "txt_del_img";

	document.all[nomeCampo].value = valore;
}


/*
**********************************************************************************
*                                                                                *
*                              IMPOSTA CHECKBOX                                  *
*                                                                                *
**********************************************************************************
*/

// Imposto il valore dei campi hidden nelle form con upload immagini
function impostaValore(nome, valore) {
	var nomeCampo;
	nomeCampo = "txt_" + nome;

	document.all[nomeCampo].value = valore;
}


function impostaValore2(indice, valore) {
	var nome = "txt_vis" + indice;
	document.all[nome].value = valore;
}
/*
**************************************************************
*                                                            *
*                    CONTROLLO CAMPO MAIL                    * 
*                                                            *
**************************************************************
*/
function controllaMail(indirizzo) {
	if (indirizzo.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
		alert('Il campo email ' + indirizzo + ' non ha un formato valido');		
		//indirizzo.focus();		
	} 
	else {
		return true;
	}
}

/*
**********************************************************************************
*                                                                                *
*                            FUNZIONI PER LA GESTIONE                            *
*                                                                                *
**********************************************************************************
*/

// Cancellazione Notizie
function elimina() {
	if (!confirm("Procedere con l'eliminazione?")) {
		return false;
	}
}

// Inserimento Notizie
function insNews(titolo,messaggio,scadenza) {
	if (titolo == "" || messaggio == ""  || messaggio == "<P>&nbsp;</P>") {
		alert ("Inserire un titolo e un messaggio");
		return false;
	}
	if (scadenza == "") {
		alert ("Inserire una data di scadenza");
		return false;
	}
}

function insGiornale(titolo,messaggio){
	if (titolo == "" || messaggio == "" ) {
		alert ("Inserire un titolo e un messaggio");
		return false;
	}
}


//Se c'č un file allegato
function insGiornale1(titolo,messaggio,nomefile,fileattuale,delfile){
	if (titolo == "" || messaggio == "" ) {
		alert ("Inserire un titolo e un messaggio");
		return false;
	}
	
	if(nomefile != "" && fileattuale != "" && !delfile){
		if(confirm("Eliminare il file attuale \n'" + fileattuale + "'\ndal server?")) {
			document.all.ckb_delfile.value = true;
		}
	}
}


function insContatti(contatto){
	if (contatto == "") {
		alert ("Inserire un contatto");
		return false;
	}
}

function insLink(titolo,messaggio,collegamento){
	if (titolo == "" || messaggio == "" || collegamento == "") {
		alert ("Inserire un titolo, descrizione e link");
		return false;
	}
}

function insServizi(servizio){
	if (servizio == "") {
		alert ("Inserire un servizio");
		return false;
	}
}

function insAttivita(attivita){
	if (attivita == "") {
		alert ("Inserire un'attivitā");
		return false;
	}
}

function insDottore(cognome){
	if (cognome == "") {
		alert ("Inserire il cognome");
		return false;
	}
}

/*
**********************************************************************************
*                                                                                *
*               FUNZIONI PER LA GESTIONE DOTTORI-ATTIVITA'                       *
*                                                                                *
**********************************************************************************
*/
function personale(iddottore){
	if (iddottore == 0) {
		alert ("Non č stato scelto nessun operatore");
		return false;
	}
	else{
		window.location.href="servizi_assegnadottori.asp?iddottore=" + iddottore;
	}
}

function attivita(idattivita){
	if (idattivita == 0) {
		alert ("Non č stata scelta nessuna attivitā");
		return false;
	}
	else{
		window.location.href="servizi_assegnadottori.asp?idattivita=" + idattivita;
	}
}


/*
**********************************************************************************
*                                                                                *
*                            FUNZIONI PER UPLOAD FILE                            *
*                                                                                *
**********************************************************************************
*/

function settaValoreCheck(nome, valore) {
	document.all["ckb_" + nome].value = valore;
}



/*
**********************************************************************************
*                                                                                *
*                            FUNZIONI PER GLI UTENTI                             *
*                                                                                *
**********************************************************************************
*/

function loginUtente(userid,pwd){
	if (userid == "" || pwd == "") {
		alert ("Scegliere un userid e una password");
		return false;
	}
}









/*********************************************************************************************************
/*********************************************************************************************************
/*********************************************************************************************************
/*********************************************************************************************************
/*********************************************************************************************************
/*********************************************************************************************************




/*
**********************************************************************************
*                                                                                *
*                             FUNZIONI PER IL LOGIN                              *
*                                                                                *
**********************************************************************************
*/

function controllaLogin(nome,id,pwd,mail,codex) {
	if (nome == "" || id == "" || pwd == "" || mail == "" || codex == "") {
		alert ("I campi contrassegnati dall'asterisco sono obbligatori");
		return false;
	}
}

function controllaLoginMod(nome,id,pwd,mail) {
	if (nome == "" || id == "" || pwd == "" || mail == "") {
		alert ("I campi contrassegnati dall'asterisco sono obbligatori");
		return false;
	}
}




function controllaCommenti(mex) {
	if (mex == "") {
		alert("Se vuoi inserire un commento \n devi scrivere qualcosa!!!");
		return false;
	}
}


/*
**********************************************************************************
*                                                                                *
*                              FUNZIONI UPLOAD FOTO                              *
*                                                                                *
**********************************************************************************
*/

function impostaValore(nome, valore) {
	var nomeCampo;
	nomeCampo = "txt_" + nome;
	
	if(nome == 'attivo') {
		document.all.txt_attivo.value = valore;
	}
	else if (nome == 'evidenza') {
		document.all.txt_evidenza.value = valore;
	}
	else if (nome == 'principale') {
		document.all.txt_archivia.value = valore;
	}
	else if (nome == 'del_img') {
		document.all.txt_del_img.value = valore;
	}
	else if (nome == 'del_ban') {
		document.all.txt_del_ban.value = valore;
	}
	else {
		document.all[nomeCampo].value = valore;
	}
}

function impostaValore2(indice, valore) {
	var nome = "txt_vis" + indice;
	document.all[nome].value = valore;
}


/*
**********************************************************************************
*                                                                                *
*                            FUNZIONI PER GLI ANNUNCI                            *
*                                                                                *
**********************************************************************************
*/

function ferma() {
	document.all.notizie.scrollAmount=0;
}
function parti() {
	document.all.notizie.scrollAmount=1;
}

/******/

function popupAnnuncio(IdNews, Click) {
	f = window.open("annuncio_popup.asp?idnews=" + IdNews + "&click=" + Click, "popup", "scrollbars left=10 top=10 toolbar=no width=400 height=200");
	f.focus();
}

function conferma() {
	if(confirm("Eliminare l'annuncio?")) {
		return true;
	}
	else {
		return false;
	}
}

/*
**********************************************************************************
*                                                                                *
*                           FUNZIONI PER LE VISITE                               *
*                                                                                *
**********************************************************************************
*/

function visite() {
	window.open("../asp/gestione_controllovisitatori.asp", "_parent");
}

function mandaMail(visitatore) {
	if(visitatore == "SI") {
		window.open("http://www.sdipisistemi.it/sdipicommerce/gae_mandamail.asp?visitatore=" + visitatore, "_self");
	//	window.open("http://www.sdipisistemi.it/sdipicommerce/gae_mandamail.asp", "_blank", "scrollbars=no left=0 top=0 toolbar=no width=1 height=1");
	}
}



function admin() {
	window.open("../asp/amministrazione.asp", "_parent");
}


function controllaFormMod(nome, cap, mail, id, pwd, pwd2) {
	var $nome = document.accountmanager.nome.value;
	var $cap = document.accountmanager.cap.value;
	var $mail = document.accountmanager.mail.value;
	var $id = document.accountmanager.id.value;
	var $pwd = document.accountmanager.pwd.value;
	var $pwd2 = document.accountmanager.pwd2.value;
	var $cont = 0;
	
	if ($nome == "" || $mail == "" || $id == "" || $pwd == "" || $pwd2 == "") {
		alert("Attenzione! \nI campi contrassegnati con \nasterisco sono obbligatori");
		$cont = 1;
		return false;
	}
	
	if (isNaN($cap)) {
		alert("Il cap deve essere numerico");
		$cont = 1;
		return false;
	}
	
	if ($pwd != $pwd2) {
		alert("Attenzione! \nLe due password non corrispondono");
		$cont = 1;
		return false;
	}

	if ($cont != 0) {
		return false;
	}
	else {
		return true;
	}
}


function controllaForm(nome, cap, mail, id, pwd, pwd2, codice) {
	var $nome = document.autenticazione.nome.value;
	var $cap = document.autenticazione.cap.value;
	var $mail = document.autenticazione.mail.value;
	var $id = document.autenticazione.id.value;
	var $pwd = document.autenticazione.pwd.value;
	var $pwd2 = document.autenticazione.pwd2.value;
	var $cod = document.autenticazione.codice.value;
	var $cont = 0;
	
	if ($nome == "" || $mail == "" || $id == "" || $pwd == "" || $pwd2 == "") {
		alert("Attenzione! \nI campi contrassegnati con \nasterisco sono obbligatori");
		$cont = 1;
		return false;
	}
	
	if (isNaN($cap)) {
		alert("Il cap deve essere numerico");
		$cont = 1;
		return false;
	}
	
	if ($cod.toUpperCase() != "H725AR") {
		alert("Attenzione! \nIl codice di accesso non č corretto. \nSe non lo ricordi manda una mail al webmaster");
		$cont = 1;
		return false;
	}
				
	if ($pwd != $pwd2) {
		alert("Attenzione! \nLe due password non corrispondono");
		$cont = 1;
		return false;
	}

	if ($cont != 0) {
		return false;
	}
	else {
		return true;
	}
}
	


