
function hide(id){
document.getElementById(id).style.display='none';
}
// pokazywanie i ukrywanie wartsw_____________________________
function hide_layer(id_layer){
document.getElementById(id_layer).style.display='none';
}
function show_layer(id_layer){
document.getElementById(id_layer).style.display='block';
}
function switch_display(id_layer)
    {
    if (document.getElementById(id_layer).style.display=='block')
        {
        hide_layer(id_layer);
    // document.getElementById(id_layer).style.display='none';
        }
    else
        {
        show_layer(id_layer);
    //  document.getElementById(id_layer).style.display='block';
        }

    }
// pokazywanie i ukrywanie wartsw__________________________



function show(id){
var idL=id+'_child';
var idSh=id+'_shadow';
var top = ((screen.height/2)-(180/2));
var left = ((screen.width/2)-(400/2));
document.getElementById(idL).style.left = left+'px';
document.getElementById(idL).style.top = (top-200)+'px';
document.getElementById(idSh).style.left = (left+16)+'px';
document.getElementById(idSh).style.top = (top-200+25)+'px';
document.getElementById(id).style.display='block';
}

function hide_rkl_forView(id)
    {
    document.getElementById(id).style.display='none';
    document.getElementById('form_vis').style.display='block';
    document.getElementById('form_hid').style.display='none';
    //document.forms.choice.ok1.disabled = false;
    //document.forms.choice.ok1.value = 'WYBIERAM  I  WYSYŁAM  DO  KOGO';
    //document.forms.choice.ok2.disabled = false;
    //document.forms.choice.ok2.value = 'WYBIERAM  I  WYSYŁAM  DO  SIEBIE';
   // document.forms.choice.ok1.disabled = false;
   // document.forms.choice.ok1.value = 'WYBIERAM  I  WYSYŁAM  JAKO  E_KARTKĘ';
    }
function Logout()
    {
    document.forms.Logowanie.Login.value = '0';
    document.forms.Logowanie.submit();
    }
function calc()
    {
    var y = document.forms.wyplata.wyp.value;
    var x = isNaN(y);
    if (x)
        {
         document.forms.wyplata.wyp1.value = '0 zł  min. wyplata 25zł';
        }
     else
        {
        if(document.forms.wyplata.wyp.value<0)
            {
             document.forms.wyplata.wyp1.value = '0 zł  min. wyplata 25zł';
            }
       else
            {
            if(document.forms.wyplata.wyp.value<500)
                {
                wartosc = (((document.forms.wyplata.wyp.value)*5)/100);
            document.forms.wyplata.wyp1.value = wartosc+' zł  min. wyplata 25zł';
                }

            else
                {
                    wartosc = (((document.forms.wyplata.wyp.value)*5)/100);
            document.forms.wyplata.wyp1.value = wartosc+' zł *OK*';
                }
            }
        }
    }

function check()
    {
     var y = document.forms.wyplata.wyp.value;
     var x = isNaN(y);
     if (x)
        {
        alert('Błędna wartosc w polu ilosci punktów do wypłaty')
        }
      else
        {
         if(y<500)
            {
            alert('Minimalna wypłata to 500 punktów TP \n co w przeliczeniu wynosi 25 zł')
            }
         else
            {
            document.forms.wyplata.submit();
            }
        }

    }
function del_msg(id_msg)
    {
     document.forms.del_msg1.id_msg_del.value = id_msg;
     document.del_msg1.submit();
    }
function rep_msg(id_msg)
    {
     document.forms.rep_msg1.id_msg_rep.value = id_msg;
     document.rep_msg1.submit();
    }

function show_note(day_note)
    {
    document.getElementById('msg_col_2').innerHTML = day_note;


    }
function fill_fields(date)
    {
    document.getElementById('filled').innerHTML = '<h2 style=\"text-transform:none;\">NOWA NOTATKA NA DZIEŃ :'+date+'</h2>';
    document.forms.add_note1.note_date.value = date;
    }
function checkForm()
    {
     if (document.forms.add_note1.note_title.value!='')
        {
         if (document.forms.add_note1.text_note.value!='')
             {
             document.forms.add_note1.add_note.value = '1';
             document.add_note1.submit();
             }
        }
    }
function show_options(date_y, date_m, date_d)
    {
    info_a = date_y+'-'+date_m+'-'+date_d;
    document.getElementById('edit').innerHTML = '<a href=\"mytpka.php?option=52&year='+date_y+'&month='+date_m+'&day='+date_d+'\">Edytuj Notatki</a>';
    document.getElementById('add').innerHTML = '<a href=\"javascript:hide_options();fill_fields(\''+info_a+'\');show(\'add_note_form\');\">Dodaj Notatkę</a><br /><a href=\"javascript:hide_options();\"><b>ZAMKNIJ</b></a>';
    //getXY(event);
    var xp = getX(event);
    var yp = getY(event);
    movePoint(xp, yp,'note_option');
    document.getElementById('note_option').style.display='block';
    }
function hide_options()
    {
    document.getElementById('note_option').style.display='none';
    }

function getXY(e)
    {
    var posx = 0;
    var posy = 0;
    if (!e) var e = window.event;
    if (e.pageX || e.pageY)
        {
        posx = e.pageX;
        posy = e.pageY;
        }
    else if (e.clientX || e.clientY)
        {
        posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
        posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
        }
    movePoint(posx, posy);
    }
function getX(e)
    {
    var posx = 0;

    if (!e) var e = window.event;
    if (e.pageX || e.pageY)
        {
        posx = e.pageX;

        }
    else if (e.clientX || e.clientY)
        {
        posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;

        }
    return posx;
    }
function getY(e)
    {

    var posy = 0;
    if (!e) var e = window.event;
    if (e.pageX || e.pageY)
        {

        posy = e.pageY;
        }
    else if (e.clientX || e.clientY)
        {

        posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
        }
    return posy;
    }
function movePoint(posx, posy, layer)
    {
    document.getElementById(layer).style.left = (posx+3)  + 'px';
    document.getElementById(layer).style.top = (posy+6) + 'px';
    }
function del_note(idNote)
    {
    document.forms.spc_note_action.add_note_action.value = 'delete';
    document.forms.spc_note_action.add_note_id.value = idNote;
    document.spc_note_action.submit();
    }
function edit_note(p1,p2,p3,p4,p5)
    {
    tytul = p1;
    tekst = p2;
    iledni = p3;
    co_rok = p4;
    idNote = p5;
    tablica = tekst.split("<br />");
    var changed_text ="";
    for(var i=0;i<(tablica.length);i++)
        {
         changed_text=changed_text+tablica[i]+"\n";
        }

    document.forms.spc_note_action.add_note_action.value = 'edit';
    document.forms.spc_note_action.note_title.value = tytul;
    document.forms.spc_note_action.text_note.value = changed_text;
    document.forms.spc_note_action.il_dn.value = iledni;
    if (co_rok ==1)
        {
         document.forms.spc_note_action.co_rok.checked = true;
        }
    else
        {
         document.forms.spc_note_action.co_rok.checked =  false ;
        }

    document.forms.spc_note_action.add_note_id.value = idNote;
    document.forms.spc_note_action.butek.value = 'Zapisz zmiany';

    }
function checkForm_note()
    {
     if (document.forms.spc_note_action.note_title.value!='')
        {
         if (document.forms.spc_note_action.text_note.value!='')
             {
             document.forms.spc_note_action.add_note.value = '1';
             document.spc_note_action.submit();
             }
        }
    }
function resetForm_note()
    {
    document.forms.spc_note_action.add_note_action.value = 'add';
    document.forms.spc_note_action.note_title.value = '';
    document.forms.spc_note_action.text_note.value = '';
    document.forms.spc_note_action.il_dn.value = '3';
    document.forms.spc_note_action.co_rok.checked = true;
    document.forms.spc_note_action.add_note_id.value = '0';
    document.forms.spc_note_action.butek.value = 'Dodaj Nową Notatkę';
    }
function del_all_msg(data)
    {
    document.forms.spc_note_action.note_date.value = data;
    document.spc_note_action.submit();
    }
function del_fav(fav_no)
    {
    document.forms.fav_action.del_fav_id.value = fav_no;
    document.fav_action.submit();
    }
function upl_file()
    {
    if (document.forms.load_file1.plik.value!='')
        {
        document.getElementById('load').style.display='block';

        document.forms.load_file1.submit();
        }


    }

function show_fr_bck(id1, id2)
    {
    document.getElementById(id2).style.display='none';
    document.getElementById(id1).style.display='block';
    }
function upl_font_file()
    {
    if (document.forms.load_font_file1.plik.value!='')
        {
        document.getElementById('load').style.display='block';

        document.forms.load_font_file1.submit();
        }


    }

function checkForm_contact()
    {
    if (document.forms.spc_contact_action.imie.value!='')
        {
        if (document.forms.spc_contact_action.nazwisko.value!='')
            {
            if (document.forms.spc_contact_action.miasto.value!='')
                {
                if (document.forms.spc_contact_action.ulica.value!='')
                    {
                    if (document.forms.spc_contact_action.kod_poczt.value!='')
                        {
                        document.forms.spc_contact_action.submit();
                        }
                    }
                }
            }
        }
    }

function contact_del(idC)
    {
     document.forms.spc_contact_action.action.value = 'del';
     document.forms.spc_contact_action.contactiD.value = idC;
     document.forms.spc_contact_action.submit();
    }
function contact_edit(par1,par2,par3,par4,par5,par6,par7,par8,par9)
    {
     document.forms.spc_contact_action.action.value = 'edit';
     document.forms.spc_contact_action.title.value = par1;
     document.forms.spc_contact_action.imie.value = par2;
     document.forms.spc_contact_action.nazwisko.value = par3;
     document.forms.spc_contact_action.miasto.value = par4;
     document.forms.spc_contact_action.ulica.value = par5;
     document.forms.spc_contact_action.kod_poczt.value = par6;
     document.forms.spc_contact_action.contactiD.value = par7;
     document.getElementById('c_kraj').value = par8;
     document.forms.spc_contact_action.e_mail.value = par9;
     document.forms.spc_contact_action.butek.value = 'Zapisz zmiany';
    }



function resetForm_contact()
    {
    document.forms.spc_contact_action.action.value = 'add';
    document.forms.spc_contact_action.title.value = '';
    document.forms.spc_contact_action.imie.value = '';
    document.forms.spc_contact_action.nazwisko.value = '';
    document.forms.spc_contact_action.miasto.value = '';
    document.forms.spc_contact_action.ulica.value = '';
    document.forms.spc_contact_action.kod_poczt.value = '';
    document.forms.spc_contact_action.contactiD.value = '0';
    document.forms.spc_contact_action.butek.value = 'Dodaj Kontakt';
    }

