function GetInputField(Name, Value) {
    return "<input type='text' name='" + Name + "' value='" + Value + "'/>"
}
/*
// function GetSelect(Name, Options) {
//     var s = ''
//     for (i = 0; i < Options.length; i++)
//         s += '<option value="' + Options[i][1] + '"' + (i == 0 ? 'selected' : '') + '>' + Options[i][0] + '</option>'
//     return '<select name="' + Name + '" id="' + Name + '">' + s + '</select>'
// }
*/
var Width = 600
var Height = 450
var Rand = 10
var Background = 'EEFFFF'
var Legendenbreite = 0
var Legendenhoehe = 0
var GoogleServer = 'http://chart.apis.google.com/chart'
var ParameterChart = new Array('europa', 'eu', 'euro', 'uefa')
var Title = new Array('Europa', 'EU', 'EURO-Zone', 'UEFA')
var LaenderFarbe = new Array('000044', '0000AA', 'CCCC00', '00CC00')
var TitleColor = "0000FF"
var TitleSize = 24
var NeutraleFarbe = '444444'
var Laender = new Array( // Name, ISO2, Text, EUROPA, EU, EURO, UEFA
    new Array('Aland', 'AX', 'Aland', true, false, false, false),
    new Array('Albanien', 'AL', 'Albanien', true, false, false, true),
    new Array('Andorra', 'AD', 'Andorra', true, false, true, true),
    new Array('Armenien', 'AM', 'Armenien', true, false, false, true),
    new Array('Aserbaidschan', 'AZ', 'Aserbaidschan', true, false, false, true),
    new Array('Belgien', 'BE', 'Belgien', true, true, true, true),
    new Array('Bosnien-H.', 'BA', 'Bosnien-H.', true, false, false, true),
    new Array('Bulgarien', 'BG', 'Bulgarien', true, true, false, true),
    new Array('Daenemark', 'DK', 'Daenemark', true, true, true, true),
    new Array('Deutschland', 'DE', 'Deutschland', true, true, true, true),
    new Array('England', 'GB-ENG', 'England', true, false, false, true),
    new Array('Estland', 'EE', 'Estland', true, true, true, true),
    new Array('Faeroeer', 'FO', 'Faeroeer', true, false, true, true),
    new Array('Finnland', 'FI', 'Finnland', true, true, true, true),
    new Array('Frankreich', 'FR', 'Frankreich', true, true, true, true),
    new Array('Georgien', 'GE', 'Georgien', true, false, false, true),
    new Array('Gibralter', 'GI', 'Gibralter', true, false, false, false),
    new Array('Griechenland', 'GR', 'Griechenland', true, true, true, true),
    new Array('Grossbritannien', 'GB', 'Grossbritannien', true, true, false, false),
    new Array('Guernsey', 'GG', 'Guernsey', true, false, false, false),
    new Array('Irland', 'IE', 'Irland', true, true, true, true),
    new Array('Isle of Man', 'IM', 'Man', true, false, false, false),
    new Array('Island', 'IS', 'Island', true, false, false, true),
    new Array('Israel', 'IL', 'Israel', false, false, false, true),
    new Array('Italien', 'IT', 'Italien', true, true, true, true),
    new Array('Kasachstan', 'KZ', 'Kasachstan', true, false, false, true),
    new Array('Kroatien', 'HR', 'Kroatien', true, false, false, true),
    new Array('Jersey', 'JE', 'Jersey', true, false, false, false),
    new Array('Lettland', 'LV', 'Lettland', true, true, false, true),
    new Array('Liechtenstein', 'LI', 'Liechtenstein', true, false, false, true),
    new Array('Litauen', 'LT', 'Litauen', true, true, false, true),
    new Array('Luxemburg', 'LU', 'Luxemburg', true, true, true, true),
    new Array('Malta', 'MT', 'Malta', true, true, true, true),
    new Array('Mazedonien', 'MK', 'Mazedonien', true, false, false, true),
    new Array('Moldawien', 'MD', 'Moldawien', true, false, false, true),
    new Array('Monaco', 'MC', 'Monaco', true, false, true, false),
    new Array('Montenegro', 'ME', 'Montenegro', true, false, false, true),
    new Array('Niederlande', 'NL', 'Niederlande', true, true, true, true),
    new Array('Nordirland', 'GB-NIR', 'Nordirland', true, false, false, true),
    new Array('Norwegen', 'NO', 'Norwegen', true, false, false, true),
    new Array('Oesterreich', 'AT', 'Oesterreich', true, true, true, true),
    new Array('Polen', 'PL', 'Polen', true, true, false, true),
    new Array('Portugal', 'PT', 'Portugal', true, true, true, true),
    new Array('Rumaenien', 'RO', 'Rumaenien', true, true, false, true),
    new Array('Russland', 'RU', 'Russland', true, false, false, true),
    new Array('San+Marino', 'SM', 'San+Marino', true, false, true, true),
    new Array('Schottland', 'GB-SCT', 'Schottland', true, false, false, true),
    new Array('Schweden', 'SE', 'Schweden', true, true, false, true),
    new Array('Schweiz', 'CH', 'Schweiz', true, false, false, true),
    new Array('Serbien', 'RS', 'Serbien', true, false, false, true),
    new Array('Slowakei', 'SK', 'Slowakei', true, true, true, true),
    new Array('Slowenien', 'SI', 'Slowenien', true, true, true, true),
    new Array('Svalbard', 'SJ', 'Svalbard', true, false, true, false),
    new Array('Spanien', 'ES', 'Spanien', true, true, true, true),
    new Array('Tschechische+Rep.', 'CZ', 'Tschechische+Rep.', true, true, false, true),
    new Array('Tuerkei', 'TR', 'Tuerkei', false, false, false, true),
    new Array('Ukraine', 'UA', 'Ukraine', true, false, false, true),
    new Array('Ungarn', 'HU', 'Ungarn', true, true, false, true),
    new Array('Vatikan', 'VA', 'Vatikan', true, false, true, false),
    new Array('Wales', 'GB-WLS', 'Wales', true, false, false, true),
    new Array('Weissrussland', 'BY', 'Weissrussland', true, false, false, true),
    new Array('Zypern', 'CY', 'Zypern', true, true, true, true)
)
function WriteMap(Chart) {
    var Chart = 'all'
    var Inverse = false
    var Color = ""
    var Debug = false
    if (window.location.search != "") {
        qs = window.location.search.substr(1)
        arrayOfStrings = qs.split("&")
        var Chart = ''
        var Inverse = false
        var Color = ""
        var Debug = false
        for (var i = 0; i < arrayOfStrings.length; i++) {
            parameter = arrayOfStrings[i].split("=")
            if (parameter[1] == undefined) parameter[1] = ''
            switch (parameter[0]) {
                case "chart":
                    if (parameter[1] != '') Chart = parameter[1]
                    break;
                case "inv":
                    Inverse = true
                    break;
                case "color":
                    if (parameter[1] != '') Color = parameter[1]
                    break;
                case "debug":
                    Debug = true
                    break;
            }
        }
        WriteEuropeMap(Chart, Inverse, Color, Debug)
    }
}
function WriteEuropeMap(Chart, Inverse, Color, Debug)
{
    var FormName = 'ifrm_' + Chart
    var sp = GetEuropeMap(Chart, Inverse, Color, Debug)
    var s =
        '<iframe '
        + 'id="' + FormName + '" name="' + FormName + '" '
        + 'width="' + Width + '" height="' + Height + '" '
        + 'scrolling="no" '
        + 'frameborder="0" ></iframe>'
    document.write(s)
    document.close()
    var iframe = getObjectByID(FormName)
    iframe = (iframe.contentWindow) ? iframe.contentWindow : (iframe.contentDocument.document) ? iframe.contentDocument.document : iframe.contentDocument;
    iframe.document.open()
    iframe.document.write(sp)
    iframe.document.close()
    eval('iframe.document.' + FormName + '.submit()')
}
function GetEuropeMap(Chart, Inverse, Color, Debug) {
    var Index = 0
    switch (Chart) {
        case 'europe':
            Index = 3
            break;
        case 'eu':
            Index = 4
            break;
        case 'euro':
            Index = 5
            break;
        case 'uefa':
            Index = 6
            break;
    }
    // chtVal = 'map:auto=' + Rand + ',' + Rand + ',' + Rand + ',' + Rand
    var chtVal = 'map:fixed=30,-20,65,60'
    var chsVal = Width + 'x' + Height
    var chttVal = Index == 0 ? 'Alle+Laender' : escape(Title[Index - 3])
    var chtsVal = TitleColor + ',' + TitleSize
    var chfVal = 'bg,s,' + Background
    var chmaVal = '10,10,10,10|' + Legendenbreite + ',' + Legendenhoehe
    var chldVal = ''
    var chcoVal = NeutraleFarbe
    var chmVal = ''
    var Land = 0
    for (i = 0; i < Laender.length; i++) {
        if ((Laender[i][Index] ^ Inverse) || (Chart == 'all')) {
            chldVal += (chldVal == '' ? '' : '|') + Laender[i][1];
            if (Chart == 'all') {
                var HSV = new HSVobject((360 / Laender.length) * i, 40, 80)
                var RGB = new RGBobject(0, 0, 0)
                HSV2RGB(HSV, RGB)
                chcoVal += '|' + RGB2hex(RGB).substr(1)
            }
            else
                chcoVal += '|' + (Color == "" ? LaenderFarbe[Index - 3] : Color)
            chmVal += (chmVal == '' ? '' : '|') + 'f' + escape(Laender[i][1]) + ',000088,0,' + Land + ',8'
            Land++
        }
    }
    var FormName = 'ifrm_' + Chart
    var sp = "<form action='" + GoogleServer + "' method='POST' id='" + FormName + "' name='" + FormName + "'>"
    + GetInputField('cht', chtVal)
    + GetInputField('chs', chsVal)
    + GetInputField('chld', chldVal)
    + GetInputField('chco', chcoVal)
    + GetInputField('chm', chmVal)
    + GetInputField('chtt', chttVal)
    + GetInputField('chts', chtsVal)
    + GetInputField('chf', chfVal)
    + GetInputField('chma', chmaVal)
    + (Debug ? 'chof' : 'validate')
    + "</form>"
    return sp
}

