// Tu będzie kod JavaScript
// ...

function OpenSelMap(selectdMap, langSpec){
    if (selectdMap != "") {
        langSpec = ReplaceSeparator(langSpec)
        selectdMap = LocalizeFile(selectdMap + ".html", langSpec);
        window.open("thematic_maps/" + selectdMap, "_blank", "resizable=1,scrollbars=1,status=1,location=1")
    }
}

function LocalizeFile(file, langSpec) {
    var fileL
    var idx

    if(langSpec != "") {
        idx = file.lastIndexOf(".", 999)
        if(idx == -1)
            fileL = file + "_" + langSpec
        else
            fileL = file.substr(0, idx) + "_" + langSpec + file.substr(idx)
    } else
        fileL = file
    return fileL;
}

function ReplaceSeparator(langSpec) {
    var fileL
    var idx
	
    idx = langSpec.lastIndexOf("/", 999)
    if(idx == -1)
        return langSpec
    else
        return langSpec.substr(0, idx) + "_" + langSpec.substr(idx + 1)
}

function GenerateApplet(type, taxons, langSpec) {
	var dim
	var config, leg, unit, code
	var proportion, factor = 0.98
	var w, h, minw

    if(type.indexOf("world", 0) == 0) {
        dim = 'width=960 height=460';
        proportion = 2.1
        minw = 960
		
        //dim = 'width=750 height=600';
        //proportion = 1.28
        //minw = 800
		
    } else {
        dim = 'width=750 height=600';
        proportion = 1.28
        minw = 800
        type = type.replace('euro', 'europe')
		
    }
    code = 'AppletPreview'
    config = type
    switch(type) {
        case "europe":      leg = 'none'
                          unit = 'none'
                          break;
        case "europe-stat": leg = 'full'
                          unit = 'all'
                          break;
        case "europe-cgrm": leg = 'small'
                          unit = 'none'
                          break;
        case "europe-crtd": leg = 'small'
                          unit = 'stat'
                          break;
        case "world2":    code = 'AppletLauncher'
                          config = 'world'
        case "world":     leg = 'none'
                          unit = 'none'
                          break;
        default: return;
    }

    w = Math.max(((navigator.appName=="Netscape") ? innerWidth : document.body.clientWidth) * factor, minw)
    h = Math.max(((navigator.appName=="Netscape") ? innerHeight : document.body.clientHeight) * factor, minw / proportion)

    if(h * proportion > w)
        h = w / proportion
    else
        w = h * proportion
    dim = 'width=' + w + ' height=' + h;
    if(code == 'AppletLauncher')
        dim = 'width=250 height=70'

    if(taxons == 2)
        config += '_2tax.giscfg'
    else
        config += '_1tax.giscfg'
    config = LocalizeFile(config, ReplaceSeparator(langSpec))

    //alert("config=" + config + " leg=" + leg + " langSpec=" + langSpec)
    //if(navigator.javaEnabled()) {
       document.write('<APPLET archive=mapping.jar code="simpledraw/' + code + '.class" ' + dim + '>')
       document.write('<PARAM name=cfgfile value="data_proto/' + config + '">')
       if(langSpec == "")
           document.write('<PARAM name=locale value="auto">')
       else
           document.write('<PARAM name=locale value="' + langSpec + '">')
       document.write('<PARAM name=legend value="' + leg + '">')
       document.write('<PARAM name=mapunit value="' + unit + '">')
       document.write('<PARAM name=monitor value="yes">')
    //}
    //document.write('<B>You have no Java installed! For a free Java download, click <A href="http://java.sun.com">HERE</A></B>')
}