function selectAnswer(id) {
	if (document.getElementById) for (i = 1; i <= num_q; i++) {
		if (i != id) document.getElementById('q' + i).className='answer';
		else document.getElementById('q' + id).className='selected';
	}
	// scroll
	var dl = document.getElementById('q' + id);
	if (!dl) return true;
	var dx = dl.offsetLeft; 
	var dy = dl.offsetTop;
	var tn = dl;
	while (tn.offsetParent && (tn.offsetParent != document.body)) {
		tn = tn.offsetParent;
		dx += tn.offsetLeft;
		dy += tn.offsetTop;
	}
	dy -= 20;
	clearInterval(timer);
	timer = setInterval('scroll('+stepsize+','+dy+','+id+')', 10);
}

function scroll(scramount, dest, anchor) {
	var wascypos = get_ypos();
	var isAbove = (wascypos < dest);
	window.scrollTo(0,wascypos + scramount);
	var iscypos = get_ypos();
	var isAboveNow = (iscypos < dest);
	if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
		window.scrollTo(0,dest);
		clearInterval(timer);
		//location.hash = 'q' + anchor;
	}
}

function get_ypos() {
	// ie5 and ie5.5
	if (document.body && document.body.scrollTop)
	return document.body.scrollTop;
	// ie6
	if (document.documentElement && document.documentElement.scrollTop)
	return document.documentElement.scrollTop;
	// netscape etc
	if (window.pageYOffset)
	return window.pageYOffset;
	return 0;
}

