// Questo script postato da Effe8 in it.comp.lang.javascript effettua il controllo desiderato basandosi sull'algoritmo reperibile in www.finanze.it
function partitaIVA(piva)
   {
    if( piva.length > 0 )
    {  
    if( piva.length != 11 )
    	return false;
        /*return "La lunghezza della partita IVA non ?\n" +
            "corretta: la partita IVA dovrebbe essere lunga\n" +
            "esattamente 11 caratteri.\n";*/
    validi = "0123456789";
    for( i = 0; i < 11; i++ ){
        if( validi.indexOf( piva.charAt(i) ) == -1 )
            return false;
            /*return "La partita IVA contiene un carattere non valido `" +
                pi.charAt(i) + "'.\nI caratteri validi sono le cifre.\n";*/
    }
    s = 0;
    for( i = 0; i <= 9; i += 2 )
        s += piva.charCodeAt(i) - '0'.charCodeAt(0);
    for( i = 1; i <= 9; i += 2 ){
        c = 2*( piva.charCodeAt(i) - '0'.charCodeAt(0) );
        if( c > 9 )  c = c - 9;
        s += c;
    }
    if( ( 10 - s%10 )%10 != piva.charCodeAt(10) - '0'.charCodeAt(0) )
        return false;
        /*return "La partita IVA non ? valida:\n" +
            "il codice di controllo non corrisponde.\n";*/
    return true;
	}
	else
	{
		return true;
	}
   }
   
//codice fiscale
function isCF(what)
{
   if ( what.length>0 )
   {
  	 var cf = what.toUpperCase();
  	 var cfReg = /^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$/;
  	
  	 if (!cfReg.test(cf))
		{
		alert("Il Codice Fiscale inserito  errato!");
		return false;
		}

   	var set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   	var set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
   	var setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   	var setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
   	var s = 0;
   	
   	for( i = 1; i <= 13; i += 2 )

      	s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));

   	for( i = 0; i <= 14; i += 2 )

      	s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));

   	if ( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) )
		{
		alert("Ricontrolla il Codice Fiscale inserito, Grazie!");
		if(confirm("Vuoi forzare l'inseriemnto del codice fiscale?"))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
   	return true;
   }
	else
   {
   	 return true;
   }
}

function checkCF ( obj, label )
{
	var mt = obj.value;
	sw = isCF ( mt );
	if (!sw)
	{
		obj.focus();
	}
	return sw;
}

//il CF inserito puo anche essere quello di un azienda in quel caso il controllo da effetuare e lo stesso che per la partita iva
function checkCF2 ( obj, label )
{
	var mt = obj.value;
	validi = "0123456789";
	if( validi.indexOf( mt.charAt(0) ) == -1 )
	{
		sw = isCF ( mt );
	}
	else
	{
		sw = partitaIVA( mt );
		if(!sw)
		{
			alert("Il campo '"+ label +"' non e corretto.");
		}
	}
	if (!sw)
	{
		obj.focus();
	}
	return sw;
}
   
function checkPartitaIva ( obj, label )
{
	var mt = obj.value;
	sw = partitaIVA ( mt );
	if (!sw)
	{
		alert("Il campo '"+ label +"' non e corretto.");
		obj.focus();
	}
	return sw;
}

function checkPassUguali( obj1, obj2 , lingua ) 
{
  var mt1=obj1.value;
  var mt2=obj2.value;
  if (mt1!=mt2) {
  	switch( lingua ) {
  		case 'it':
  		alert("Le password devono essere uguali.");
  		break;
  		case 'en':
  		alert("Passwords don’t match");
  		break;  		
  	}  	
    obj1.focus();
    return false;
  } else {
    return true; 
  }
}

function checkPassLenght( obj1, lingua ) 
{
  var mt1=obj1.value;
  if ( mt1.length < 5 ) {
  	switch( lingua ) {
  		case 'it':
  		alert("La password deve essere lunga almeno cinque caratteri.");
  		break;
  		case 'en':
  		alert("The password\'s lenght must be at least five characters.");
  		break;  		
  	}  	
    obj1.focus();
    return false;
  } else {
    return true; 
  }
}



function forceNumber( obj ) {
  num = parseInt( obj.value );
  if (isNaN(num))
    num = '';
  obj.value = num;
}

function noCheck( obj, label ) {
  return true; 
}