function show_inserts(id_layer)
    {
    if (document.getElementById(id_layer).style.display=='block')
        {
        document.getElementById(id_layer).style.display='none';
        }
    else
        {
         document.getElementById(id_layer).style.display='block';
        }

    }

function checkForm_ask()
    {
    if (document.forms.spc_add_ask_action.imie_znajomy.value!='')
        {
        if (document.forms.spc_add_ask_action.imie_moje.value!='')
            {
            if (document.forms.spc_add_ask_action.email_znajomy.value!='')
                {

                document.getElementById('load').style.display='block';
                document.forms.spc_add_ask_action.submit();

                }
            }
        }
    }
function ask_again(id_ask)
    {
    document.forms.spc_add_ask_action.ask_ag_id.value = id_ask;
    document.forms.spc_add_ask_action.ask_ag.value = '1';
    document.getElementById('load').style.display='block'; 
    document.forms.spc_add_ask_action.submit();
    }

function confirmation_pdk2(type)
    {
    var check = 0;
    var ornt_poz = document.forms.add_pdk2.podklad_ornt_poz.value;
    var typ=type;
    for (var i=0;i<(typ);i++)
        {
        var pos_X_id = 'wkl_X'+(i+1);
        var pos_Y_id = 'wkl_Y'+(i+1);
        var szr_od = 'wkl_Szr'+(i+1);
        var wys_id = 'wkl_Wys'+(i+1);
        var kat_id = 'wkl_Kat'+(i+1);
        var pos_X = document.getElementById(pos_X_id).value;
        var pos_Y = document.getElementById(pos_Y_id).value;
        var szr = document.getElementById(szr_od).value;
        if (ornt_poz==1)
            {
            if ((szr>1748) || (szr<0))
                {
                szr=1748;
                document.getElementById(szr_od).value=1748;
                }
            }
        else
            {
            if ((szr>1240) ||(szr<0))
                {
                szr=1240;
                document.getElementById(szr_od).value=1240;
                }
            }
        var wys = document.getElementById(wys_id).value;
        if (ornt_poz==1)
            {
            if ((wys>1240) ||(wys<0))
                {
                wys=1240;
                document.getElementById(wys_id).value=1240;
                }
            }
        else
            {
            if ((wys>1748) || (wys<0))
                {
                wys=1748;
                document.getElementById(wys_id).value=1748;
                }
            }
        var kat = document.getElementById(kat_id).value;
        if ((pos_X=='') || (pos_Y=='') || (szr=='') || (wys=='') || (kat==''))
            {
            check = check +1;
            }
         if ((is_numeric(pos_X)!=true) || (is_numeric(pos_Y)!=true) || (is_numeric(szr)!=true) || (is_numeric(wys)!=true) || (is_numeric(kat)!=true))
            {
            check = check +1;
            }
        }

    if (check >0)
        {
        alert('Błędne dane lub puste dane w polach parametrów obszarów wklejek');
        }

     else
        {
        var answer = confirm('Parametry obszaru(ów) wklejek są prawidłowe ?\nPo akceptacji nie będzie możliwości zmiany tych danych !!!')
	    if (answer)
           {
           document.forms.add_pdk2.submit();
	       }
	    else
           {
	       //alert(nie);
	       }
        }

    }

function preview(type)
    {
    var position='';
    var uri ='';
    var tmp_file=document.forms.add_pdk2.plik_podklad.value;
    var ornt_poz = document.forms.add_pdk2.podklad_ornt_poz.value;
    var typ=type;
    var width = 0;
    var height= 0;
    if(ornt_poz==1)
        {
        width=524;
        height=372;
        }
    else
        {
        width=372;
        height=524;
        }
    var check = 0;
    for (var i=0;i<(typ);i++)
        {
        var pos_X_id = 'wkl_X'+(i+1);
        var pos_Y_id = 'wkl_Y'+(i+1);
        var szr_od = 'wkl_Szr'+(i+1);
        var wys_id = 'wkl_Wys'+(i+1);
        var kat_id = 'wkl_Kat'+(i+1);
        var pos_X = document.getElementById(pos_X_id).value;
        var pos_Y = document.getElementById(pos_Y_id).value;
        var szr = document.getElementById(szr_od).value;
        if (ornt_poz==1)
            {
            if ((szr>1748) || (szr<0))
                {
                szr=1748;
                document.getElementById(szr_od).value=1748;
                }
            }
        else
            {
            if ((szr>1240) ||(szr<0))
                {
                szr=1240;
                document.getElementById(szr_od).value=1240;
                }
            }
        var wys = document.getElementById(wys_id).value;
        if (ornt_poz==1)
            {
            if ((wys>1240) ||(wys<0))
                {
                wys=1240;
                document.getElementById(wys_id).value=1240;
                }
            }
        else
            {
            if ((wys>1748) || (wys<0))
                {
                wys=1748;
                document.getElementById(wys_id).value=1748;
                }
            }
        var kat = document.getElementById(kat_id).value;
        position = position+'&'+'Wx'+(i+1)+'='+pos_X;
        position = position+'&'+'Wy'+(i+1)+'='+pos_Y;
        position = position+'&'+'Ws'+(i+1)+'='+szr;
        position = position+'&'+'Ww'+(i+1)+'='+wys;
        position = position+'&'+'Wk'+(i+1)+'='+kat;
        if ((pos_X=='') || (pos_Y=='') || (szr=='') || (wys=='') || (kat==''))
            {
            check = check +1;
            }
        if ((is_numeric(pos_X)!=true) || (is_numeric(pos_Y)!=true) || (is_numeric(szr)!=true) || (is_numeric(wys)!=true) || (is_numeric(kat)!=true))
            {
            check = check +1;
            }
        }
    if (check>0)
        {
        alert('Błędne dane lub puste dane w polach parametrów obszarów wklejek\nWypełnij pola aby aktywować podgląd');
        }
    else

        {
        //alert(position);
         uri = 'file='+tmp_file+position+'&type='+typ+'&orntp='+ornt_poz;
        var ly_prv = document.getElementById('bloczek');
        ly_prv.style.display = 'block';
        ly_prv.innerHTML = '<div style=\"margin-top:15%\"><center><a  href=\"javascript:hide(\'bloczek\')\"><img style=\"border:1px solid #555555;\" src=\"pdkprv.php?'+uri+'\" width=\"'+width+'\" height=\"'+height+'\"/></a></center></div>';
        }
    }

function setTitle()
    {
    if (document.forms.add_pdk.typ_podkladu.value>0)
        {
        document.getElementById('krok').innerHTML = 'Dodawanie nowego podkładu : KROK 1 z 4...<br /><br />';
        }
    else
        {
        document.getElementById('krok').innerHTML = 'Dodawanie nowego podkładu : KROK 1 z 3...<br /><br />';
        }
    }

function confirmation_pdk3()
    {
    if(document.getElementById('Handshage_designer').checked)
        {
        document.getElementById('load').style.display = 'block';
        document.forms.add_pdk3.submit();
        }
    else
        {
        alert('Aby zakończyć dodawanie podkładu należy zaakceptować regulamin.\nZgoda artysty jest kluczowym elementem współpracy Twórców z serwisem.');
        }
    }
function abort_pdk3()
    {
    var answer = confirm('Anulowanie spowoduje wykasowanie załadowanego pliku\ni usunięcie wszystkich zapisanych danych dla tego podkładu !!!');
    if (answer)
        {
        document.forms.add_pdk3.del_pdk_r_form.value = '1';
        document.forms.add_pdk3.step.value = '0';
        document.forms.add_pdk3.submit();
        }
    }
function abort_pdk()
    {
    var answer = confirm('Anulowanie spowoduje wykasowanie załadowanego pliku\ni usunięcie wszystkich zapisanych danych dla tego podkładu !!!');
    if (answer)
        {
        document.forms.add_pdk.del_pdk_r_form.value = '1';
        document.forms.add_pdk.step.value = '0';
        document.forms.add_pdk.submit();
        }
    }

/*function calculate_card_price1(pp)
    {
    var x1 =document.getElementById('format');
    var x = x1.options[x1.selectedIndex].value;
    var y1 =document.getElementById('r_wysylki');
    var y = y1.options[y1.selectedIndex].value;
    var extra = 0;
    if((parseInt(document.getElementById('aw_txt_font_price').value)>0) && (parseInt(document.getElementById('rew_txt_font_price1').value)>0) && (parseInt(document.getElementById('rew_txt_font_price2').value)>0))
        {
        extra = parseInt(document.getElementById('aw_txt_font_price').value);
        }
    else
        {
        if(parseInt(document.getElementById('aw_txt_font_price').value)>0)
            {
            extra = parseInt(document.getElementById('aw_txt_font_price').value);
            }
        if(parseInt(document.getElementById('rew_txt_font_price1').value)>0)
            {
            extra = parseInt(document.getElementById('rew_txt_font_price1').value);
            }
        if(parseInt(document.getElementById('rew_txt_font_price2').value)>0)
            {
            extra = parseInt(document.getElementById('rew_txt_font_price2').value);
            }
        }
    var sum = pp+extra;
    if(x==0)
        {
        sum = sum;
        if(y==1)
        {
        sum = sum+40;
        }
        }
    if(x==1)
        {
        sum = sum+50;
        if(y==1)
        {
        sum = sum+50;
        }
        }
    if(x==2)
        {
        sum = sum+70;
        if(y==1)
        {
        sum = sum+70;
        }
        }



    document.getElementById('pdk_price').innerHTML ="<br />CENA Z WYSŁANIEM&nbsp;ZA&nbsp;SZTUKĘ <br /><h3>&nbsp;&nbsp;&nbsp; "+(sum/100)+" zł / "+(sum/5)+" TP <a href=\"#\" class=\"hintanchor\" onMouseover=\"showhint('Cena zależna jest od:<br />1. Typu kartki,<br />2.Formatu kartki,<br />3.Rodzaju wysyłki.', this, event, '120px')\">[?]</a></h3>";
    document.getElementById('pdk_price_rew').innerHTML ="<br />CENA Z WYSŁANIEM&nbsp;ZA&nbsp;SZTUKĘ <br /><h3>&nbsp;&nbsp;&nbsp; "+(sum/100)+" zł / "+(sum/5)+" TP <a href=\"#\" class=\"hintanchor\" onMouseover=\"showhint('Cena zależna jest od:<br />1. Typu kartki,<br />2.Formatu kartki,<br />3.Rodzaju wysyłki.', this, event, '120px')\">[?]</a></h3>";
    sum = 0;
    }
*/
function file_del_form(idW)
    {
    var p1 = "idP_file_"+idW;
    var p3 = "file_name_"+idW;
    var p4 = "photo_"+idW+"_more";
    var p5 = "photo_"+idW+"_fname";
    var p6 = "photo_"+idW+"_option";
    var p7 = "adv_photo_"+idW;
    var p8 = "idCrpon_"+idW;
    var p9 = "idCrpX_"+idW;
    var p10 = "idCrpY_"+idW;
    var p11 = "idCrpW_"+idW;
    var p12 = "idCrpH_"+idW;
    var p13 = "photo_"+idW+"_image";
    var p14 = "mirror_"+idW;
    var p15 = "gr_filtr_"+idW;
    document.getElementById(p14).value = '0';
    document.getElementById(p15).value = '0';
    document.getElementById(p1).value = '0';
    document.getElementById(p9).value = '0';
    document.getElementById(p10).value = '0';
    document.getElementById(p11).value = '0';
    document.getElementById(p12).value = '0';
    document.getElementById(p8).value = '0';

    var text ="";
    text =  "<h2>Umieszczony obraz (wklejka "+idW+"):<br />&nbsp;&nbsp; Pusty</h2>";
    var text1 = "";
    text1 ="<h2 style=\"font-size:105%;\">Wstaw obraz z:<br />&nbsp; <a href=\"javascript:nulll();\" onclick=\"javascript:dBase_open('"+idW+"');\">Moja baza zdjęć</a>&nbsp;&nbsp;&nbsp;<a href=\"javascript:nulll();\" onclick=\"New_open('"+idW+"');\">Nowy plik</a></h2>";
    document.getElementById(p5).innerHTML = text;
    document.getElementById(p6).innerHTML = text1;
    document.getElementById(p13).innerHTML = "&nbsp;";
    hide_layer(p7);
    hide_layer(p4);
    Crop_del(idW);
    Calculate_quality(0,idW);
    hide_Imageinfo()
    }

