var stringBuilder;
druhSubjektu = "";
function createxmlfinal() {
    stringBuilder = new $.StringBuilder();
    stringBuilder.appendLine('<?xml version="1.0" encoding="utf-8"?>');

    stringBuilder.appendLine('<SPDMOv25 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">');

    stringBuilder.appendLine('\t<strana1>');

    stringBuilder.appendLine('\t\t<nazov></nazov>');


    stringBuilder.appendLine('\t<vseobnalezitosti>');

    stringBuilder.appendLine('\t\t<SekColnyUrad>');
    stringBuilder.appendLine('\t\t\t<colnyurad>' + htmlEncode($('#colnyurad').val()) + '</colnyurad>');
    stringBuilder.appendLine('\t\t\t<pocetstran2>' + htmlEncode($('#pocetstran2').val()) + '</pocetstran2>');
    stringBuilder.appendLine('\t\t</SekColnyUrad>');

    stringBuilder.appendLine('\t\t<drpr>');

    var val = ""
    if ($('#druhPriznania-2').is(":checked")) val = 2
    else if ($('#druhPriznania-1').is(":checked")) val = 1
    else if ($('#druhPriznania-0').is(":checked")) val = 0

    stringBuilder.appendLine('\t\t\t<druhPriznania>' + val + '</druhPriznania>');

    var val = $("#datumZisteniaDdp").datepicker("getDate");
    if (val != null) {
        val.setDate(val.getDate() + 1)
        stringBuilder.appendLine('\t\t<datumZisteniaDdp>' + val.toISOString().substring(0, 10) + '</datumZisteniaDdp>');
    }

    stringBuilder.appendLine('\t\t</drpr>');

    stringBuilder.appendLine('\t\t<zdanovacieobdobie>');
    var val = $("#den2").val();
    if (val) {
        stringBuilder.appendLine('\t\t\t<den2>' + val + '</den2>');
    }

    stringBuilder.appendLine('\t\t\t<mesiac>' + htmlEncode($('#mesiac').val()) + '</mesiac>');
    stringBuilder.appendLine('\t\t\t<rok>' + htmlEncode($('#rok').val()) + '</rok>');
    stringBuilder.appendLine('\t\t</zdanovacieobdobie>');

    stringBuilder.appendLine('\t</vseobnalezitosti>');


    stringBuilder.appendLine('\t<identifikacia>');

    stringBuilder.appendLine('\t\t<rcpsd>');
    stringBuilder.appendLine('\t\t\t<registracne>' + htmlEncode($('#registracne').val()) + '</registracne>');
    stringBuilder.appendLine('\t\t</rcpsd>');

    stringBuilder.appendLine('\t\t<ecpsd>');

    var druh = "";
    if ($('#evidencnecislo').is(":checked")) druh = "evidencnecislo"
    else if ($('#ico').is(":checked")) druh = "ico"
    else if ($('#rc').is(":checked")) druh = "rc"
    stringBuilder.appendLine('\t\t\t<groupEC>' + druh + '</groupEC>');
    if (druh == "evidencnecislo") stringBuilder.appendLine('\t\t\t<hodnotaec>' + htmlEncode($('#hodnotaec').val()) + '</hodnotaec>');
    else if (druh == "ico") stringBuilder.appendLine('\t\t\t<hodnotaico>' + htmlEncode($('#hodnotaico').val()) + '</hodnotaico>');
    else if (druh == "rc") stringBuilder.appendLine('\t\t\t<hodnotarc>' + htmlEncode($('#hodnotarc').val()) + '</hodnotarc>');

    stringBuilder.appendLine('\t\t</ecpsd>');

    stringBuilder.appendLine('\t\t<dlznikziadatel>');
    druh = "";
    if ($('#platiteldane').is(":checked")) druh = "platiteldane"
    else if ($('#ziadatelovrateniedane').is(":checked")) druh = "ziadatelovrateniedane"
    stringBuilder.appendLine('\t\t\t<groupPlatitel>' + druh + '</groupPlatitel>');
    stringBuilder.appendLine('\t\t\t<nazovdanovehosubjektu>' + htmlEncode($('#nazovdanovehosubjektu').val()) + '</nazovdanovehosubjektu>');
    stringBuilder.appendLine('\t\t</dlznikziadatel>');

    stringBuilder.appendLine('\t\t<adresa>');
    stringBuilder.appendLine('\t\t\t<ulica>' + htmlEncode($('#ulica').val()) + '</ulica>');
    stringBuilder.appendLine('\t\t\t<psc>' + htmlEncode($('#psc').val()) + '</psc>');
    stringBuilder.appendLine('\t\t\t<cislodomu>' + htmlEncode($('#cislodomu').val()) + '</cislodomu>');
    stringBuilder.appendLine('\t\t\t<obec>' + htmlEncode($('#obec').val()) + '</obec>');
    stringBuilder.appendLine('\t\t</adresa>');

    stringBuilder.appendLine('\t</identifikacia>');

    stringBuilder.appendLine('\t<bankovespojenie>');

    var val = $("#hodnotaiban").val();
    if (val) {
        stringBuilder.appendLine('\t\t<hodnotaiban>' + val + '</hodnotaiban>');
    }

    stringBuilder.appendLine('\t</bankovespojenie>');

    stringBuilder.appendLine('\t<MenoAPriezviskoOo>');

    stringBuilder.appendLine('\t\t<riadokoo>' + htmlEncode($('#riadokoo').val()) + '</riadokoo>');

    stringBuilder.appendLine('\t\t<TelFax>');
    stringBuilder.appendLine('\t\t\t<telefonoo>' + htmlEncode($('#telefonoo').val()) + '</telefonoo>');
    stringBuilder.appendLine('\t\t</TelFax>');

    stringBuilder.appendLine('\t\t<emailoo>' + htmlEncode($('#emailoo').val()) + '</emailoo>');

    stringBuilder.appendLine('\t\t<vyhlasenie>');
	
	var val = $("#datumvyhlasenia").datepicker("getDate");
	if (val != null) {
		val.setDate(val.getDate() + 1)		
	}
	stringBuilder.appendLine('\t\t<datumvyhlasenia>' + val.toISOString().substring(0, 10) + '</datumvyhlasenia>');
    stringBuilder.appendLine('\t\t</vyhlasenie>');

    stringBuilder.appendLine('\t</MenoAPriezviskoOo>');

    stringBuilder.appendLine('\t<vypracoval>');

    stringBuilder.appendLine('\t\t<MenoPriezviskovypracoval>');
    stringBuilder.appendLine('\t\t\t<riadokvypracoval>' + htmlEncode($('#riadokvypracoval').val()) + '</riadokvypracoval>');
    stringBuilder.appendLine('\t\t</MenoPriezviskovypracoval>');

    stringBuilder.appendLine('\t\t<TelFaxVypracoval>');
    stringBuilder.appendLine('\t\t\t<telefonv>' + htmlEncode($('#telefonv').val()) + '</telefonv>');
    stringBuilder.appendLine('\t\t</TelFaxVypracoval>');

    stringBuilder.appendLine('\t\t<emailv>' + htmlEncode($('#emailv').val()) + '</emailv>');

    stringBuilder.appendLine('\t</vypracoval>');

    stringBuilder.appendLine('\t</strana1>');

    stringBuilder.appendLine('\t<str2>');

    $('#layoutRow41374').pageableSection().saveCurrentPage();
    var polesekcii = $('#layoutRow41374').pageableSection();
    var pocetsekcii = polesekcii.totalPages;
    for (var aktcyklus = 1; aktcyklus <= pocetsekcii; aktcyklus++) {
        var pageValues1 = polesekcii.pages[aktcyklus - 1];

        stringBuilder.appendLine('\t<T1_9_2011>');

        stringBuilder.appendLine('\t\t<T1_R1_2011>');

        stringBuilder.appendLine('\t\t\t<T1_R1S1_vyberdruhuminoleja_2011>');
        stringBuilder.appendLine('\t\t\t\t<checkbox1>' + getPageValueCh2Xml(pageValues1, 'checkbox1') + '</checkbox1>');
        stringBuilder.appendLine('\t\t\t\t<checkbox3>' + getPageValueCh2Xml(pageValues1, 'checkbox3') + '</checkbox3>');
        stringBuilder.appendLine('\t\t\t\t<checkbox4>' + getPageValueCh2Xml(pageValues1, 'checkbox4') + '</checkbox4>');
        stringBuilder.appendLine('\t\t\t\t<checkbox5>' + getPageValueCh2Xml(pageValues1, 'checkbox5') + '</checkbox5>');
        stringBuilder.appendLine('\t\t\t\t<checkbox6>' + getPageValueCh2Xml(pageValues1, 'checkbox6') + '</checkbox6>');
        stringBuilder.appendLine('\t\t\t\t<checkbox8>' + getPageValueCh2Xml(pageValues1, 'checkbox8') + '</checkbox8>');
        stringBuilder.appendLine('\t\t\t\t<checkbox12>' + getPageValueCh2Xml(pageValues1, 'checkbox12') + '</checkbox12>');
        stringBuilder.appendLine('\t\t\t\t<checkbox10>' + getPageValueCh2Xml(pageValues1, 'checkbox10') + '</checkbox10>');
        stringBuilder.appendLine('\t\t\t\t<checkbox11>' + getPageValueCh2Xml(pageValues1, 'checkbox11') + '</checkbox11>');
        stringBuilder.appendLine('\t\t\t</T1_R1S1_vyberdruhuminoleja_2011>');

        stringBuilder.appendLine('\t\t\t<sekcia6364a>');
        stringBuilder.appendLine('\t\t\t\t<box63>' + getPageValueCh2Xml(pageValues1, 'box63') + '</box63>');
        stringBuilder.appendLine('\t\t\t\t<box64>' + getPageValueCh2Xml(pageValues1, 'box64') + '</box64>');
        stringBuilder.appendLine('\t\t\t\t<box65>' + getPageValueCh2Xml(pageValues1, 'box65') + '</box65>');
        stringBuilder.appendLine('\t\t\t\t<A>' + getPageValueCh2Xml(pageValues1, 'A') + '</A>');
        stringBuilder.appendLine('\t\t\t\t<B>' + getPageValueCh2Xml(pageValues1, 'B') + '</B>');
        stringBuilder.appendLine('\t\t\t</sekcia6364a>');

        stringBuilder.appendLine('\t\t</T1_R1_2011>');

        stringBuilder.appendLine('\t\t<T1_R2_2011>');
        stringBuilder.appendLine('\t\t\t<s2r02>' + encodeXML(getPageValue2Xml(pageValues1, 's2r02')) + '</s2r02>');
        stringBuilder.appendLine('\t\t</T1_R2_2011>');

        stringBuilder.appendLine('\t\t<T1_R3_2011>');
        stringBuilder.appendLine('\t\t\t<s2r03>' + encodeXML(getPageValue2Xml(pageValues1, 's2r03')) + '</s2r03>');
        stringBuilder.appendLine('\t\t</T1_R3_2011>');

        stringBuilder.appendLine('\t\t<secMineralnyOlejZRiadka3>');

        stringBuilder.appendLine('\t\t\t<T1_R4_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r04>' + encodeXML(getPageValue2Xml(pageValues1, 's2r04')) + '</s2r04>');
        stringBuilder.appendLine('\t\t\t</T1_R4_2011>');

        stringBuilder.appendLine('\t\t\t<secOslobodenehoOdDane>');

        stringBuilder.appendLine('\t\t\t\t<T1_R5_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r05>' + encodeXML(getPageValue2Xml(pageValues1, 's2r05')) + '</s2r05>');
        stringBuilder.appendLine('\t\t\t\t</T1_R5_2011>');

        stringBuilder.appendLine('\t\t\t\t<T1_R6_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r06>' + encodeXML(getPageValue2Xml(pageValues1, 's2r06')) + '</s2r06>');
        stringBuilder.appendLine('\t\t\t\t</T1_R6_2011>');

        stringBuilder.appendLine('\t\t\t\t<T1_R7_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r07>' + encodeXML(getPageValue2Xml(pageValues1, 's2r07')) + '</s2r07>');
        stringBuilder.appendLine('\t\t\t\t</T1_R7_2011>');

        stringBuilder.appendLine('\t\t\t\t<T1_R8_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r08>' + encodeXML(getPageValue2Xml(pageValues1, 's2r08')) + '</s2r08>');
        stringBuilder.appendLine('\t\t\t\t</T1_R8_2011>');

        stringBuilder.appendLine('\t\t\t\t<T1_R9_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r09>' + encodeXML(getPageValue2Xml(pageValues1, 's2r09')) + '</s2r09>');
        stringBuilder.appendLine('\t\t\t\t</T1_R9_2011>');

        stringBuilder.appendLine('\t\t\t</secOslobodenehoOdDane>');

        stringBuilder.appendLine('\t\t</secMineralnyOlejZRiadka3>');

        stringBuilder.appendLine('\t\t<T1_R10_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r10>' + encodeXML(getPageValue2Xml(pageValues1, 's2r10')) + '</s2r10>');
        stringBuilder.appendLine('\t\t</T1_R10_2011>');

        stringBuilder.appendLine('\t\t<secMnozstvoMO>');

        stringBuilder.appendLine('\t\t\t<T1_R11_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r11>' + encodeXML(getPageValue2Xml(pageValues1, 's2r11')) + '</s2r11>');
        stringBuilder.appendLine('\t\t\t</T1_R11_2011>');

        stringBuilder.appendLine('\t\t\t<T1_R12_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r12>' + encodeXML(getPageValue2Xml(pageValues1, 's2r12')) + '</s2r12>');
        stringBuilder.appendLine('\t\t\t</T1_R12_2011>');

        stringBuilder.appendLine('\t\t\t<T1_R13_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r13>' + encodeXML(getPageValue2Xml(pageValues1, 's2r13')) + '</s2r13>');
        stringBuilder.appendLine('\t\t\t</T1_R13_2011>');

        stringBuilder.appendLine('\t\t\t<T1_R14_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r14>' + encodeXML(getPageValue2Xml(pageValues1, 's2r14')) + '</s2r14>');
        stringBuilder.appendLine('\t\t\t</T1_R14_2011>');

        stringBuilder.appendLine('\t\t\t<secVratenieDane>');

        stringBuilder.appendLine('\t\t\t\t<T1_R15_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r15>' + encodeXML(getPageValue2Xml(pageValues1, 's2r15')) + '</s2r15>');
        stringBuilder.appendLine('\t\t\t\t</T1_R15_2011>');

        stringBuilder.appendLine('\t\t\t\t<T1_R16_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r16>' + encodeXML(getPageValue2Xml(pageValues1, 's2r16')) + '</s2r16>');
        stringBuilder.appendLine('\t\t\t\t</T1_R16_2011>');

        stringBuilder.appendLine('\t\t\t\t<T1_R17_2011>');
        stringBuilder.appendLine('\t\t\t\t\t<s2r17>' + encodeXML(getPageValue2Xml(pageValues1, 's2r17')) + '</s2r17>');
        stringBuilder.appendLine('\t\t\t\t</T1_R17_2011>');

        stringBuilder.appendLine('\t\t\t</secVratenieDane>');

        stringBuilder.appendLine('\t\t\t<T1_R18_2011>');
        stringBuilder.appendLine('\t\t\t\t<s2r18>' + encodeXML(getPageValue2Xml(pageValues1, 's2r18')) + '</s2r18>');
        stringBuilder.appendLine('\t\t\t</T1_R18_2011>');

        stringBuilder.appendLine('\t\t</secMnozstvoMO>');

        stringBuilder.appendLine('\t\t<T1_R19_2011>');
        stringBuilder.appendLine('\t\t\t\t<s2r19>' + encodeXML(getPageValue2Xml(pageValues1, 's2r19')) + '</s2r19>');
        stringBuilder.appendLine('\t\t</T1_R19_2011>');

        stringBuilder.appendLine('\t\t<T1_R20_2011>');
        stringBuilder.appendLine('\t\t\t\t<s2r20>' + encodeXML(getPageValue2Xml(pageValues1, 's2r20')) + '</s2r20>');
        stringBuilder.appendLine('\t\t</T1_R20_2011>');

        stringBuilder.appendLine('\t</T1_9_2011>');
    }

    stringBuilder.appendLine('\t<VDVD_main_2012>');
    stringBuilder.appendLine('\t\t\t<VyslednaDan>' + htmlEncode($('#VyslednaDan').val()) + '</VyslednaDan>');
    stringBuilder.appendLine('\t\t\t<SlovomEur>' + htmlEncode($('#SlovomEur').val()) + '</SlovomEur>');
    stringBuilder.appendLine('\t</VDVD_main_2012>');


    stringBuilder.appendLine('\t</str2>');

    stringBuilder.appendLine('</SPDMOv25>');
    return stringBuilder.string();
}

