
/* --- calls the window.print function --- */
function printWindow() {
	window.print();
}

/* --- sets display:block for an element --- */
function showElm(elm) {
	document.getElementById(elm).style.display = "block"
}

/* --- sets display:none for an element --- */
function hideElm(elm) {
	document.getElementById(elm).style.display = "none"
}

/* --- pops up a new window --- */
function popWin(url, winName, width, height) {
	var popWin = window.open(url, winName, "width=" + width + ",height=" + height + ",left=200,top=150,scrollbars");
	popWin.focus(); 

	return false;
}

/* --- functionality for tab switching on start page --- */
function tabSwitch(e) {
	var elm;
	// get source element of the event
	if (!e) var e = window.event;
	target = (e.target) ? e.target : e.srcElement;
	if (!target) return;

	switch (target.parentNode.id) {
		case "tab1":
			if (elm = document.getElementById("tab1")) elm.className = "selected";
			if (elm = document.getElementById("tab2")) elm.className = "";
			if (elm = document.getElementById("tab3")) elm.className = "";
			showElm("tabContent1");
			hideElm("tabContent2");
			hideElm("tabContent3");
			break;
		case "tab2":
			if (elm = document.getElementById("tab2")) elm.className = "selected";
			if (elm = document.getElementById("tab1")) elm.className = "";
			if (elm = document.getElementById("tab3")) elm.className = "";
			showElm("tabContent2");
			hideElm("tabContent1");
			hideElm("tabContent3");
			break;
		case "tab3":
			if (elm = document.getElementById("tab3")) elm.className = "selected";
			if (elm = document.getElementById("tab1")) elm.className = "";
			if (elm = document.getElementById("tab2")) elm.className = "";
			showElm("tabContent3");
			hideElm("tabContent1");
			hideElm("tabContent2");
			break;
	}
	return false;
}

/* --- event attaching, done when document is loaded --- */
function doOnLoad() {
	var elm;

	/* --- attach event to Print button --- */
	if (elm = document.getElementById("printButton")) {
		elm.onclick = printWindow;
		elm.href = "javascript:void(0)";
	}

	/* --- attach events to tabs on start page --- */
	if (elm = document.getElementById("tab1")) {
		elm.onclick = tabSwitch;
	}
	if (elm = document.getElementById("tab2")) {
		elm.onclick = tabSwitch;
	}
	if (elm = document.getElementById("tab3")) {
		elm.onclick = tabSwitch;
	}

	return false;
}

/* --- attach onload event to window --- */
window.onload = doOnLoad;