function checkEmpty( obj, label , lingua ) {
  var mt= trim(obj.value);
  if (mt.length<1) {
  	switch( lingua ) {
  		case 'it':
  		alert("Impossibile accettare il campo '"+label+"' vuoto.");
  		break;
  		case 'en':
  		alert("It is impossible to accept '"+label+"' field empty.");
  		break;  		
  	}
    obj.focus();
    return false;
  }
  else { 
    return true; 
  }
}

function checkEmptyOr( obj1, label1 ,obj2 , label2 , lingua ) {
  var mt1=obj1.value;
  var mt2=obj2.value;
  if (mt1.length<1 && mt2.length<1 ) {
  	switch( lingua ) {
  		case 'it':
  		alert("Almeno uno tra i campi "+label1+" e "+label2+" devono essere riempiti");
  		break;
  		case 'en':
  		alert("Please fill at least one of your telephone numbers");
  		break;  		
  	}
    obj2.focus();
    return false;
  }
  else { 
    return true; 
  }
}

function checkEmptyFckEditor( element_ID, label)
{
	stringEditor = str_replace('&nbsp;', '', FCKeditorAPI.GetInstance(element_ID).GetXHTML());
	if (stringEditor.replace(/(<([^>]+)>)/ig,'')=='') 
	{
    alert("Impossibile accettare il campo '"+label+"' vuoto.");
		return false;
	}
	return true;	
}

function checkCode( obj, label ) 
{
	var mt = obj.value;
	sw = true;
 	if ( mt.length > 0 )
 	{
		sw = isCode ( mt );
		if (!sw)
		{
			obj.focus();
		}
	}
	return sw;
}
	
	

function isCode( val, label ) {
 	sw = true;
    for( i=0; i<val.length; i++ ) {
      ch = val.charAt(i);
      if ( !( ((ch >= "a") && (ch <= "z")) || ((ch >= "A") && (ch <= "Z")) || (ch=="_") || (ch=="-") || (ch==".") || ((ch >= "0") && (ch <= "9")) ) ) {
        sw = false;
      }
    }
    if (!sw)
	{
		alert("Per il campo '"+label+"'\nsono ammessi solo caratteri alfanumerici, '_', '.' e '-' .");
	}
    return sw;
}

function checkCurrency( obj, label ) 
{
	var mt = obj.value;
	sw = true;
 	if ( mt.length > 0 )
 	{
		sw = isCurrency ( mt, label );
		if (!sw)
		{
			obj.focus();
		}
	}
	return sw;
}

/*function isCurrency( val, label ) {
  	if (val.length<3) 
  	{
    	alert("Troppo corta, per il campo '"+label+"'\nla valuta deve essere nel formato 'NNNN.NN' (con due decimali).");
    	return false;
  	} 
  	else 
  	{ 
    	sw = true;
    	pos = val.length - 3;
    	for( i=0; i<val.length; i++ )
    	{
    		ch = val.charAt(i);
    	  	if ((i>pos)) 
    	  	{
    	    	if ( !( ((ch >= "0") && (ch <= "9")) ) ) 
    	    	{
    	      		sw = false;
    	    	}
    	  	} 
    	  	else if ((i==pos)) 
    	  	{
    	    	if ( (ch != ".") ) 
    	    	{
    	      		sw = false;
    	    	}
    	  	} 
    	  	else if (i<pos) 
    	  	{
    	    	if ( !( ((ch >= "0") && (ch <= "9")) ) ) 
    	    	{
    	      		sw = false;
    	    	}
    	  	}
    	}
    	if (!sw)
      	alert("Per il campo '"+label+"'\nla valuta deve essere nel formato 'NNNN.NN' (con due decimali).");
		return sw;
  	}
}*/

function isCurrency( val, label ) 
{
  	sw = true;
  	pos=val.indexOf("."); 
  	if ( (val.length - pos) > 3 && pos >= 0 )
  	{
  		sw = false;
  	}
	else
	{
    	for( i=0; i<val.length; i++ )
    	{
    		ch = val.charAt(i);
    	  	if ((i>pos)) 
    	  	{
    	    	if ( !( ((ch >= "0") && (ch <= "9")) ) ) 
    	    	{
    	      		sw = false;
    	    	}
    	  	} 
    	  	else if ((i==pos)) 
    	  	{
    	    	if ( (ch != ".") ) 
    	    	{
    	      		sw = false;
    	    	}
    	  	} 
    	  	else if (i<pos) 
    	  	{
    	    	if ( !( ((ch >= "0") && (ch <= "9")) ) ) 
    	    	{
    	      		sw = false;
    	    	}
    	  	}
    	}
    }
    if (!sw)
    alert("Per il campo '"+label+"'\nla valuta deve essere nel formato 'NNNN.NN' (con massimo due decimali).");
	return sw;
}

