<!--
// ****************************************************************************************************************************************

// funzione che taglia la stringa da sinistra
function fxLeft(total_chars)
{
	return this.substring(0, total_chars);
}
String.prototype.left = fxLeft;

// funzione che taglia la stringa da destra
function fxRight(total_chars)
{
	return this.substring(this.length - total_chars, this.length)
}
String.prototype.right = fxRight;

// funzione che ritaglia la stringa da sinistra a destra
function fxMid(i, x)
{
	return this.substring(i-1,i-1+x);
}
String.prototype.mid = fxMid;

// funzione che ettettua la trim della stringa
function fxTrim()
{
	var vTrim = new RegExp("^\\s*|\\s*$","g");
	return this.replace(vTrim,'');
}
String.prototype.trim = fxTrim;

// funzione che formatta una stringa mettendo in maiuscolo il primo carattere (formato "Inizio paragrafo")
function fxTitleCase()
{
	var temp_string = this.trim(), temp1 = temp_string.left(1), temp2 = temp_string.rught(temp_string.length-1);
	temp_string = temp1.toUpperCase() + temp2.toLowerCase();
	return temp_string;
}
String.prototype.toTitleCase = fxTitleCase;

// ****************************************************************************************************************************************

function fxShowHideGroup(src,action)
{
	var vArray = new Array();
	var nItems = 0, y = 0;
	
	vAction = action.toLowerCase();
	vArray = src.split(',');
	
	if (vAction == 'on' || vAction == 'off')
	{
		if (vAction == 'on')
		{ var vDisplayGroup = 'inline'; }
		else
		{ var vDisplayGroup = 'none'; }
		
		if (vArray.length == 1)
		{
			// viene usato un array di elementi con lo stesso identificativo
			nItems = document.getElementById(src).length;
			
			for (y = 0; y < nItems; y++)
			{ document.getElementById(src)[y].style.display = vDisplayGroup; }
		}
		else
		{
			// viene usata la virgola per separare i vari identificativi degli elementi
			nItems = vArray.length;
			
			for (y = 0; y < nItems; y++)
			{
				if (vArray[y] != '' && !!document.getElementById(vArray[y]))
				{ document.getElementById(vArray[y]).style.display = vDisplayGroup; }
			}
		}
	}
	else // vAction == 'auto'
	{
		if (vArray.length == 1)
		{
			// viene usato un array di elementi con lo stesso identificatico
			nItems = document.getElementById(src).length;
			
			for (y = 0; y < nItems; y++)
			{
				if (document.getElementById(src)[y].style.display == 'none')
				{ document.getElementById(src)[y].style.display = 'inline'; }
				else
				{ document.getElementById(src)[y].style.display = 'none'; }
			}
		}
		else
		{
			// viene usata la virgola per separare i vari identificativi degli elementi
			nItems = vArray.length;
			
			for (y = 0; y < nItems; y++)
			{
				if (document.getElementById(vArray[y]).style.display == 'none')
				{ document.getElementById(vArray[y]).style.display = 'inline'; }
				else
				{ document.getElementById(vArray[y]).style.display = 'none'; }
			}
		}
	}
}

function fxShowHide(src,action)
{
	var vAction = action.toLowerCase();
	
	if (vAction == 'on')
	{ document.getElementById(src).style.display = 'inline'; }
	else if (vAction == 'off')
	{ document.getElementById(src).style.display = 'none'; }
	else // vAction == 'auto'
	{
		if (document.getElementById(src).style.display == 'none')
		{ document.getElementById(src).style.display = 'inline'; }
		else
		{ document.getElementById(src).style.display = 'none'; }
	}
}

// funzione che trasforma i caratteri digitati in maiuscolo o minuscolo
function fxSwitchChar(vStyle)
{
  var code, char;
  
  code = window.event.keyCode;
  
	if (vStyle == 'UpperCase')
	{
		if (code >= 97 && code <= 122) { code = code - 32; }
	}
	else if (vStyle == 'LowerCase')
	{
		if (code >= 65 && code <= 90) { code = code + 32; }
	}
	
  char = String.fromCharCode(code);
	window.event.keyCode = code;
}

// Swap dell'immagini
function fxSwapImage(id,over)
{
	document.all(id).src = over;
}

// Apertura di una sola finestra di popup per pagina
function fxAperturaFinestra(fileName,titolo,dimensioni)
{
  var Finestra = window.open(fileName,titolo,dimensioni);
  Finestra.focus();
	return false;
}

