var key_tab = 9;
var basic = true;
	function replace(string,text,by) {
	    var strLength = string.length, txtLength = text.length;
	    if ((strLength == 0) || (txtLength == 0)) return string;
	    var i = string.indexOf(text);
	    if ((!i) && (text != string.substring(0,txtLength))) return string;
	    if (i == -1) return string;
	    var newstr = string.substring(0,i) + by;
	    if (i+txtLength < strLength)
	        newstr += replace(string.substring(i+txtLength,strLength),text,by);
	    return newstr;
	}
	function count_strings(string, word) {
		var substrings = string.split(word);
		return substrings.length - 1;
	}
	function preview(textarea_obj) {
		var txt = get_textarea(textarea_obj);
		var pop_win = window.open("", "win", "width=400,height=250");
		pop_win.document.open("text/html", "replace");
		pop_win.document.write("<");
		pop_win.document.write("title>Preview</");
		pop_win.document.write("title>\r<");
		pop_win.document.write("link rel=stylesheet type=text/css href=../stile/stile0.css>\r<");
		pop_win.document.write("table width='100%' align='center'>\r<");
		pop_win.document.write("tr>\r<");
		pop_win.document.write("td class='TDDato' width='100%'>\r");
		pop_win.document.write(replace(replace(txt,"\r","\r<br>"),"  "," &nbsp;"));
		pop_win.document.write("\r<");
		pop_win.document.write("/td>\r<");
		pop_win.document.write("/tr>\r<");
		pop_win.document.write("/table>\r");
		pop_win.focus();
	}
	function get_selection() {
		if (document.getSelection) {
			var txt = document.getSelection();
		} else if (document.selection && document.selection.createRange) {
			var range = document.selection.createRange();
			var txt = range.text;
		} else {
			var txt = "Sorry, this is not supported with your browser.";
		}
		return(txt);
	}
	function get_textarea(textarea_obj) {
		return(textarea_obj.value);
	}
	function set_textarea(textarea_obj,txt) {
		textarea_obj.value = txt;
	}
	function append_textarea(textarea_obj,txt) {
		textarea_obj.value += txt;
	}
	function processTab() {
	  if ( window.event.keyCode == key_tab ) 
	  {
		var s = document.selection;
		var tr = s.createRange();
		if ( tr != null ) 
			tr.text = "\t";
			window.event.returnValue=false;
	  }
	}
	function taginsert(textarea_obj,tag1_txt,tag2_txt) {
		var txt = get_selection();
		var existing_txt = get_textarea(textarea_obj);
		var string_count = count_strings(existing_txt,txt);
		if (txt == "" || string_count > 1) {
			append_textarea(textarea_obj,"<"+tag1_txt+"></"+tag2_txt+">");
		} else if (txt != null) {
			var new_txt = existing_txt.replace(txt,"<"+tag1_txt+">"+txt+"</"+tag2_txt+">");
			set_textarea(textarea_obj,new_txt);
		}
	}
//	function right(e) {
//		if (navigator.appName == 'Netscape' && 
//		(e.which == 3 || e.which == 2))
//		return false;
//		else if (navigator.appName == 'Microsoft Internet Explorer' && 
//		(event.button == 2 || event.button == 3)) {
//		alert("Spiacente, la funzionalitą del tasto destro non č disponibile.");
//		return false;}
//		return true;}
//	document.onmousedown=right; document.onmouseup=right;
//	if (document.layers) window.captureEvents(Event.MOUSEDOWN);
//	if (document.layers) window.captureEvents(Event.MOUSEUP);
//	window.onmousedown=right; window.onmouseup=right;

