function openPop (fname) {
	lightPop = window.open (fname, 8, 'width=900, height=700, status=yes, toolbar=no, scrollbars=yes, resizable=yes');
	window.lightPop.focus ();
}

function showPage (page, lang) {
	document.getElementById ('acon').scrollTop = 0;
	showDoc (page, lang, 'acontext');
	document.getElementById ('acon').style.visibility = 'visible';
	document.getElementById ('aconcx').style.visibility = 'visible';
}
function hideElem (id) {
	document.getElementById (id).style.visibility = 'hidden';
	document.getElementById ('aconcx').style.visibility = 'hidden';
}

function toggleActive (id) {
	for (i = 1; i < 20; i++) {
		rid = 'm'+ i;
		if (document.getElementById (rid)) {
			resetClass (rid);
		}
		else { break; }
	}
	document.getElementById (id).className = 'active';
}
function resetClass (id) {
	document.getElementById (id).className = '';
}

function stopScroll () {
	if (typeof (scrollrate) != 'undefined') {
		clearInterval (scrollrate);
	}
}
function scrollUp (area) {
	scrollrate = window.setInterval (function () { document.getElementById (area).scrollTop -= 5; }, 10);
}
function scrollDown (area) {
	scrollrate = window.setInterval (function () { document.getElementById (area).scrollTop += 5; }, 10);
}

function checkForm () {
	var okts = true;

	if (document.forms[0].cname.value.length < 3) {
		document.forms[0].cname.style.background = '#ffcccc';
		okts = false;
	}
	else document.forms[0].cname.style.background = '#ffffff';

	// email empty, puhelin empty
	if (document.forms[0].email.value.length < 1 && document.forms[0].phone.value.length < 1) {
		document.forms[0].email.style.background = '#ffcccc';
		document.forms[0].phone.style.background = '#ffcccc';
		okts = false;
	}
	// email empty, puhelin liian lyhyt
	else if (document.forms[0].email.value.length < 1 && document.forms[0].phone.value.length > 0 && document.forms[0].phone.value.length < 4) {
		document.forms[0].email.style.background = '#ffffff';
		document.forms[0].phone.style.background = '#ffcccc';
		okts = false;
	}
	// email liian lyhyt
	else if (document.forms[0].email.value.length > 0 && document.forms[0].email.value.length < 6) {
		document.forms[0].email.style.background = '#ffcccc';
		// puhelin ok
		if (document.forms[0].phone.value.length < 1 || document.forms[0].phone.value.length > 3) {
			document.forms[0].phone.style.background = '#ffffff';
		}
		// puhelin liian lyhyt
		else if (document.forms[0].phone.value.length > 0 && document.forms[0].phone.value.length < 4) {
			document.forms[0].phone.style.background = '#ffcccc';
		}
		okts = false;
	}
	// email riittavan pitka
	else if (document.forms[0].email.value.length > 5) {
		document.forms[0].email.style.background = '#ffffff';
		document.forms[0].phone.style.background = '#ffffff';
		// email virheellinen
		if (document.forms[0].email.value.indexOf ('@') < 1 || document.forms[0].email.value.indexOf ('.') < 2) {
			document.forms[0].email.style.background = '#ffcccc';
			okts = false;
		}
		// puhelin ok
		if (document.forms[0].phone.value.length < 1 || document.forms[0].phone.value.length > 3) {
			document.forms[0].phone.style.background = '#ffffff';
		}
		// puhelin liian lyhyt
		else if (document.forms[0].phone.value.length > 0 && document.forms[0].phone.value.length < 4) {
			document.forms[0].phone.style.background = '#ffcccc';
			okts = false;
		}
	}

	if (document.forms[0].topic.value.length < 1) {
		document.forms[0].topic.style.background = '#ffcccc';
		okts = false;
	}
	else { document.forms[0].topic.style.background = '#ffffff'; }

	if (document.forms[0].msg.value.length < 6) {
		document.forms[0].msg.style.background = '#ffcccc';
		okts = false;
	}
	else { document.forms[0].msg.style.background = '#ffffff'; }

	return okts;
}

function swapAd () {
	cad = 1;
	swapTime = window.setInterval (function () {
		document.getElementById ('ad'+ cad).className = 'hide';
		if (++cad > tads) {
			cad = 1;
		}
		document.getElementById ('ad'+ cad).className = 'show';
	}, 15000);
}