function Crop_close()
    {

    document.getElementById('load_ifr').innerHTML = "";
    document.getElementById('load').innerHTML = "";
    hide_layer('load_ifr');
    hide_layer('load');
    }

function Crop_open(idW)
    {
    var x1 = "fileW_"+idW;
    var x2 = "fileH_"+idW;
    windowHeight = document.getElementById(x2).value;
    windowWidth = document.getElementById(x1).value;
    document.getElementById('load_ifr').innerHTML = "<iframe  src=\"_blank\" name=\"Crop_action\"  noresize=\"noresize\" frameborder=\"0\" border=\"0\" cellspacing=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" style=\"width:"+windowWidth+"px;height:"+windowHeight+"px;\"></iframe>";
    show_layer('load_ifr');
    document.getElementById('load_ifr').style.height = document.body.scrollHeight+'px';//'1670px';
    document.body.scrollTop = '0px';
    //document.getElementById('load_ifr').style.paddingTop = '0px';
    var x = "photo_file_"+idW;
    var form = document.getElementById(x);
    form.action = "includes/cropimage/test.cropinterface.php";
    form.target = "Crop_action";
    form.submit();
    }
function Crop_accept(CrOn,CrX,CrY,CrW,CrH,idW)
    {
    var p1= "idCrpon_"+idW;
    var p2= "idCrpX_"+idW;
    var p3= "idCrpY_"+idW;
    var p4= "idCrpW_"+idW;
    var p5= "idCrpH_"+idW;
    document.getElementById(p1).value = CrOn;
    document.getElementById(p2).value = CrX;
    document.getElementById(p3).value = CrY;
    document.getElementById(p4).value = CrW;
    document.getElementById(p5).value = CrH;
    show_layer('image_refresh');
    Crop_close();
    var infoText ="";
    var p6 = "photo_"+idW+"_cropping";
    document.getElementById(p6).innerHTML = "<h2 style=\"font-size:90%;\">Kadrowanie ręczne zdjęcia  >> <a href=\"javascript:nulll();\" onclick=\"Crop_open('"+idW+"');\">Zmień</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"javascript:nulll();\" onclick=\"Crop_del('"+idW+"');\">Usuń</a></h2>";
    Calculate_quality(1,idW);
    send_proj_form(1);
    }
function Crop_del(idW)
    {
    var p1= "idCrpon_"+idW;
    var p2= "idCrpX_"+idW;
    var p3= "idCrpY_"+idW;
    var p4= "idCrpW_"+idW;
    var p5= "idCrpH_"+idW;
    document.getElementById(p1).value = '0';
    document.getElementById(p2).value = '0';
    document.getElementById(p3).value = '0';
    document.getElementById(p4).value = '0';
    document.getElementById(p5).value = '0';
    show_layer('image_refresh');
    var infoText ="";
    var p6 = "photo_"+idW+"_cropping";
    document.getElementById(p6).innerHTML = "<h2 style=\"font-size:90%;\">Kadrowanie ręczne zdjęcia  >> <a href=\"javascript:nulll();\" onclick=\"Crop_open('"+idW+"');\">Kadruj</a></h2>";
    Calculate_quality(1,idW);
    send_proj_form(1);
    }


function New_open(idW)
    {
    document.getElementById('load').innerHTML = "<iframe  src=\"_blank\" name=\"Add_action_new\"  noresize=\"noresize\" frameborder=\"0\" border=\"0\" cellspacing=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" style=\"width:500px;height:400px;\"></iframe>";
    show_layer('load');
    var x = "photo_file_"+idW;
    var form = document.getElementById(x);
    form.action = "includes/filetocard/addnew.php";
    form.target = "Add_action_new";
    form.submit();
    }

function dBase_open(idW)
    {
    document.getElementById('load').innerHTML = "<iframe  src=\"_blank\" name=\"Add_action_dB\"  noresize=\"noresize\" frameborder=\"0\" border=\"0\" cellspacing=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" style=\"width:500px;height:400px;\"></iframe>";
    show_layer('load');
    var x = "photo_file_"+idW;
    var form = document.getElementById(x);
    form.action = "includes/filetocard/addfromdbase.php";
    form.target = "Add_action_dB";
    form.submit();
    }
 function file_add_form(idF,idW,Fname,fileW,fileH,FileUrl,file_org_W,file_org_H)
    {
    var p1 = "idP_file_"+idW;
    var p3 = "file_name_"+idW;
    var p4 = "photo_"+idW+"_more";;
    var p5 = "photo_"+idW+"_fname";
    var p6 = "photo_"+idW+"_option";
    var p7 = "fileW_"+idW;
    var p8 = "fileH_"+idW;
    var p9 = "photo_"+idW+"_image";
    var p10 = "mirror_"+idW;
    var p11 = "gr_filtr_"+idW;
    var p12 = "org_W_"+idW;
    var p13 = "org_H_"+idW;
    document.getElementById(p10).value = '0';
    document.getElementById(p11).value = '1';
    document.getElementById(p7).value = fileW;
    document.getElementById(p8).value = fileH;
    document.getElementById(p1).value = idF;
    document.getElementById(p12).value = file_org_W;
    document.getElementById(p13).value = file_org_H;
    var text ="";
    text =  "<h2>Umieszczony obraz (wklejka "+idW+"):<br />&nbsp;&nbsp; "+Fname+"</h2>";
    var text1 = "";
    text1 ="<h2 style=\"font-size:105%;\"><a href=\"javascript:nulll();\" onclick=\"file_del_form('"+idW+"');\">Usuń obraz</a><br /><br />Zmień obraz na inny z :<br />&nbsp; <a href=\"javascript:nulll();\" onclick=\"javascript:dBase_open('"+idW+"');\">Moja baza zdjęć</a>&nbsp;&nbsp;&nbsp;<a href=\"javascript:nulll();\" onclick=\"New_open('"+idW+"');\">Nowy plik</a></h2>";
    document.getElementById(p5).innerHTML = text;
    document.getElementById(p6).innerHTML = text1;
    var rozmiary = '';

    if ((fileW-2)>(fileH-164))
        {
        rozmiary = "width=\""+120+"\" height=\""+Math.round(((fileH-164)*(120/(fileW-2))))+"\"";
         }
    else
        {
        rozmiary = "height=\""+120+"\" width=\""+Math.round(((fileW-2)*(120/(fileH-164))))+"\"";
        }
    var text2 = "<img src=\"images/zdjecia_wklejki/iconed/"+FileUrl+"\" "+rozmiary+" />";
    document.getElementById(p9).innerHTML = text2;
    show_layer(p4);
    show_layer('image_refresh');
    //dd.elements.txt_aw.hide()
   // dd.elements.txt_aw.setZ(0);
    Calculate_quality(1,idW);
    Crop_del(idW);
    Crop_close();
    show_layer('adv_photo_'+idW);
    send_proj_form(1);
    show_layer('adv_photo_info');
    }

