﻿function ComboElm(kod, nazwa)
{
    this.kod = kod;
    this.nazwa = nazwa;
}

var tab_dic_Kraje = new Array(
new ComboElm('DE','NIEMCY'),
new ComboElm('PL','POLSKA'));

var tab_KrajTo = new Array();
tab_KrajTo[0] = ['PL'];
tab_KrajTo[1] = ['DE'];

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="DE">NIEMCY</option>');
	document.write('<option selected="selected" value="PL">POLSKA</option>');
	document.write('</select> ');
	document.form.KrajW.value = idKrajFrom;
	if (parseInt(width))
		document.form.KrajW.style.width = width + "px";
}

function ShowComboD(idKrajTo, width)
{
    document.write('<select id="KrajD" name="KrajD">');
    document.write('<option value="DE">NIEMCY</option>');
    document.write('</select>');
    SetComboD(document.getElementById("KrajW"));
    
    document.form.KrajD.value = idKrajTo;
	if (parseInt(width))
		document.form.KrajD.style.width = width + "px";
}

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);
}
