// Chris Englmeier <machin@mindspring.com>
// feel free to use this script as long as this text remains intact
// http://www.geocities.com/SiliconValley/Heights/2052
// Copyright 1996 Chris Englmeier

function cpscalc(myform)
{
	var bytes = 0
	var trans = 0 

  bytes = myform.dimensione.value * ((myform.unita.options[0].selected == true) + ( (myform.unita.options[1].selected == true)*1024) + ((myform.unita.options[2].selected == true) * 1024*1024))

 trans = myform.velocita.value / ( (myform.unitaV.options[0].selected == true) + ( (myform.unitaV.options[1].selected == true) * 8))

myform.result.value =  getmin(Math.round(bytes/trans))     	  		
}

function getmin(sec)
{
		var ore = 0
		var minuti = 0
    var secondi = 0
		var tempo = " "

		if(sec<1) return ("meno di un secondo")
					ore = Math.floor (sec/3600)
					minuti =  Math.floor((sec - (ore * 3600))/60)
					secondi = Math.floor (sec - ((ore*3600) + (minuti * 60)))

		if(sec > 86400) return ("more than a day")			
		else if(sec  >=  3600) tempo = "Ore: " + ore + "  minutei: " + minuti + "  secondi: " + secondi  														
  	else if( sec< 3600 & sec >=60) tempo = "Minuti: " + minuti + "  secondi: " + secondi
		else tempo = "Secondi: " + secondi 

		
	return(tempo)
}