function Calculate_quality(on,idW)
    {
    var p1 = "photo_"+idW+"_quality";
    var p2 = "fileW_"+idW;
    var p3 = "fileH_"+idW;
    var p4 = "org_W_"+idW;
    var p5 = "org_H_"+idW;
    var p6 = "wkl_W_"+idW;
    var p7 = "wkl_H_"+idW;
    var p8 = "idCrpW_"+idW;
    var p9 = "idCrpH_"+idW;
    var p10 = "idCrpon_"+idW;
    var Qh = 0;
    var Qw = 0;
    var Qall = 0;
    var tempw1 = 0;
    var temph1 = 0;
    var tempw2 = 0;
    var temph2 = 0;
    var color = '#00FF00';
    var r = '00';
    var g = 'FF';
    var tempg = 0;
    var tempr = 0;
    var wsk = 0;
    var x =40;
    var dz = 0.1;
    var qu_txt = 'Bardzo dobra';
    if (on==1)
        {
        if(parseInt(document.getElementById(p10).value)==1) // crop zalaczone
            {
            tempw1 =(parseInt(document.getElementById(p4).value))/(parseInt(document.getElementById(p2).value)-2);
            tempw2 = tempw1*(parseInt(document.getElementById(p8).value));
            Qw = Math.round((tempw2/parseInt(document.getElementById(p6).value))*100);
            temph1 =(parseInt(document.getElementById(p5).value))/(parseInt(document.getElementById(p3).value)-234);
            temph2 = temph1*(parseInt(document.getElementById(p9).value));
            Qh = Math.round((temph2/parseInt(document.getElementById(p7).value))*100);
            if(Qw>=Qh)
                {
                Qall = Qh;
                }
            else
                {
                Qall = Qw;
                }
            if(Qall>100)
                {
                Qall = 100;
                }
            if(Qall<80)
                {
                qu_txt = 'Dobra';
                if(Qall<70)
                    {
                    qu_txt = 'Wystarczająca';
                    if(Qall<50)
                        {
                        qu_txt = 'Słaba';
                        if(Qall<40)
                            {
                            qu_txt = 'Bardzo słaba';
                            if(Qall<30)
                                {
                                qu_txt = 'Niewystarczająca';
                                }
                            }
                        }
                    }
                }
            //dz = Qall/100;
            if(Qall>=50)
                {
                dz = Qall/100;
                tempg = Math.round(100*(228/100));
                tempr = Math.round((100-(Qall*dz))*(228/100));
                }
            else
                {
                dz = 1-(Qall/100);
                tempg = Math.round((100*(1-dz)+Qall*dz)*(228/100));
                tempr = Math.round((100)*(228/100));
                }
            //tempg = Math.round(Qall*(255/100));
            //tempr = Math.round((100-Qall)*(255/100));
            r = tempr.toString(16);
            g = tempg.toString(16);
            if(g.length==1)
                {
                 g='0'+g;
                }
            if(r.length==1)
                {
                 r='0'+r;
                }
            color = '#'+r+g+'00';
            //Qall = 90;
            document.getElementById(p1).innerHTML = '<div>Szacowana jakość po wydruku : '+Qall+'%&nbsp; ('+qu_txt+')<div style="width:150px;border:1px solid #000000;"><div style="width:'+Math.round(Qall*(150/100))+'px;height:8px;background:'+color+';"></div></div></div>';
            }
        else
            {
            Qw = Math.round((parseInt(document.getElementById(p4).value)/parseInt(document.getElementById(p6).value)*100));
            Qh = Math.round((parseInt(document.getElementById(p5).value)/parseInt(document.getElementById(p7).value)*100));
            //Qall = Math.round((Qw+Qh)/2);
            if(Qw>=Qh)
                {
                Qall = Qh;
                }
            else
                {
                Qall = Qw;
                }
            if(Qall>100)
                {
                Qall = 100;
                }
            if(Qall<80)
            {
            qu_txt = 'Dobra';
            if(Qall<70)
                {
                qu_txt = 'Wystarczająca';
                if(Qall<50)
                    {
                    qu_txt = 'Słaba';
                    if(Qall<40)
                        {
                        qu_txt = 'Bardzo słaba';
                        if(Qall<30)
                            {
                            qu_txt = 'Niewystarczająca';
                            }
                        }
                    }
                }
            }
            //dz = Qall/100;
            if(Qall>=50)
                {
                dz = Qall/100;
                tempg = Math.round(100*(228/100));
                tempr = Math.round((100-(Qall*dz))*(228/100));
                }
            else
                {
                dz = 1-(Qall/100);
                tempg = Math.round((100*(1-dz)+Qall*dz)*(228/100));
                tempr = Math.round((100)*(228/100));
                }
            //tempg = Math.round(Qall*(255/100));
            //tempr = Math.round((100-Qall)*(255/100));
            r = tempr.toString(16);
            g = tempg.toString(16);
            if(g.length==1)
                {
                 g='0'+g;
                }
            if(r.length==1)
                {
                 r='0'+r;
                }
            color = '#'+r+g+'00';
            //Qall = 90;
            document.getElementById(p1).innerHTML = '<div>Szacowana jakość po wydruku : '+Qall+'%&nbsp; ('+qu_txt+')<div style="width:150px;border:1px solid #000000;"><div style="width:'+Math.round(Qall*(150/100))+'px;height:8px;background:'+color+';"></div></div></div>';
            }
        }
    else
        {
        document.getElementById(p1).innerHTML = '&nbsp;';
        }
    }

function aw_refresh()
    {
    var or;
    var wymiary;
    if(document.getElementById('pdk_or').value=='0')
        {
        or = 0;
        wymiary = ' width="333" height="470"';
        }
    else
        {
        or = 1;
        wymiary = ' width="470" height="333"';
        }
    document.getElementById('txt_aw').innerHTML = '<img src="textforviewawers.php?from=self&or='+or+'&id='+Math.random(100)+'" />';
    // aktywaqcja wstawiania obrazów widokow pocztowki i teksu
   document.getElementById('image').innerHTML = '<img src="forviewawersnotext.php?from=self&or='+or+'&id='+Math.random(100)+'" '+wymiary+'/>';

   // wait('2000');
    setTimeout("hide_layer('image_prepare')",1500);
    //hide_layer('image_prepare');
    }
function send_proj_form(act_step)
    {
    if(act_step==1)
        {
        hide_layer('image_refresh');
        show_layer('image_prepare');
        document.getElementById('ref1').value = '1';
        document.getElementById('ref2').value = '0';
        document.getElementById('flo4').value = '0';
        }
    if(act_step==2)
        {
        hide_layer('rew_refresh');
        show_layer('rew_prepare');
        document.getElementById('ref1').value = '0';
        document.getElementById('ref2').value = '1';
        document.getElementById('flo4').value = '0';
        }
    if(act_step==3)
        {
        //warstwa z img zapisem do my projects
        var message = '';
        message = '<center>';
        message = message+'<b style="font-size:140%;">Trwa zapisywanie danych projektu<br />w Twojej bazie \'Moje Projekty\'</b><br /><br />';
        message = message+'<img src="images/strona/load.gif" width="120" height="30" alt="Ładowanie pliku" />';
        message = message+'</center>';
        show_layer('load');
        document.getElementById('load').innerHTML = message;
        document.getElementById('ref1').value = '0';
        document.getElementById('ref2').value = '0';
        document.getElementById('flo4').value = '1';
        }
    move_aw_datas_txt();
    move_aw_design_datas();
    move_proj_detail();
    move_rew_s1_details();
    move_rew_s2_details();
    move_reciv_details();

    document.getElementById('main_st0').submit();
    }
function projbarRefresh(idCurrProj,error,error_info)
    {
    var czas  = new Date();
    if(error==0)
        {
        document.getElementById('flo2').value = idCurrProj;
        document.getElementById('load').innerHTML = '';
        hide_layer('load');
        var add_div = '';
        var save_info = '';
        save_info = '<div style="width:159px;background:#EEF8DE;border: 2px solid #95AB6E;color:#95AB6E;"><h2 style="font-size:95%;text-align:center;padding-left:15px;padding-right:15px;">Projekt został pomyślnie zapisany o godzinie<br />'+czas.getHours()+':'+czas.getMinutes()+':'+czas.getSeconds()+'</h2></div>';
        add_div = '<h2 style="font-size:150%;text-align:center;padding-left:15px;padding-right:15px;">Zapisz Zmiany</h2><h2 style="font-size:100%;text-align:center;padding-left:15px;padding-right:15px;font-weight:normal;">Aktualizuje wpis w akualnie zapisanym projekcie w Twojej bazie projektów</h2>';
        add_div = add_div+'<input class="button" type="button" value="Zapisz Projekt" style="margin-left:25px;" onclick="saveProjectinMyProjectsAsCurrent();" />';
        document.getElementById('sasc').innerHTML = add_div;
        document.getElementById('bask_info').innerHTML = save_info;
        show_layer('bask_info');
        }
    else
        {
        var save_info = '';
        save_info = '<div style="width:159px;background:#FFF1F1;border: 2px solid #D17B7B;color:#D17B7B;"><h2 style="font-size:95%;text-align:center;padding-left:15px;padding-right:15px;">Błąd podczas zapisywania projektu<br />'+czas.getHours()+':'+czas.getMinutes()+':'+czas.getSeconds()+'</h2></div>';
        var message = '';
        message = '<center>';
        message = message+'<b style="font-size:140%;">BŁĄ&nbsp;ZAPISU&nbsp;DO&nbsp;BAZY<br /> \'Moje Projekty\'</b><br /><br />';
        message = message+'<img src="images/strona/load.gif" width="120" height="30" alt="Ładowanie pliku" />';
        message = message+'<br /><b style="font-size:200%;"><a href="javascript:hide_layer(\'load\');">ZAMKNIJ</a></b></center>';
        document.getElementById('flo2').value = idCurrProj;
        document.getElementById('load').innerHTML = message;
        document.getElementById('bask_info').innerHTML = save_info;
        show_layer('bask_info');
        //hide_layer('load');
        }

    }
function move_aw_datas_txt()
    {
    if (document.getElementById('tekst_awersu').value!='')
        {
        document.getElementById('aw1').value = '1';
        document.getElementById('aw2').value = document.getElementById('aw_txt_poz_x').value;
        document.getElementById('aw3').value = document.getElementById('aw_txt_poz_y').value;
        document.getElementById('aw4').value = document.getElementById('aw_font_type').value;
        document.getElementById('aw5').value = document.getElementById('aw_font_siz').value;
        document.getElementById('aw6').value = document.getElementById('aw_col').value;
        if(document.getElementById('aw_sh_on').checked)
            {
            document.getElementById('aw7').value = '1';
            }
        else
            {
            document.getElementById('aw7').value = '0';
            }
        document.getElementById('aw8').value = document.getElementById('aw_sh_col').value;
        document.getElementById('aw9').value = document.getElementById('tekst_awersu').value;
        //document.getElementById('ref1').value = '1';
        dd.elements.txt_aw.show();
        }
    else
        {
        document.getElementById('aw1').value = '1';
        document.getElementById('aw2').value = document.getElementById('aw_txt_poz_x').value;
        document.getElementById('aw3').value = document.getElementById('aw_txt_poz_y').value;
        document.getElementById('aw4').value = document.getElementById('aw_font_type').value;
        document.getElementById('aw5').value = document.getElementById('aw_font_siz').value;
        document.getElementById('aw6').value = document.getElementById('aw_col').value;
        if(document.getElementById('aw_sh_on').checked)
            {
            document.getElementById('aw7').value = '1';
            }
        else
            {
            document.getElementById('aw7').value = '0';
            }
        document.getElementById('aw8').value = document.getElementById('aw_sh_col').value;
        document.getElementById('aw9').value = document.getElementById('tekst_awersu').value;
       dd.elements.txt_aw.moveTo(dd.elements.txt_aw.defx, dd.elements.txt_aw.defy)
        dd.elements.txt_aw.hide();
        }

    }