function fxSetAttributes(objName,objAttrib,attrValue)
{
	if (objName != '' && objAttrib != '' && attrValue != '')
	{
		var Objs = objName.split(',');
		var nItems = Objs.length;
		var i = 0;
		
		if (objAttrib == 'disabled')
		{
			if (attrValue == 'true' ) { attrValue = true;  }
			if (attrValue == 'false') { attrValue = false; }
			
			for (i = 0; i < nItems; i++)
			{ document.all(Objs[i]).disabled = attrValue; }
		}
		else if (objAttrib == 'readonly')
		{
			for (i = 0; i < nItems; i++)
			{ document.all(Objs[i]).readonly = attrValue; }
		}
		else if (objAttrib == 'display')
		{
			for (i = 0; i < nItems; i++)
			{ document.all(Objs[i]).style.display = attrValue; }
		}
		else if (objAttrib == 'value')
		{
			for (i = 0; i < nItems; i++)
			{ document.all(Objs[i]).value = attrValue; }
		}
	}
}

// ****************************************************************************************************************************************

// funzione che permette di inserire solo i caratteri validi per fare una data
function fxCheckDate()
{
	var code, char;
	
	code = window.event.keyCode;
	char = String.fromCharCode(code);
	
	if ((char < '0' || char > '9') && char != '/' && char != '-' && code != 13) { window.event.keyCode = 0; }
}

// funzione che permette di inserire solo i numeri ed il punto per i decimali
function fxCheckNumber()
{
	var code, char;
	
	code = window.event.keyCode;
	char = String.fromCharCode(code);
	
	if ((char < '0' || char > '9') && char != ',' && char != '.' && code != 13) { window.event.keyCode = 0; }
	if (char == ',') { window.event.keyCode = 46; }
}

// funzione che permette di inserire solo i numeri
function fxCheckInteger()
{
  var code, char;
  
  code = window.event.keyCode;
  char = String.fromCharCode(code);
  
	if ((char < '0' || char > '9') && code != 13) { window.event.keyCode = 0; }
}

// funzione che permette di inserire solo determinati caratteri
function fxCheckForcedChar(src)
{
	var vArray = new Array();
	var vTrovato = false, code = 0, char = '';
	var x = 0, nElementi = 0;
	
	code = window.event.keyCode;
	char = String.fromCharCode(code).toUpperCase();
	vArray = src.split(',');
	
	nElementi = vArray.length;
	
	if (nElementi > 1)
	{
		for (x = 0; x < nElementi; x++)
		{ if (char == vArray[x].toUpperCase()) { vTrovato = true; } }
	}
	else
	{ if (char == vArray) { vTrovato = true; } }
	
	if (!vTrovato) { window.event.keyCode = 0; }
}

// funzione che permette di controllare la sintassi di un indirizzo E-Mail
function fxCheckEMail(EMailAddress)
{
	var EMailRegExp = /^[A-Za-z0-9][\w-.]+[A-Za-z0-9]@[A-Za-z0-9]([\w-.]+[A-Za-z0-9]\.)+([A-Za-z]){2,4}$/i;
	var regTrim = /^\s*$/;
	
	if (regTrim.test(EMailAddress)) return true;
	
	return EMailRegExp.test(EMailAddress);
}

// funzione che controlla la sintassi di un indirizzo E-Mail
function fxEMailSyntax(EMailAddress)
{
	var aEMail = EMailAddress.split('@');
	
	if (aEMail.length == 1)
	{ return false; }
	else
	{
		if (aEMail[1].indexOf('.') == -1)
		{ return false; }
		else
		{ return true; }
	}
}

