
function UpDown2(){
	var o=$byclass('updown');
	
	for(i=0;i<o.length;i++){
		var img=document.createElement('img');

		img.src='/images/updown.png';
		img.id=o[i].id+'-updown';
		img.className='updownimage';
		
		addEvent(img,'mouseup',function(event){UpDownHandler(event);});
		insertAfter(img, o[i]);
	}
	
}

function insertAfter(I,i){var l=i.parentNode;if(l.lastchild==i){l.appendChild(I)}else{l.insertBefore(I,i.nextSibling)}}

function UpDownHandler(event){
	
	
	var p=event.srcElement.id,o=p.split('-')[0];
	var p=$(p),x=event.offsetX,y=event.offsetY,o=$(o),s=$size(p),ov=parseInt(o.value);

	if (y < (s[1] / 2)) {
		// Increment
		o.value=ov+1;
		if(isNaN(o.value)){o.value='1';return;}
	} else {
		if(ov>0)ov=ov-1;
		if(ov==0)
			o.value='';
		else
			o.value=ov;
	}
	
	
}