function move_proj_detail()
    {
    document.getElementById('pdk1').value = document.getElementById('pdk_gr_fl').value;
    //document.getElementById('pdk2').value = document.getElementById('ch_ornt').value;
    //document.getElementById('pdk3').value = document.getElementById('mirror_pdk').value;
    document.getElementById('all1').value = document.getElementById('all_gr_fl').value;
    document.getElementById('pr1').value = document.getElementById('idKrt').value;
    document.getElementById('pdk4').value = document.getElementById('rew_txt_bck').value

    }
function move_aw_design_datas()
    {
    var x = document.getElementById('idKtyp').value;//-1;
    if (x>1)
        {
        for (i=1;i<x;i++)
            {
            var from1 = 'idP_file_'+i;
            var from2 = 'mirror_'+i;
            var from3 = 'gr_filtr_'+i;
            var from4 = 'idCrpon_'+i;
            var from5 = 'idCrpX_'+i;
            var from6 = 'idCrpY_'+i;
            var from7 = 'idCrpW_'+i;
            var from8 = 'idCrpH_'+i;
            var to1 = 'p'+i+'1';
            var to2 = 'p'+i+'2';
            var to3 = 'p'+i+'3';
            var to4 = 'p'+i+'4';
            var to5 = 'p'+i+'5';
            var to6 = 'p'+i+'6';
            var to7 = 'p'+i+'7';
            var to8 = 'p'+i+'8';
            document.getElementById(to1).value = document.getElementById(from1).value;
            document.getElementById(to2).value = document.getElementById(from2).value;
            document.getElementById(to3).value = document.getElementById(from3).value;
            document.getElementById(to4).value = document.getElementById(from4).value;
            document.getElementById(to5).value = document.getElementById(from5).value;
            document.getElementById(to6).value = document.getElementById(from6).value;
            document.getElementById(to7).value = document.getElementById(from8).value;
            document.getElementById(to8).value = document.getElementById(from7).value;
            }
        }
    }
function move_rew_s1_details()
    {
    //document.getElementById('s11').value = document.getElementById(from1).value;
    document.getElementById('s12').value = document.getElementById('tekst_rewersu1').value;
    document.getElementById('s13').value = document.getElementById('rew_text_align1').value;
    document.getElementById('s14').value = document.getElementById('rew_font_type1').value;
    document.getElementById('s15').value = document.getElementById('rew_text_fntsz1').value;
    document.getElementById('s16').value = document.getElementById('rew_txt_font_color1').value;
    document.getElementById('s17').value = document.getElementById('rew_text_vlign1').value;

    }
function move_rew_s2_details()
    {
    //document.getElementById('s21').value = document.getElementById(from1).value;
    document.getElementById('s22').value = document.getElementById('tekst_rewersu2').value;
    document.getElementById('s23').value = document.getElementById('rew_text_align2').value;
    document.getElementById('s24').value = document.getElementById('rew_font_type2').value;
    document.getElementById('s25').value = document.getElementById('rew_text_fntsz2').value;
    document.getElementById('s26').value = document.getElementById('rew_txt_font_color2').value;
    document.getElementById('s27').value = document.getElementById('rew_text_vlign2').value;
    }
function move_reciv_details()
    {
    document.getElementById('pr2').value = document.getElementById('format').value;
    document.getElementById('pr3').value = document.getElementById('r_wysylki').value;
    document.getElementById('pr4').value = document.getElementById('data_wys').value;
    //document.getElementById('pr').value = document.getElementById('').value;
    document.getElementById('pr6').value = document.getElementById('pr_tryb').value;
    document.getElementById('pr7').value = document.getElementById('ilosc_zestaw').value;
    document.getElementById('pr8').value = document.getElementById('accept_promotion').value;
    }
function rew_refresh()
    {
    var x1 =document.getElementById('format');
    var x = x1.options[x1.selectedIndex].value;
    ornt = document.getElementById('pdk_or').value;
    idbck = document.getElementById('rew_txt_bck').value;
    if (x==1)
        {

        document.getElementById('rew').innerHTML = '<img src="forviewrewers.php?from=self&id='+Math.random(100)+'&s=1" width="524" height="372"/>';
        }
    if (x==2)
        {
        if(ornt==0)
            {
            par = ' width="744" height="524"';
            }
        else
            {
            par = ' width="524" height="744"';
            }
        // aktywacja widoku rewersu kartki A
        document.getElementById('rew').innerHTML = '<img src="forviewrewers_card.php?from=self&id='+Math.random(100)+'&idC='+idbck+'&or='+ornt+'" '+par+'/>';

        }
    if (x==3)
        {
        if(ornt==0)
            {
            par = ' width="744" height="524"';
            }
        else
            {
            par = ' width="524" height="744"';
            }
        // aktywacja widoku rewersu kartki B
        document.getElementById('rew').innerHTML = '<img src="forviewrewers_card.php?from=self&id='+Math.random(100)+'&idC='+idbck+'&or='+ornt+'" '+par+'/>';

        }
    // wait('2000');
    setTimeout("hide_layer('rew_prepare')",1500);
    //hide_layer('image_prepare');
    }

function nulll()
    {

    }

function set_aw_font(font, idfont,ad_fn_price,card_price)
    {
    document.getElementById('f_img').innerHTML = "<img src=\"choice_font.php?font="+font+"&ftxt=topfont%20nr%20"+idfont+"\" />";
    document.getElementById('aw_font_type').value = idfont;
    document.getElementById('aw_txt_font_price').value=ad_fn_price;
    hide_layer('font_choice');
    show_layer('image_refresh');
     var option = document.getElementById('pr_tryb').value;
    if(option==1)
        {
        calculate_card_price1(card_price);
        }
    if(option==2)
        {
        calculate_card_price2(card_price);
        }
    if(option==3)
        {
        calculate_card_price3(card_price);
        }
    }
function show_aw_fonts()
    {
    show_layer('font_choice');
    }
function set_rew_font1(font, idfont,ad_fn_price,card_price)
    {
    document.getElementById('f_rew_img1').innerHTML = "<img src=\"choice_font.php?font="+font+"&ftxt=topfont%20nr%20"+idfont+"\" />";
    document.getElementById('rew_font_type1').value = idfont;
    document.getElementById('rew_txt_font_price1').value=ad_fn_price;
    hide_layer('font_choice1');
    show_layer('rew_refresh');
     var option = document.getElementById('pr_tryb').value;
    if(option==1)
        {
        calculate_card_price1(card_price);
        }
    if(option==2)
        {
        calculate_card_price2(card_price);
        }
    if(option==3)
        {
        calculate_card_price3(card_price);
        }
    }
function set_rew_font2(font, idfont,ad_fn_price,card_price)
    {
    document.getElementById('f_rew_img2').innerHTML = "<img src=\"choice_font.php?font="+font+"&ftxt=topfont%20nr%20"+idfont+"\" />";
    document.getElementById('rew_font_type2').value = idfont;
    document.getElementById('rew_txt_font_price2').value=ad_fn_price;
    hide_layer('font_choice2');
    show_layer('rew_refresh');
     var option = document.getElementById('pr_tryb').value;
    if(option==1)
        {
        calculate_card_price1(card_price);
        }
    if(option==2)
        {
        calculate_card_price2(card_price);
        }
    if(option==3)
        {
        calculate_card_price3(card_price);
        }
    }
function switch_step(step_sh,step_hd)
    {
    var sh = 'step'+step_sh;
    var hd = 'step'+step_hd;
    document.getElementById(hd).style.display = 'none';
    document.getElementById(sh).style.display = 'block';

    }