// funzione che permette il controllo della validità del numero di carta di credito (parte 1/2)
function fxCheckCreditCardNumber(ccNumber,ccName,ccMM,ccYY)
{
	var AcceptableTypes = '5436', Messaggio = '';
	
	/* Check Card Name */
	if (ccName == '')
	{ Messaggio = Messaggio + '\n * Tipo di Carta di Credito mancante!'; }
	
	if (ccName != 'visa' && ccName != 'mastercard' && ccName != 'american express' && ccName != 'amex' && ccName != 'discover')
	{ Messaggio = Messaggio + '\n * Tipo di Carta di Credito errato!'; }
	
	/* Check Credit Card Number */
	if (!fxIsCreditCard(ccNumber))
	{ Messaggio = Messaggio + '\n * Il numero della Carta di Credito non e\' valido!'; }
	
	/* Check Card Type */
	if (AcceptableTypes.indexOf(ccNumber.charAt(0)) == -1)
	{ Messaggio = Messaggio + '\n * Il numero della Carta di Credito non e\' valido!'; }
	else if (ccNumber.charAt(0) == 5 && ccName.toLowerCase().indexOf('mastercard') == -1)
	{ Messaggio = Messaggio + '\n * Il numero della Carta di Credito non e\' valido!'; }
	else if (ccNumber.charAt(0) == 4 && ccName.toLowerCase().indexOf('visa') == -1)
	{ Messaggio = Messaggio + '\n * Il numero della Carta di Credito non e\' valido!'; }
	else if (ccNumber.charAt(0) == 3 && (ccName.toLowerCase().indexOf('american express') == -1 || ccName.toLowerCase().indexOf('amex') == -1))
	{ Messaggio = Messaggio + '\n * Il numero della Carta di Credito non e\' valido!'; }
	else if (ccNumber.charAt(0) == 6 && ccName.toLowerCase().indexOf('discover') == -1)
	{ Messaggio = Messaggio + '\n * Il numero della Carta di Credito non e\' valido!'; }
	
	/* Check Expiration Month */
	var month = parseInt(ccMM, 10);
	
	if (isNaN(month) || month < 1 || month > 12)
	{ Messaggio = Messaggio + '\n * Il mese di scadenza della Carta di Credito deve essere compreso tra 1 e 12!'; }
	
	/* Check Expiration Year */
	var year = parseInt(ccYY, 10);
	//	var now = new Date();
	//	var validyear = now.getFullYear()-1994 /* -2000 + 6 */
	var validyear = 7;
	
	if (isNaN(year) || year > validyear)
	{ Messaggio = Messaggio + '\n * Data di scadenza della Carta di Credito errata!'; }
	
	if (Messaggio != '') { return Messaggio; }
	else { return true; }
}

// funzione che permette il controllo della validità del numero di carta di credito (parte 2/2)
function fxIsCreditCard(st)
{
	var len = st.length;
	var sum = 0;
	var mul = 1; 
	var digit, tproduct;
	
	if (len > 19 || len < 10) { return false; }
	
	while (len--)
	{
		digit = st.charAt(len);
		
		if (digit >= "0" && digit <= "9")
		{
			tproduct = parseInt(digit ,10) * mul;
			sum += (tproduct >= 10) ? (tproduct % 10) + 1 : tproduct;
			mul = (mul == 1) ? 2 : 1;
		}
	}
	
	return ((sum % 10) == 0);
}

// controllo del formato della data
function fxControlloData(Data,Formato)
{
	var regTrim = /^\s*$/;
	
	if (regTrim.test(Data))
	{ return true; }
	
	var Giorno, Mese, Anno, errore = '', Controllo = true, x = 0;
	var ArrayData = new Array(), vArrayData = new Array();
	
	// Trim normale (dx,sx)
	var vTrim = new RegExp("^\\s*|\\s*$","g");
	// Trim su tutta la stringa
	var cTrim = new RegExp("\\s","g");
	// Sostituzione di un particolare carattere su tutta la stringa
	var vReplace = new RegExp("-","g");
	
	Formato = Formato.toUpperCase();
	
	// Pulizia della data e sostituzione caratteri
	Data = Data.replace(cTrim,'');
	Data = Data.replace(vReplace,'/');
	
	// Controllo formato della data
	
	vArrayData = Data.split('/');
	
	if (vArrayData.length != 3)
	{
		if (!(vArrayData.length == 1 && !isNaN(vArrayData)))
		{
			errore = 'Data errata!';
			Controllo = false;
		}
	}
	else
	{
		for(x=0; x<=2; x++)
		{
			if (isNaN(vArrayData[x]))
			{
				errore = 'Data errata!';
				Controllo = false;
			}
		}
	}
	
	if (Controllo == true)
	{
		// Il formato della data inserita ? valida. Controllo della validità della data
		
		ArrayData[0]  = '';
		ArrayData[1]  = 31;
		ArrayData[2]  = 29;
		ArrayData[3]  = 31;
		ArrayData[4]  = 30;
		ArrayData[5]  = 31;
		ArrayData[6]  = 30;
		ArrayData[7]  = 31;
		ArrayData[8]  = 31;
		ArrayData[9]  = 30;
		ArrayData[10] = 31;
		ArrayData[11] = 30;
		ArrayData[12] = 31;
		
		if (Formato == 'ITA')
		{
			Giorno = vArrayData[0];
			Mese   = vArrayData[1];
			Anno   = vArrayData[2];
		}
		else if (Formato == 'ENG')
		{
			Giorno = vArrayData[1];
			Mese   = vArrayData[0];
			Anno   = vArrayData[2];
		}
		else if (Formato == 'USA')
		{
			Giorno = vArrayData[2];
			Mese   = vArrayData[1];
			Anno   = vArrayData[0];
		}
		else if (Formato == 'ISO')
		{
			Giorno = Data.substring(6,8);
			Mese   = Data.substring(4,6);
			Anno   = Data.substring(0,4);
		}
		
		if (Giorno != '' && Mese != '' && Anno != '')
		{
			if (isNaN(Giorno) || isNaN(Mese) || isNaN(Anno))
			{ errore = 'Data errata!'; }
			else
			{
				if (Giorno < 1 || Giorno > 31 || Mese < 1 || Mese > 12)
				{ errore = 'Data errata!'; }
				else
				{
					if (Giorno < 10) { Giorno = Giorno.replace(/^0/g, ""); }
					if (Mese < 10) { Mese = Mese.replace(/^0/g, ""); }
					
					if (Giorno > ArrayData[Mese]) { errore = 'Data errata!'; }
					else
					{
						if ((Anno%4 != 0 && Mese == 2 && Giorno == 29) || (Anno%100 == 0 && Anno%400 != 0 && Mese == 2 && Giorno == 29))
						{ errore = 'Data errata!'; }
						else
						{
							if (Giorno < 10) { Giorno = '0' + Giorno; }
							if (Mese < 10) { Mese = '0' + Mese; }
						}
					}
				}
			}
			
			if (errore != '')
			{ Controllo = false; }
		}
		else
		{ Controllo == true; }
	}
	
	if (Controllo == true) { return true; }
	else { return false; }
}