//-------------------------------------------------------------------------------------------------
function show_calendar(str_target, str_datetime) {
	var arr_months = ["Gennaio - ", "Febbraio - ", "Marzo - ", "Aprile - ", "Maggio - ", "Giugno - ",
		"Luglio - ", "Agosto - ", "Settembre - ", "Ottobre - ", "Novembre - ", "Dicembre - "];
	var week_days = ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa"];
	var n_weekstart = 1; // day week starts from (normally 0 or 1)

	if (str_datetime == "--") str_datetime = null;
	var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt(str_datetime));
	var dt_prev_month = new Date(dt_datetime);
	dt_prev_month.setMonth(dt_datetime.getMonth()-1);
	var dt_next_month = new Date(dt_datetime);
	dt_next_month.setMonth(dt_datetime.getMonth()+1);
	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);
	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	var dt_lastday = new Date(dt_next_month);
	dt_lastday.setDate(0);
	
	// html generation (feel free to tune it for your particular application)
	// print calendar header
	var str_buffer = new String (
		"<html>\n"+
		"<head>\n"+
		"	<title>Calendar</title>\n"+
		"</head>\n"+
		"<body bgcolor=\"White\">\n"+
		"<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
		"<tr><td bgcolor=\"#4682B4\">\n"+
		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
		"<tr>\n	<td bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar('"+
		str_target+"', '"+ dt2dtstr(dt_prev_month)+"');\">"+
		"<img src=\"../stile/prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"Previous Month\"></a></td>\n"+
		"	<td bgcolor=\"#4682B4\" colspan=\"5\" align=\"center\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\"><b>"
		+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</b></font></td>\n"+
		"	<td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('"
		+str_target+"', '"+dt2dtstr(dt_next_month)+"');\">"+
		"<img src=\"../stile/next.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"Next Month\"></a></td>\n</tr>\n"
	);

	var dt_current_day = new Date(dt_firstday);
	// print weekdays titles
	str_buffer += "<tr>\n";
	for (var n=0; n<7; n++)
		str_buffer += "	<td bgcolor=\"#87CEFA\" align=\"center\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\"><b>"+
		week_days[(n_weekstart+n)%7]+"</b></font></td>\n";
	// print calendar table
	str_buffer += "</tr>\n";
	while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
		dt_current_day.getMonth() == dt_firstday.getMonth()) {
		// print row heder
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
				if (dt_current_day.getDate() == dt_datetime.getDate() &&
					dt_current_day.getMonth() == dt_datetime.getMonth())
					// print current date
					str_buffer += "	<td bgcolor=\"#FFB6C1\" align=\"right\">";
				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
					// weekend days
					str_buffer += "	<td bgcolor=\"#DBEAF5\" align=\"right\">";
				else
					// print working days of current month
					str_buffer += "	<td bgcolor=\"white\" align=\"right\">";

				if (dt_current_day.getMonth() == dt_datetime.getMonth())
					// print days of current month
					str_buffer += "<a href=\"javascript:"+
					"window.opener."+str_target+"G.value='"+dt_current_day.getDate()+"'; "+
					"window.opener."+str_target+"M.value='"+(dt_current_day.getMonth()+1)+"'; "+
					"window.opener."+str_target+"A.value='"+dt_current_day.getFullYear()+"'; "+
					"window.close();\">"+
					"<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
				else 
					// print days of other months
					str_buffer += "<a href=\"javascript:"+
					"window.opener."+str_target+"G.value='"+dt_current_day.getDate()+"'; "+
					"window.opener."+str_target+"M.value='"+(dt_current_day.getMonth()+1)+"'; "+
					"window.opener."+str_target+"A.value='"+dt_current_day.getFullYear()+"'; "+
					"window.close();\">"+
					"<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		// print row footer
		str_buffer += "</tr>\n";
	}
	// print calendar footer
	str_buffer +=
		"</table>\n" +
		"</td>\n</tr>\n</table>\n" +
		"</body>\n" +
		"</html>\n";

	var vWinCal = window.open("", "Calendar", 
		"width=240,height=220,status=no,resizable=yes,top=200,left=200");
	vWinCal.opener = self;
	var calc_doc = vWinCal.document;
	calc_doc.write (str_buffer);
	calc_doc.close();
}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt (str_datetime) {
	var re_date = /^(\d+)\-(\d+)\-(\d+)$/;
	if (!re_date.exec(str_datetime))
		return alert("Invalid DateTime Format: "+ str_datetime);
	return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}
function dt2dtstr (dt_datetime) {
	return (new String (
			dt_datetime.getDate()+"-"+(dt_datetime.getMonth()+1)+"-"+dt_datetime.getFullYear()+""));
}
function dt2tmstr (dt_datetime) {
	return (new String (
			dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds()));
}

//-------------------------------------------------------------------------------------------------
function SortableTable(oTable, oSortTypes) {

	this.sortTypes = oSortTypes || [];

	this.sortColumn = null;
	this.descending = null;

	var oThis = this;
	this._headerOnclick = function (e) {
		oThis.headerOnclick(e);
	};

	if (oTable) {
		this.setTable( oTable );
		this.document = oTable.ownerDocument || oTable.document;
	}
	else {
		this.document = document;
	}


	// only IE needs this
	var win = this.document.defaultView || this.document.parentWindow;
	this._onunload = function () {
		oThis.destroy();
	};
	if (win && typeof win.attachEvent != "undefined") {
		win.attachEvent("onunload", this._onunload);
	}
}

SortableTable.gecko = navigator.product == "Gecko";
SortableTable.msie = /msie/i.test(navigator.userAgent);
// Mozilla is faster when doing the DOM manipulations on
// an orphaned element. MSIE is not
SortableTable.removeBeforeSort = SortableTable.gecko;