function prepare_card(card_price)
    {

    var x1 =document.getElementById('format');
    var x = x1.options[x1.selectedIndex].value;
    var option = document.getElementById('pr_tryb').value;
    if(option==1)
        {
        calculate_card_price1(card_price);
        }
    if(option==2)
        {
        calculate_card_price2(card_price);
        }
    if(option==3)
        {
        calculate_card_price3(card_price);
        }

    var innerText = '';
    destinDiv = document.getElementById('pkd_part5');
    idbck = document.getElementById('rew_txt_bck').value;
    ornt = document.getElementById('pdk_or').value;
    var par = '';
    var par1 = '';
    var marginLeft = '';
    if (x==1)
        {
        marginLeft = 'margin-left:100px;';
        hide_layer('rew_text2');
       // document.getElementById('rew_txt_bck_img').innerHTML = '<img src="choice_bck.php?bck=0" />';
        //document.getElementById('rew_txt_font_color1').value = '000000';
        hide_layer('rew_txt_font_color1_view');
        hide_layer('rew_txt_bck_view');
      //  document.getElementById('rew_txt_bck').value = '0';
        //document.getElementById('rew_txt_font_color1').value = '000000';
        //document.getElementById('rew').innerHTML = '<img src="forviewrewers.php?from=self&id='+Math.random(100)+'&s=1" width="470" height="333"/>';
        par = ' width="524" height="372"';
        par1 ='width:524px;height:372px;';
        innerText = '<div id="pdk_part5_title" style="text-align:center;background:#F0F0F0;border:1px solid #DCDCDC;"><h3>Parametry tekstu na awersie</h3></div>';
        innerText = innerText + '<div id="rew_area" style="border:1px solid #000000;margin-top:5px;margin-bottom:5px;float:left;'+par1+'padding:0px 0px 0px 0px;'+marginLeft+'">';
        innerText = innerText + '<div id="rew_all" style="overflow:hidden;position:relative;top:0;left:0;'+par1+'">';
        innerText = innerText + '<div id="rew" style="position:relative;top:0;left:0;'+par1+'">';
        innerText = innerText + '<img src="forviewrewers.php?from=self&id='+Math.random(100)+'&idC='+idbck+'" '+par+'/>';
        innerText = innerText + '</div>';
        innerText = innerText + '<div id="rew_refresh" style="position:absolute;'+par1+'top:0%;left:0%;display:none;cursor:pointer;background-image:url(images/strona/tlo_block.png);background-repeat: repeat;" onclick="send_proj_form(2);">';
        innerText = innerText + '<center><b style="font-size:140%;"><br /><br /><br /><br /><br /><br /><br />Kliknij aby odświeżyć<br />widok rewersu</b><br /><br />';
        innerText = innerText + '<img src="images/strona/load.gif" width="120" height="30" alt="Ładowanie pliku" /></center>';
        innerText = innerText + '</div>';
        innerText = innerText + '<div id="rew_prepare" style="position:absolute;'+par1+'top:0%;left:0%;display:none;background-image:url(images/strona/tlo_block.png);background-repeat: repeat;">';
        innerText = innerText + '<center><b style="font-size:140%;"><br /><br /><br /><br /><br /><br /><br />Generowanie tekstu</b><br /><br />';
        innerText = innerText + '<img src="images/strona/load.gif" width="120" height="30" alt="Ładowanie pliku" /></center>';
        innerText = innerText + '</div>';
        innerText = innerText + '</div>';
       // innerText = innerText + '</div>';
        destinDiv.innerHTML = innerText;

        send_proj_form(2);
        }
    if (x==2)
        {
        show_layer('rew_text2');
        show_layer('rew_txt_font_color1_view');
        show_layer('rew_txt_bck_view');
        if(ornt==0)
            {
            par = ' width="744" height="524"';
            par1 ='width:744px;height:524px;';
            marginLeft = 'margin-left:10px;';
            }
        else
            {
            par = ' width="524" height="744"';
            par1 ='width:524px;height:744px;';
            marginLeft = 'margin-left:100px;';
            }
        innerText = '<div id="pdk_part5_title" style="text-align:center;background:#F0F0F0;border:1px solid #DCDCDC;"><h3>Parametry tekstu na awersie</h3></div>';
        innerText = innerText + '<div id="rew_area" style="border:1px solid #000000;margin-top:5px;margin-bottom:5px;float:left;'+par1+'padding:0px 0px 0px 0px;'+marginLeft+'">';
        innerText = innerText + '<div id="rew_all" style="overflow:hidden;position:relative;top:0;left:0;'+par1+'">';
        innerText = innerText + '<div id="rew" style="position:relative;top:0;left:0;'+par1+'">';
        innerText = innerText + '<img src="forviewrewers_card.php?from=self&id='+Math.random(100)+'&idC='+idbck+'&or='+ornt+'" '+par+'/>';
        innerText = innerText + '</div>';
        innerText = innerText + '<div id="rew_refresh" style="position:absolute;'+par1+'top:0%;left:0%;display:none;cursor:pointer;background-image:url(images/strona/tlo_block.png);background-repeat: repeat;" onclick="send_proj_form(2);">';
        innerText = innerText + '<center><b style="font-size:140%;"><br /><br /><br /><br /><br /><br /><br />Kliknij aby odświeżyć<br />widok rewersu</b><br /><br />';
        innerText = innerText + '<img src="images/strona/load.gif" width="120" height="30" alt="Ładowanie pliku" /></center>';
        innerText = innerText + '</div>';
        innerText = innerText + '<div id="rew_prepare" style="position:absolute;'+par1+'top:0%;left:0%;display:none;background-image:url(images/strona/tlo_block.png);background-repeat: repeat;">';
        innerText = innerText + '<center><b style="font-size:140%;"><br /><br /><br /><br /><br /><br /><br />Generowanie tekstu</b><br /><br />';
        innerText = innerText + '<img src="images/strona/load.gif" width="120" height="30" alt="Ładowanie pliku" /></center>';
        innerText = innerText + '</div>';
        innerText = innerText + '</div>';
       // innerText = innerText + '</div>';
        destinDiv.innerHTML = innerText;
        send_proj_form(2);
        // aktywacja widoku rewersu kartki A
        //document.getElementById('rew').innerHTML = '<img src="forviewrewers_card.php?from=self&id='+Math.random(100)+'" width="470" height="333"/>';

        }
    if (x==3)
        {
        show_layer('rew_text2');
        show_layer('rew_txt_font_color1_view');
        show_layer('rew_txt_bck_view');
        // aktywacja widoku rewersu kartki B
        //document.getElementById('rew').innerHTML = '<img src="forviewrewers_card.php?from=self&id='+Math.random(100)+'" width="470" height="333"/>';
        if(ornt==0)
            {
            par = ' width="744" height="524"';
            par1 ='width:744px;height:524px;';
            marginLeft = 'margin-left:10px;';
            }
        else
            {
            par = ' width="524" height="744"';
            par1 ='width:524px;height:744px;';
            marginLeft = 'margin-left:100px;';
            }
        innerText = '<div id="pdk_part5_title" style="text-align:center;background:#F0F0F0;border:1px solid #DCDCDC;"><h3>Parametry tekstu na awersie</h3></div>';
        innerText = innerText + '<div id="rew_area" style="border:1px solid #000000;margin-top:5px;margin-bottom:5px;float:left;'+par1+'padding:0px 0px 0px 0px;'+marginLeft+'">';
        innerText = innerText + '<div id="rew_all" style="overflow:hidden;position:relative;top:0;left:0;'+par1+'">';
        innerText = innerText + '<div id="rew" style="position:relative;top:0;left:0;'+par1+'">';
        innerText = innerText + '<img src="forviewrewers_card.php?from=self&id='+Math.random(100)+'&idC='+idbck+'&or='+ornt+'" '+par+'/>';
        innerText = innerText + '</div>';
        innerText = innerText + '<div id="rew_refresh" style="position:absolute;'+par1+'top:0%;left:0%;display:none;cursor:pointer;background-image:url(images/strona/tlo_block.png);background-repeat: repeat;" onclick="send_proj_form(2);">';
        innerText = innerText + '<center><b style="font-size:140%;"><br /><br /><br /><br /><br /><br /><br />Kliknij aby odświeżyć<br />widok rewersu</b><br /><br />';
        innerText = innerText + '<img src="images/strona/load.gif" width="120" height="30" alt="Ładowanie pliku" /></center>';
        innerText = innerText + '</div>';
        innerText = innerText + '<div id="rew_prepare" style="position:absolute;'+par1+'top:0%;left:0%;display:none;background-image:url(images/strona/tlo_block.png);background-repeat: repeat;">';
        innerText = innerText + '<center><b style="font-size:140%;"><br /><br /><br /><br /><br /><br /><br />Generowanie tekstu</b><br /><br />';
        innerText = innerText + '<img src="images/strona/load.gif" width="120" height="30" alt="Ładowanie pliku" /></center>';
        innerText = innerText + '</div>';
        innerText = innerText + '</div>';
       // innerText = innerText + '</div>';
        destinDiv.innerHTML = innerText;
        send_proj_form(2);
        }


    }
function t_aform(txt_no)
    {
    var p1  = 'auf_t'+txt_no;
    var p2  = 'rew_text_align'+txt_no;
    var p3 = 'rew_text_vlign'+txt_no;
    var p4 = 'rew_text_fntsz'+txt_no;
    var p5 = 'additional_set_txt'+txt_no;
    if(document.getElementById(p1).checked)
        {
        show_layer('rew_refresh');
        document.getElementById(p2).value = '1';
        document.getElementById(p3).value = '1';
        document.getElementById(p4).value = '0';
        hide_layer(p5);

        }
    else
        {
        show_layer(p5);
        }
    }
function insert_new_receiver()
    {
        var p1 = document.getElementById('c_ttl').value;
        var p2 = document.getElementById('c_im').value;
        var p3 = document.getElementById('c_naz').value;
        var p4 = document.getElementById('c_mi').value;
        var p5 = document.getElementById('c_ul').value;
        var p6 = document.getElementById('c_country').value;
        var p7 = document.getElementById('c_kod').value;
        var p8 = document.getElementById('add_con_DB');
        if(p2!='' && p3!='' && p4!='' && p5!='' && p7!='')
            {
            var x = document.getElementById('wpisy').rows;
            var ilwierszy  = x.length;

            var x_akt=document.getElementById('wpisy').insertRow(ilwierszy);
            document.getElementById('wpisy').rows[ilwierszy].align = 'center';
            // 1-tekst notatki, coroczne,(rok, miesiac, dzien )-data;
            var Rec_data=x_akt.insertCell(0);
            var Country = x_akt.insertCell(1);
            var Country_cost = x_akt.insertCell(2);
            var DB_add = x_akt.insertCell(3);
            var Option = x_akt.insertCell(4);
            //Rec_data.style.scrollLeft = '50px';
          //  Rec_data.innerHTML = p1+'<br />'+p2+'<br />'+p3+'<br />'+p4+'br />'+p5+'<br />'+p7;
            if(p1=='0')
                {
                Rec_data.innerHTML = ' :';
                }
            else
                {
                Rec_data.innerHTML = p1+':';
                }

            Rec_data.innerHTML = Rec_data.innerHTML+p2+':';
            Rec_data.innerHTML = Rec_data.innerHTML+p3+':';
            Rec_data.innerHTML = Rec_data.innerHTML+p4+':';
            Rec_data.innerHTML = Rec_data.innerHTML+p5+':';
            Rec_data.innerHTML = Rec_data.innerHTML+p7;
            Country.innerHTML = p6+'/id/.      '+getcounrty_name(parseInt(p6));
           // Country_cost.innerHTML = '45 gr';
            Country_cost.innerHTML = getAddPrice(parseInt(p6))+' gr';
            if(p8.checked)
                {
                DB_add.innerHTML = '1/id/TAK';
                }
            else
                {
                DB_add.innerHTML = '0/id/NIE';
                }
           // text_opcji = '<div id=\"r'+ilwierszy+'\"><center><b><a href=\"javascript:edit_note(\''+(ilwierszy+0)+'\')\">Zmień</a><br /><a href=\"javascript:usun_note(\''+(ilwierszy+0)+'\')\">Usuń</a></b></center></div>';
            text_opcji = '<div id=\"r'+ilwierszy+'\"><center><b><br /><a href=\"javascript:usun_odbiorce(\''+(ilwierszy+0)+'\')\">Usuń</a></b></center></div>';


           Option.innerHTML = text_opcji;
            var ilwierszy1 = ilwierszy+1;
            if (ilwierszy1 >1)
                {
                show_layer('But_go_basket');
                show_layer('Adresaci');
                document.getElementById('Adr_data').reset();
                }
         //   var proj_price_PLN = ((ilwierszy1-1)*parseInt(document.getElementById('all_cost').value))/100;
         //   var proj_price_TP = ((ilwierszy1-1)*parseInt(document.getElementById('all_cost').value))/5;
         //   document.getElementById('pdk_price_adr2').innerHTML = '<br />CENA CAŁKOWITA <br /><h3>&nbsp;&nbsp;'+proj_price_PLN+' zł/ '+proj_price_TP+' TP <br />&nbsp;&nbsp;&nbsp;(Adresatów : '+(ilwierszy1-1)+' )<a href="#" class="hintanchor" onMouseover="showhint(\'Cena obliczana na podstawie:<br />1.Ceny projektu za sztukę,<br />2.Ilości adresatów,<br />3.Kraju Adresata.\', this, event, \'120px\')">[?]</a></h3>';
         recalculate_project_price(1);
         if(document.getElementById('pr_tryb').value==2)
            {
            add_to_basket();
            }
         }
    else
         {
         alert('Należy podać niezbędne pola:\nImię\nNazwisko\nMiasto\nUlicę\nKraj\nKod pocztowy');
         }

    }


