<script type="text/javascript">
//<![CDATA[

var array = [0, -3, 10, -10, 15];

//Must be sorted from the smallest to the highest
array = array.sort(function(a, b){
	return a - b;
});

document.write(
	"Array = [", array, "]<br />Indexes of the nearest numbers to:<br />",
	"5 = ", getNearestNumber(array, 5), "<br />",
	"9 = ", getNearestNumber(array, 9), "<br />",
	"15 = ", getNearestNumber(array, 15), "<br />",
	"-15 = ", getNearestNumber(array, -15), "<br />",
	"-2 = ", getNearestNumber(array, -2)
);

//]]>
</script>