var layerstring = "layers.";
var stylestring = "";	

if (document.all) {
layerstring = "all.";
stylestring = ".style";

}
if (document.layers) {
layerstring = "layers.";
stylestring = "";

}
if (document.getElementById) {
layerstring = "getElementById('";
stylestring = "').style";
}

function open_lr(layer) {
	eval("document." + layerstring + layer + stylestring + ".visibility = 'visible'");
}
//
function close_lr(layer) { 
	eval("document." + layerstring + layer + stylestring + ".visibility = 'hidden'");
}

<!--



function open_win(strUrl, width, height){
	var new_win = open(strUrl,'new_win','resizable,toolbar=no,Location=no,Menubar=no,scrollbars=yes,width='+width+',height='+height);

	if(navigator.appName == 'Netscape')
		set_size(new_win, width, height);
	else
		set_size(new_win, width, height);
}
 
function open_win2(strUrl, width, height){
	var new_win = open(strUrl,'_blank','resizable,toolbar=no,Location=no,Menubar=no,scrollbars=yes,width='+width+',height='+height);

	if(navigator.appName == 'Netscape')
		set_size(new_win, width, height);
	else
		set_size(new_win, width, height);
}

function open_freepasswd(strUrl, width, height){
	var new_win = open(strUrl,'_blank','resizable,toolbar=no,Location=no,Menubar=no,scrollbars=no,width='+width+',height='+height);

	if(navigator.appName == 'Netscape')
		set_size(new_win, width, height);
	else
		set_size(new_win, width, height);
}


function set_size(win,w,h) {
	win.resizeTo(w,h);
	win.moveTo((window.screen.width/2)-(w/2),(window.screen.height/2)-(h/2));
}


	function open_news_win(newsid, newsaction){
		var strUrl;
		strUrl = 'news_win.php?newsid='+ newsid +'&newsaction=' + newsaction;
		open_win(strUrl, 750, 450);
	}

        function open_bug_win(bugid, bugaction){
                var strUrl;
                strUrl = 'bug_win.php?bugid='+ bugid +'&bugaction=' + bugaction;
                open_win(strUrl, 750, 460);
        }

	function erikoiskasittelya(toimenpide){
		if(!document.selection.createRange().text) return;

		switch (toimenpide){
			case 'bold':
				lihavointi();
				break;
			case 'link':
				linkki();
				break;
			case 'keno':
				kenotus();
				break;
 			case 'palsta':
				palstoitus();
				break;
			default:
				return;
		}
	}

	function lihavointi(){
		strValinta = document.selection.createRange().text;
		if(strValinta != ''){
			document.selection.createRange().text = '<b>' + strValinta + '</b>';
		}
		return;
	}
	function linkki() {
		strValinta = document.selection.createRange().text;
		if(strValinta == "") document.text.text.focus();
		strHref = prompt('Anna linkki:','http://');
		if(strHref == null || strHref=='http://') return;
		strClass = prompt("Syötä linkin luokka:","linkki1");
		if(strClass == null) strClass = 'text';
		document.selection.createRange().text = '<a href="' + strHref + '" target="_blank" class="'+ strClass +'">' + strValinta + '</a>';
		return;
	}
	function kenotus() {
		strValinta = document.selection.createRange().text;
		document.selection.createRange().text = "<i>" + strValinta + "</i>";
		return;
	}
	function palstoitus() {
		strValinta = document.selection.createRange().text;
		document.selection.createRange().text = '<p class="m1">' + strValinta + "</p>";
		return;
	}

	function aseta_kuva(textbox, pic_path){
//		textbox.focus();
		strValinta = document.selection.createRange().text;
		if(strValinta == "") textbox.focus();
		document.selection.createRange().text = '<img src="'+ pic_path +'" width="32" height="32" border="0">';
//		textbox.value = '<img src="'+ pic_path +'" width="32" height="32" border="0">';
		return;

	}
  
	function calc_length(sName, oElem, maxLength, oElem2){
		//alert(oElem.value.length);
		if(oElem2){
			oElem2.value = oElem.value.length;
		}
		if(oElem.value.length>maxLength){
			var tmp_val = oElem.value.toString().substr(0, maxLength);
			oElem.value = tmp_val;
			oElem2.value = oElem.value.length;
			alert('Kentän "' + sName + '" merkkimäärä ylittää sallitun ('+ maxLength +')');
			this.focus();
		}
	}
//end hiding Javascript code -->
 