function getAddPrice(country_no)
    {
    if(document.getElementById('pr_tryb').value==1)
        {
        var y1 =document.getElementById('r_wysylki');
        var y = parseInt(y1.options[y1.selectedIndex].value);
        if (y==1)
            {
            return country_price_1[country_no];
            }
        if (y==2)
            {
            return country_price_2[country_no];
            }
        }
    if(document.getElementById('pr_tryb').value==2)
        {
        var y =document.getElementById('r_wysylki').value;
        if (y==1)
            {
            return country_price_1[country_no];
            }
        if (y==2)
            {
            return country_price_2[country_no];
            }
        }
    }
function getcounrty_name(country_no)
    {
    if(document.getElementById('pr_tryb').value==1)
        {
        var y1 =document.getElementById('r_wysylki');
        var y = parseInt(y1.options[y1.selectedIndex].value);
        if (y==1)
            {
            return country_name_1[country_no];
            }
        if (y==2)
            {
            return country_name_2[country_no];
            }
        }
    if(document.getElementById('pr_tryb').value==2)
        {
        var y =document.getElementById('r_wysylki').value;
        if (y==1)
            {
            return country_name_1[country_no];
            }
        if (y==2)
            {
            return country_name_2[country_no];
            }
        }
    }
function getcounrty_id(country_no)
    {
    if(document.getElementById('pr_tryb').value==1)
        {
        var y1 =document.getElementById('r_wysylki');
        var y = parseInt(y1.options[y1.selectedIndex].value);
        if (y==1)
            {
            return country_id_1[country_no];
            }
        if (y==2)
            {
            return country_id_2[country_no];
            }
        }
    if(document.getElementById('pr_tryb').value==2)
        {
        var y =document.getElementById('r_wysylki').value;
        if (y==1)
            {
            return country_id_1[country_no];
            }
        if (y==2)
            {
            return country_id_2[country_no];
            }
        }
    }
function recalculate_project_price(sum)
    {
    var option = document.getElementById('pr_tryb').value;
    if(option==1)
        {
    var x = document.getElementById('wpisy').rows;
    var ilwierszy  = x.length;
    var proj_PLN = 0;
    var proj_TP = 0;
    var proj_price = parseInt(document.getElementById('all_cost').value);
    var sum_price = 0;

    for (var i=1;i<(ilwierszy);i++)
        {
        var Country_old  = document.getElementById('wpisy').rows[i].cells[1].innerHTML;
        var Country_cost_old = document.getElementById('wpisy').rows[i].cells[2].innerHTML;

        var no_country = parseInt(Country_old);
        document.getElementById('wpisy').rows[i].cells[1].innerHTML = no_country+'/id/.      '+getcounrty_name(no_country);
        document.getElementById('wpisy').rows[i].cells[2].innerHTML = getAddPrice(no_country)+' gr';
        sum_price = sum_price+proj_price+getAddPrice(no_country);
        }
    proj_PLN = sum_price/100;
    proj_TP = sum_price/5;
    document.getElementById('pdk_price_adr2').innerHTML = '<br />CENA CAŁKOWITA <br /><h3>&nbsp;&nbsp;'+proj_PLN+' zł/ '+proj_TP+' TP <br />&nbsp;&nbsp;&nbsp;(Adresatów : '+(ilwierszy-1)+' )<a href="#" class="hintanchor" onMouseover="showhint(\'Cena obliczana na podstawie:<br />1.Ceny projektu za sztukę,<br />2.Ilości adresatów,<br />3.Kraju Adresata.\', this, event, \'120px\')">[?]</a></h3>';
        }
    if((option==2) && (sum!=1))
        {
        var proj_PLN = sum/100;
        var proj_TP = sum/5;
        document.getElementById('pdk_price_adr2').innerHTML="CENA CAŁKOWITA Z DOSTAWĽ <br /><h3>"+proj_PLN+" zł/ "+proj_TP+" TP</h3>";
        }
    if(option==3)
        {
        //e-kartki
        }
    }
function usun_odbiorce(id_w)
    {
    var x = document.getElementById('wpisy').rows;
    var z=1;

    if (x.length>id_w)
            {
            for(var g=(id_w);g<=(x.length-1);g++)
                {
                var numer_wiersza = (x.length-1)-z;
                var info = document.getElementById('wpisy').rows[numer_wiersza].cells[4].innerHTML
                document.getElementById('wpisy').rows[(numer_wiersza+1)].cells[4].innerHTML = info;
                z=z+1;
                }
            }
    document.getElementById('wpisy').deleteRow(id_w);
    var akt_row = document.getElementById('wpisy').rows;
    //alert(akt_row.length);
    if (akt_row.length <2)
            {
            hide_layer('But_go_basket');
            hide_layer('Adresaci');

            }
    recalculate_project_price(1);


    }
function add_to_basket()
    {
    if(document.getElementById('data_wys').value!="")
            {
          var ilosc_w = document.getElementById('wpisy').rows;
          var forma = document.getElementById('main_st0');

          var title = '';
          var Fname ='';
          var Lname = '';
          var Street = '';
          var City = '';
          var Country_id = '';
          var zip_code = '';
          var add_to_dbase = '';
          var tablica = new Array();
          for (x=1;x<ilosc_w.length;x++)
              {

            p1 = parseInt(document.getElementById('wpisy').rows[x].cells[1].innerHTML);
            if(document.getElementById('pr_tryb').value==1)
                {
                var y1 =document.getElementById('r_wysylki');
                var y = parseInt(y1.options[y1.selectedIndex].value);
                }
            if(document.getElementById('pr_tryb').value==2)
                {
                var y =document.getElementById('r_wysylki').value;
                }
            if (y==1)
                {
                Country_id =  country_id_1[p1];
                }
            if (y==2)
                {
                Country_id =  country_id_2[p1];
                }
            p2 = document.getElementById('wpisy').rows[x].cells[3].innerHTML;
            var z = parseInt(p2)
            if(p2=='TAK')
                {
                add_to_dbase = '1';
                }
            else
                {
                add_to_dbase = '0';
                }

            all = document.getElementById('wpisy').rows[x].cells[0].innerHTML;
            tablica = all.split(" ");

            move_aw_datas_txt();
            move_aw_design_datas();
            move_proj_detail();
            move_rew_s1_details();
            move_rew_s2_details();
            move_reciv_details();
            f_txt = '<input  type="hidden" name="ds'+(x)+'" value="'+all+'" />';
         // alert(all);
         // alert(f_txt);
          // f_txt = '<input  type="hidden" name="title'+(x)+'" value="'+tablica[0]+'" />';
          //  f_txt = f_txt +'<input  type="hidden" name="fname'+(x)+'" value="'+tablica[1]+'" />';
          //  f_txt = f_txt +'<input  type="hidden" name="lname'+(x)+'" value="'+tablica[2]+'" />';
           // f_txt = f_txt +'<input  type="hidden" name="street'+(x)+'" value="'+tablica[4]+'" />';
           // f_txt = f_txt +'<input  type="hidden" name="city'+(x)+'" value="'+tablica[3]+'" />';
            f_txt = f_txt +'<input  type="hidden" name="country_id'+(x)+'" value="'+Country_id+'" />';
           // f_txt = f_txt +'<input  type="hidden" name="zip_code'+(x)+'" value="'+tablica[5]+'" />';
            f_txt = f_txt +'<input  type="hidden" name="add_dBase'+(x)+'" value="'+z+'" />';

            forma.innerHTML = forma.innerHTML + f_txt;
            }
        forma.innerHTML = forma.innerHTML + '<input  type="hidden" name="ilosc_odbiorcow" value="'+(ilosc_w.length-1)+'" />';;
        forma.action = "basket.php";
        forma.target = "_self";
        forma.submit();


        }
    else
        {
        alert('Należy podać datę wysyłki Kartki \nTo pole znajduje się na pierwszej stronie');
        }
    }
function addreceiverfromdBase(p1,p2,p3,p4,p5,p6,p7)
    {
    document.getElementById('c_ttl').value = p1;
    document.getElementById('c_im').value = p2;
    document.getElementById('c_naz').value = p3;
    document.getElementById('c_mi').value = p4;
    document.getElementById('c_ul').value = p5;
    //document.getElementById('c_country').value;
    document.getElementById('c_kod').value = p6;
    if(document.getElementById('add_con_DB').checked)
        {
        document.getElementById('add_con_DB').checked = false;
        }

    if(document.getElementById('pr_tryb').value==1)
        {
        document.getElementById('c_country').value = p7;
        insert_new_receiver();
        }
    if(document.getElementById('pr_tryb').value==2)
        {
        //insert_sets_receiver();
        }

    document.getElementById('load').innerHTML = "";
    hide_layer('load');
    }
function viewDBase(letter)
    {
    hide_layer('letters');
    //document.getElementById('load').innerHTML = "<iframe  src=\"includes/filetocard/addfromdbase.php\" name=\"Add_fromDbase\"  noresize=\"noresize\" frameborder=\"0\" border=\"0\" cellspacing=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" style=\"width:500px;height:400px;\"></iframe>";
    //includes/filetocard/addfromdbase.php
    document.getElementById('load').innerHTML = "<iframe  src=\"includes/receivertocard/addrecfromdbase.php?letter="+letter+"\" name=\"Add_fromDbase\"  noresize=\"noresize\" frameborder=\"0\" border=\"0\" cellspacing=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" style=\"width:500px;height:400px;\"></iframe>";
    show_layer('load');

    }
function view_wishDBase(idC,site_no)
    {
    var hdl = 'wishes'+site_no;
    hide_layer(hdl);
    //document.getElementById('load').innerHTML = "<iframe  src=\"includes/filetocard/addfromdbase.php\" name=\"Add_fromDbase\"  noresize=\"noresize\" frameborder=\"0\" border=\"0\" cellspacing=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" style=\"width:500px;height:400px;\"></iframe>";
    //includes/filetocard/addfromdbase.php
    document.getElementById('load').innerHTML = "<iframe  src=\"includes/wishtocard/addwishfromdbase.php?idC="+idC+"&sNo="+site_no+"\" name=\"Add_fromDbase\"  noresize=\"noresize\" frameborder=\"0\" border=\"0\" cellspacing=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" style=\"width:500px;height:400px;\"></iframe>";
    show_layer('load');
    }
