function findInput(el) {
	el = el.parentNode
	for (var i = 0; i < el.childNodes.length; i++) if (el.childNodes[i].nodeName == 'INPUT' ) { el = el.childNodes[i]; break; }
	if (el.nodeName == 'INPUT') return el
}

function spin(el, dir, inc) {
	el = findInput(el)
	if (!el.spin) {
		var range = [-10000000, 10000000]
		var func
		if (el.getAttribute('spinrange')) range = el.getAttribute('spinrange').split('-')
		if(func = el.getAttribute('spinfunc')) el.spinFunc = new Function(func);
		el.spinRangeBegin = range[0]
		el.spinRangeEnd = parseInt(range[1])
		el.spin = true
	}
	if (el.disabled) return false
	el.focus()
	fl = 1/inc
	fl = (fl > 1) ? fl : 1
	var t = parseFloat(el.value)
	if (isNaN(t)) t = 0
	var t = t * fl + dir * fl * inc 
	t = t / fl
	if (t < el.spinRangeBegin || t > el.spinRangeEnd) return false
	el.value = t
	if (el.spinFunc) el.spinFunc()
	return false
}

function spinObj(el) {
	var range = el.getAttribute('spinrange').split('-')
	this.spin = true
	this.rangeBegin = range[0]
	this.rangeEnd = range[1]
}

function attachSpin(inc,ret) { if (!inc) inc = 1; var t = '<a href="#" onclick="return spin(this,1,' + inc + ')" onselectstart="return false;" ondblclick="return spin(this,1,' + inc + ')"><img title="+' + inc + '" style="-moz-user-select: none; position: relative; top: 1px; margin-right: -10px;" src="/imgs/frm_up.gif" width="10" height="9" border="0" align="top"></a><a href="#" onselectstart="return false;" onclick="return spin(this,-1,' + inc + ')" ondblclick="return spin(this,-1,' + inc + ')"><img title="-' + inc + '" style="-moz-user-select: none; position: relative; top: 10px; margin-right; -10px;" src="/imgs/frm_down.gif" width="10" height="9" border="0" align="top"></a>'; if (ret) return t; else document.write(t); }

