function openpopup(width, height, fileName, windowName){
	if(typeof windowName == "undefined"){
    	windowName = "popup";
	}
	window.open(fileName, windowName, 'width=' + width + ',height=' + height + ',scrollbars=yes,resizable=no,menubar=no,toolbar=no,status=no,titlebar=no');
}

function updatecontent(content_url, target, callfunc, type){
	var conn;
	var result;
	conn = (typeof(XMLHttpRequest) != "undefined") ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
	conn.onreadystatechange = function(){
		if(conn.readyState==4) if(conn.status == 200){
			//result = conn.responseText;
			if(type == "value") target.value = conn.responseText;
			else target.innerHTML = conn.responseText;
			if(callfunc){
				eval(callfunc);
			}
		}
	}
	conn.open('get', content_url);
	conn.send(null);
	return result;
}

function trim(val){
	while("" + val.charAt(0) == " ") val = val.substring(1, val.length);
	while("" + val.charAt(val.length - 1) == " ") val = val.substring(0, val.length - 1);
	return val;
}

function submitSearch(formName){
	searchWord = trim(document.forms[formName].searchword.value);
	if(searchWord.length >= 3) rval = true;
	else{
		rval = false;
		alert('Virhe! Hakusanan tulee olla vähintään kolmen merkin pituinen.');
	}
	return rval;
}

function menuConv(itemName){
	itemName = itemName.toLowerCase();
	a = 0;
	var newItemName = "";
	while(a < itemName.length){
		var itemChar = itemName.charAt(a);
		if(itemChar == 'å') var itemChar = 'a';
		if(itemChar == 'ä') var itemChar = 'a';
		if(itemChar == 'ö') var itemChar = 'o';
		if(itemChar == ' ') var itemChar = '_';
		newItemName = newItemName + itemChar;
		a++;
	}
	return newItemName;
}