function checkMail( obj, label , lingua ) 
{
	var mt = obj.value;
	sw = true;
 	if ( mt.length > 0 )
 	{
		sw = isMail ( mt, label );
		if (!sw)
		{
			switch( lingua ) {
				case 'it':
				alert("Il campo '"+label+"' non risulta una email valida.");
				break;
				case 'en':
				alert("Invalid email address");
				break;  		
			}			
			obj.focus();
		}
	}
	return sw;
}

function isMail( val ) {
  parts = val.split('@');
  if( (parts.length != 2) ) {
  	return false;
  }
  dom = parts[1].split('.');
  if (   		
			(dom.length != 2 ) ||		  			
			(parts[0].length == 0) ||
			(dom[0].length == 0) ||  		
			(dom[1].length == 0) ||
			(parts[1].length == 0) ||      
			(val.search(' ')!=-1) ||
			(val.search('/')!=-1) ||
			(val.search('&')!=-1) ||
			(val.search('\\?')!=-1) ||
			(val.search(':')!=-1) 
     ) {
    return false;
  }
  return true;
}

function checkMaxSize( obj, label, size ) {
  var mt=obj.value;
  sw = true;
  if (mt.length > size) {
    alert("Il campo '"+label+"' contiene "+mt.length+" caratteri,\nne puo' contenere massimo "+size+"."); 
    obj.focus();
    sw = false;
  }
  return sw;
}

function checkExactSize( obj, label, size ) {
  var mt=obj.value;
  sw = true;
  if (mt.length != size) {
    alert("Il campo '"+label+"' contiene "+mt.length+" caratteri,\nne deve contenere "+size+"."); 
    obj.focus();
    sw = false;
  }
  return sw;
}

function checkDate( obj, label ) {
  	var mt=obj.value;
	sw = true;
 	if ( mt.length > 0 )
 	{
	  	sw = true;
	 	if ( mt.length > 0 )
	 	{
	  		if (!isDate(mt,'dd/MM/yyyy')) {
	    		alert("Per il campo '"+label+"' la data deve essere \nvalida e nel formato 'GG/MM/AAAA'.");
	    		obj.focus();
	    		sw = false;
	  		}
	  	}
	}
  	return sw;
}

function isTime ( val )
{
	sw = true;
	size = val.length;
	if ( size != 8 )
	{
		return false;
	}
	for( i=0; i<val.length; i++ )
	{
		ch = val.charAt(i);
		if ( i==2 || i==5 )
		{
			if ( ch!=":" )
			{
				sw = false;
			}
		}
		else
		{
			if ( !( ((ch >= "0") && (ch <= "9")) ) ) 
    	    {
    	      	sw = false;
    	    }
    	}
    }
    hours = val.substring(0,2);
    minutes = val.substring(3,5);
    secondes = val.substring(6,8);
    if (!( hours < 24 && minutes < 60 && secondes < 60 ))
    {
    	sw = false;
    }
    return sw;
}
    	
				


function isDatetime( val ,formatDate )
{
	if ( val.length > 0 )
	{
		pos = formatDate.length;
		dateVal = val.substring ( 0, pos );
		if (!isDate(dateVal,formatDate))
		{
			return false;
		}
		ch = val.charAt(pos);
		if ( ch = " " )
		{
			time = val.substring ( pos+1, val.length );
			return isTime( time );
		}
		else
		{
			return false;
		}
	} 
	else
	{
		return true;
	}
}
		
function checkDatetime( obj, label ) {
  	var mt=obj.value;
  	sw = true;
 	if ( mt.length > 0 )
 	{
  		if (!isDatetime(mt,'dd/MM/yyyy')) {
    		alert("Per il campo '"+label+"' la data-ora deve essere \nvalida e nel formato 'GG/MM/AAAA HH:MM:SS'.");
    		obj.focus();
    		sw = false;
  		}
  	}
  	return sw;
}		
	