// formattazione della data
function fxFormattaData(Data,input,output)
{
	var regTrim = /^\s*$/;
	
	if (regTrim.test(input) || regTrim.test(output)) { return false; }
	
	if (regTrim.test(Data))
	{ return ''; }
	else
	{
		input = input.toUpperCase();
		output = output.toUpperCase();
		
		if (input != 'ISO')
		{
			var vData = new Array();
			vData = Data.split('/');
			
			vData[0] = '00' + vData[0];
			vData[0] = vData[0].right(2);
			
			vData[1] = '00' + vData[1];
			vData[1] = vData[1].right(2);
			
			vData[2] = '0000' + vData[2];
			vData[2] = vData[2].right(4);
			
			switch (input)
			{
				case 'ITA':
					// ITA -> ISO
					Data = vData[2] + vData[1] + vData[0];
					break;
				case 'ENG':
					// ENG -> ISO
					Data = vData[2] + vData[0] + vData[1];
					break;
				case 'USA':
					// USA -> ISO
					Data = vData[0] + vData[1] + vData[2];
					break;
				case 'ISO':
					// ISO -> ISO
					Data = vData[0];
					break;
				default:
					return false;
					break;
			}
		}
		
		var Giorno = 0, Mese = 0, Anno = 0;
		Data = '' + Data + '';
		
		Giorno = Data.substring(6, 8);
		Mese   = Data.substring(4, 6);
		Anno   = Data.substring(0, 4);
		
		switch (output)
		{
			case 'ITA':
				// ISO -> ITA
				Data = Giorno + '/' + Mese + '/' + Anno;
				break;
			case 'ENG':
				// ISO -> ENG
				Data = Mese + '/' + Giorno + '/' + Anno;
				break;
			case 'USA':
				// ISO -> USA
				Data = Anno + '/' + Mese + '/' + Giorno;
				break;
			case 'ISO':
				// ISO -> ISO
				Data = Anno + '' + Mese + '' + Giorno;
				break;
			default:
				return false;
				break;
		}
		
		return Data;
	}
}

// Controllo del formato del dato
function fxCheckFormat(src)
{
	if (src != '')
	{
		if (isNaN(src))
		{
			if (src.toLowerCase() == 'true' || src.toLowerCase() == 'false')
			{ return 'Boolean'; }
			else if (fxControlloData(src,'ita')) // || fxControlloData(src,'eng') || fxControlloData(src,'usa')
			{ return 'Date'; }
		}
		else
		{
			if (src == '-1' || src == '0' || src == '1')
			{ return 'Boolean'; }
			else if (src.indexOf('.') == -1 && Math.round(src) == (src * 1))
			{ return 'Integer'; }
			else
			{ return 'Numeric'; }
		}
		
		return 'Text';
	}
	
	return false;
}

// ****************************************************************************************************************************************

