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

var opened_help = false;
var okno_help;

var opened_preview = false;
var okno_preview;

function open_help(help_url) {
    open_new(help_url,opened_help,okno_help);
}

function open_preview(pre_url) {
    open_new(pre_url,opened_preview,okno_preview);
}

function open_new(url,opened,okno) {

    var name = url.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)
	{ 
	    opened = true;
	    okno = window.open(url,name,features);
	    okno.focus();  
	}
    else if (okno.closed)
	{
	    okno = window.open(url,name,features);
	}
    else { 
	okno.focus();
	okno.location.replace(url);
    }
}

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

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

function general_help(lh,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 = "help.act?lh=" + lh + "&fn=" + fln + "&ac=" + ac + "&tp=" + type;
    open_help(url);
};


function close_it() {
    window.close();

}

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