function view_bckDBase(idBck)
    {
    hide_layer('bck_choice');
    //document.getElementById('load').innerHTML = "<iframe  src=\"includes/filetocard/addfromdbase.php\" name=\"Add_fromDbase\"  noresize=\"noresize\" frameborder=\"0\" border=\"0\" cellspacing=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" style=\"width:500px;height:400px;\"></iframe>";
    //includes/filetocard/addfromdbase.php
    var or = document.getElementById('pdk_or').value;
    document.getElementById('load').innerHTML = "<iframe  src=\"includes/backgroundtocard/addbackground.php?idC="+idBck+"&ornt="+or+"\" name=\"Add_fromDbase\"  noresize=\"noresize\" frameborder=\"0\" border=\"0\" cellspacing=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" style=\"width:500px;height:400px;\"></iframe>";
    show_layer('load');
    }
function add_bcktoCard(idBck)
    {
    document.getElementById('rew_txt_bck').value = ''+idBck+'';
    document.getElementById('rew_txt_bck_img').innerHTML = "<img src=\"choice_bck.php?bck="+idBck+"\" />";
    document.getElementById('load').innerHTML = "";
    hide_layer('load');
    show_layer('rew_refresh');
    send_proj_form(2);
    }
function addwishesfromdBase(p1,p2)
    {
    var site = "tekst_rewersu"+p2;
    document.getElementById(site).value = p1;
    document.getElementById('load').innerHTML = "";
    hide_layer('load');
    show_layer('rew_refresh');
    send_proj_form(2);
    }
function Item_delete(It_no)
    {
    document.getElementById('bask_option').value = 'delete';
    document.getElementById('item').value = ''+It_no+'';
    document.getElementById('b_opt').submit();
    }
function Item_use(It_no,idtryb)
    {
    document.getElementById('bask_option').value = 'edit';
    document.getElementById('from_ex').value = 'basket_based';
    document.getElementById('item').value = ''+It_no+'';
    if(idtryb==1)
        {
        document.getElementById('b_opt').action = 'chosen.php';
        }
    if(idtryb==2)
        {
        document.getElementById('b_opt').action = 'chosen_self.php';
        }
    document.getElementById('b_opt').submit();
    }
function Item_edit(It_no,idtryb)
    {
    document.getElementById('bask_option').value = 'edit';
    document.getElementById('item').value = ''+It_no+'';
    if(idtryb==1)
        {
        document.getElementById('b_opt').action = 'chosen.php';
        }
    if(idtryb==2)
        {
        document.getElementById('b_opt').action = 'chosen_self.php';
        }
    document.getElementById('b_opt').submit();
    }
function saveProjectinMyProjectsAsNew()
    {
    document.getElementById('flo2').value = '0';
    send_proj_form(3);
    }
function saveProjectinMyProjectsAsCurrent()
    {
    send_proj_form(3);
    }
function hide_Imageinfo()
    {
    var wklejone;
    var typ_pdk;
    var odkryta = '';
    wklejone = 0;
    typ_pdk = 1;
    typ_pdk = document.getElementById('idKtyp').value;
    for (i=1;i<typ_pdk;i++)
        {
        odkryta = 'idP_file_'+i;
        if(document.getElementById(odkryta).value==0)
            {
            wklejone = wklejone;
            }
        else
            {
            wklejone = wklejone+1;
            }
         }
    if (wklejone==0)
        {
        hide_layer('adv_photo_info');
        }
    }
function payBasket(payment_type)
    {
    if(payment_type=='tp')
        {
        document.getElementById('fw').value='basket';
        document.getElementById('h').value='toppoints';
        document.getElementById('bask_pay').submit();
        //alert('top');
        }
    if(payment_type=='money')
        {
        document.getElementById('fw').value='basket';
        document.getElementById('h').value='money';
        document.getElementById('bask_pay').submit();
       // alert('money');
        }
    if(payment_type=='notmoney')
        {
        document.getElementById('fw').value='basket';
        document.getElementById('h').value='notmoney';
        document.getElementById('bask_pay').submit();
        }
    if((payment_type!='tp') && (payment_type!='money') && (payment_type!='notmoney'))
        {
        alert('WIEEEELLLL...BLAD');
        }
    }
function payFont(payment_type)
    {
    if(payment_type=='tp')
        {
        document.getElementById('fw').value='font';
        document.getElementById('h').value='toppoints';
        document.getElementById('bask_pay1').submit();
        //alert('top');
        }
    if(payment_type=='money')
        {
        document.getElementById('fw').value='font';
        document.getElementById('h').value='money';
        document.getElementById('bask_pay1').submit();
       // alert('money');
        }
    if((payment_type!='tp') && (payment_type!='money'))
        {
        alert('WIEEEELLLL...BLAD');
        }
    }
function payTPpoints()
    {
    document.getElementById('fw').value='toppoints';
    document.getElementById('h').value='money';
    document.getElementById('bask_pay2').submit();
    }
function check_pay_Form()
    {
    var error = 0;
    if(document.getElementById('k_in').value=='')
        {
        error = error+0;
        }
    if(document.getElementById('k_a').value=='')
        {
        error = error+0;
        }
    if(document.getElementById('k_k').value=='')
        {
        error = error+0;
        }
    if(document.getElementById('k_m').value=='')
        {
        error = error+0;
        }
    if(document.getElementById('k_e').value=='')
        {
        error = error+1;
        }
    else
        {

        }
    if(error==0)
        {
        alert('Zostaniesz teraz przekierowany na strone firmy Przelewy24.pl\n obsługującej płatności internetowe.')
        document.getElementById('pay_datas').submit();
        }
    else
        {
        alert('Wykonanie zapłaty wymaga podania Twojego e-mail\'a\nPodanie pozostałych danych umożliwi Ci zapłatę również kartami płatniczymi');
        }
    }
function handledwkr (field, event) {
    var allowkeys = new Array();
    var error = 0;
    allowkeys = ['58','13'];
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    for (z=0;z<allowkeys.length;z++)
        {
        if (keyCode == allowkeys[z]) {
          error = error+1;
          }
        }
       //	if (keyCode == '58') {
        if(error>0) {
        var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
		   //	i = (i + 1) % field.form.elements.length;
		  //	field.form.elements[i].focus();
			return false;
		}
		else
		return true;
	}

function check_rej_Form()
    {
    if(document.getElementById('Handshage_user').checked)
        {
        var p1 = document.getElementById('user_nick').value;
        var p2 = document.getElementById('user_email').value;
        var p3 = document.getElementById('user_p1').value;
        var p4 = document.getElementById('user_p2').value;
        if((p1!='') || (p2!='') || (p3!='') || (p4!=''))
            {
            if((document.getElementById('user_p1').value)==(document.getElementById('user_p2').value))
               {
               document.getElementById('rejorder').value = '1';
              // alert('ok');
               document.getElementById('register').submit();

               }
            else
                {
                alert('Hasło i jego powtórzenie muszą być identyczne');
                document.getElementById('rejorder').value = '0';
                }
            }
        else
            {
            alert('Wypełnij prawidłowo pola obowiązkowe !');
            document.getElementById('rejorder').value = '0';
            }
        }
    else
        {
        alert('Aby kontynuować proces rejestracji należy zaakceptować regulamin serwisu !');
        document.getElementById('rejorder').value = '0';
        }
    }
function editfrommyproject(idP,tryb)
    {
    if(tryb==1)
        {
        document.getElementById('ProjID').value = idP;
        document.getElementById('myproj_form').action="chosen.php";
        document.getElementById('myproj_form').submit();
        }
    if(tryb==2)
        {
        document.getElementById('ProjID').value = idP;
        document.getElementById('myproj_form').action="chosen_self.php";
        document.getElementById('myproj_form').submit();
        }
    }
function Flip_img(direction, patch, file)
    {
    var off =patch+file;
    var on =patch+file;
    if (direction==1)
        {
        document.getElementById('hlp1').src =on;
        }
    else
        {
        document.getElementById('hlp1').src =off;
        }
    }
function Go_there(url)
    {
    window.open(url);
    }

function choice_send(nr)
    {
    var form=document.getElementById('get_choice_form');
    if (nr==1)
        {
        form.submit();
        }
    if (nr==2)
        {
        form.action = 'chosen_self.php';
        form.submit();
        }
    if (nr==3)
        {
        form.action = 'chosen_ecards.php';
        form.submit();
        }
    }
function insert_sets_receiver()
    {
     if(document.getElementById('data_wys').value!="")
        {
        insert_new_receiver();
        }
     else
        {
        alert('Należy podać datę wysyłki Kartki \nTo pole znajduje się na pierwszej stronie');
        }
    }
function switch_sponsored(price)
    {
    var sponsor_allow = document.getElementById('accept_promotion').value;
    var info_div = document.getElementById('sponsor_info');

    if(sponsor_allow=="0")
        {
        //sponsor_allow = 1;
        document.getElementById('accept_promotion').value="1";
        // zmiana ceny;
        // ustawienie ikony sponsoringu
        info_div.innerHTML = "<img src=\"images/strona/sponsor_on.jpg\" width=\"178\" height=\"29\" alt=\"sponsor załšczony - kartka tańsza o dopłate sponsora\"/>";;
        prepare_card(price);
        }
    else
        {
        //sponsor_allow = 0;
        //zmiana ceny
        // schowanie ikony sponsoringu
        document.getElementById('accept_promotion').value="0";
        info_div.innerHTML = "<img src=\"images/strona/sponsor_off.jpg\" width=\"178\" height=\"29\" alt=\"sponsor wyłšczony - kartka droższa\"/>";;
        prepare_card(price);
        }

    }
function Go_there_self(url)
    {
    window.location.href=(url);
    }
function delPhoto_fromDBase(idPhoto)
    {
    var del_ok = confirm('Czy chcesz usunšć ten plik ze swojej bazy obrazów\n w serwisie TopKartka.pl');
    if(del_ok)
        {
        document.getElementById('del_file_accept').value = "1" ;
        document.getElementById('del_file_id').value = idPhoto;
        document.getElementById('del_file').submit();
        }
    }
function view_detail_info(text, show)
    {
    if(show==1)
        {
        var xp = getX(event);
        var yp = getY(event);
        document.getElementById('info_detail').innerHTML=text;

        movePoint(xp, yp,'info_detail');
        show_layer('info_detail');
        }
    else
        {
        hide_layer('info_detail');
        }
    }