// -*- coding: utf-8 -*-

var opened_help = false;
var okno_help;

function open_help(url_help) {

    var name = url_help.replace(/\..*/,"");
    //next line because of IE, which dislike "-"
    name = name.replace(/-/g,"");

    var features = "toolbar=no, status=yes, height=700, width=800, scrollbars=yes, resizable=yes, screenX=400";

    if (!opened_help)
	{ 
	    opened_help = true;
	    okno_help = window.open(url_help,name,features);
	    okno_help.focus();  
	}
    else if (okno_help.closed)
	{
	    okno_help = window.open(url_help,name,features);
	}
    else { 
	okno_help.focus();
	okno_help.location.replace(url_help);
    }
}

function help(ac) {
    general_help(ac,"hlp");
};

function instructions(ac) {
    general_help(ac,"inst");
};

function general_help(ac,type) {
    //extract the id of page from full url
    var flname = document.URL;

    if (ac == "") {
	flname = flname.replace(/.*\/(.*)/,"$1");
	var flname2 = flname.split(".");
	var fln = flname2[0];
    }
    else {
	fln = "";
    }

    url = "kpm_help.act?fn=" + fln  + "&ac=" + ac + "&tp=" + type;
    open_help(url);
};


function close_it() {
    window.close();

}

////////////////////////////////////////
