var _flagActive = 0; // Indicates if there's an open answer.
var _current; // Stores current answer.
var currentIndex = 0;
var agt = navigator.userAgent.toLowerCase();
var explorer = navigator.appVersion.split("MSIE");
var exp_version = parseFloat(arVersion[1]);
var refresh_flag = 0;

// If browser is Firefox, adds "Click" function.
if (agt.indexOf("firefox") != -1){
	HTMLElement.prototype.click = function() {
		var evt = this.ownerDocument.createEvent('MouseEvents');
		evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
		this.dispatchEvent(evt);
	}
}

function showAnswer(div, span, oscroll){
	var changeSpan = document.getElementById('span' + span);
	var oldSpan = document.getElementById('span' + currentIndex);

	if (oscroll != "no"){
		// IE 7
		if((exp_version > 6) && (exp_version < 8)){
			setTimeout('gotoAnchor("' + div + 'a' + '")', 800);
		}
			
		// IE 6
		else {
		if((exp_version > 5) && (exp_version < 7)){
			refresh_flag++;
			if(refresh_flag > 1){
				var urll = location.href;
				temp1 = urll.split('?');
				temp = temp1[0].split('#');
				urlll = temp[0] + '?ie6=1';
				location.href = urlll;
			}
			else
				setTimeout('gotoAnchor("' + div + 'a' + '")', 700);
		}
			// Firefox
			else
				gotoAnchor(div + 'a');
		}
	}
	
	if(_flagActive == 0){
		currentIndex = span;
		changeSpan.style.color = '#d7d91e';
		_flagActive = div;
		_current = div;
		new Effect.BlindDown(div);
	}
	else {
		if(_current == div){
			changeSpan.style.color = '#9fa4ff';
			new Effect.BlindUp(div);
			_flagActive = 0;
			currentIndex = 0;
		}
		else {
			changeSpan.style.color = '#d7d91e';
			oldSpan.style.color = '#9fa4ff';
			new Effect.BlindUp(_current);
			new Effect.BlindDown(div);
			_flagActive = div;
			_current = div
			currentIndex = span;
		}
	}
}

function transBold(span) {
	var text = document.getElementById('span' + span.toString());
	
	if(currentIndex != span)
		text.style.color = '#d7d91e';
}

function transNormal(span) {
	var text = document.getElementById('span' + span.toString());
	
	if(currentIndex != span)
		text.style.color = '#9fa4ff';
}

function gotoAnchor(anchorPoint) {
	var obj = document.getElementById(anchorPoint);
	
	obj.click();
}