SortableTable.prototype.onsort = function () {};

// default sort order. true -> descending, false -> ascending
SortableTable.prototype.defaultDescending = false;

// shared between all instances. This is intentional to allow external files
// to modify the prototype
SortableTable.prototype._sortTypeInfo = {};

SortableTable.prototype.setTable = function (oTable) {
	if ( this.tHead )
		this.uninitHeader();
	this.element = oTable;
	this.setTHead( oTable.tHead );
	this.setTBody( oTable.tBodies[0] );
};

SortableTable.prototype.setTHead = function (oTHead) {
	if (this.tHead && this.tHead != oTHead )
		this.uninitHeader();
	this.tHead = oTHead;
	this.initHeader( this.sortTypes );
};

SortableTable.prototype.setTBody = function (oTBody) {
	this.tBody = oTBody;
};

SortableTable.prototype.setSortTypes = function ( oSortTypes ) {
	if ( this.tHead )
		this.uninitHeader();
	this.sortTypes = oSortTypes || [];
	if ( this.tHead )
		this.initHeader( this.sortTypes );
};

// adds arrow containers and events
// also binds sort type to the header cells so that reordering columns does
// not break the sort types
SortableTable.prototype.initHeader = function (oSortTypes) {
	if (!this.tHead) return;
	var cells = this.tHead.rows[0].cells;
	var doc = this.tHead.ownerDocument || this.tHead.document;
	this.sortTypes = oSortTypes || [];
	var l = cells.length;
	var img, c;
	for (var i = 0; i < l; i++) {
		c = cells[i];
		if (this.sortTypes[i] != null && this.sortTypes[i] != "None") {
			img = doc.createElement("IMG");
			img.src = "../stile/blank.png";
			c.appendChild(img);
			if (this.sortTypes[i] != null)
				c._sortType = this.sortTypes[i];
			if (typeof c.addEventListener != "undefined")
				c.addEventListener("click", this._headerOnclick, false);
			else if (typeof c.attachEvent != "undefined")
				c.attachEvent("onclick", this._headerOnclick);
			else
				c.onclick = this._headerOnclick;
		}
		else
		{
			c.setAttribute( "_sortType", oSortTypes[i] );
			c._sortType = "None";
		}
	}
	this.updateHeaderArrows();
};

// remove arrows and events
SortableTable.prototype.uninitHeader = function () {
	if (!this.tHead) return;
	var cells = this.tHead.rows[0].cells;
	var l = cells.length;
	var c;
	for (var i = 0; i < l; i++) {
		c = cells[i];
		if (c._sortType != null && c._sortType != "None") {
			c.removeChild(c.lastChild);
			if (typeof c.removeEventListener != "undefined")
				c.removeEventListener("click", this._headerOnclick, false);
			else if (typeof c.detachEvent != "undefined")
				c.detachEvent("onclick", this._headerOnclick);
			c._sortType = null;
			c.removeAttribute( "_sortType" );
		}
	}
};

SortableTable.prototype.updateHeaderArrows = function () {
	if (!this.tHead) return;
	var cells = this.tHead.rows[0].cells;
	var l = cells.length;
	var img;
	for (var i = 0; i < l; i++) {
		if (cells[i]._sortType != null && cells[i]._sortType != "None") {
			img = cells[i].lastChild;
			if (i == this.sortColumn)
				img.className = "sort-arrow " + (this.descending ? "descending" : "ascending");
			else
				img.className = "sort-arrow";
		}
	}
};

SortableTable.prototype.headerOnclick = function (e) {
	// find TH element
	var el = e.target || e.srcElement;
	while (el.tagName != "TH")
		el = el.parentNode;

	this.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex);
};

// IE returns wrong cellIndex when columns are hidden
SortableTable.getCellIndex = function (oTd) {
	var cells = oTd.parentNode.childNodes
	var l = cells.length;
	var i;
	for (i = 0; cells[i] != oTd && i < l; i++)
		;
	return i;
};

SortableTable.prototype.getSortType = function (nColumn) {
	return this.sortTypes[nColumn] || "String";
};

// only nColumn is required
// if bDescending is left out the old value is taken into account
// if sSortType is left out the sort type is found from the sortTypes array

