function fmtDateTime(pUTCValue) {
var result = "";

	var d = new Date(parseFloat(pUTCValue));
	
	var dy = d.getDate();
	var mnth = d.getMonth() + 1;
	var yr = d.getFullYear();
	
	var hrs = d.getHours();
	var mnts = d.getMinutes();
	var secs = d.getSeconds();
	
	result = dy + "/" + mnth + "/" + yr + " " + hrs + ":" + mnts + ":" + secs

return result;
}

function fmtDate(pUTCValue) {
var result = "";

	var d = new Date(parseFloat(pUTCValue));
	
	var dy = d.getDate();
	var mnth = d.getMonth() + 1;
	var yr = d.getFullYear();
		
	result = dy + "/" + mnth + "/" + yr;

return result;
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  left = (screen.width - width) / 2;
  top = (screen.height - height) / 2;
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function fake() {
	alert("fake!");
}

var reDateTimeField = /dt_/g;

function validateDateTimeFields(theForm) {
	var reValidDateTime = /^\d+\/\d+\/\d+\s\d+:\d+:\d+$/;
	var reValidDate = /^\d+\/\d+\/\d+$/;

	var val;
	var el;
	for (var i=0; i<theForm.elements.length; i++) {
		el = theForm.elements[i].name;
		if (el.match(reDateTimeField)) {
			val = theForm.elements[i].value;
			if (!val.match(reValidDateTime) && !val.match(reValidDate)) {
				alert("Attenzione\ncontrollare che le date siano inserite in uno dei formati:\n[gg/mm/aaaa] oppure [gg/mm/aaaa hh:mm:ss]");
				return false;
			}
		}
	}
		
return true;
}

function fmtDateToSQL( theForm ) {
	var el;
	var g, m, a;
	var aMatch;
	for (var i=0; i<theForm.elements.length; i++) {
		el = theForm.elements[i];
		if (el.name.match(reDateTimeField)) {
			aMatch = /^(\d+)\/(\d+)\/(\d+)/.exec( String(el.value) )
			g = aMatch[1];
			m = aMatch[2];
			a = aMatch[3];
			el.value = m + "/" + g + "/" + a
		}
	}
}

function cleanFieldsNames( theForm ) {
	var fName;
	for (var i=0; i<theForm.elements.length; i++) {
		fName = theForm.elements[i].name;
		theForm.elements[i].name = fName.replace(/^(\w)+\./, "")
	}
}

function prova() {
	alert("funziona!");
}

function uploadFile(pSubFolder, pReturnFieldName) {
	var winHeight = 300;
	var winWidth = 325;
	popUpWindow('/scripts/winUploadFile.asp?remoteSubFolder=' + escape(pSubFolder) + '&returnFieldName=' + escape(pReturnFieldName), 0, 0, winWidth, winHeight );
	return;
}

function on( e ) {
	e.style.backgroundColor='#FFFFCC';
	return;
}

function off( e ) {
	e.style.backgroundColor='white';
	return;
}

/* Manutenzione Additiva: Aggiunta funzionalitą di conferma eliminazione record
* Author: Giacomo Iaucaniello 
* Website: www.giacuaniello.altervista.org
*/


function confirmDeleteRecord(theForm) {
	
	 var x = confirm('Sei sicuro di voler eliminare questo oggetto ?');
	 if (x==true){
			theForm.act.value='delete';
			
			theForm.submit();
			}
	else {  alert ('Operazione Annullata')
		
		
	}
}

function confirmDeleteOrg(theForm) {
	
	 var x = confirm('Sei sicuro di voler eliminare questo oggetto ?');
	 if (x==true){
			theForm.act.value='delete_org';
			theForm.confirm.value='/admin/confirm.asp';
			theForm.submit();
			}
	else {  alert ('Operazione Annullata')
		
		
	}
}
/* Manutezione Additiva : Fine Aggiunta funzionalitą di conferma eliminazione record */
