    function vIE(){
        return (navigator.appName=='Microsoft Internet Explorer') ? parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]) : -1;
    }

    var reqlinklogin;
    var reqlinkregul;
    var tabError = new Array();
    var formToSubmit;
    var saveCalc;
    var bNewUser = false;
    var div_content_reg = '';
    var div_content_rem = '';
    var sSetPage;
    var sFormChangeId = '';



    if (document.images){
        preloadimg = new Image();
        aImgs = new Array('bottom.gif', 'btn_nowe_konto.gif', 'btn_nowe_konto2.gif', 'btn_wyslij.gif', 'btn_zaloguj.gif', 'btn_zamknij.gif', 'btn_zamknij2.gif', 'btn_zamknij3.gif', 'o11.jpg', 'o12.jpg', 'o13.jpg', 'o21.jpg', 'o31.jpg', 'o311.jpg', 'top.gif', 'btn_powrot.gif', 'btn_zamknij_txt.gif');

        for(i=0; i<aImgs.length; i++){
            preloadimg.src = 'https://'+document.domain+'/img/popup/'+aImgs[i];
        }
    }

    function showLoginDiv(ajax_reqlinklogin, ajax_reqlinkregul, sForm, savecalc, bregister, setPage){

        reqlinklogin = ajax_reqlinklogin;
        reqlinkregul = ajax_reqlinkregul;

        if(sForm != ''){
            formToSubmit = sForm;
        }
        if(savecalc != ''){
            saveCalc = savecalc;
        }
        
        if(typeof(setPage)!="undefined"){
            sSetPage = setPage;
        } else {
            sSetPage = '';
        }

        tabError[1] = 'Użytkownik o takim adresie e-mail już istnieje.';
        tabError[2] = 'Podaj adres e-mail.';
        tabError[3] = 'Podaj prawidłowy adres e-mail';
        tabError[4] = 'Adres e-mail nie może mieć więcej niż 63 znaki.';
        tabError[5] = 'Podaj hasło do Twojego konta w sklepie.';
        tabError[6] = 'Hasło powinno mieć przynajmniej 6 znaków.';
        tabError[7] = 'Hasło nie moze mieć więcej niż 20 znaków.';
        tabError[8] = 'Hasło może zawierać tylko znaki alfanumeryczne.';
        tabError[9] = 'Zły login lub hasło.';
        tabError[10] = 'Nie ma użytkownika o takim adresie e-mail';
        tabError[11] = 'Konto nie zostalo jeszcze zweryfikowane.';
        tabError[12] = 'Hasło musi zawierać przynajmniej jedną cyfrę.';
        tabError[13] = 'Musisz zaakceptować regulamin.';

        if(saveCalc == 'true'){
            var search_name = document.getElementById('calc_nazwakalk');

            if(search_name.value == '-wpisz-'){
                alert('Podaj nazwę kalkulacji, którą chcesz zapisać!');
                return void(null);
                false;
            }
        }

        var search_container = document.getElementById('search_container');
        var search_form = document.getElementById('search_form');
        var div_content = '';

        hideSelect();
        //search_container.style.width = "100%";
        //search_container.style.height = "100%";
        search_container.style.display = "block";
        //search_form.style.width = "400px";
        //search_form.style.height = "330px";
        search_form.style.display = "block";


    div_content += '<form name="frm_login" id="frm_login" onsubmit="javascript:return false;" method="post">';
    div_content += '<table id="main_tbl" cellpadding="0" cellspacing="0" border="0" style="width: 302px;">';
    div_content += '<tr>';
    div_content += '<td id="preimg1" style="width: 302px; height: 9px; background-image: url(\'/img/popup/top.gif\'); background-repeat: no-repeat; background-position: top left;"></td>';
    div_content += '</tr>';
    div_content += '<tr id="tr1">';
    div_content += '<td id="td1" style="width: 302px; height: 142px; background-image: url(\'/img/popup/o11.jpg\'); background-repeat: no-repeat; background-position: top left;" valign="top">';
    div_content += '    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%;">';
    div_content += '    <tr>';
    div_content += '    <td valign="top" style="text-align: left; padding: 10px 0px 10px 18px;">';
    div_content += '    <p style="font-weight: bold; font-size: 16px; color: #FFFFFF;">Logowanie</p>';
    div_content += '    </td>';
    div_content += '    <td>';
    div_content += '    <p>&nbsp;</p>';
    div_content += '    </td>';
    div_content += '    <td valign="top" style="text-align: right; padding: 5px 12px 0px 0px;">';
    div_content += '    <a href="javascript:void(null);" onclick="javascript:hideSearch2();"><img id="preimg2" src="/img/popup/btn_zamknij.gif" alt="zamknij" style="border-style: none;" /></a>';
    div_content += '    </td>';
    div_content += '    </tr>';
    div_content += '    <tr>';
    div_content += '    <td colspan="3" valign="top" style="width: 100%; display:none; text-align: center; padding: 0px 0px 3px 0px;" id="loadingtd">';
    div_content += '    </td>';
    div_content += '    </tr>';
    div_content += '    <tr id="frm1_tr1">';
    div_content += '    <td style="text-align: right;" valign="middle">';
    div_content += '    <p style="color: #FFFFFF; margin-right: 5px;">Login (e-mail)</p>';
    div_content += '    </td>';
    div_content += '    <td style="text-align: left;" valign="middle">';
    div_content += '    <input onkeypress="javascript:var keycode = event.keyCode; if (keycode == 13) {ajax_login2();} else {return void(null);}" name="login" id="sEmailDiv" type="text" maxlength="50" style="border: 1px solid #a0a0a0; width: 140px; height: 16px;" tabindex="1000" />';
    div_content += '    </td>';
    div_content += '    <td>';
    div_content += '    <p>&nbsp;</p>';
    div_content += '    </td>';
    div_content += '    </tr>';
    div_content += '    <tr id="frm1_tr2">';
    div_content += '    <td style="text-align: right; padding-top:1px;" valign="middle">';
    div_content += '    <p style="color: #FFFFFF; margin-right: 5px;">Hasło</p>';
    div_content += '    </td>';
    div_content += '    <td style="text-align: left; padding-top:1px;" valign="middle">';
    div_content += '    <input onkeypress="javascript:var keycode = event.keyCode; if (keycode == 13) {ajax_login2();} else {return void(null);}" name="password" id="sPasswordDiv" type="password" maxlength="50" style="border: 1px solid #a0a0a0; width: 140px; height: 14px;" tabindex="1001" />';
    div_content += '    </td>';
    div_content += '    <td>';
    div_content += '    <p>&nbsp;</p>';
    div_content += '    </td>';
    div_content += '    </tr>';
    div_content += '    <tr id="frm1_tr3">';
    div_content += '    <td colspan="2" style="text-align: right; padding-top:5px;" valign="top">';
    div_content += '    <a href="javascript:void(null);" onclick="javascript:ajax_login2();"><img src="/img/popup/btn_zaloguj.gif" id="preimg3" alt="zaloguj" style="border-style: none;" tabindex="1002" /></a>';
    div_content += '    </td>';
    div_content += '    <td>';
    div_content += '    </td>';
    div_content += '    </tr>';
    div_content += '    </table>';
    div_content += '</td>';
    div_content += '</tr>';
    div_content += '<tr id="tr2">';
    div_content += '<td id="td2" style="width: 302px; height: 54px; background-image: url(\'/img/popup/o12.jpg\'); background-repeat: no-repeat; background-position: top left;" valign="top">';
    div_content += '    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%;">';
    div_content += '    <tr>';
    div_content += '    <td valign="top" style="text-align: left; padding: 10px 0px 0px 18px;">';
    div_content += '    <p style="font-weight: bold; font-size: 16px; color: #535353;">Nowe konto';
    div_content += '    <br /><b style="font-weight: normal; font-size: 10px;">Nie masz jeszcze konta?</b></p>';
    div_content += '    </td>';
    div_content += '    <td valign="middle" style="text-align: left; padding: 12px 0px 0px 5px;">';
    div_content += '    <a href="javascript:void(null);" onClick="javascript:showRegister(true);" tabindex="1003"><img id="preimg4" src="/img/popup/btn_nowe_konto.gif" alt="nowe konto" style="border-style: none;" /></a>';
    div_content += '    </td>';
    div_content += '    </tr>';
    div_content += '    </table>';
    div_content += '</td>';
    div_content += '</tr>';
    div_content += '<tr id="tr3">';
    div_content += '<td id="td3" style="width: 302px; height: 28px; background-image: url(\'/img/popup/o13.jpg\'); background-repeat: no-repeat; background-position: top left;">';
    div_content += '    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%;">';
    div_content += '    <tr>';
    div_content += '    <td valign="top" style="text-align: left; padding: 4px 0px 0px 18px;">';
    div_content += '    <p style="font-size: 11px; color: #FFFFFF;">Zapomniałeś hasło? Kliknij <a href="javascript:void(null);" onclick="javascript:showPassRemind();" style="color: #ffffff; text-decoration: underline;" tabindex="1004">tutaj</a></p>';
    div_content += '    </td>';
    div_content += '    </tr>';
    div_content += '    </table>';
    div_content += '</td>';
    div_content += '</tr>';
    div_content += '<tr>';
    div_content += '<td id="preimg5" style="width: 302px; height: 8px; background-image: url(\'/img/popup/bottom.gif\'); background-repeat: no-repeat; background-position: top left;"></td>';
    div_content += '</tr>';
    div_content += '</table>';
    div_content += '</form>';


    div_content_reg = '';
    div_content_reg += '    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%;">';
    div_content_reg += '    <tr>';
    div_content_reg += '    <td valign="top" style="text-align: left; padding: 10px 0px 0px 18px;">';
    div_content_reg += '    <p style="font-weight: bold; font-size: 16px; color: #535353; white-space: nowrap;">Nowe konto</p>';
    div_content_reg += '    </td>';
    div_content_reg += '    <td>';
    div_content_reg += '    <p>&nbsp;</p>';
    div_content_reg += '    </td>';
    div_content_reg += '    <td valign="top" style="text-align: right; padding: 5px 12px 0px 0px;">';
    div_content_reg += '    <a href="javascript:void(null);" id="a_exit" onclick="javascript:hideSearch2();"><img src="/img/popup/btn_zamknij2.gif" id="preimg6" alt="zamknij" style="border-style: none;" /></a>';
    div_content_reg += '    </td>';
    div_content_reg += '    </tr>';
    div_content_reg += '    <tr>';
    div_content_reg += '    <td colspan="3" valign="top" style="width: 100%; display:none; text-align: center; padding: 0px;" id="loadingtd">';
    div_content_reg += '    </td>';
    div_content_reg += '    </tr>';
    div_content_reg += '    <tr id="frm2_tr1">';
    div_content_reg += '    <td style="text-align: right;" valign="middle">';
    div_content_reg += '    <p style="color: #535353; margin-right: 5px;">Login <b style="font-size: 9px; font-weight: normal;">(e-mail)</b></p>';
    div_content_reg += '    </td>';
    div_content_reg += '    <td style="text-align: left;" valign="middle">';
    div_content_reg += '    <input onkeypress="javascript:var keycode = event.keyCode; if (keycode == 13) {ajax_register_login2();} else {return void(null);}" name="sEmailDiv2" id="sEmailDiv2" type="text" maxlength="50" style="border: 1px solid #a0a0a0; width: 140px; height: 16px;" tabindex="1101" />';
    div_content_reg += '    </td>';
    div_content_reg += '    <td>';
    div_content_reg += '    <p>&nbsp;</p>';
    div_content_reg += '    </td>';
    div_content_reg += '    </tr>';
    div_content_reg += '    <tr id="frm2_tr2">';
    div_content_reg += '    <td style="text-align: right; padding-top:1px;" valign="middle">';
    div_content_reg += '    <p style="color: #535353; margin-right: 5px; margin-left: 15px;">Hasło <b style="font-size: 9px; font-weight: normal;">(minimum 6 <span style="white-space: nowrap; color: #535353; font-size: 9px;">znaków w tym 1 cyfra)</span></b></p>';
    div_content_reg += '    </td>';
    div_content_reg += '    <td style="text-align: left; padding-top:1px; vertical-align: top;" valign="middle">';
    div_content_reg += '    <input onkeypress="javascript:var keycode = event.keyCode; if (keycode == 13) {ajax_register_login2();} else {return void(null);}" name="sPasswordDiv2" id="sPasswordDiv2" type="password" maxlength="50" style="border: 1px solid #a0a0a0; width: 140px; height: 14px;" tabindex="1102" />';
    div_content_reg += '    </td>';
    div_content_reg += '    <td>';
    div_content_reg += '    <p>&nbsp;</p>';
    div_content_reg += '    </td>';
    div_content_reg += '    </tr>';
    div_content_reg += '    <tr id="frm2_tr3">';
    div_content_reg += '    <td style="text-align: right; padding-top:1px;" valign="middle">';
    div_content_reg += '    <p style="color: #535353; margin-right: 5px;">Powtórzenie hasła</p>';
    div_content_reg += '    </td>';
    div_content_reg += '    <td style="text-align: left; padding-top:1px;" valign="middle">';
    div_content_reg += '    <input onkeypress="javascript:var keycode = event.keyCode; if (keycode == 13) {ajax_register_login2();} else {return void(null);}" name="sPassword2Div2" id="sPassword2Div2" type="password" maxlength="50" style="border: 1px solid #a0a0a0; width: 140px; height: 14px;" tabindex="1103" />';
    div_content_reg += '    </td>';
    div_content_reg += '    <td>';
    div_content_reg += '    <p>&nbsp;</p>';
    div_content_reg += '    </td>';
    div_content_reg += '    </tr>';
    div_content_reg += '    <tr id="frm2_tr4">';
    div_content_reg += '    <td colspan="2" style="text-align: left; padding-top:1px; padding-right: 0px;" valign="top" colspan="2">';
    div_content_reg += '    <p style="color: #535353; vertical-align: middle; margin-left: 15px;"><input checked="checked" value="1" type="checkbox" name="nMarketing" id="nMarketing" tabindex="1104" /> <label for="nMarketing" style="font-size: 11px;">wyrażam zgodę na otrzymywanie informacji o konkursach, promocjach i akcjach marketingowych</label></p>';
    div_content_reg += '    <p style="color: #535353; vertical-align: middle; margin-left: 15px;"><input value="1" type="checkbox" checked="checked" name="nRegulamin" id="nRegulamin" tabindex="1105" /> <label for="nRegulamin" style="font-size: 11px;">akceptuję <a href="javascript:void(null);" onclick="showRegulaminMain(); return false;" style="font-size: 11px;">Regulamin</a></label></p>';
    div_content_reg += '    </td>';
    div_content_reg += '    </tr>';
    div_content_reg += '    <tr id="frm2_tr5">';
    div_content_reg += '    <td colspan="2" style="text-align: right;" valign="top">';
    div_content_reg += '    <a href="javascript:void(null);" onClick="javascript:ajax_register_login2();" tabindex="1105"><img src="/img/popup/btn_nowe_konto2.gif" id="preimg7" alt="nowe konto" style="border-style: none;" /></a>';
    div_content_reg += '    </td>';
    div_content_reg += '    <td>';
    div_content_reg += '    </td>';
    div_content_reg += '    </tr>';
    div_content_reg += '    </table>';






    div_content_rem = '';
    div_content_rem += '    <table cellpadding="0" cellspacing="0" border="0" style="width: 100%;">';
    div_content_rem += '    <tr>';
    div_content_rem += '    <td valign="top" style="text-align: left; padding: 10px 0px 30px 18px;" colspan="2">';
    div_content_rem += '    <p style="font-weight: bold; font-size: 16px; color: #FFFFFF; white-space: nowrap;">Przypomnienie hasła</p>';
    div_content_rem += '    </td>';
    div_content_rem += '    <td valign="top" style="text-align: right; padding: 5px 12px 0px 0px;">';
    div_content_rem += '    <a href="javascript:void(null);" onclick="javascript:hideSearch2();"><img src="/img/popup/btn_zamknij3.gif" id="preimg7" alt="zamknij" style="border-style: none;" /></a>';
    div_content_rem += '    </td>';
    div_content_rem += '    </tr>';
    div_content_rem += '    <tr>';
    div_content_rem += '    <td colspan="3" valign="top" style="width: 100%; display:none; text-align: center; padding: 0px;" id="loadingtd">';
    div_content_rem += '    </td>';
    div_content_rem += '    </tr>';
    div_content_rem += '    <tr id="frm3_tr1">';
    div_content_rem += '    <td style="text-align: center;" valign="middle" colspan="3">';
    div_content_rem += '    <p style="color: #FFFFFF; margin: 0px 5px 10px 5px; font-weight: bold;" id="p_remind">Przypomnienie zostanie wysłane <br />na podany adres e-mail</p>';
    div_content_rem += '    </td>';
    div_content_rem += '    </tr>';
    div_content_rem += '    <tr id="frm3_tr2">';
    div_content_rem += '    <td style="text-align: center;" valign="middle" colspan="3">';
    div_content_rem += '    <p style="color: #FFFFFF;">Login (e-mail) <input onkeypress="javascript:var keycode = event.keyCode; if (keycode == 13) {ajax_remind_pass();} else {return void(null);}" name="login" id="sEmailDiv" type="text" maxlength="50" style="border: 1px solid #a0a0a0; width: 140px; height: 16px;" tabindex="1201" /></p>';
    div_content_rem += '    </td>';
    div_content_rem += '    </tr>';
    div_content_rem += '    <tr id="frm3_tr3">';
    div_content_rem += '    <td colspan="3" style="text-align: right; padding-top:5px; padding-right: 45px;" valign="top">';
    div_content_rem += '    <a href="javascript:void(null);" onclick="javascript:ajax_remind_pass();" tabindex="1202"><img src="/img/popup/btn_wyslij.gif" id="preimg8" alt="wyślij przypomnienie" style="border-style: none;" /></a>';
    div_content_rem += '    </td>';
    div_content_rem += '    <td>';
    div_content_rem += '    </td>';
    div_content_rem += '    </tr>';
    div_content_rem += '    </table>';




        search_form.innerHTML = div_content;

        if(bregister){
            showRegister(true);
        } else {
            document.getElementById('sEmailDiv').focus();
            if (vIE()<7 && vIE()>0){
                setTimeout('loadImgs()',10);
            }
        }





    }


    function showRegister(bDelete){
        var td1 = document.getElementById('td1');
        var main_tbl = document.getElementById('main_tbl');

        if(bDelete){
            main_tbl.deleteRow(2);
        }

        td1.style.backgroundImage = 'url(/img/popup/o21.jpg)';
        td1.style.height = '196px';
        td1.innerHTML = div_content_reg;

        if (vIE()<7 && vIE()>0){
            setTimeout('loadImgsReg()',10);
        }

    }


    function loadImgs(){
        document.getElementById('preimg1').style.backgroundImage = 'url(/img/popup/top.gif)';
        document.getElementById('preimg2').src = '/img/popup/btn_zamknij.gif';
        document.getElementById('preimg3').src = '/img/popup/btn_zaloguj.gif';
        document.getElementById('preimg4').src = '/img/popup/btn_nowe_konto.gif';
        document.getElementById('preimg5').style.backgroundImage = 'url(/img/popup/bottom.gif)';
        document.getElementById('td1').style.backgroundImage = 'url(/img/popup/img/popup/o11.jpg)';
        document.getElementById('td2').style.backgroundImage = 'url(/img/popup/o12.jpg)';
        document.getElementById('td3').style.backgroundImage = 'url(/img/popup/o13.jpg)';
    }

    function loadImgsReg(){
        document.getElementById('preimg1').style.backgroundImage = 'url(/img/popup/top.gif)';
        document.getElementById('preimg6').src = '/img/popup/btn_zamknij2.gif';
        document.getElementById('preimg7').src = '/img/popup/btn_nowe_konto2.gif';
        document.getElementById('preimg5').style.backgroundImage = 'url(/img/popup/bottom.gif)';
        document.getElementById('td1').style.backgroundImage = 'url(/img/popup/o21.jpg)';
        document.getElementById('td3').style.backgroundImage = 'url(/img/popup/o13.jpg)';
    }

    function loadImgsRem(){
        document.getElementById('preimg1').style.backgroundImage = 'url(/img/popup/top.gif)';
        document.getElementById('preimg7').src = '/img/popup/btn_zamknij3.gif';
        document.getElementById('preimg8').src = '/img/popup/btn_wyslij.gif';
        document.getElementById('preimg5').style.backgroundImage = 'url(/img/popup/bottom.gif)';
        document.getElementById('td1').style.backgroundImage = 'url(/img/popup/o31.jpg)';
    }

    function loadImgsRegulamin(){
        document.getElementById('preimg1').style.backgroundImage = 'url(/img/popup/top.gif)';
        document.getElementById('preimg7').src = '/img/popup/btn_zamknij3.gif';
        document.getElementById('preimg15').src = '/img/popup/btn_powrot.gif';
        document.getElementById('preimg5').style.backgroundImage = 'url(/img/popup/bottom.gif)';
        document.getElementById('td1').style.backgroundImage = 'url(/img/popup/o31.jpg)';
    }



    function showPassRemind(){
        var td1 = document.getElementById('td1');
        var main_tbl = document.getElementById('main_tbl');

        main_tbl.deleteRow(main_tbl.rows.length-2);
        if(main_tbl.rows.length==4){
            main_tbl.deleteRow(main_tbl.rows.length-2);
        }


        td1.style.backgroundImage = 'url(/img/popup/o31.jpg)';
        td1.style.height = '194px';
        td1.innerHTML = div_content_rem;
        if (vIE()<7 && vIE()>0){
            setTimeout('loadImgsRem()',10);
        }

    }
    
    
    function showRegulaminMain(){
        if(document.getElementById('container_regulamin')){
            document.getElementById('container_regulamin').style.display = 'block';
        } else {
            showRegulamin();
        }
    }


    function showRegulamin(){
    
        
        var frm_container = document.getElementById('search_form');
        
        var newEl = document.createElement('div');
        newEl.style.width = '600px';
        newEl.style.position = 'absolute';
        newEl.style.top = '-50px';
        newEl.style.left = '-150px';
        newEl.style.margin = '0px auto';
        newEl.id = 'container_regulamin';
        
        var topDiv = document.createElement('div');
        topDiv.style.height = '8px';
        topDiv.style.width = newEl.style.width;
        topDiv.style.backgroundImage = 'url(/img/popup/reg_top.gif)';
        topDiv.style.backgroundRepeat = 'no-repeat';
        var middleDiv = document.createElement('div');
        
        middleDiv.style.height = '350px';
        middleDiv.style.padding = '5px 0px 10px 0px';
        middleDiv.style.backgroundColor = '#ffffff';
        middleDiv.style.textAlign = 'right';
        middleDiv.innerHTML = '<a href="javascript:void(null);" onclick="javascript:closeRegulamin();" tabindex="1202" style="margin-right: 13px;"><img src="/img/popup/btn_zamknij_bialy.gif" alt="powrót" style="border-style: none;" /></a>';
        var bottomDiv = document.createElement('div');
        bottomDiv.style.height = '8px';
        bottomDiv.style.width = newEl.style.width;
        bottomDiv.style.backgroundImage = 'url(/img/popup/reg_bottom.gif)';
        
        var regCont = document.createElement('div');
        regCont.style.height = '290px';
        regCont.style.overflow = 'auto';
        regCont.style.padding = '0px 20px 0px 20px';
        regCont.style.margin = '10px 5px 0px 5px';
        regCont.style.textAlign = 'left';
        var btnCont = document.createElement('div');
        btnCont.style.textAlign = 'center';
        btnCont.style.paddingTop = '5px';
        btnCont.innerHTML = '<a href="javascript:void(null);" onclick="javascript:closeRegulamin();" tabindex="1202"><img src="/img/popup/btn_powrot_bialy.gif" id="preimg15" alt="powrót" style="border-style: none;" /></a>';
        
        
        middleDiv.appendChild(regCont);
        middleDiv.appendChild(btnCont);
        
        //document.getElementById('preimg15').src = '/img/popup/btn_wyslij.gif';
        
        newEl.appendChild(topDiv);
        newEl.appendChild(middleDiv);
        newEl.appendChild(bottomDiv);
                
        frm_container.appendChild(newEl);
    
    
    
        advAJAX.post({
            url: ''+reqlinkregul+'',
                parameters : {
                "nrDoc" : 1
            },
            onSuccess : function(obj) {
                var res = obj.responseXML;

                if(res.getElementsByTagName("error")[0]){
                    texta.value = '';
                } else {
                    var xmlDoc = res.getElementsByTagName("doc")[0];
                    for (i=0; i<xmlDoc.childNodes.length; i++){
                        if(xmlDoc.childNodes[i].nodeName=='content'){
                            regCont.innerHTML = xmlDoc.childNodes[i].firstChild.nodeValue;
                        }
                    }
                }
            },
            onLoading : function(obj) {
                regCont.innerHTML = '<img src="/img/popup/loader_white.gif" alt="loading" style="margin-left: 270px; margin-top: 100px;"/>';
            }   
        });
    
    
    
    }
    
    
    
    function closeRegulamin(){
        if(document.getElementById('container_regulamin')){
            document.getElementById('container_regulamin').style.display = 'none';
        }
    }
    


    function hideSearch2(){
        unhideSelect();
        var search_container = document.getElementById('search_container');
        var search_form = document.getElementById('search_form');
        search_container.style.display="none";

        search_form.style.display = "none";
        search_form.innerHTML = '';
    }



    function hideSelect(){
        var aSelects = document.getElementsByTagName("select");
        for (j=0; j<aSelects.length; j++) {
            aSelects[j].style.visibility = "hidden";
        }
    }

    function unhideSelect(){
        var aSelects = document.getElementsByTagName("select");
        for (j=0; j<aSelects.length; j++) {
            aSelects[j].style.visibility = "visible";
        }
    }



    function ajax_remind_pass(){
        var sEmailDiv = document.getElementById('sEmailDiv');

        advAJAX.post({
              url: ''+reqlinklogin+'',
                parameters : {
                "sEmail" : sEmailDiv.value,
                "remind_pass" : 1
            },
            onLoading :function(obj) {
                changeVis('frm3_tr1',false);
                changeVis('frm3_tr2',false);
                changeVis('frm3_tr3',false);
                changeVis('loadingtd',true);
                document.getElementById('loadingtd').innerHTML = '<img src="/img/loading.gif" alt="loading"/>';
            },
            onSuccess : function(obj) {
                var res = obj.responseXML;

                if(res.getElementsByTagName("error")[0]){
                    changeVis('frm3_tr1',true);
                    changeVis('frm3_tr2',true);
                    changeVis('frm3_tr3',true);
                    var xmlDoc = res.getElementsByTagName("error")[0];
                        //for (i=0; i<xmlDoc.childNodes.length; i++){
                            document.getElementById('p_remind').innerHTML = '';
                            document.getElementById('loadingtd').innerHTML = '<p style="color:#fe9730; font-size:11px; font-weight: bold; text-align: center;">' + tabError[xmlDoc.childNodes[0].firstChild.nodeValue] + '</p>';
                        //}
                        //document.forms[formToSubmit].submit();


                } else {
                    var xmlDoc = res.getElementsByTagName("sent")[0];

                    if(xmlDoc.childNodes[0].nodeValue=='true'){
                        document.getElementById('loadingtd').innerHTML = '<p style="color:#FFFFFF; font-size:11px; font-weight: bold; text-align: center;">Przypomnienie zostało wysłane</p>';
                        setTimeout ( 'hideSearch2()', 2000 );
                    }
                    //document.location.href = "my_insurances.html";
                }
            }
        });

    }


    function ajax_login2(){

        var sEmailDiv = document.getElementById('sEmailDiv');
        var sPasswordDiv = document.getElementById('sPasswordDiv');


        if(bNewUser==true){
            ajax_register_login2();
            return false;
        }

        advAJAX.post({
              url: ''+reqlinklogin+'',
                parameters : {
                "sEmail" : sEmailDiv.value,
                "sPassword" : sPasswordDiv.value,
                "eventlogin" : 1,
                "formname" : "login"
            },
            onLoading :function(obj) {
                changeVis('frm1_tr1',false);
                changeVis('frm1_tr2',false);
                changeVis('frm1_tr3',false);
                changeVis('loadingtd',true);
                document.getElementById('loadingtd').innerHTML = '<img src="/img/loading.gif" alt="loading"/>';
            },
            onFailure :function(obj) {

            },
            onSuccess : function(obj) {
                var res = obj.responseXML;

                if(res.getElementsByTagName("error")[0]){
                    var xmlDoc = res.getElementsByTagName("error")[0];
                    changeVis('frm1_tr1',true);
                    changeVis('frm1_tr2',true);
                    changeVis('frm1_tr3',true);
                    document.getElementById('loadingtd').innerHTML = '<p style="color:#fe9730; font-size:11px; font-weight: bold;" align="center">'+tabError[xmlDoc.childNodes[0].nodeValue]+'<br /></p>';
                } else {
                    var xmlDoc = res.getElementsByTagName("logged")[0];

                    if(xmlDoc.childNodes[0].nodeValue=='true'){
                        if(formToSubmit != '' && saveCalc=='true'){
                            document.getElementById(formToSubmit).elements[0].value = 10;
                            document.getElementById(formToSubmit).submit();
                        } else {
                            //document.location.href=document.location.href;
                            //document.location.reload(true);
                            //document.location.href=location.hostname+location.pathname;
                            if(sFormChangeId){
                                document.getElementById(sFormChangeId).elements[0].value = 11;
                                document.getElementById(sFormChangeId).submit();
                            } else {
                            
                                if(sSetPage != ''){
                                    document.location.href = sSetPage;
                                    //hideSearch2();
                                } else {
                                    var tab = document.location.href.split('#');
                                    document.location.href = tab[0];
                                    
                                }
                            }
                        }
                    } else {
                        document.getElementById('loadingtd').innerHTML = '<p style="color:#fe9730; font-size:11px; font-weight: bold;" align="center">Błąd logowania<br /></p>';
                    }


                    //document.location.href = "my_insurances.html";
                }
            }
        });

    }


    function ajax_register_login2(){

        var sEmailDiv = document.getElementById('sEmailDiv2');
        var sPasswordDiv = document.getElementById('sPasswordDiv2');
        var sPassword2Div2 = document.getElementById('sPassword2Div2');
        var nMarketing = document.getElementById('nMarketing');
        var nRegulamin = document.getElementById('nRegulamin');
        var sErrorTxt = '';
        var nMarketValue = 0;

        if(sPasswordDiv.value != sPassword2Div2.value){
            changeVis('loadingtd',true);
            document.getElementById('loadingtd').innerHTML = '<p style="color:#ff0000; font-size:11px; font-weight: bold;" align="center">Hasla nie są identyczne<br /></p>';
            return false;
        }

        if(nMarketing.checked){
            nMarketValue=1;
        } else {
            nMarketValue=0;
        }
        
        
        if(nRegulamin.checked){
            nRegulaminValue=1;
        } else {
            nRegulaminValue=0;
        }

        advAJAX.post({
              url: ''+reqlinklogin+'',
                parameters : {
                "sEmail" : sEmailDiv.value,
                "sPassword" : sPasswordDiv.value,
                "nMarketing" : nMarketValue,
                "nRegulamin" : nRegulaminValue,
                "bRegister" : "true"
            },
            onLoading :function(obj) {
                changeVis('frm2_tr1',false);
                changeVis('frm2_tr2',false);
                changeVis('frm2_tr3',false);
                changeVis('frm2_tr4',false);
                changeVis('frm2_tr5',false);
                changeVis('loadingtd',true);
                document.getElementById('loadingtd').innerHTML = '<img src="/img/loading2.gif" alt="loading"/>';
            },
            onSuccess : function(obj) {

                var res = obj.responseXML;


                if(res.getElementsByTagName("error")[0]){

                    changeVis('frm2_tr1',true);
                    changeVis('frm2_tr2',true);
                    changeVis('frm2_tr3',true);
                    changeVis('frm2_tr4',true);
                    changeVis('frm2_tr5',true);
                    var xmlDoc = res.getElementsByTagName("error")[0];

                    //for (i=0; i<xmlDoc.childNodes.length; i++){
                        //if(xmlDoc.childNodes[i].nodeName=='er'){
                            sErrorTxt += tabError[xmlDoc.childNodes[0].firstChild.nodeValue];
                        //}
                    //}

                        document.getElementById('loadingtd').innerHTML = '<p style="color:#ff0000; font-size:11px; font-weight: bold; text-align: center;">'+sErrorTxt+'</p>';

                } else {
                    var xmlDoc = res.getElementsByTagName("logged")[0];

                    if(xmlDoc.childNodes[0].nodeValue=='true'){
                        if(formToSubmit != '' && saveCalc=='true'){
                            document.getElementById('loadingtd').innerHTML = '';
                            document.forms(formToSubmit).elements[0].value = 10;
                            document.forms(formToSubmit).submit();
                        } else {
                            document.getElementById('loadingtd').innerHTML = '<br /><p style="color:#535353; font-size:11px; font-weight: bold; text-align: center;">Dziękujemy za założenie konta</p><p style="color:#535353; font-size:11px; font-weight: bold; text-align: center;">w naszym markecie.</p><br><p style="color:#535353; font-size:11px; text-align: center;">Pamiętaj, że przeglądanie zakupionych polis</p><p style="color:#535353; font-size:11px; text-align: center;">oraz zmiana danych możliwa będzie dopiero po</p><p style="color:#535353; font-size:11px; text-align: center;">aktywowaniu konta. W tym celu wystarczy kliknąć</p><p style="color:#535353; font-size:11px; text-align: center;">w link aktywacyjny, który właśnie otrzymałeś e-mailem.</p><br /><p><a id="a_exit2" href="#none"><img id="preimg16" alt="Zamknij" title="Zamknij" /></a></p>';
                            //setTimeout ( 'document.location.href=document.location.href', 2000 );
                            
                            document.getElementById('preimg16').src = '/img/popup/btn_zamknij_txt.gif';
                            
                            var setPage = '';
                            
                            if(sSetPage != ''){
                                //setTimeout ( 'var tab = document.location.href.split(\'#\'); document.location.href = sSetPage', 2000);
                                //var tab = document.location.href.split('#'); 
                                //document.location.href = sSetPage;
                                setPage = sSetPage;
                            } else {
                                //setTimeout ( 'var tab = document.location.href.split(\'#\'); document.location.href = tab[0]', 2000);
                                var tab = document.location.href.split('#'); 
                                //document.location.href = tab[0];
                                setPage = tab[0];
                            }
                            
                            
                            var a_element = document.getElementById('a_exit');
                            var a_element2 = document.getElementById('a_exit2');
                            
                            a_element.href = '#'; //obejscie dla IE6
                            a_element.onclick = function reload_page()
                            {
                                document.location.href=setPage;
                            }
                            a_element2.onclick = function reload_page2()
                            {
                                document.location.href=setPage;
                            }
                            
                            
                        }
                    } else {
                        document.getElementById('loadingtd').innerHTML = '<p style="color:#ff0000; font-size:11px; font-weight: bold;" align="center">Błąd logowania<br /></p>';
                    }
                }
            }
        });

    }


    function changeVis(el, bDisplay){
        var type = document.getElementById(el).nodeName;
        if(bDisplay==true){
            if(window.opera){
                if(type=='TD'){
                    document.getElementById(el).style.display = 'table-cell';
                } else if(type=='TR'){
                    document.getElementById(el).style.display = 'table-row';
                } else {
                    document.getElementById(el).style.display = 'block';
                }
            } else if(document.all){
                document.getElementById(el).style.display = 'block';
            } else {
                if(type=='TD'){
                    document.getElementById(el).style.display = 'table-cell';
                } else if(type=='TR'){
                    document.getElementById(el).style.display = 'table-row';
                } else {
                    document.getElementById(el).style.display = 'block';
                }
            }
        } else {
            document.getElementById(el).style.display = 'none';
        }

    }