SortableTable.prototype.sort = function (nColumn, bDescending, sSortType) {
	if (!this.tBody) return;
	if (sSortType == null)
		sSortType = this.getSortType(nColumn);

	// exit if None
	if (sSortType == "None")
		return;

	if (bDescending == null) {
		if (this.sortColumn != nColumn)
			this.descending = this.defaultDescending;
		else
			this.descending = !this.descending;
	}
	else
		this.descending = bDescending;

	this.sortColumn = nColumn;

	if (typeof this.onbeforesort == "function")
		this.onbeforesort();

	var f = this.getSortFunction(sSortType, nColumn);
	var a = this.getCache(sSortType, nColumn);
	var tBody = this.tBody;

	a.sort(f);

	if (this.descending)
		a.reverse();

	if (SortableTable.removeBeforeSort) {
		// remove from doc
		var nextSibling = tBody.nextSibling;
		var p = tBody.parentNode;
		p.removeChild(tBody);
	}

	// insert in the new order
	var l = a.length;
	for (var i = 0; i < l; i++)
		tBody.appendChild(a[i].element);

	if (SortableTable.removeBeforeSort) {
		// insert into doc
		p.insertBefore(tBody, nextSibling);
	}

	this.updateHeaderArrows();

	this.destroyCache(a);

	if (typeof this.onsort == "function")
		this.onsort();
};

SortableTable.prototype.asyncSort = function (nColumn, bDescending, sSortType) {
	var oThis = this;
	this._asyncsort = function () {
		oThis.sort(nColumn, bDescending, sSortType);
	};
	window.setTimeout(this._asyncsort, 1);
};

SortableTable.prototype.getCache = function (sType, nColumn) {
	if (!this.tBody) return [];
	var rows = this.tBody.rows;
	var l = rows.length;
	var a = new Array(l);
	var r;
	for (var i = 0; i < l; i++) {
		r = rows[i];
		a[i] = {
			value:		this.getRowValue(r, sType, nColumn),
			element:	r
		};
	};
	return a;
};

SortableTable.prototype.destroyCache = function (oArray) {
	var l = oArray.length;
	for (var i = 0; i < l; i++) {
		oArray[i].value = null;
		oArray[i].element = null;
		oArray[i] = null;
	}
};

SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) {
	// if we have defined a custom getRowValue use that
	if (this._sortTypeInfo[sType] && this._sortTypeInfo[sType].getRowValue)
		return this._sortTypeInfo[sType].getRowValue(oRow, nColumn);

	var s;
	var c = oRow.cells[nColumn];
	if (typeof c.innerText != "undefined")
		s = c.innerText;
	else
		s = SortableTable.getInnerText(c);
	return this.getValueFromString(s, sType);
};

SortableTable.getInnerText = function (oNode) {
	var s = "";
	var cs = oNode.childNodes;
	var l = cs.length;
	for (var i = 0; i < l; i++) {
		switch (cs[i].nodeType) {
			case 1: //ELEMENT_NODE
				s += SortableTable.getInnerText(cs[i]);
				break;
			case 3:	//TEXT_NODE
				s += cs[i].nodeValue;
				break;
		}
	}
	return s;
};

SortableTable.prototype.getValueFromString = function (sText, sType) {
//	if (this._sortTypeInfo[sType])
//		return this._sortTypeInfo[sType].getValueFromString( sText );
//	return sText;
	
	switch (sType) {
		case "Number":
			return Number(sText.replace(",","."));
		case "CaseInsensitiveString":
			return sText.toUpperCase();
		case "Date":
			if (sText.search("/") < 1) {sText = "01/01/0001/" + sText};
			if (sText.search(".") < 1) {sText = sText + "/00/00/00"};

			sText = sText.replace(" ","/");
			sText = sText.replace(".","/");
			sText = sText.replace("//","/");

			var parts = sText.split("/");
			var d = new Date(0);
			d.setFullYear(parts[2]);
			d.setDate(parts[0]);
			d.setMonth(parts[1] - 1);
			d.setHours(parts[3]);
			d.setMinutes(parts[4]);
			d.setSeconds(parts[5]);
			return d.valueOf();
	}
	return sText;
	
	};

SortableTable.prototype.getSortFunction = function (sType, nColumn) {
	if (this._sortTypeInfo[sType])
		return this._sortTypeInfo[sType].compare;
	return SortableTable.basicCompare;
};

SortableTable.prototype.destroy = function () {
	this.uninitHeader();
	var win = this.document.parentWindow;
	if (win && typeof win.detachEvent != "undefined") {	// only IE needs this
		win.detachEvent("onunload", this._onunload);
	}
	this._onunload = null;
	this.element = null;
	this.tHead = null;
	this.tBody = null;
	this.document = null;
	this._headerOnclick = null;
	this.sortTypes = null;
	this._asyncsort = null;
	this.onsort = null;
};

