function suycDateDiff( start, end, interval, wholedays ) {

    var iOut = 0;
    
    // Create 2 error messages, 1 for each argument. 
    var startMsg = "Check the Start Date and End Date\n"
        startMsg += "must be a valid date format.\n\n"
        startMsg += "Please try again." ;
		
    var intervalMsg = "Sorry the dateAdd function only accepts\n"
        intervalMsg += "d, h, m OR s intervals.\n\n"
        intervalMsg += "Please try again." ;

    var bufferA = Date.parse( start ) ;
    var bufferB = Date.parse( end ) ;
    
    // check that the start parameter is a valid Date. 
    if ( isNaN (bufferA) || isNaN (bufferB) ) {
        alert( startMsg ) ;
        return null ;
    }
	
    // check that an interval parameter was not numeric. 
    if ( interval.charAt == 'undefined' ) {
        // the user specified an incorrect interval, handle the error. 
        alert( intervalMsg ) ;
        return null ;
    }
    
    var number = bufferB-bufferA ;
    
    // what kind of add to do? 
    switch (interval.charAt(0))
    {
        case 'd': case 'D': 
            iOut = parseInt(number / 86400000) ;
            if(wholedays) iOut += parseInt((number % 86400000)/43200001) ;
            break ;
        case 'h': case 'H':
            iOut = parseInt(number / 3600000 ) ;
            if(wholedays) iOut += parseInt((number % 3600000)/1800001) ;
            break ;
        case 'm': case 'M':
            iOut = parseInt(number / 60000 ) ;
            if(wholedays) iOut += parseInt((number % 60000)/30001) ;
            break ;
        case 's': case 'S':
            iOut = parseInt(number / 1000 ) ;
            if(wholedays) iOut += parseInt((number % 1000)/501) ;
            break ;
        default:
        // If we get to here then the interval parameter
        // didn't meet the d,h,m,s criteria.  Handle
        // the error. 		
        alert(intervalMsg) ;
        return null ;
    }
    

    return iOut ;
}



// The presentDate function is called on when you 
// click on the button on the form.
function presentDate(StartDate, EndDate) {
    var ierr = 1 ;
    
   // Verify whether the user wants to return only whole
   // intervals or intervals rounded to the nearest number 
   // of interval.
   
	//imposto manualmente questa variabile a 1....fondamentalmente perchè non ho capito a cosa serva!!!!!!
   //var roundDays = f.chkWholeDays.checked ;
	var roundDays = 1
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Parte di codice scritta da giacomo in data17/02/2005, necessaria per creare la data nel formato americano mm/gg/aaaa.
	var giornoDal = StartDate.value.slice(0, 2);
	var meseDal = StartDate.value.slice(3, 5);
	var annoDal = StartDate.value.slice(6, 10);
	var strDataDal = meseDal + '/' + giornoDal + '/' + annoDal
	//alert(strDataDal);
	var giornoAl = EndDate.value.slice(0, 2);
	var meseAl = EndDate.value.slice(3, 5);
	var annoAl = EndDate.value.slice(6, 10);
	var strDataAl = meseAl + '/' + giornoAl + '/' + annoAl
	//alert(strDataAl);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
   // Verify that the user entered something in the
   // Start Date input box.
    if(strDataDal != '') {
        if(!isNaN(Date.parse( strDataDal ))) {
            var s = new Date(Date.parse(strDataDal)) ;
            ierr = 0 ;
        }
    }
    
   // Verify that the user entered something in the
   // Ending Date input box.
    if(strDataAl != '' && ierr != 1) {
        if(!isNaN(Date.parse( strDataAl ))) {
            var e = new Date(Date.parse(strDataAl)) ;
            
            // call the dateDiff function.
			//pongo il valore del campo f.selTypeOf.value (che ho tolto) a 'd' cioè fa il calcolo sul giorno
            //var temp = suycDateDiff( s, e, f.selTypeOf.value, roundDays ) ;
			var temp = suycDateDiff( s, e,'d', roundDays ) ;
        }else{
            ierr = 1;
        }
    }else{
        ierr = 1;
    }
    
    // update the tellTime field with our new value.
    if ( temp != null && ierr != 1 ) {
		if (temp.toString() > 0) {
			return 'S'
		}else{
			return 'N'
		}
	}
}