function encodeXML(value) {
    if (value) {
        if (value.indexOf('\n') > -1 || value.indexOf('\\') > -1 || value.indexOf('"') > -1 || value.indexOf('\u00a0') > -1 || value.indexOf('&nbsp;') > -1 || value.indexOf('&') > -1) {
            value = '<![CDATA[' + value + ']]>';
        } else {
            value = $('<div/>').text(value).html();
        }
    }
    return value;
}

function getPageValue2Xml(pageValues, elementId, x, y) {
    for (var i = 0; i < pageValues.values.length; i++) {
        var value = pageValues.values[i];
        if (value.key === elementId) {
            if (!isNaN(x) && !isNaN(y))
                return value.value.substr(x, y);
            else {
                return value.value || '';
            }
        }
    }
}

function getPageValueCh2Xml(pageValues, elementId) {
    var vrat = '0';
    for (var i = 0; i < pageValues.values.length; i++) {
        var value = pageValues.values[i];
        if (value.key === elementId) {
            //if ($("#"+value.key).attr("checked") == true) {
            if (value.value == true) {
                vrat = '1';
            }
            break;
        }
    }
    return vrat;
}

var xmlDoc;
function loadxmlfinal(txt) {
    if (window.DOMParser) {
        parser = new DOMParser();
        xmlDoc = parser.parseFromString(txt, "text/xml");
    } else // Internet Explorer
    {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = false;
        xmlDoc.loadXML(txt);
    }
    var dokument_xx = xmlDoc.getElementsByTagName('SPDMOv25')[0];
    if (dokument_xx) {
        var strana1_xx = dokument_xx.getElementsByTagName('strana1')[0];
        if (strana1_xx) {
            var vseobnalezitosti_xx = strana1_xx.getElementsByTagName('vseobnalezitosti')[0];
            if (vseobnalezitosti_xx) {
                var SekColnyUrad_xx = vseobnalezitosti_xx.getElementsByTagName('SekColnyUrad')[0];
                if (SekColnyUrad_xx) {
                    $('#colnyurad').val(getElementsValXml(SekColnyUrad_xx.getElementsByTagName('colnyurad')[0]));
                    $('#pocetstran2').val(getElementsValXml(SekColnyUrad_xx.getElementsByTagName('pocetstran2')[0]));
                }
                var drpr_xx = vseobnalezitosti_xx.getElementsByTagName('drpr')[0];
                if (drpr_xx) {
                    $('#druhPriznania-0').attr("checked", getElementsValXml(drpr_xx.getElementsByTagName('druhPriznania')[0]) == 0 ? true : false);
                    $('#druhPriznania-1').attr("checked", getElementsValXml(drpr_xx.getElementsByTagName('druhPriznania')[0]) == 1 ? true : false);
                    $('#druhPriznania-2').attr("checked", getElementsValXml(drpr_xx.getElementsByTagName('druhPriznania')[0]) == 2 ? true : false);
                    if (drpr_xx.getElementsByTagName('datumZisteniaDdp')[0]) {
                        var parts = getElementsValXml(drpr_xx.getElementsByTagName('datumZisteniaDdp')[0]).split("-");
                        var datum = (parts[0] != 'null') ? parts[2] + "." + parts[1] + "." + parts[0] : "";
                        $('#datumZisteniaDdp').val(datum);
                    }
                }
                var zdanovacieobdobie_xx = vseobnalezitosti_xx.getElementsByTagName('zdanovacieobdobie')[0];
                if (zdanovacieobdobie_xx) {
                    if (zdanovacieobdobie_xx.getElementsByTagName('den2')[0]) {
                        $('#den2').val(getElementsValXml(zdanovacieobdobie_xx.getElementsByTagName('den2')[0]));
                    }
                    $('#mesiac').val(getElementsValXml(zdanovacieobdobie_xx.getElementsByTagName('mesiac')[0]));
                    $('#rok').val(getElementsValXml(zdanovacieobdobie_xx.getElementsByTagName('rok')[0]));
                }
            }
            var identifikacia_xx = strana1_xx.getElementsByTagName('identifikacia')[0];
            if (identifikacia_xx) {
                var rcpsd_xx = identifikacia_xx.getElementsByTagName('rcpsd')[0];
                if (rcpsd_xx) {
                    $('#registracne').val(getElementsValXml(rcpsd_xx.getElementsByTagName('registracne')[0]));
                }
                var ecpsd_xx = identifikacia_xx.getElementsByTagName('ecpsd')[0];
                if (ecpsd_xx) {
                    if (getElementsValXml(ecpsd_xx.getElementsByTagName('groupEC')[0]) == 'evidencnecislo') {
                        $('#evidencnecislo').attr("checked", true);
                        $('#hodnotaec').val(getElementsValXml(ecpsd_xx.getElementsByTagName('hodnotaec')[0]));

                    }
                    else if (getElementsValXml(ecpsd_xx.getElementsByTagName('groupEC')[0]) == 'ico') {
                        $('#ico').attr("checked", true);
                        $('#hodnotaico').val(getElementsValXml(ecpsd_xx.getElementsByTagName('hodnotaico')[0]));

                    }
                    else if (getElementsValXml(ecpsd_xx.getElementsByTagName('groupEC')[0]) == 'rc') {
                        $('#rc').attr("checked", true);
                        $('#hodnotarc').val(getElementsValXml(ecpsd_xx.getElementsByTagName('hodnotarc')[0]));

                    }
                }
                var dlznikziadatel_xx = identifikacia_xx.getElementsByTagName('dlznikziadatel')[0];
                if (dlznikziadatel_xx) {
                    $('#platiteldane').attr("checked", getElementsValXml(dlznikziadatel_xx.getElementsByTagName('groupPlatitel')[0]) == 'platiteldane' ? true : false);
                    $('#ziadatelovrateniedane').attr("checked", getElementsValXml(dlznikziadatel_xx.getElementsByTagName('groupPlatitel')[0]) == 'ziadatelovrateniedane' ? true : false);
                    $('#nazovdanovehosubjektu').val(getElementsValXml(dlznikziadatel_xx.getElementsByTagName('nazovdanovehosubjektu')[0]));
                }
                var adresa_xx = identifikacia_xx.getElementsByTagName('adresa')[0];
                if (adresa_xx) {
                    $('#ulica').val(getElementsValXml(adresa_xx.getElementsByTagName('ulica')[0]));
                    $('#psc').val(getElementsValXml(adresa_xx.getElementsByTagName('psc')[0]));
                    $('#cislodomu').val(getElementsValXml(adresa_xx.getElementsByTagName('cislodomu')[0]));
                    $('#obec').val(getElementsValXml(adresa_xx.getElementsByTagName('obec')[0]));
                }
            }
            var bankovespojenie_xx = strana1_xx.getElementsByTagName('bankovespojenie')[0];
            if (bankovespojenie_xx) {
                if (bankovespojenie_xx.getElementsByTagName('hodnotaiban')[0]) {
                    $('#hodnotaiban').val(getElementsValXml(bankovespojenie_xx.getElementsByTagName('hodnotaiban')[0]));
                }
            }
            var MenoAPriezviskoOo_xx = strana1_xx.getElementsByTagName('MenoAPriezviskoOo')[0];
            if (MenoAPriezviskoOo_xx) {
                $('#riadokoo').val(getElementsValXml(MenoAPriezviskoOo_xx.getElementsByTagName('riadokoo')[0]));
                var TelFax_xx = MenoAPriezviskoOo_xx.getElementsByTagName('TelFax')[0];
                if (TelFax_xx) {
                    $('#telefonoo').val(getElementsValXml(TelFax_xx.getElementsByTagName('telefonoo')[0]));
                }
                $('#emailoo').val(getElementsValXml(MenoAPriezviskoOo_xx.getElementsByTagName('emailoo')[0]));
                var vyhlasenie_xx = MenoAPriezviskoOo_xx.getElementsByTagName('vyhlasenie')[0];
                if (vyhlasenie_xx) {
                    var parts = getElementsValXml(vyhlasenie_xx.getElementsByTagName('datumvyhlasenia')[0]).split("-");
                    var datum = (parts[0] != 'null') ? parts[2] + "." + parts[1] + "." + parts[0] : "";
                    $('#datumvyhlasenia').val(datum);
                }
            }
            var vypracoval_xx = strana1_xx.getElementsByTagName('vypracoval')[0];
            if (vypracoval_xx) {
                var MenoPriezviskovypracoval_xx = vypracoval_xx.getElementsByTagName('MenoPriezviskovypracoval')[0];
                if (MenoPriezviskovypracoval_xx) {
                    $('#riadokvypracoval').val(getElementsValXml(MenoPriezviskovypracoval_xx.getElementsByTagName('riadokvypracoval')[0]));
                }
                var TelFaxVypracoval_xx = vypracoval_xx.getElementsByTagName('TelFaxVypracoval')[0];
                if (TelFaxVypracoval_xx) {
                    $('#telefonv').val(getElementsValXml(TelFaxVypracoval_xx.getElementsByTagName('telefonv')[0]));
                }
                $('#emailv').val(getElementsValXml(vypracoval_xx.getElementsByTagName('emailv')[0]));
            }
        }
        var str2_xx = dokument_xx.getElementsByTagName('str2')[0];
        if (str2_xx) {
            opaksekcia = str2_xx.getElementsByTagName('T1_9_2011');
            if (opaksekcia.length) {
                var pocetSekcii = opaksekcia.length;
                var strankovaciaSekcia = $('#layoutRow41374').pageableSection();
                if (opaksekcia.length > 0) {
                    var poma = strankovaciaSekcia.totalPages;
                    if (poma > 1) {
                        for (var pomb = 1; pomb < poma; pomb++) {
                            strankovaciaSekcia.removePage();
                        }
                    }
                }
                for (var i = 0; i < pocetSekcii; i++) {
                    if (i > 0) {
                        strankovaciaSekcia.addPage();
                    }
                    var T1_R1_2011_xx = str2_xx.getElementsByTagName('T1_R1_2011')[i];
                    if (T1_R1_2011_xx) {
                        var T1_R1S1_vyberdruhuminoleja_2011_xx = T1_R1_2011_xx.getElementsByTagName('T1_R1S1_vyberdruhuminoleja_2011')[0];
                        if (T1_R1S1_vyberdruhuminoleja_2011_xx) {
                            $('#checkbox1').attr("checked", getElementsValXml(T1_R1S1_vyberdruhuminoleja_2011_xx.getElementsByTagName('checkbox1')[0]) == 1 ? true : false);
                            $('#checkbox3').attr("checked", getElementsValXml(T1_R1S1_vyberdruhuminoleja_2011_xx.getElementsByTagName('checkbox3')[0]) == 1 ? true : false);
                            $('#checkbox4').attr("checked", getElementsValXml(T1_R1S1_vyberdruhuminoleja_2011_xx.getElementsByTagName('checkbox4')[0]) == 1 ? true : false);
                            $('#checkbox5').attr("checked", getElementsValXml(T1_R1S1_vyberdruhuminoleja_2011_xx.getElementsByTagName('checkbox5')[0]) == 1 ? true : false);
                            $('#checkbox6').attr("checked", getElementsValXml(T1_R1S1_vyberdruhuminoleja_2011_xx.getElementsByTagName('checkbox6')[0]) == 1 ? true : false);
                            $('#checkbox8').attr("checked", getElementsValXml(T1_R1S1_vyberdruhuminoleja_2011_xx.getElementsByTagName('checkbox8')[0]) == 1 ? true : false);
                            $('#checkbox12').attr("checked", getElementsValXml(T1_R1S1_vyberdruhuminoleja_2011_xx.getElementsByTagName('checkbox12')[0]) == 1 ? true : false);
                            $('#checkbox10').attr("checked", getElementsValXml(T1_R1S1_vyberdruhuminoleja_2011_xx.getElementsByTagName('checkbox10')[0]) == 1 ? true : false);
                            $('#checkbox11').attr("checked", getElementsValXml(T1_R1S1_vyberdruhuminoleja_2011_xx.getElementsByTagName('checkbox11')[0]) == 1 ? true : false);
                        }
                        var sekcia6364a_xx = T1_R1_2011_xx.getElementsByTagName('sekcia6364a')[0];
                        if (sekcia6364a_xx) {
                            $('#box63').attr("checked", getElementsValXml(sekcia6364a_xx.getElementsByTagName('box63')[0]) == 1 ? true : false);
                            $('#box64').attr("checked", getElementsValXml(sekcia6364a_xx.getElementsByTagName('box64')[0]) == 1 ? true : false);
                            $('#box65').attr("checked", getElementsValXml(sekcia6364a_xx.getElementsByTagName('box65')[0]) == 1 ? true : false);
                            $('#A').attr("checked", getElementsValXml(sekcia6364a_xx.getElementsByTagName('A')[0]) == 1 ? true : false);
                            $('#B').attr("checked", getElementsValXml(sekcia6364a_xx.getElementsByTagName('B')[0]) == 1 ? true : false);
                        }
                    }
                    var T1_R2_2011_xx = str2_xx.getElementsByTagName('T1_R2_2011')[i];
                    if (T1_R2_2011_xx) {
                        $('#s2r02').val(getElementsValXml(T1_R2_2011_xx.getElementsByTagName('s2r02')[0]));
                    }
                    var T1_R3_2011_xx = str2_xx.getElementsByTagName('T1_R3_2011')[i];
                    if (T1_R3_2011_xx) {
                        $('#s2r03').val(getElementsValXml(T1_R3_2011_xx.getElementsByTagName('s2r03')[0]));
                    }
                    var secMineralnyOlejZRiadka3_xx = str2_xx.getElementsByTagName('secMineralnyOlejZRiadka3')[i];
                    if (secMineralnyOlejZRiadka3_xx) {
                        var T1_R4_2011_xx = secMineralnyOlejZRiadka3_xx.getElementsByTagName('T1_R4_2011')[0];
                        if (T1_R4_2011_xx) {
                            $('#s2r04').val(getElementsValXml(T1_R4_2011_xx.getElementsByTagName('s2r04')[0]));
                        }
                        var secOslobodenehoOdDane_xx = secMineralnyOlejZRiadka3_xx.getElementsByTagName('secOslobodenehoOdDane')[0];
                        if (secOslobodenehoOdDane_xx) {
                            var T1_R5_2011_xx = secOslobodenehoOdDane_xx.getElementsByTagName('T1_R5_2011')[0];
                            if (T1_R5_2011_xx) {
                                $('#s2r05').val(getElementsValXml(T1_R5_2011_xx.getElementsByTagName('s2r05')[0]));
                            }
                            var T1_R6_2011_xx = secOslobodenehoOdDane_xx.getElementsByTagName('T1_R6_2011')[0];
                            if (T1_R6_2011_xx) {
                                $('#s2r06').val(getElementsValXml(T1_R6_2011_xx.getElementsByTagName('s2r06')[0]));
                            }
                            var T1_R7_2011_xx = secOslobodenehoOdDane_xx.getElementsByTagName('T1_R7_2011')[0];
                            if (T1_R7_2011_xx) {
                                $('#s2r07').val(getElementsValXml(T1_R7_2011_xx.getElementsByTagName('s2r07')[0]));
                            }
                            var T1_R8_2011_xx = secOslobodenehoOdDane_xx.getElementsByTagName('T1_R8_2011')[0];
                            if (T1_R8_2011_xx) {
                                $('#s2r08').val(getElementsValXml(T1_R8_2011_xx.getElementsByTagName('s2r08')[0]));
                            }
                            var T1_R9_2011_xx = secOslobodenehoOdDane_xx.getElementsByTagName('T1_R9_2011')[0];
                            if (T1_R9_2011_xx) {
                                $('#s2r09').val(getElementsValXml(T1_R9_2011_xx.getElementsByTagName('s2r09')[0]));
                            }
                        }
                    }
                    var T1_R10_2011_xx = str2_xx.getElementsByTagName('T1_R10_2011')[i];
                    if (T1_R10_2011_xx) {
                        $('#s2r10').val(getElementsValXml(T1_R10_2011_xx.getElementsByTagName('s2r10')[0]));
                    }
                    var secMnozstvoMO_xx = str2_xx.getElementsByTagName('secMnozstvoMO')[i];
                    if (secMnozstvoMO_xx) {
                        var T1_R11_2011_xx = secMnozstvoMO_xx.getElementsByTagName('T1_R11_2011')[0];
                        if (T1_R11_2011_xx) {
                            $('#s2r11').val(getElementsValXml(T1_R11_2011_xx.getElementsByTagName('s2r11')[0]));
                        }
                        var T1_R12_2011_xx = secMnozstvoMO_xx.getElementsByTagName('T1_R12_2011')[0];
                        if (T1_R12_2011_xx) {
                            $('#s2r12').val(getElementsValXml(T1_R12_2011_xx.getElementsByTagName('s2r12')[0]));
                        }
                        var T1_R13_2011_xx = secMnozstvoMO_xx.getElementsByTagName('T1_R13_2011')[0];
                        if (T1_R13_2011_xx) {
                            $('#s2r13').val(getElementsValXml(T1_R13_2011_xx.getElementsByTagName('s2r13')[0]));
                        }
                        var T1_R14_2011_xx = secMnozstvoMO_xx.getElementsByTagName('T1_R14_2011')[0];
                        if (T1_R14_2011_xx) {
                            $('#s2r14').val(getElementsValXml(T1_R14_2011_xx.getElementsByTagName('s2r14')[0]));
                        }
                        var secVratenieDane_xx = secMnozstvoMO_xx.getElementsByTagName('secVratenieDane')[0];
                        if (secVratenieDane_xx) {
                            var T1_R15_2011_xx = secVratenieDane_xx.getElementsByTagName('T1_R15_2011')[0];
                            if (T1_R15_2011_xx) {
                                $('#s2r15').val(getElementsValXml(T1_R15_2011_xx.getElementsByTagName('s2r15')[0]));
                            }
                            var T1_R16_2011_xx = secVratenieDane_xx.getElementsByTagName('T1_R16_2011')[0];
                            if (T1_R16_2011_xx) {
                                $('#s2r16').val(getElementsValXml(T1_R16_2011_xx.getElementsByTagName('s2r16')[0]));
                            }
                            var T1_R17_2011_xx = secVratenieDane_xx.getElementsByTagName('T1_R17_2011')[0];
                            if (T1_R17_2011_xx) {
                                $('#s2r17').val(getElementsValXml(T1_R17_2011_xx.getElementsByTagName('s2r17')[0]));
                            }
                        }
                        var T1_R18_2011_xx = secMnozstvoMO_xx.getElementsByTagName('T1_R18_2011')[0];
                        if (T1_R18_2011_xx) {
                            $('#s2r18').val(getElementsValXml(T1_R18_2011_xx.getElementsByTagName('s2r18')[0]));
                        }
                    }
                    var T1_R19_2011_xx = str2_xx.getElementsByTagName('T1_R19_2011')[i];
                    if (T1_R19_2011_xx) {
                        $('#s2r19').val(getElementsValXml(T1_R19_2011_xx.getElementsByTagName('s2r19')[0]));
                    }
                    var T1_R20_2011_xx = str2_xx.getElementsByTagName('T1_R20_2011')[i];
                    if (T1_R20_2011_xx) {
                        $('#s2r20').val(getElementsValXml(T1_R20_2011_xx.getElementsByTagName('s2r20')[0]));
                    }
                    strankovaciaSekcia.saveCurrentPage();
                }
            }
            var VDVD_main_2012_xx = str2_xx.getElementsByTagName('VDVD_main_2012')[0];
            if (VDVD_main_2012_xx) {
                $('#VyslednaDan').val(getElementsValXml(VDVD_main_2012_xx.getElementsByTagName('VyslednaDan')[0]));
                $('#SlovomEur').val(getElementsValXml(VDVD_main_2012_xx.getElementsByTagName('SlovomEur')[0]));
            }
        }
    }
}

