try {
	window.addEventListener("load", loadPopup, false);
	window.addEventListener("load", hoverFunc, false);
	window.addEventListener("load", show_or_hide, false);
} catch(e) {
	window.attachEvent("onload", loadPopup);
	window.attachEvent("onload", hoverFunc);
	window.attachEvent("onload", show_or_hide);
}

function loadPopup() {
	var img = new Array(8);
	for (var i=0; i<img.length; i++)
		img[i] = new Image();
	img[0].src = './img/bg_parent_answer_1_on.gif';
	img[1].src = './img/bg_parent_answer_2_on.gif';
	img[2].src = './img/bg_parent_answer_3_on.gif';
	img[3].src = './img/bg_parent_answer_4_on.gif';
	img[4].src = './img/bg_child_answer_1_on.gif';
	img[5].src = './img/bg_child_answer_2_on.gif';
	img[6].src = './img/bg_child_answer_3_on.gif';
	img[7].src = './img/bg_child_answer_4_on.gif';
}

function hoverFunc() {
	var elm = document.getElementsByTagName("img");
	for (var i=0; i<elm.length; i++) {
		if (elm[i].className.indexOf("hover") >= 0) {
			elm[i].onmouseover = mouse_over_image;
			elm[i].onmouseout = mouse_out_image;
		}
	}
	elm = document.getElementsByTagName("input");
	for (var i=0; i<elm.length; i++) {
		if (elm[i].className.indexOf("hover") >= 0) {
			elm[i].onmouseover = mouse_over_image;
			elm[i].onmouseout = mouse_out_image;
		}
	}
}

function mouse_over_image() {
	if (this.src.indexOf(".jpg") > 0)
		this.src = this.src.replace(".jpg", "_on.jpg");
	else if (this.src.indexOf(".gif") > 0)
		this.src = this.src.replace(".gif", "_on.gif");
}

function mouse_out_image() {
	if (this.src.indexOf(".jpg") > 0)
		this.src = this.src.replace("_on.jpg", ".jpg");
	else if (this.src.indexOf(".gif") > 0)
		this.src = this.src.replace("_on.gif", ".gif");
}

function demo_pagefeed(max, feed) {
	bodyid = document.body.className;
	num = parseInt(bodyid.substring(12), 10);
	if (feed > 0 && num < max) bodyid = ('popup show_q' + (num+feed));
	else if (feed < 0 && num > 1) bodyid = ('popup show_q' + (num+feed));
	document.body.className = bodyid;
}

function show_or_hide() {
	if ((an = document.URL.indexOf('#')) > 0) {
		id = document.URL.substring(an+1);
		elm = document.getElementById(id);
		if (elm) elm.style.display = 'block';
	}
}

function demo_login() {
	document.getElementById('guest_user').style.display = 'none';
	document.getElementById('login_user').style.display = 'block';
}

function advice_explanation(name) {
	open_elm = document.getElementById(name);
	if (open_elm.className.indexOf(' opened') >= 0) {
		open_elm.className = open_elm.className.replace(' opened', '');
	} else {
		open_elm.className += ' opened';
	}
}