// Adds a sort type to all instance of SortableTable
// sType : String - the identifier of the sort type
// fGetValueFromString : function ( s : string ) : T - A function that takes a
//    string and casts it to a desired format. If left out the string is just
//    returned
// fCompareFunction : function ( n1 : T, n2 : T ) : Number - A normal JS sort
//    compare function. Takes two values and compares them. If left out less than,
//    <, compare is used
// fGetRowValue : function( oRow : HTMLTRElement, nColumn : int ) : T - A function
//    that takes the row and the column index and returns the value used to compare.
//    If left out then the innerText is first taken for the cell and then the
//    fGetValueFromString is used to convert that string the desired value and type

SortableTable.prototype.addSortType = function (sType, fGetValueFromString, fCompareFunction, fGetRowValue) {
	this._sortTypeInfo[sType] = {
		type:				sType,
		getValueFromString:	fGetValueFromString || SortableTable.idFunction,
		compare:			fCompareFunction || SortableTable.basicCompare,
		getRowValue:		fGetRowValue
	};
};

// this removes the sort type from all instances of SortableTable
SortableTable.prototype.removeSortType = function (sType) {
	delete this._sortTypeInfo[sType];
};

SortableTable.basicCompare = function compare(n1, n2) {
	if (n1.value < n2.value)
		return -1;
	if (n2.value < n1.value)
		return 1;
	return 0;
};

SortableTable.idFunction = function (x) {
	return x;
};

SortableTable.toUpperCase = function (s) {
	return s.toUpperCase();
};

SortableTable.toDate = function (s) {
	if (s.search("/") < 1) {s = "01/01/0001/" + s};
	if (s.search(".") < 1) {s = s + "/00/00/00"};

	s = s.replace(" ","/");
	s = s.replace(".","/");
	s = s.replace("//","/");

	var parts = s.split("/");
	var d = new Date(0);
	d.setFullYear(parts[2]);
	d.setDate(parts[0]);
	d.setMonth(parts[1] - 1);
	d.setHours(parts[3]);
	d.setMinutes(parts[4]);
	d.setSeconds(parts[5]);
	return d.valueOf();
};


// add sort types
SortableTable.prototype.addSortType("Number", Number);
SortableTable.prototype.addSortType("CaseInsensitiveString", SortableTable.toUpperCase);
SortableTable.prototype.addSortType("Date", SortableTable.toDate);
SortableTable.prototype.addSortType("String");
// None is a special case

//-------------------------------------------------------------------------------------------------
var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}

function displaylimit(thetext,theform,thelimit){
var limit_text=thetext+' <b><span id="'+theform.toString()+'">'+thelimit+'</span></b>'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}

//-------------------------------------------------------------------------------------------------
function ConfOp(numMess) {
          var procedi = confirm(strMess[numMess]);
          if (procedi == false) {return false;}}

function FormFilled(strArray) {
          var Pass = true;var strCampo = strArray.split(',');
          if(strCampo.length>1){	for(i=1;i<strCampo.length;i++){if(document.ModuloDati.elements[strCampo[i]].value==''){Pass = false;}}}
          if (!Pass){alert(strMess[2]);return false;}else {return ConfOp('0');}}

function OnlyNumeric(evt) {
          var Pass = true;
          evt = (evt) ? evt : event;
          var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
          if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46 && charCode != 45 && charCode != 44) {Pass = false}
          if (!Pass){alert(strMess[3].replace('char',String.fromCharCode(charCode)));return false;}}

function ValidMail(strCampo) {
          var Pass = true;
          var strMail = document.ModuloDati.elements[strCampo].value;
          if (strMail.indexOf('..') > 0) {Pass = false}
          var strNames = strMail.split('@');
          if (strNames.length != 2) {Pass = false}
          for (x=0;x<strNames.length;x++){
               var numLen = strNames[x].length - 1
               if ((strNames[x].substr(0,1) == '.')||(strNames[x].substr(numLen,1) == '.')){Pass = false}
               if (strNames[x].length <= 0) {Pass = false}
               if (x==1) {
                    if (strNames[x].indexOf('.') < 0) {Pass = false}
                    var numDom = strNames[x].length - strNames[x].lastIndexOf('.') - 1;
                    if ((numDom != 2) && (numDom != 3)) {Pass = false}
               }
               for (i=0;i<strNames[x].length;i++){
                    var c = strNames[x].substr(i,1); c = c.toLowerCase();
                    if ('abcdefghijklmnopqrstuvwxyz_-.1234567890'.indexOf(c)<0) {Pass = false}
               }
          }
          if (strMail.length == 0) {Pass = true;}
          if (!Pass){alert(strMess[4]);document.ModuloDati.elements[strCampo].value = '';}}