function getElementsValXml(element) {
    return htmlDecode(element.textContent) || htmlDecode(element.text) || '';
}

function createfdf(segment, index) {
    var result = null;

    if (segment == 0 && index == 0) {
        result = createMainFdf();
    }

    if (segment == 1) {
        var fdfs = createNfdf();
        if (index < fdfs.length)
            result = fdfs[index];
    }
    //if (segment == 2) {
    //	var fdfs = createN2fdf();
    //	if (index < fdfs.length)
    //		result = fdfs[index];
    //}
    return result;
}


function createMainFdf() {
    stringBuilder = new $.StringBuilder();
    stringBuilder.appendLine('%FDF-1.2');
    stringBuilder.appendLine('%%âăĎÓ');
    stringBuilder.appendLine('1 0 obj');
    stringBuilder.appendLine('<<');
    stringBuilder.appendLine('  /FDF');
    stringBuilder.appendLine('    << /Fields');
    stringBuilder.appendLine('      [');
    stringBuilder.appendLine('       << /V(' + prepisznakyFdf('Tlačivo vytlačené z Portálu FS') + ')/T (print)>>');
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#colnyurad').val()) + ')/T (colny_urad)>>');
    stringBuilder.appendLine('    << /V (' + ($('#druhPriznania-0').is(':checked') ? 'X' : '') + ')/T (rdp)>>');
    stringBuilder.appendLine('    << /V (' + ($('#druhPriznania-1').is(':checked') ? 'X' : '') + ')/T (odp)>>');
    stringBuilder.appendLine('    << /V (' + ($('#druhPriznania-2').is(':checked') ? 'X' : '') + ')/T (ddp)>>');
    var datumDDP = $("#datumZisteniaDdp").datepicker("getDate");
    if (datumDDP != null) {
        stringBuilder.appendLine('    << /V (' + datumDDP.getDate() + ')/T (zs_den)>>');
        stringBuilder.appendLine('    << /V (' + (datumDDP.getMonth() + 1) + ')/T (zs_mes)>>');
        stringBuilder.appendLine('    << /V (' + (datumDDP.getFullYear() + "").substr(2) + ')/T (zs_rok)>>');
    }
    else {
        stringBuilder.appendLine('    << /V ()/T (zs_den)>>');
        stringBuilder.appendLine('    << /V ()/T (zs_mes)>>');
        stringBuilder.appendLine('    << /V ()/T (zs_rok)>>');
    }
    stringBuilder.appendLine('    << /V (' + $("#den2").val().replace(/^0/g, "") + ')/T (zo_den)>>');
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#mesiac').val()) + ')/T (zo_mes)>>');
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#rok').val().substr(2)) + ')/T (zo_rok)>>');
    stringBuilder.appendLine('    << /V (' + $('#pocetstran2').val() + ')/T (PocetStran)>>');
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#registracne').val()) + ')/T (rcpdmo)>>');

    if ($('#evidencnecislo').is(':checked')) {
        stringBuilder.appendLine('    << /V (X)/T (ecd)>>');
        stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#hodnotaec').val()) + ')/T (ecspdmo)>>');
    }
    if ($('#ico').is(':checked')) {
        stringBuilder.appendLine('    << /V (X)/T (ic)>>');
        stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#hodnotaico').val()) + ')/T (ecspdmo)>>');
    }
    if ($('#rc').is(':checked')) {
        stringBuilder.appendLine('    << /V (X)/T (rc)>>');
        stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#hodnotarc').val()) + ')/T (ecspdmo)>>');
    }

    stringBuilder.appendLine('    << /V (' + ($('#platiteldane').is(':checked') ? 'X' : '') + ')/T (platitel)>>');
    stringBuilder.appendLine('    << /V (' + ($('#ziadatelovrateniedane').is(':checked') ? 'X' : '') + ')/T (ziadatel)>>');

    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#nazovdanovehosubjektu').val().substr(0, 37)) + ')/T (pdzp_meno1)>>');
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#nazovdanovehosubjektu').val().substr(37)) + ')/T (pdzp_meno2)>>');
    stringBuilder.appendLine('     << /V (' + prepisznakyFdf($('#ulica').val()) + ')/T (pdzp_ulica)>>');
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#cislodomu').val()) + ')/T (pdzp_cislo)>>');
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#psc').val()) + ')/T (pdzp_psc)>>');
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#obec').val()) + ')/T (pdzp_obec)>>');
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#hodnotaiban').val()) + ')/T (cuakb)>>');
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#riadokoo').val()) + ')/T (platitel_meno)>>');
    stringBuilder.appendLine('     << /V (' + prepisznakyFdf($('#telefonoo').val()) + ')/T (platitel_tel)>>');
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#emailoo').val()) + ')/T (platitel_email)>>');
    if (!!$('#datumvyhlasenia').val()) {
        stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#datumvyhlasenia').val().split(".")[0]) + ')/T (vyhlasenie_den)>>');
    } else {
        stringBuilder.appendLine('    << /V ()/T (vyhlasenie_den)>>');
    }
    if (!!$('#datumvyhlasenia').val()) {
        stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#datumvyhlasenia').val().split(".")[1]) + ')/T (vyhlasenie_mes)>>');
    } else {
        stringBuilder.appendLine('    << /V ()/T (vyhlasenie_mes)>>');
    }
    if (!!$('#datumvyhlasenia').val()) {
        stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#datumvyhlasenia').val().split(".")[2].substr(2)) + ')/T (vyhlasenie_rok)>>');
    } else {
        stringBuilder.appendLine('    << /V ()/T (vyhlasenie_rok)>>');
    }
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#riadokvypracoval').val()) + ')/T (vyhotovil_meno)>>');
    stringBuilder.appendLine('     << /V (' + prepisznakyFdf($('#telefonv').val()) + ')/T (vyhotovil_tel)>>');
    stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#emailv').val()) + ')/T (vyhotovil_email)>>');

    stringBuilder.appendLine('      ]');
    stringBuilder.appendLine('    /F (form.618.SPDMO-25-print-save.pdf)');
    stringBuilder.appendLine('    /ID [ <97fb02b45ad58b6aa2b6872c3aa1944c><9de158208a4c769cd4170b2fe84a6777>]');
    stringBuilder.appendLine('  >> ');
    stringBuilder.appendLine('>> ');
    stringBuilder.appendLine('endobj');
    stringBuilder.appendLine('trailer');
    stringBuilder.appendLine('<< /Root 1 0 R >>');
    stringBuilder.appendLine('%%EOF');
    return stringBuilder.string();
}