function checkInteger( obj, label ) 
{
	var mt = obj.value;
	sw = true;
 	if ( mt.length > 0 )
 	{
		sw = isInteger ( mt, label );
		if (!sw)
		{
			obj.focus();
		}
	}
	return sw;
}

function isInteger( val ) {
  for( i=0; i<val.length; i++ ) {
    ch = val.charAt(i);
    if ( !((ch >= "0") && (ch <= "9"))) {
     	return false;
    }
  }
  return true;
}

function isNumeric( val ) 
{
  decimalCount = 0;
  for( i=0; i<val.length; i++ ) 
  {
    ch = val.charAt(i);
    if ( !( ((ch >= "0") && (ch <= "9")) || (ch == ".") || (ch == "-") ) ) 
    {
      return false;
    }
    if (ch == ".")
    {
    	decimalCount++;	
    }
    if ( (ch == "-") && (i > 0) )
    {
      return false;
    }
  }
  if (decimalCount > 1)
  {
  	return false;	
  }
  return true;
}

function openWin(action,win,w,h) {
	var wf = "";	
	wf = wf + "width=" + w;
	wf = wf + ",height=" + h;
	wf = wf + ",resizable=" + "yes";
	wf = wf + ",scrollbars=" + "yes";
	wf = wf + ",menubar=" + "no";
	wf = wf + ",toolbar=" + "no";
	wf = wf + ",directories=" + "no";
	wf = wf + ",location=" + "no";
	wf = wf + ",status=" + "no";
	window.open(action,win,wf);
}

function showPreview( u, a, w, h ) {
	win = new PopupWindow();
	win.setUrl( u );
	win.autoHide(); 
	win.setSize(w,h);
	win.offsetX = 50;
	win.offsetY = 0 - h;
	win.setWindowProperties("resizable=yes");
	win.showPopup( a );
}

function showOffsetPreview( u, a, w, h, ox, oy ) {
	win = new PopupWindow();
	win.setUrl( u );
	win.autoHide(); 
	win.setSize(w,h);
	win.offsetX = ox;
	win.offsetY = oy;
	win.setWindowProperties("resizable=yes,scrollbars=yes");
	win.showPopup( a );
}

function myPrint() {
	window.print();
}

function goBack() {
	window.history.go(-1);
}

function confirmLocation( msg, lnk ) {
	if (confirm(msg)) {
		window.document.location = lnk;
		return true;
	} else {
		return false;
	}
}

function goLocation( lnk ) {
	window.document.location = lnk;
	return true;
}

