function StopError() {
         return true;
}

window.onerror = StopError;

function WritePrintButton() {
	if (window.print) {
		document.write ('<a href="javascript:window.print();" id="printButton"><img src="/img/button_tulosta.gif" width="60" height="15" border="0" alt="Tulosta" /></a>');
	}
}

function extWindow(URL){
    myWin=open(URL,"displayWindow","toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=300");
    if (!myWin.closed)
        myWin.blur();
    myWin.focus();
    
}

function MM_openWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function showdiv(id) {
	$(id).show();
}

function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function changeLoginField(element,add) {
	if(element == null)
		return;
	if (element.value == '' && add)
		element.addClassName('markup')
	else if (element.value != '' && element.hasClassName('markup'))
		element.removeClassName('markup');		
}

function activeLoginField(event) {
	Event.element(event).removeClassName('markup');
}

function checkLoginField(event) {
	changeLoginField(Event.element(event),true);
}

function removeOnly(event) {
	changeLoginField(Event.element(event),false);
}


Event.observe(document, 'dom:loaded', function() {
	
	changeLoginField($('username'));
	changeLoginField($('password'));

	var form = $('loginFormTop');
	if(form != null) {
	
		if(form.addEventListener){
			form.addEventListener('focus',	activeLoginField,	true);
			form.addEventListener('blur',	checkLoginField,	true);
			form.addEventListener('keypress',removeOnly,		true);
		} else {
			form.observe('focusin', activeLoginField).observe('focusout', checkLoginField).observe('keypress', removeOnly);
		}
		
		new Form.Element.Observer(
			'password',
			0.5,
			function (element,value){
				changeLoginField(element,false);
			});
	}
});

function writeAds(target) {
		// Modify to reflect site specifics
		var adserver = "http://adserver.sanomawsoy.fi";
		// Cache-busting and pageid values
		var random = Math.round(Math.random() * 10000000000);
		if (!pageNum)
		var pageNum = Math.round(Math.random() * 10000000000);
		document.write('<SCR');
		document.write('IPT SRC="' + adserver + '/jserver' + target + '/acc_random=' + random + '/pageid=' + pageNum + '">');
		document.write('</SCR');
		document.write('IPT>');
}