
function StopError() {
         return true;
}

window.onerror = StopError;


function openPopUp(width,height,name,parameters) {
	var parameterString;
	if ( (width == null) || (width <= 0) ) {
		width = 600;
	}
	if ( (height == null) || (height <= 0) ) {
		height = 400;
	}
	if (name == null) {
		name = "apuPopUp";
	}
	
	if (parameters) {
		parameterString = "directories=no,width="+width+",height="+height+",personalbar=no,"+parameters;
	} else {
		parameterString = "directories=no,width="+width+",height="+height+",location=no,menubar=no,personalbar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
	}
	apuPopUpWin=window.open("",name,parameterString);
	apuPopUpWin.focus();
}

function writePrintButton() {
	if (window.print) {
		document.write ('<li><a href="javascript:window.print();"><img src="/img/icon_print.gif" alt="" border="0"> Tulosta sivu</a></li>');
	}
}

function openInLauncher(url) {
	if (window.opener && !window.opener.closed) {
		window.opener.top.location.href=url;
		window.opener.top.focus();
	} else {
		apuWin=window.open(url,"apu","");
		apuWin.focus();
	}
}


/* Navi */
var menuInitialized = false; 
var currentSection = 0;

function initRollover (menuItemAmount) {
	if (document.getElementById || document.all) {
		for (var i = 1; i < (menuItemAmount + 1); i++) {
			eval ('menuItem' + i + 'Active = new Image ()'); 
			eval ('menuItem' + i + 'Active.src = document.images.rolloverImg' + i + '.src');
			eval ('menuItem' + i + 'Passive = new Image ()'); 
			eval ('menuItem' + i + 'Passive.src = document.images.menuItem' + i + '.src');
		}
		menuInitialized = true;
	}
}

function rolloverActive (imgNr) {
	if (menuInitialized && imgNr != currentSection) eval ('document.images.menuItem' + imgNr + '.src = menuItem' + imgNr + 'Active.src');
}

function rolloverPassive (imgNr) {
	if (menuInitialized && imgNr != currentSection) eval ('document.images.menuItem' + imgNr + '.src = menuItem' + imgNr + 'Passive.src');
}
/* /Navi */


/* Ristikko */

function openRistikkoPopUp(width,height,name,parameters) {
	var parameter_string;
	var scrollbars = 'no';
	if ( (width == null) || (width <= 0) ) {
		width = 600;
	}
	if ( (height == null) || (height <= 0) ) {
		height = 400;
	}
	width = width + 200;
	if (width > screen.availWidth) {
		width = screen.availWidth - 12;
		scrollbars = 'yes';
	}
	height = height + 100;
	if (height > screen.availHeight) {
		height = screen.availHeight - 61;
		scrollbars = 'yes';
	}
	
	parameter_string = "location=no,menubar=no,resizable=yes,scrollbars=" + scrollbars + ",status=no,toolbar=no";

	name = "apuRistikkoPopUp";
	
	openPopUp(width, height, name, parameter_string);
}

function createGroupRoom(this_form) {
	var crossword_id = this_form.id.options[this_form.id.selectedIndex].value;
	var width = parseInt(eval('this_form.leveys_' + crossword_id + '.value'));
	var height = parseInt(eval('this_form.korkeus_' + crossword_id + '.value'));
	openRistikkoPopUp(width,height);
} 

function createGroupRoomB(width, height, baseurl, ristikkoid) {
	var scrollbars = 'no';
	if ( (width == null) || (width <= 0) ) {
		width = 600;
	}
	if ( (height == null) || (height <= 0) ) {
		height = 400;
	}
	width = width + 200;
	if (width > screen.availWidth) {
		width = screen.availWidth - 12;
		scrollbars = 'yes';
	}
	height = height + 100;
	if (height > screen.availHeight) {
		height = screen.availHeight - 61;
		scrollbars = 'yes';
	}
	
	var parameterString = "directories=no,width="+width+",height="+height+",personalbar=no,location=no,menubar=no,resizable=yes,scrollbars=" + scrollbars + ",status=no,toolbar=no";
	var name = "apuRistikkoPopUp";
	ristikkoPopWin = window.open(baseurl+"?id="+ristikkoid,name,parameterString);
	ristikkoPopWin.focus();
	return false;
} 
/* /Ristikko */