function compareDatetime(datetime1,dateformat1,datetime2,dateformat2) {
	date1 = datetime1.substring(0,dateformat1.length);
	date2 = datetime2.substring(0,dateformat2.length);
	var d1=getDateFromFormat(date1,dateformat1);
	var d2=getDateFromFormat(date2,dateformat2);
	if (d1==0 || d2==0) 
	{
		return -1;
	}
	else if( date1 == date2 )
	{
		if (datetime1 > datetime2)
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	else
	{
		sw = compareDates(date1,dateformat1,date2,dateformat2);
		return sw;
	}
	
}

//---------------------------------------------------------------
// FUNZIONI PER IL CHECK DELLE STRINGHE DI RICERCA

function trim(s) {
	if (s==null)
		return null
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function checkRicerca( obj, label, tipoData)
{
	var mt;
	var pos;
	var operatore;
	var arg1;
	var arg2;
	var result;
	mt = obj.value;
	mt = trim ( mt ); 
	ch_0 = mt.charAt(0);
	if ( ch_0 == "<" || ch_0 == ">" )
	{
		ch_1 = mt.charAt(1);
		if ( ch_1 == "=" )
		{
			arg1 = mt.substring( 2, mt.length);
			arg1=trim(arg1);
		}
		else
		{
			arg1 = mt.substring( 1, mt.length);
			arg1=trim(arg1);
		}			
	}
	else
	{
		if ( ch_0 == "=" )
		{
			arg1 = mt.substring( 1, mt.length);
			arg1=trim(arg1);
		}
		else
		{
			if ( ( pos = mt.indexOf("..") ) != -1 )
			{
				if ( pos == 0 )
				{
					alert('formato non corretto per il campo '+label);
					 obj.focus();
					return false;
				}
				else
				{
					arg1 = mt.substring( 0, pos);
					arg1=trim(arg1);
					arg2 = mt.substring( pos+2 , mt.length);
					arg2=trim(arg2);
				}
			} 
			else
			{
				arg1 = mt;
			}
		}
	}
	switch (tipoData)
	{
  		case 'INTEGER':
  		case 'INT':
    		result = isInteger(arg1,label);
    		if ( result && arg2 )
			{
				result = isInteger(arg2,label);
				if ( Number(arg2) < Number(arg1) )
				{
					alert("l'intervallo inserito per il campo "+label+" non e coretto");
					 obj.focus();
					return false;
				}
			}
   			break;
  	  	case 'CURRENCY':
  	  		result = isCurrency(arg1,label);
    		if ( result && arg2 )
			{
				result = isCurrency(arg2,label);
				if ( Number(arg2) < Number(arg1) )
				{
					alert("l'intervallo inserito per il campo "+label+" non e coretto");
					 obj.focus();
					return false;
				}
			}
     		break;
     	case 'DATE':
     		result = isDate(arg1,'dd/MM/yyyy');
    		if ( result && arg2 )
			{
				result = isDate(arg2,'dd/MM/yyyy');
				if ( compareDates(arg1,'dd/MM/yyyy',arg2,'dd/MM/yyyy'))
				{
					alert("l'intervallo inserito per il campo "+label+" non e coretto");
					obj.focus();
					return false;
				}
			}
			if(!result)
			{
				alert("Per il campo '"+label+"' la data deve essere \nvalida e nel formato 'GG/MM/AAAA'.");
			}
     		break; 
     	case 'DATETIME':
     		result = isDatetime(arg1,'dd/MM/yyyy');
    		if ( result && arg2 )
			{
				result = isDatetime(arg2,'dd/MM/yyyy');
				if ( compareDatetime(arg1,'dd/MM/yyyy',arg2,'dd/MM/yyyy'))
				{
					alert("l'intervallo inserito per il campo "+label+" non e coretto");
					obj.focus();
					return false;
				}
			}
			if(!result)
			{
				alert("Per il campo '"+label+"' la data-ora deve essere \nvalida e nel formato 'dd/MM/yyyy hh:mm:ss'.");
			}
     		break;   
     	default:
     		if ( arg2 && arg2 < arg1 )
			{
				alert("l'intervallo inserito per il campo "+label+" non e coretto");
				obj.focus();
				return false;
			}
     		result = true;
     		break;
	} 
	if(!result)
	{
		obj.focus();
	}
	return result;
  
}

function todayStr() {
var today=new Date();
var month=(today.getMonth()+1);
var day=today.getDate();
if ( month < 10 )
{
	month='0'+ month;
}
if (day < 10)
{
	day=0 + day;
}
var oggi=(today.getFullYear())+month+day;
return oggi;
}

function compareDateToOggi( obj )
{
	var mydate=obj.value;
	var today = todayStr();
	var mydate_array=mydate.split("/");
	mydate=( mydate_array[2] + mydate_array[1] + mydate_array[0] );
	if ( mydate < today )
	{
		return -1;
	}
	else if(  mydate == today )
	{
		return 0;
	}
	else
	{
		return 1;
	}
}

function confrontaDate( obj1, obj2 )
{
	var mydate=obj1;
	var mydate2=obj2;
	var mydate_array=mydate.split("/");
	var mydate2_array=mydate2.split("/");
	mydate=( mydate_array[2] + mydate_array[1] + mydate_array[0] );
	mydate2=( mydate2_array[2] + mydate2_array[1] + mydate2_array[0] );
	if ( mydate < mydate2 )
	{
		return -1;
	}
	else if(  mydate == mydate2 )
	{
		return 0;
	}
	else
	{
		return 1;
	}
}

function confrontaDateAnno( obj1, obj2 )
{
	var mydate=obj1;
	var mydate2=obj2;
	
	var mydate2_array=mydate2.split("/");
	if(  mydate < mydate2_array[2] )
	{
		return -1;
	}
	else
	{
		return 1;
	}
}

//rende uguale la larghezza dei td della tabella html destTbl a quelli della tabella html srcTbl
function setSameTDWidthOfTwoTables(srcTbl, destTbl)
{
		//controllo se c' almeno una riga in entrambe le tabelle
		if(srcTbl.rows.length == 0 || destTbl.rows.length == 0)
		{
			return;
		}
		//controllo che le 2 tabelle abbiano lo stesso numero di colonne
	 	if(srcTbl.rows[0].cells.length != destTbl.rows[0].cells.length)
	 	{
	 			alert("Il numero delle colonne delle due tabelle deve essere uguale!");
	 			return;
	 	}
	 	
	 	//metto la stessa width della tab con i dati alla tab che ha le intestazioni
	 	if(srcTbl.clientWidth != destTbl.clientWidth)
	 	{
	 		destTbl.width = (srcTbl.clientWidth) + "px";	
	 	}
	 	//calcolo il fattore di differenza in base a cellpadding cellspacing e border
	 	diff = parseInt(srcTbl.cellPadding) + parseInt(srcTbl.cellSpacing) + parseInt(srcTbl.border);
		//ciclo sui td e setto la nuova width
	 	for(i=0;i<srcTbl.rows[0].cells.length;i++)
	 	{
	 		destTbl.rows[0].cells[i].style.width = srcTbl.rows[0].cells[i].clientWidth - diff + "px";
	 		//alert(srcTbl.rows[0].cells[i].innerHTML + ": \n" + srcTbl.rows[0].cells[i].clientWidth + " " + destTbl.rows[0].cells[i].clientWidth);
	 	}
 		//alert("tbls witdh:\n\n" + srcTbl.clientWidth + " " + dest.clientWidth);
}


function textCounter(field,cntfield,maxlimit)
{
	if (field.value.length > maxlimit)
	{
		field.value = field.value.substring(0, maxlimit);
	}
	else
	{
		cntfield.value = maxlimit - field.value.length;
	}
}

function isEmpty(s)
{
	if (s == null)
		return true;
	return (trim(s) == '');
}

function str_replace(what, by, val)
{
	if (val == null || trim(val) == '')
	{
		return val;
	}
	return val.replace(eval('/\\' + what + '/ig'), by);
}

function isEmptyFckEditor(element_ID)
{
	stringEditor = str_replace('&nbsp;', '', FCKeditorAPI.GetInstance(element_ID).GetXHTML());
	if (stringEditor.replace(/(<([^>]+)>)/ig,'')=='') 
	{
		return true;
	}
	return false;	
}

function calToIsoDate(calElementID, destElementID, sm_date_format, isDateTime)//
{
	document.getElementById(destElementID).value = '';
	
	cc = new Calendar(0);
	ret = cc.parseDate(document.getElementById(calElementID).value, sm_date_format);
	if(!ret)
	{
		return false;
	}
		function fmtMinorTen(val)
		{
			if (val < 10)
				return '0' + val;
			else
				return val;
		}
	document.getElementById(destElementID).value = fmtMinorTen(ret.getFullYear()) + '-' + fmtMinorTen(ret.getMonth()+1) + "-" + fmtMinorTen(ret.getDate());
	if(isDateTime)
	{
		document.getElementById(destElementID).value += ' ' + fmtMinorTen(ret.getHours()) + ':' + fmtMinorTen(ret.getMinutes()) + ':' + fmtMinorTen(ret.getSeconds());
	}
	return true;
}

function userFloatToDb(userFloatID, destElementID)
{
	if(_FLOAT_DECIMAL_SEP_USER != '.')
	{
		document.getElementById(destElementID).value = str_replace(",", ".", document.getElementById(userFloatID).value);
	}
	else
	{
		document.getElementById(destElementID).value = document.getElementById(userFloatID).value;
	}
	
}

function formatDecimal(e)
{
	if(_FLOAT_DECIMAL_SEP_USER == '.')
	{
		return;	
	}
	if (e.target) 
	{
		targ = e.target;
		key = e.which;
	}
	else if (e.srcElement) 
	{
		key = e.keyCode;
		targ = e.srcElement;
	}
	if (targ.nodeType == 3) // defeat Safari bug
	{
		targ = targ.parentNode;
		key = e.which;
	}
	if(key == 110 || key == 190)
	{
		targ.value = targ.value.substring(0,targ.value.length-1) + _FLOAT_DECIMAL_SEP_USER;
	}
}