function createNfdf() {
    var fdfObsah = new Array();
    var pocetvsetkychsekcii = 1;
    var pocetvsetkychsekcii = $('#layoutRow41374').pageableSection().totalPages;
    var pocetsekciinastranu = 2;
    var pocetmaxstran = 6;
    var davka = 0;
    for (var t = 1; t <= pocetvsetkychsekcii; t += (pocetsekciinastranu * pocetmaxstran)) {
        davka = davka + 1;
        var r = 0;
        if ((pocetsekciinastranu * pocetmaxstran * davka) > pocetvsetkychsekcii) {
            r = pocetvsetkychsekcii;
        } else {
            r = pocetsekciinastranu * pocetmaxstran * davka;
        }
        fdfObsah[davka-1] = createopakovaneNfdf(davka, t, r, pocetsekciinastranu, pocetmaxstran);
    }
    var x = 1;
    return fdfObsah;
}

function createopakovaneNfdf(davka, zaciatoksekcii, koniecsekcii, pocetsekciinastranu, pocetmaxstran) {
    var polesekcii = $('#layoutRow41374').pageableSection();
    var pocetsekcii = koniecsekcii - zaciatoksekcii + 1;
    var sekciinastranu = pocetsekciinastranu;
    var zacniprazdne = 0;
    var zacnisekciu = 0;
    var sekcia = 0;
    var aktstrana = 0;
    var cisloPoslSek = 0;
    var pocetstran = vypocetpoctustranFdf(pocetsekcii, sekciinastranu);
    stringBuilder = new $.StringBuilder();
    stringBuilder.appendLine('%FDF-1.2');
    stringBuilder.appendLine('%%âăĎÓ');
    stringBuilder.appendLine('1 0 obj');
    stringBuilder.appendLine('<<');
    stringBuilder.appendLine('  /FDF');
    stringBuilder.appendLine('    << /Fields');
    stringBuilder.appendLine('      [');
    stringBuilder.appendLine('       << /V(' + prepisznakyFdf('Tlačivo vytlačené z Portálu FS') + ')/T (print)>>');
    stringBuilder.appendLine('        << /V (' + pocetstran + ')/T (PocetStran)>>');

    if ($('#evidencnecislo').is(':checked')) {
        stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#hodnotaec').val()) + ')/T (ecspdmo)>>');
    }
    if ($('#ico').is(':checked')) {
        stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#hodnotaico').val()) + ')/T (ecspdmo)>>');
    }
    if ($('#rc').is(':checked')) {
        stringBuilder.appendLine('    << /V (' + prepisznakyFdf($('#hodnotarodcis').val()) + ')/T (ecspdmo)>>');
    }
    stringBuilder.appendLine('        << /V (1)/T (akt)>>');
    stringBuilder.appendLine('        << /V (' + pocetstran2fdf('layoutRow41374', 2) + ')/T (pocet)>>');
    for (var strana = 0; strana <= pocetstran - 1; strana++) {
        aktstrana = ((zaciatoksekcii - 1) / pocetsekciinastranu) + strana + 1;
        var pdfstrana = strana + 1;
        stringBuilder.appendLine('      << /T (' + Number(pdfstrana) + ')/Kids');
        stringBuilder.appendLine('    	[');
        stringBuilder.appendLine('	       << /V(' + Number(strana + 1) + ')/T (strana)>>');

        for (var aktcyklus = 1; aktcyklus <= sekciinastranu; aktcyklus++) {
            zacniprazdne = aktcyklus + 1;
            if (zacniprazdne >= sekciinastranu) {
                zacniprazdne = 1;
            }
            sekcia = (zaciatoksekcii - 1) + (strana * sekciinastranu) + aktcyklus;
            zacnisekciu = sekcia;
            if ((strana * sekciinastranu) + aktcyklus > pocetsekcii) {
                break;
            }
            var pageValues1 = polesekcii.pages[sekcia - 1];
            stringBuilder.appendLine('	       << /T (' + ((aktcyklus & 1) ? '1' : '2') + ')/Kids');
            stringBuilder.appendLine('	        [');
            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'T1_R1S1_vyberdruhuminoleja_2011') == 1 || getPageValueRbList2Fdf(pageValues1, 'checkbox1') == true) ? 'X' : '') + ')/T (r1-61a)>>');
            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'T1_R1S1_vyberdruhuminoleja_2011') == 2 || getPageValueRbList2Fdf(pageValues1, 'checkbox3') == true) ? 'X' : '') + ')/T (r1-61b)>>');
            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'T1_R1S1_vyberdruhuminoleja_2011') == 3 || getPageValueRbList2Fdf(pageValues1, 'checkbox4') == true) ? 'X' : '') + ')/T (r1-61c)>>');
            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'T1_R1S1_vyberdruhuminoleja_2011') == 4 || getPageValueRbList2Fdf(pageValues1, 'checkbox5') == true) ? 'X' : '') + ')/T (r1-61d)>>');
            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'T1_R1S1_vyberdruhuminoleja_2011') == 5 || getPageValueRbList2Fdf(pageValues1, 'checkbox6') == true) ? 'X' : '') + ')/T (r1-61e)>>');
            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'T1_R1S1_vyberdruhuminoleja_2011') == 6 || getPageValueRbList2Fdf(pageValues1, 'checkbox8') == true) ? 'X' : '') + ')/T (r1-61f1)>>');
            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'T1_R1S1_vyberdruhuminoleja_2011') == 7 || getPageValueRbList2Fdf(pageValues1, 'checkbox12') == true) ? 'X' : '') + ')/T (r1-61f2)>>');
            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'T1_R1S1_vyberdruhuminoleja_2011') == 8 || getPageValueRbList2Fdf(pageValues1, 'checkbox10') == true) ? 'X' : '') + ')/T (r1-61g1)>>');
            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'T1_R1S1_vyberdruhuminoleja_2011') == 9 || getPageValueRbList2Fdf(pageValues1, 'checkbox11') == true) ? 'X' : '') + ')/T (r1-61g2)>>');

            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'sekcia6364a') == 1 || getPageValueRbList2Fdf(pageValues1, 'box63') == true) ? 'X' : '') + ')/T (r1-63)>>');
            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'sekcia6364a') == 2 || getPageValueRbList2Fdf(pageValues1, 'box64') == true) ? 'X' : '') + ')/T (r1-64)>>');
            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'sekcia6364a') == 3 || getPageValueRbList2Fdf(pageValues1, 'box65') == true) ? 'X' : '') + ')/T (r1-65)>>');

            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'sekcia6364a') == 4 || getPageValueRbList2Fdf(pageValues1, 'A') == true) ? 'X' : '') + ')/T (r1-A)>>');
            stringBuilder.appendLine('	           << /V (' + ((getPageValueRbList2Fdf(pageValues1, 'sekcia6364a') == 5 || getPageValueRbList2Fdf(pageValues1, 'B') == true) ? 'X' : '') + ')/T (r1-B)>>');

            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r02')) + ')/T (r2)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r02'), 2) + ')/T (r2d)>>');

            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r03')) + ')/T (r3)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r03'), 3) + ')/T (r3d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r04')) + ')/T (r4)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r04'), 3) + ')/T (r4d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r05')) + ')/T (r5)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r05'), 3) + ')/T (r5d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r06')) + ')/T (r6)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r06'), 3) + ')/T (r6d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r07')) + ')/T (r7)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r07'), 3) + ')/T (r7d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r08')) + ')/T (r8)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r08'), 3) + ')/T (r8d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r09')) + ')/T (r9)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r09'), 3) + ')/T (r9d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r10')) + ')/T (r10)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r10'), 3) + ')/T (r10d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r11')) + ')/T (r11)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r11'), 3) + ')/T (r11d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r12')) + ')/T (r12)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r12'), 3) + ')/T (r12d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r13')) + ')/T (r13)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r13'), 3) + ')/T (r13d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r14')) + ')/T (r14)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r14'), 3) + ')/T (r14d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r15')) + ')/T (r15)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r15'), 3) + ')/T (r15d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r16')) + ')/T (r16)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r16'), 3) + ')/T (r16d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r17')) + ')/T (r17)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r17'), 3) + ')/T (r17d)>>');
            stringBuilder.appendLine('	           << /V (' + celacast(getPageValue2Fdf(pageValues1, 's2r18')) + ')/T (r18)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r18'), 3) + ')/T (r18d)>>');
            stringBuilder.appendLine('	           << /V (' + prepisznakyFdf(znamienko(getPageValue2Fdf(pageValues1, 's2r19'))) + ')/T (r19z)>>');
            stringBuilder.appendLine('	           << /V (' + bezZnamienka(celacast(getPageValue2Fdf(pageValues1, 's2r19'))) + ')/T (r19)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r19'), 3) + ')/T (r19d)>>');
            stringBuilder.appendLine('	           << /V (' + prepisznakyFdf(znamienko(getPageValue2Fdf(pageValues1, 's2r20'))) + ')/T (r20z)>>');
            stringBuilder.appendLine('	           << /V (' + bezZnamienka(celacast(getPageValue2Fdf(pageValues1, 's2r20'))) + ')/T (r20)>>');
            stringBuilder.appendLine('	           << /V (' + desatinnacast(getPageValue2Fdf(pageValues1, 's2r20'), 2) + ')/T (r20d)>>');
            stringBuilder.appendLine('            ]');
            stringBuilder.appendLine('            >>');
            if (!(aktcyklus & 1) && (pdfstrana == pocetstran)) {
                stringBuilder.appendLine('	         << /V (' + prepisznakyFdf(znamienko($('#VyslednaDan').val())) + ')/T (vysledna_danz)>>');
                stringBuilder.appendLine('	         << /V (' + bezZnamienka(celacast($('#VyslednaDan').val())) + ')/T (vysledna_dan)>>');
                stringBuilder.appendLine('	         << /V (' + desatinnacast($('#VyslednaDan').val(), 2) + ')/T (vysledna_dand)>>');
                stringBuilder.appendLine('	         << /V (' + prepisznakyFdf($('#SlovomEur').val()) + ')/T (vysledna_dans)>>');
                stringBuilder.appendLine('            ]');
                stringBuilder.appendLine('            >>');
            } else if (!(aktcyklus & 1)) {
                stringBuilder.appendLine('	         << /V ()/T (vysledna_danz)>>');
                stringBuilder.appendLine('	         << /V ()/T (vysledna_dan)>>');
                stringBuilder.appendLine('	         << /V ()/T (vysledna_dand)>>');
                stringBuilder.appendLine('	         << /V ()/T (vysledna_dans)>>');
                stringBuilder.appendLine('         ]');
                stringBuilder.appendLine('       >>');
            }
            cisloPoslSek = aktcyklus + 1;
        }
        stringBuilder.appendLine('');
    }
    if ($('#layoutRow41374').pageableSection().totalPages & 1) {
        stringBuilder.appendLine('	       << /T (2)/Kids');
        stringBuilder.appendLine('	        [');
        stringBuilder.appendLine('	           << /V ()/T (r1-28a)>>');
        stringBuilder.appendLine('	           << /V ()/T (r1-28b)>>');
        stringBuilder.appendLine('	           << /V ()/T (r1-28c)>>');
        stringBuilder.appendLine('	           << /V ()/T (r1-28d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r1-28e)>>');
        stringBuilder.appendLine('	           << /V ()/T (r1-p)>>');
        stringBuilder.appendLine('	           << /V ()/T (r1-d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r2ap)>>');
        stringBuilder.appendLine('	           << /V ()/T (r2a)>>');
        stringBuilder.appendLine('	           << /V ()/T (r2ad)>>');
        stringBuilder.appendLine('	           << /V ()/T (r2bp)>>');
        stringBuilder.appendLine('	           << /V ()/T (r2b)>>');
        stringBuilder.appendLine('	           << /V ()/T (r2bd)>>');
        stringBuilder.appendLine('	           << /V ()/T (r2cp)>>');
        stringBuilder.appendLine('	           << /V ()/T (r2c)>>');
        stringBuilder.appendLine('	           << /V ()/T (r2cd)>>');
        stringBuilder.appendLine('	           << /V ()/T (r3)>>');
        stringBuilder.appendLine('	           << /V ()/T (r3d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r4)>>');
        stringBuilder.appendLine('	           << /V ()/T (r4d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r5)>>');
        stringBuilder.appendLine('	           << /V ()/T (r5d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r6)>>');
        stringBuilder.appendLine('	           << /V ()/T (r6d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r7)>>');
        stringBuilder.appendLine('	           << /V ()/T (r7d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r8)>>');
        stringBuilder.appendLine('	           << /V ()/T (r8d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r9)>>');
        stringBuilder.appendLine('	           << /V ()/T (r9d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r10)>>');
        stringBuilder.appendLine('	           << /V ()/T (r10d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r11)>>');
        stringBuilder.appendLine('	           << /V ()/T (r11d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r12)>>');
        stringBuilder.appendLine('	           << /V ()/T (r12d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r13)>>');
        stringBuilder.appendLine('	           << /V ()/T (r13d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r14)>>');
        stringBuilder.appendLine('	           << /V ()/T (r14d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r15)>>');
        stringBuilder.appendLine('	           << /V ()/T (r15d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r16)>>');
        stringBuilder.appendLine('	           << /V ()/T (r16d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r17)>>');
        stringBuilder.appendLine('	           << /V ()/T (r17d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r18)>>');
        stringBuilder.appendLine('	           << /V ()/T (r18d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r19z)>>');
        stringBuilder.appendLine('	           << /V ()/T (r19)>>');
        stringBuilder.appendLine('	           << /V ()/T (r19d)>>');
        stringBuilder.appendLine('	           << /V ()/T (r20z)>>');
        stringBuilder.appendLine('	           << /V ()/T (r20)>>');
        stringBuilder.appendLine('	           << /V ()/T (r20d)>>');
        stringBuilder.appendLine('            ]');
        stringBuilder.appendLine('            >>');
        if (pdfstrana == pocetstran) {
            stringBuilder.appendLine('	         << /V (' + prepisznakyFdf(znamienko($('#VyslednaDan').val())) + ')/T (vysledna_danz)>>');
            stringBuilder.appendLine('	         << /V (' + bezZnamienka(celacast($('#VyslednaDan').val())) + ')/T (vysledna_dan)>>');
            stringBuilder.appendLine('	         << /V (' + desatinnacast($('#VyslednaDan').val(), 2) + ')/T (vysledna_dand)>>');
            stringBuilder.appendLine('	         << /V (' + prepisznakyFdf($('#SlovomEur').val()) + ')/T (vysledna_dans)>>');
            stringBuilder.appendLine('         ]');
            stringBuilder.appendLine('       >>');
        } else {
            stringBuilder.appendLine('	         << /V ()/T (vysledna_danz)>>');
            stringBuilder.appendLine('	         << /V ()/T (vysledna_dan)>>');
            stringBuilder.appendLine('	         << /V ()/T (vysledna_dand)>>');
            stringBuilder.appendLine('	         << /V ()/T (vysledna_dans)>>');
            stringBuilder.appendLine('         ]');
            stringBuilder.appendLine('       >>');
        }
    }
    stringBuilder.appendLine('      ]');
    stringBuilder.appendLine('    /F (form.618.SPDMO-25-Strana2-print-save.pdf)');
    stringBuilder.appendLine('    /ID [ <97fb02b45ad58b6aa2b6872c3aa1944c><9de158208a4c769cd4170b2fe84a6777>]');
    stringBuilder.appendLine('  >> ');
    stringBuilder.appendLine('>> ');
    stringBuilder.appendLine('endobj');
    stringBuilder.appendLine('trailer');
    stringBuilder.appendLine('<< /Root 1 0 R >>');
    stringBuilder.appendLine('%%EOF');
    return stringBuilder.string();
}