function fxCheckFormData(src)
{
	var Messaggio = '', tempItem = '', tMessaggio = '', var1 = '', var2 = '', vTextTemp = '';
	var testItem = false, chkFields = false;
	var x = 0, y = 0, z = 0, nElementi = 0;
	var aOggetti = new Array();
	var regTrim = /^\s*$/;
	var fFormCheck = src;
	
//	char = fFormCheck.elements[x].name
//	char = document.all(fFormCheck.elements[x].name).dataType;
	
	if (fFormCheck)
	{
		nElementi = fFormCheck.length;
		
		if (nElementi)
		{
			for (x = 0; x < nElementi; x++)
			{
				
				// notEmpty
				
				if (fFormCheck[x].notEmpty && !fFormCheck[x].disabled)
				{
					if (fFormCheck[x].notEmpty.toLowerCase() == 'true')
					{
						// text, textarea, select
						if (fFormCheck[x].value.trim() == '' && fFormCheck[x].type.toLowerCase() != 'radio' && fFormCheck[x].type.toLowerCase() != 'checkbox')
						{
							vTextTemp = '\n * ' + fFormCheck[x].id + ' is required!';
							
							if (Messaggio.indexOf(vTextTemp) == -1)
							{ Messaggio = Messaggio + vTextTemp; }
						}
						
						// radio , checkbox
						else if (fFormCheck[x].type.toLowerCase() == 'radio' || fFormCheck[x].type.toLowerCase() == 'checkbox')
						{
							if (tempItem != fFormCheck[x].id)
							{
								testItem = false;
								z = fFormCheck(fFormCheck[x].name).length;
								
								if (!z)
								{
									if (fFormCheck(fFormCheck[x].name).checked)
									{ testItem = true; }
								}
								else
								{
									for (y = 0; y < z; y++)
									{
										if (fFormCheck(fFormCheck[x].name)(y).checked)
										{ testItem = true; }
									}
								}
								
								if (!testItem)
								{
									tempItem = fFormCheck[x].id;
									vTextTemp = '\n * ' + fFormCheck[x].id + ' is required!';
									
									if (Messaggio.indexOf(vTextTemp) == -1)
									{ Messaggio = Messaggio + vTextTemp; }
								}
							}
						}
					}
				}
				
				// dataType
				
				if (fFormCheck[x].value.trim() != '')
				{
					if (fFormCheck[x].dataType)
					{
						var vDataFormat = fxCheckFormat(fFormCheck[x].value);
						
						// numeric
						if (fFormCheck[x].dataType.toLowerCase() == 'numeric')
						{
							if (vDataFormat != 'Numeric' && vDataFormat != 'Integer' && vDataFormat != 'Boolean')
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' must be a number!';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
						}
						
						// integer
						else if (fFormCheck[x].dataType.toLowerCase() == 'integer')
						{
							if (vDataFormat != 'Integer' && vDataFormat != 'Boolean')
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' must be an integer!';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
						}
						
						// boolean
						else if (fFormCheck[x].dataType.toLowerCase() == 'boolean')
						{
							if (vDataFormat != 'Boolean')
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' must be a boolean! (true / false)';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
						}
						
						// email
						else if (fFormCheck[x].dataType.toLowerCase() == 'email')
						{
							if (!fxCheckEMail(fFormCheck[x].value))
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' must be a valid e-mail address!';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
							else if (!fxEMailSyntax(fFormCheck[x].value))
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' must be a valid e-mail address!';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
						}
						
						// date
						else if (fFormCheck[x].dataType.toLowerCase() == 'date')
						{
							if (vDataFormat != 'Date')
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' must be a valid date! (dd/mm/yyyy)';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
							else
							{
								var tFieldDate = parseInt(fxFormattaData(fFormCheck[x].value,'ita','iso'));
								
								// minDate
								
								if (fFormCheck[x].minDate)
								{
									// CurrentDate
									if (fFormCheck[x].minDate == 'CurrentDate')
									{
										var tMinDate = new Date();
										tMinDate = tMinDate.getDate()+'/'+(tMinDate.getMonth()+1)+'/'+tMinDate.getYear();
										tMinDate = parseInt(fxFormattaData(tMinDate,'ita','iso'));
									}
									// minDate
									else
									{ var tMinDate = parseInt(fxFormattaData(fFormCheck[x].minDate,'ita','iso')); }
								}
								
								// maxDate
								
								if (fFormCheck[x].maxDate)
								{
									// CurrentDate
									if (fFormCheck[x].maxDate == 'CurrentDate')
									{
										var tMaxDate = new Date();
										tMaxDate = tMaxDate.getDate()+'/'+(tMaxDate.getMonth()+1)+'/'+tMaxDate.getYear();
										tMaxDate = parseInt(fxFormattaData(tMaxDate,'ita','iso'));
									}
									// maxDate
									else
									{ var tMaxDate = parseInt(fxFormattaData(fFormCheck[x].maxDate,'ita','iso')); }
								}
								
								if (fFormCheck[x].minDate && fFormCheck[x].maxDate)
								{
									if (tFieldDate < tMinDate || tFieldDate > tMaxDate)
									{
										tMinDate = fxFormattaData(tMinDate,'iso','ita');
										tMaxDate = fxFormattaData(tMaxDate,'iso','ita');
										vTextTemp = '\n * ' + fFormCheck[x].id + ' must be between ' + tMinDate + ' and ' + tMaxDate + '!';
										
										if (Messaggio.indexOf(vTextTemp) == -1)
										{ Messaggio = Messaggio + vTextTemp; }
									}
								}
								else if (fFormCheck[x].minDate)
								{
									if (tFieldDate < tMinDate)
									{
										tMinDate = fxFormattaData(tMinDate,'iso','ita');
										vTextTemp = '\n * ' + fFormCheck[x].id + ' must be equal or greater of ' + tMinDate + '!';
										
										if (Messaggio.indexOf(vTextTemp) == -1)
										{ Messaggio = Messaggio + vTextTemp; }
									}
								}
								else if (fFormCheck[x].maxDate)
								{
									if (tFieldDate > tMaxDate)
									{
										tMaxDate = fxFormattaData(tMaxDate,'iso','ita');
										vTextTemp = '\n * ' + fFormCheck[x].id + ' must be equal or minor of ' + tMaxDate + '!';
										
										if (Messaggio.indexOf(vTextTemp) == -1)
										{ Messaggio = Messaggio + vTextTemp; }
									}
								}
							}
						}
					}
					
					// minValue
					
					if (fFormCheck[x].minValue)
					{
						if (!isNaN(fFormCheck[x].value))
						{
							if (parseFloat(fFormCheck[x].value) * 1 < parseFloat(fFormCheck[x].minValue) * 1)
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' is too small! (min. ' + fFormCheck[x].minValue + ')';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
						}
					}
					
					// maxValue
					
					if (fFormCheck[x].maxValue)
					{
						if (!isNaN(fFormCheck[x].value))
						{
							if (parseFloat(fFormCheck[x].value) * 1 > parseFloat(fFormCheck[x].maxValue) * 1)
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' is too big! (max. ' + fFormCheck[x].maxValue + ')';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
						}
					}
					
					// minLen
					
					if (fFormCheck[x].minLen)
					{
						if (parseInt(fFormCheck[x].value.length) < parseInt(fFormCheck[x].minLen))
						{
							vTextTemp = '\n * ' + fFormCheck[x].id + ' is too short [' + fFormCheck[x].value.length + ']! (min. ' + fFormCheck[x].minLen + ' chars)';
							
							if (Messaggio.indexOf(vTextTemp) == -1)
							{ Messaggio = Messaggio + vTextTemp; }
						}
					}
					
					// maxLen
					
					if (fFormCheck[x].maxLen)
					{
						if (parseInt(fFormCheck[x].value.length) > parseInt(fFormCheck[x].maxLen))
						{
							vTextTemp = '\n * ' + fFormCheck[x].id + ' is too long [' + fFormCheck[x].value.length + ']! (max. ' + fFormCheck[x].maxLen + ' chars)';
							
							if (Messaggio.indexOf(vTextTemp) == -1)
							{ Messaggio = Messaggio + vTextTemp; }
						}
					}
					
					// fixedLength
					
					if (fFormCheck[x].fixedLength)
					{
						if (parseInt(fFormCheck[x].value.length) != parseInt(fFormCheck[x].fixedLength))
						{
							vTextTemp = '\n * ' + fFormCheck[x].id + ' must be ' + fFormCheck[x].fixedLength + ' chars!';
							
							if (Messaggio.indexOf(vTextTemp) == -1)
							{ Messaggio = Messaggio + vTextTemp; }
						}
					}
					
					// forcedValues
					
					if (fFormCheck[x].forcedValues)
					{
						var vArray = new Array();
						var vTrovato = false;
						
						vArray = fFormCheck[x].forcedValues.split(',');
						z = vArray.length;
						
						if (z > 1)
						{
							for (y = 0; y < z; y++)
							{
								if (vArray[y].toUpperCase() == fFormCheck[x].value.trim().toUpperCase())
								{ vTrovato = true; }
							}
						}
						else if (vArray == fFormCheck[x].value.trim().toUpperCase())
						{ vTrovato = true; }
						
						if (!vTrovato && fFormCheck[x].value != '')
						{
							vTextTemp = '\n * ' + fFormCheck[x].id + ' is not valid!';
							
							if (Messaggio.indexOf(vTextTemp) == -1)
							{ Messaggio = Messaggio + vTextTemp; }
						}
					}
				}
				
				//  CompareOp / CompareObj
				
				if (fFormCheck[x].CompareOp && fFormCheck[x].CompareObj)
				{
					if (fFormCheck[x].CompareOp == '<' || fFormCheck[x].CompareOp == '>' || fFormCheck[x].CompareOp == '<=' || fFormCheck[x].CompareOp == '>=' || fFormCheck[x].CompareOp == '=' || fFormCheck[x].CompareOp == '<>')
					{
						if ((fFormCheck[x].value == '' && fFormCheck(fFormCheck[x].CompareObj).value != '') || (fFormCheck[x].value != '' && fFormCheck(fFormCheck[x].CompareObj).value == ''))
						{
							vTextTemp = '\n * ' + fFormCheck[x].id + ' mismatches ' + fFormCheck(fFormCheck[x].CompareObj).id + '!';
							
							if (Messaggio.indexOf(vTextTemp) == -1)
							{ Messaggio = Messaggio + vTextTemp; }
						}
						else if (fFormCheck[x].value != '' && fFormCheck(fFormCheck[x].CompareObj).value != '')
						{
							if (fFormCheck[x].dataType)
							{
								var vDataFormat = fxCheckFormat(fFormCheck[x].value);
								
								// numeric
								if (fFormCheck[x].dataType.toLowerCase() == 'numeric')
								{
									if (vDataFormat == 'Numeric' && fxCheckFormat(fFormCheck(fFormCheck[x].CompareObj).value) == 'Numeric')
									{
										var1 = parseFloat(fFormCheck[x].value);
										var2 = parseFloat(fFormCheck(fFormCheck[x].CompareObj).value);
									}
								}
								// integer
								else if (fFormCheck[x].dataType.toLowerCase() == 'integer')
								{
									if (vDataFormat == 'Integer' && fxCheckFormat(fFormCheck(fFormCheck[x].CompareObj).value) == 'Integer')
									{
										var1 = parseInt(fFormCheck[x].value);
										var2 = parseInt(fFormCheck(fFormCheck[x].CompareObj).value);
									}
								}
								// boolean
								else if (fFormCheck[x].dataType.toLowerCase() == 'boolean')
								{
									if (vDataFormat == 'Boolean' && fxCheckFormat(fFormCheck(fFormCheck[x].CompareObj).value) == 'Boolean')
									{
										var1 = parseInt(fFormCheck[x].value);
										var2 = parseInt(fFormCheck(fFormCheck[x].CompareObj).value);
									}
								}
								// date
								else if (fFormCheck[x].dataType.toLowerCase() == 'date')
								{
									if (vDataFormat == 'Date' && fxCheckFormat(fFormCheck(fFormCheck[x].CompareObj).value) == 'Date')
									{
										var1 = parseInt(fxFormattaData(fFormCheck[x].value,'ita','iso'));
										var2 = parseInt(fxFormattaData(fFormCheck(fFormCheck[x].CompareObj).value,'ita','iso'));
									}
								}
								// text
								else
								{
									var1 = fFormCheck[x].value;
									var2 = fFormCheck(fFormCheck[x].CompareObj).value;
								}
							}
							// text
							else
							{
								var1 = fFormCheck[x].value;
								var2 = fFormCheck(fFormCheck[x].CompareObj).value;
							}
							
							if (fFormCheck[x].CompareOp == '<' && var1 >= var2)
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' must be minor of ' + fFormCheck(fFormCheck[x].CompareObj).id + '!';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
							else if (fFormCheck[x].CompareOp == '>' && var1 <= var2)
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' must be greater of ' + fFormCheck(fFormCheck[x].CompareObj).id + '!';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
							else if (fFormCheck[x].CompareOp == '<=' && var1 > var2)
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' must be minor or equal to ' + fFormCheck(fFormCheck[x].CompareObj).id + '!';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
							else if (fFormCheck[x].CompareOp == '>=' && var1 < var2)
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' must be greater or equal to ' + fFormCheck(fFormCheck[x].CompareObj).id + '!';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
							else if (fFormCheck[x].CompareOp == '=' && var1 != var2)
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' must be equal to ' + fFormCheck(fFormCheck[x].CompareObj).id + '!';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
							else if (fFormCheck[x].CompareOp == '<>' && var1 == var2)
							{
								vTextTemp = '\n * ' + fFormCheck[x].id + ' must be different from ' + fFormCheck(fFormCheck[x].CompareObj).id + '!';
								
								if (Messaggio.indexOf(vTextTemp) == -1)
								{ Messaggio = Messaggio + vTextTemp; }
							}
						}
					}
				}
				
				// inFieldsGroup / outFieldsGroup
				
				if (fFormCheck[x].inFieldsGroup && fFormCheck[x].outFieldsGroup)
				{
					chkFields = false;
					
					if (fFormCheck[x].inFieldsGroup == 'anyFieldsGroup')
					{
						chkFields = true;
					}
					else
					{
						if (fFormCheck[x].inFieldsGroup.indexOf(",") > -1)
						{
							var vArray = new Array();
							
							vArray = fFormCheck[x].inFieldsGroup.split(',');
							z = vArray.length;
							
							if (fFormCheck[x].type == 'checkbox' || fFormCheck[x].type == 'radio')
							{
								for (y = 0; y < z; y++)
								{
									if (fFormCheck(vArray[y]).checked != '' && fFormCheck[x].outFieldsGroup)
									{ chkFields = true; }
								}
							}
							else
							{
								for (y = 0; y < z; y++)
								{
									if (fFormCheck(vArray[y]).value.trim() != '' && fFormCheck[x].outFieldsGroup)
									{ chkFields = true; }
								}
							}
						}
						else // self
						{
							if (fFormCheck[x].type == 'checkbox' || fFormCheck[x].type == 'radio')
							{
								if (fFormCheck(fFormCheck[x].inFieldsGroup).checked != '' && fFormCheck[x].outFieldsGroup)
								{ chkFields = true; }
							}
							else
							{
								if (fFormCheck(fFormCheck[x].inFieldsGroup).value.trim() != '' && fFormCheck[x].outFieldsGroup)
								{ chkFields = true; }
							}
						}
					}
					
					if (chkFields)
					{
						if (fFormCheck[x].outFieldsGroup.indexOf(",") > -1)
						{
							var vArray = new Array();
							var bMessage = false;
							var tMessaggio = '';
							
							vArray = fFormCheck[x].outFieldsGroup.split(',');
							z = vArray.length;
							
							for (y = 0; y < z; y++)
							{
								if (fFormCheck(vArray[y]).value.trim() == '')
								{
									vTextTemp = '\n * ' + fFormCheck(vArray[y]).id + ' is required';
									
									if (Messaggio.indexOf(vTextTemp) == -1 && tMessaggio.indexOf(vTextTemp) == -1)
									{ tMessaggio = tMessaggio + vTextTemp; }
								}
								else
								{ bMessage = true; }
							}
							
							if (fFormCheck[x].type == 'checkbox' || fFormCheck[x].type == 'radio')
							{ bMessage = true; }
							
							if (bMessage && tMessaggio != '')
							{ Messaggio = Messaggio + tMessaggio; }
						}
						else
						{
							if (!fFormCheck(fFormCheck[x].outFieldsGroup).length)
							{
								if (((fFormCheck(fFormCheck[x].outFieldsGroup).type == 'checkbox' || fFormCheck(fFormCheck[x].outFieldsGroup).type == 'radio') && !fFormCheck(fFormCheck[x].outFieldsGroup).checked) || fFormCheck(fFormCheck[x].outFieldsGroup).value.trim() == '')
								{
									vTextTemp = '\n * ' + fFormCheck(fFormCheck[x].outFieldsGroup).id + ' is required!';
									
									if (Messaggio.indexOf(vTextTemp) == -1)
									{ Messaggio = Messaggio + vTextTemp; }
								}
							}
							else
							{
								z = fFormCheck(fFormCheck[x].outFieldsGroup).length;
								
								for (y = 0; y < z ; y++)
								{
									if (((fFormCheck(fFormCheck[x].outFieldsGroup)[y].type == 'checkbox' || fFormCheck(fFormCheck[x].outFieldsGroup)[y].type == 'radio') && !fFormCheck(fFormCheck[x].outFieldsGroup)[y].checked) || fFormCheck(fFormCheck[x].outFieldsGroup)[y].value.trim() == '')
									{
										vTextTemp = '\n * ' + fFormCheck(fFormCheck[x].outFieldsGroup)[y].id + ' is required!';
										
										if (Messaggio.indexOf(vTextTemp) == -1)
										{ Messaggio = Messaggio + vTextTemp; }
									}
								}
							}
						}
					}
				}
				
				// equalTo
				
				if (fFormCheck[x].equalTo)
				{
					if (fFormCheck[x].value != fFormCheck(fFormCheck[x].equalTo).value)
					{
						vTextTemp = '\n * ' + fFormCheck[x].id + ' mismatches ' + fFormCheck(fFormCheck[x].equalTo).id + '!';
						
						if (Messaggio.indexOf(vTextTemp) == -1)
						{ Messaggio = Messaggio + vTextTemp; }
					}
				}
			}
			
			if (Messaggio != '')
			{
				Messaggio = 'Warning! The following error(s) occured:\n' + Messaggio;
				return Messaggio;
			}
		}
		else
		{
			Messaggio = 'There is not any form elemet to check!';
			return Messaggio;
		}
	}
	
	return true;
}

function fxFormCheck(src,req)
{
	var Controllo = fxCheckFormData(src);
	
	if (Controllo != true)
	{
		alert (Controllo);
		return false;
	}
	
//	if (req == 'on')
//	{ return confirm('Proceed with the data-updates?'); }
	
	return true;
}

// ****************************************************************************************************************************************
//-->

