﻿function ComboElm(kod, nazwa)
{
    this.kod = kod;
    this.nazwa = nazwa;
}

var tab_dic_Kraje = new Array(
    new ComboElm('BE','BELGIA'),
    new ComboElm('DK','DANIA'),
    new ComboElm('FR','FRANCJA'),
    new ComboElm('NL','HOLANDIA'),
    new ComboElm('DE','NIEMCY'),
    new ComboElm('NO','NORWEGIA'),
    new ComboElm('PL','POLSKA'),
    new ComboElm('SE','SZWECJA'),
    new ComboElm('GB','WIELKA BRYTANIA')
);

var tab_KrajTo = new Array();
tab_KrajTo[0] = ['PL'];
tab_KrajTo[1] = ['PL'];
tab_KrajTo[2] = ['PL'];
tab_KrajTo[3] = ['PL'];
tab_KrajTo[4] = ['PL'];
tab_KrajTo[5] = ['PL'];
tab_KrajTo[6] = ['BE','DK','FR','NL','DE','NO','SE','GB'];
tab_KrajTo[7] = ['PL'];
tab_KrajTo[8] = ['PL'];



function SetComboD(idKraj)
{

    var bottom_array = new Array();
    var up_country = idKraj.options[ idKraj.selectedIndex ].value;
	var index = 0;

    document.getElementById("KrajD").length = 0;
    for( index = 0; index  < tab_dic_Kraje.length; index++ )
		if (tab_dic_Kraje[index].kod == up_country)
			break;
	
	var k = 0;
	for ( var i = 0; i < tab_KrajTo[index].length; i++)
		for ( var z = 0; z < tab_dic_Kraje.length; z++)
			if (tab_KrajTo[index][i] == tab_dic_Kraje[z].kod)
				bottom_array[k++] = new ComboElm(tab_dic_Kraje[z].kod, tab_dic_Kraje[z].nazwa);

    for( var idx = 0; idx <  bottom_array.length; idx++ )
 		document.getElementById("KrajD").options[idx] = new Option( bottom_array[ idx ].nazwa, bottom_array[ idx ].kod);
}

function ShowComboW(idAkw, idKrajFrom, width)
{
	document.write('<input name="OpenAgent" value="" type="hidden" />');
	document.write('<input name="IDAKW" value="' + idAkw + '" type="hidden" />');
	document.write('<select id="KrajW" name="KrajW" onchange="SetComboD(this);">');
	    document.write('<option value="BE">BELGIA</option>');
    document.write('<option value="DK">DANIA</option>');
    document.write('<option value="FR">FRANCJA</option>');
    document.write('<option value="NL">HOLANDIA</option>');
    document.write('<option value="DE">NIEMCY</option>');
    document.write('<option value="NO">NORWEGIA</option>');
    document.write('<option value="PL">POLSKA</option>');
    document.write('<option value="SE">SZWECJA</option>');
    document.write('<option value="GB">WIELKA BRYTANIA</option>');

	document.write('</select> ');

	selectByValue( document.getElementById('KrajW'), idKrajFrom );
	if (parseInt(width))
		document.getElementById('KrajW').style.width = width + "px";
}

function ShowComboD(idKrajTo, width)
{
    document.write('<select id="KrajD" name="KrajD">');
    document.write('<option value="AT">AUSTRIA</option>');
    document.write('</select>');
    SetComboD(document.getElementById("KrajW"));
    
    selectByValue( document.getElementById('KrajD'), idKrajTo );
    if (parseInt(width))
	document.getElementById('KrajD').style.width = width + "px";
}

function selectByValue(sel, value) {
  var i = 0;
  var end = sel.options.length;
  while(i < end) {
    if (sel.options[i].value == value) {
      sel.options[i].selected = true;
      sel.selectedIndex = i;
      return;
    }
    i++;
  }
}

function ShowComboOs(lblLiczbaOsob, lblBiletOW, lblBiletRT)
{
	document.write(lblLiczbaOsob + '<select name="osob">');
	document.write('<option selected="selected">1</option>');
	document.write('<option>2</option>');
	document.write('<option>3</option>');
	document.write('<option>4</option>');
	document.write('</select> <br />');
	document.write('<input id="isPowrot" checked="checked" name="isPowrot" type="radio" value="0" />- ' + lblBiletOW);		
	document.write('<input id="isPowrot" name="isPowrot" type="radio" value="1" />- ' + lblBiletRT);
}
