var s_parent_id=0;
var s_selected_id=0;

var category = new Array();

category[1]="RTV/AGD";
category[2]="Elektronika";
category[3]="Elementy elektroniczne";
category[4]="Urządzenia pomiarowe";
category[5]="Urządzenia sterujące";
category[6]="Karty chipowe";
category[7]="Programatory";
category[8]="Urządzenia zasilające";
category[9]="Pozostałe";
category[10]="AGD";
category[11]="Wyposażenie łazienek";
category[12]="Wyposażenie kuchnii";
category[13]="Sprzęt domowy";
category[14]="Pozostałe";
category[15]="Audio";
category[16]="Car audio";
category[17]="Głośniki, kolumny i słuchawki";
category[18]="Wieże";
category[19]="Odtwarzacze CD/DVD/MD";
category[20]="Odtwarzacze MP3/MP4";
category[21]="Gramofony i miksery";
category[22]="Wzmaczniacze i tunery";
category[23]="Odtwarzacze przenośne";
category[24]="Sprzęt studyjny";
category[25]="Pozostałe";
category[26]="TV, Video, DVD";
category[27]="Telewizory";
category[28]="Sprzęt satelitarny";
category[29]="Kino domowe";
category[30]="Magnetowidy";
category[31]="Odtwarzacze DVD";
category[32]="Akcesoria";
category[33]="Pozostałe";
category[34]="Pozostałe";
category[35]="Fotografia";
category[36]="Fotoreportaże";
category[37]="Videofilmowanie";
category[38]="Aparaty";
category[39]="Cyfrowe";
category[40]="Analogowe";
category[41]="Pozostałe";
category[42]="Akcesoria";
category[43]="Karty pamięci";
category[44]="Lampy błyskowe";
category[45]="Statywy";
category[46]="Pozostałe";
category[47]="Obiektywy";
category[48]="Komputery i Internet";
category[49]="Usługi komputerowe";
category[50]="Usługi internetowe";
category[51]="Konsole";
category[52]="Komputery PC";
category[53]="Monitory";
category[54]="Notebooki, laptopy";
category[55]="Podzespoły";
category[56]="Karty graficzne";
category[57]="Karty dźwiękowe";
category[58]="Dyski twarde";
category[59]="Pamięci RAM";
category[60]="Płyty główne";
category[61]="Procesory";
category[62]="Napędy";
category[63]="Zasilacze";
category[64]="Obudowy";
category[65]="Pozostałe";
category[66]="Drukarki";
category[67]="Akcesoria";
category[68]="Atramentowe";
category[69]="Laserowe";
category[70]="Igłowe";
category[71]="Pozostałe";
category[72]="Sprzęt sieciowy";
category[73]="Skanery";
category[74]="Urządzenia wielofunkcyjne";
category[75]="Oprogramowanie";
category[76]="Gry";
category[77]="Akcesoria komputerowe";
category[78]="Pozostałe";
category[79]="Telefony i akcesoria";
category[80]="Telefony stacjonarne";
category[81]="Przewodowe";
category[82]="Bezprzewodowe";
category[83]="Akcesoria GSM";
category[84]="Usługi telekomunikacyjne";
category[85]="Telefony komórkowe";
category[86]="Alcatel";
category[87]="LG";
category[88]="Motorola";
category[89]="Nokia";
category[90]="Sagem";
category[91]="Samsung";
category[92]="Siemens";
category[93]="SonyEricsson";
category[94]="Ericsson";
category[95]="Panasonic";
category[96]="Mitsubishi";
category[97]="Sony";
category[98]="Sendo";
category[99]="Philips";
category[100]="Sharp";
category[101]="Sanyo";
category[102]="NEC";
category[103]="Manta";
category[104]="BenQ";
category[105]="Haier";
category[106]="Pantech";
category[107]="Maxon";
category[108]="BenQ-Siemens";
category[109]="Pozostałe";
category[110]="Pozostałe";
category[111]="Hobby i kolekcjonerstwo";
category[112]="Modelarstwo";
category[113]="Kolekcjonerstwo";
category[114]="Filatelistyka";
category[115]="Numizmatyka";
category[116]="Karty telefoniczne";
category[117]="Karty pocztowe";
category[118]="Pozostałe";
category[119]="Antyki";
category[120]="Meble";
category[121]="Rzeżby";
category[122]="Zegary";
category[123]="Pozostałe";
category[124]="Sztuka";
category[125]="Grafiki";
category[126]="Obrazy";
category[127]="Rzeźby";
category[128]="Pozostałe";
category[129]="Pozostałe";
category[130]="Film i Muzyka";
category[131]="Bilety";
category[132]="Instrumenty";
category[133]="Kasety";
category[134]="Audio";
category[135]="Wideo";
category[136]="Płyty";
category[137]="CD";
category[138]="DVD";
category[139]="VCD";
category[140]="Winylowe";
category[141]="Kolekcje";
category[142]="Akcesoria";
category[143]="Pozostałe";
category[144]="Odzież i biżuteria";
category[145]="Biżuteria";
category[146]="Galanteria i dodatki";
category[147]="Obuwie";
category[148]="Odzież";
category[149]="Damska";
category[150]="Męska";
category[151]="Dziecięca";
category[152]="Zegarki";
category[153]="Pozostałe";
category[154]="Edukacja";
category[155]="Kursy i szkolenia";
category[156]="Przedszkola";
category[157]="Szkoły podstawowe";
category[158]="Gimnazja";
category[159]="Szkoły średnie";
category[160]="Szkoły wyższe";
category[161]="Artykuły szkolne";
category[162]="Materiały edukacyjne";
category[163]="Pozostałe";
category[164]="Zdrowie i uroda";
category[165]="Kosmetyki";
category[166]="Makijaż";
category[167]="Manicure";
category[168]="Akcesoria";
category[169]="Pedicure";
category[170]="Perfumy i wody";
category[171]="Pozostałe";
category[172]="Zdrowie";
category[173]="Sprzęt rehabiliitacyjny";
category[174]="Leki";
category[175]="Zioła";
category[176]="Lekarze prywatnie";
category[177]="Paramedycyna";
category[178]="Usługi";
category[179]="Pozostałe";
category[180]="Pozostałe";
category[181]="Turystyka";
category[182]="Kwatery";
category[183]="Hotele";
category[184]="Pola namiotowe i camping";
category[185]="Oferty sezonowe";
category[186]="Oferty biur turystycznych";
category[187]="Przejazdy";
category[188]="Wypoczynek";
category[189]="Sprzęt turystyczny";
category[190]="Usługi";
category[191]="Pozostałe";
category[192]="Motoryzacja";
category[193]="Samochody";
category[194]="Ciężarowe";
category[195]="Osobowe";
category[196]="Vany";
category[197]="Dostawcze";
category[198]="Terenowe";
category[199]="Pozostałe";
category[200]="Autobusy";
category[201]="Sprzęt motorowodny";
category[202]="Motocykle";
category[203]="Zabytkowe";
category[204]="Przyczepy i naczepy";
category[205]="Uszkodzone i powypadkowe";
category[206]="Części";
category[207]="Usługi";
category[208]="Pozostałe";
category[209]="Nieruchomości";
category[210]="Domy";
category[211]="Domki letniskowe";
category[212]="Działki";
category[213]="Rekreacyjne";
category[214]="Budowlane";
category[215]="Przemysłowe";
category[216]="Pozostałe";
category[217]="Grunty i gospodarstwa rolne";
category[218]="Mieszkania";
category[219]="Magazyny, lokale i sklepy";
category[220]="Pozostałe";
category[221]="Sport i rekreacja";
category[222]="Bilard";
category[223]="Bilety";
category[224]="Golf";
category[225]="Jeździectwo";
category[226]="Narciarstwo";
category[227]="Rowery";
category[228]="Snowboard i skateboard";
category[229]="Siłownia i fitness";
category[230]="Sporty wodne";
category[231]="Tenis i Squash";
category[232]="Wędkarstwo";
category[233]="Wypoczynek";
category[234]="Usługi";
category[235]="Pozostałe";
category[236]="Praca";
category[237]="Szukam pracy";
category[238]="Dam prace";
category[239]="CV";
category[240]="Usługi";
category[241]="Pozostałe";
category[242]="Biznes";
category[243]="Szukam inwestora";
category[244]="Współpraca";
category[245]="Wyprzedaże";
category[246]="Przetargi";
category[247]="Pozostałe";
category[248]="Zwierzęta";
category[249]="Akwarystyka";
category[250]="Akwaria i wyposażenie";
category[251]="Ryby";
category[252]="Literatura";
category[253]="Pozostałe";
category[254]="Terrarystyka";
category[255]="Terraria i wyposażenie";
category[256]="Zwierzęta terrariowe";
category[257]="Literatura";
category[258]="Pozostałe";
category[259]="Artykuły zoologiczne";
category[260]="Artykuły dla zwierząt";
category[261]="Karmy i odżywki";
category[262]="Klatki i pojemniki";
category[263]="Książki i kasety";
category[264]="Pozostałe";
category[265]="Żywe zwierzęta";
category[266]="Gryzonie";
category[267]="Konie";
category[268]="Koty";
category[269]="Psy";
category[270]="Ptaki";
category[271]="Pozostałe";
category[272]="Usługi";
category[273]="Pozostałe";
category[274]="Dom i ogród";
category[275]="Budownictwo i Akcesoria";
category[276]="Elektryka i akcesoria";
category[277]="Garaże";
category[278]="Dachy";
category[279]="Hydraulika i akcesoria";
category[280]="Kominki i akcesoria";
category[281]="Ogrodzenia i bramy";
category[283]="Okna i drzwi";
category[284]="Podłogi";
category[285]="Ściany i elewacje";
category[286]="Pozostałe";
category[287]="Meble";
category[288]="Narzędzia";
category[289]="Ogród";
category[290]="Wyposażenie";
category[291]="Pozostałe";
category[292]="Maszyny i urządzenia";
category[293]="Agregaty";
category[294]="Dziewiarskie";
category[295]="Elektryczne";
category[296]="Mleczarskie";
category[297]="Obrabiarki";
category[298]="Pakujące";
category[299]="Piece";
category[300]="Rolnicze";
category[301]="Ciągniki";
category[302]="Kombajny";
category[303]="Przyczepy";
category[304]="Osprzęt";
category[305]="Pozostałe";
category[306]="Silniki";
category[307]="Spawarki";
category[308]="Spożywcze";
category[309]="Chłodziarki";
category[310]="Zamrażarki";
category[311]="Krajalnice";
category[312]="Pozostałe";
category[313]="Sprężarki";
category[314]="Wózki widłowe";
category[315]="Wtryskarki";
category[316]="Pozostałe";
category[317]="Usługi";
category[318]="Wypożyczalnie samochodów";
category[319]="Doradztwo";
category[320]="Detektywistyczne";
category[321]="Gastronomiczne";
category[322]="Kredyty, Pożyczki";
category[323]="Księgowo-finansowe";
category[324]="Poligrafia i Reklama";
category[325]="Prawne";
category[326]="Sprzątanie, mycie";
category[327]="Tłumaczenia";
category[328]="Transportowe";
category[329]="Ubezpieczenia";
category[330]="Windykacyjne";
category[331]="Komunalne";
category[332]="Pozostałe";
category[333]="Pozostałe";
category[334]="Artykuły spożywcze";
category[335]="Imprezy";
category[336]="Sprzedam";
category[337]="Towarzysko-matrymonialne";
category[338]="Zguby";
category[339]="Pozostałe";
category[340]="Pozostałe";

var childrens = new Array();
childrens[0]=new Array(242, 274, 154, 130, 35, 111, 48, 292, 192, 209, 144, 333, 236, 1, 221, 79, 181, 317, 164, 248);
childrens[1]=new Array(10, 15, 2, 34, 26);
childrens[2]=new Array(3, 6, 9, 7, 4, 5, 8);
childrens[10]=new Array(14, 13, 12, 11);
childrens[15]=new Array(16, 17, 21, 19, 20, 23, 25, 24, 18, 22);
childrens[26]=new Array(32, 29, 30, 31, 33, 28, 27);
childrens[35]=new Array(42, 38, 36, 47, 340, 37);
childrens[38]=new Array(40, 39, 41);
childrens[42]=new Array(43, 44, 46, 45);
childrens[48]=new Array(77, 66, 76, 52, 51, 53, 54, 75, 55, 78, 73, 72, 74, 50, 49);
childrens[55]=new Array(58, 57, 56, 62, 64, 59, 60, 65, 61, 63);
childrens[66]=new Array(67, 68, 70, 69, 71);
childrens[79]=new Array(83, 110, 85, 80, 84);
childrens[80]=new Array(82, 81);
childrens[85]=new Array(86, 104, 108, 94, 105, 87, 103, 107, 96, 88, 102, 89, 95, 106, 99, 109, 90, 91, 101, 98, 100, 92, 97, 93);
childrens[111]=new Array(119, 113, 112, 129, 124);
childrens[113]=new Array(114, 117, 116, 115, 118);
childrens[119]=new Array(120, 123, 121, 122);
childrens[124]=new Array(125, 126, 128, 127);
childrens[130]=new Array(142, 131, 132, 133, 141, 136, 143);
childrens[133]=new Array(134, 135);
childrens[136]=new Array(137, 138, 139, 140);
childrens[144]=new Array(145, 146, 147, 148, 153, 152);
childrens[148]=new Array(149, 151, 150);
childrens[154]=new Array(161, 158, 155, 162, 163, 156, 157, 159, 160);
childrens[164]=new Array(165, 180, 172);
childrens[165]=new Array(168, 166, 167, 169, 170, 171);
childrens[172]=new Array(176, 174, 177, 179, 173, 178, 175);
childrens[181]=new Array(183, 182, 186, 185, 184, 191, 187, 189, 190, 188);
childrens[192]=new Array(200, 206, 202, 208, 204, 193, 201, 207, 205, 203);
childrens[193]=new Array(194, 197, 195, 199, 198, 196);
childrens[209]=new Array(211, 210, 212, 217, 219, 218, 220);
childrens[212]=new Array(214, 216, 215, 213);
childrens[221]=new Array(222, 223, 224, 225, 226, 235, 227, 229, 228, 230, 231, 234, 232, 233);
childrens[236]=new Array(239, 238, 241, 237, 240);
childrens[242]=new Array(247, 246, 243, 244, 245);
childrens[248]=new Array(249, 259, 273, 254, 272, 265);
childrens[249]=new Array(250, 252, 253, 251);
childrens[254]=new Array(255, 256, 257, 258);
childrens[259]=new Array(260, 261, 262, 263, 264);
childrens[265]=new Array(266, 267, 268, 269, 270, 271);
childrens[274]=new Array(275, 287, 288, 289, 291, 290);
childrens[275]=new Array(278, 276, 277, 279, 280, 281, 283, 284, 286, 285);
childrens[292]=new Array(293, 294, 295, 296, 297, 298, 299, 316, 300, 306, 307, 308, 313, 314, 315);
childrens[300]=new Array(301, 302, 304, 305, 303);
childrens[308]=new Array(309, 311, 312, 310);
childrens[317]=new Array(320, 319, 321, 331, 322, 323, 324, 332, 325, 326, 327, 328, 329, 330, 318);
childrens[333]=new Array(334, 335, 339, 336, 337, 338);

var parents = new Array();

function getParents(id)
{
	var countAll = category.length;
	
	for(var indx in category)
	{
		if(typeof(childrens[indx]) != "undefined")
			for(var indx2 in childrens[indx])
				if(childrens[indx][indx2] == id)
				{
					window.parents[window.parents.length] = indx;
					getParents(indx);			
				}

	}
}



function showaa(sel_id)
{
  var selIndex = document.getElementById('sel_row[' + sel_id + ']').selectedIndex;
}

function show_select()
{
  initialize(1, 0);
}

var katClear = 0;

function initialize(sel_id, parent_id)
{

  var selIndex = document.getElementById('sel_row[' + sel_id + ']').selectedIndex;
  
  //calkowite wyczyszczenie select`a
  document.getElementById('sel_row[' + sel_id + ']').options.length=0;
  document.getElementById('sel_row[' + 3 + ']').options.length=0;  


  if(childrens[parent_id])
  { 

    document.getElementById('sel_row[' + sel_id + ']').style.display = 'inline';   
    document.getElementById('nazwa_kategoria').value = '';
    document.getElementById('kategoria').value = '';
    
    if(katClear>0)
    {   
      document.forms.SaveOgloszenie.kategoria.value="";
    }
     

    for(i=0; i<childrens[parent_id].length; i++)
    {

         document.getElementById('sel_row[' + sel_id + ']').options[i] = new Option(category[childrens[parent_id][i]]);
         document.getElementById('sel_row[' + sel_id + ']').options[i].value = childrens[parent_id][i];
      
    }    
  } 
  else 
  {
   document.getElementById("nazwa_kategoria").value = category[parent_id];
   document.forms.SaveOgloszenie.kategoria.value=parent_id; 

  }
}

function wybierz(parent_id)
{
  if(!childrens[parent_id])
  { 
    document.getElementById('nazwa_kategoria').value = category[parent_id];
    document.forms.SaveOgloszenie.kategoria.value=parent_id; 
  }
}


function selectItem(Elem, val)
{
  Elem.options[val].selected="selected";
}









//Written by Bogdan Blaszczak/BlaTek
//blatek@25.pl
function Calendar(E,T){
 if(!document.getElementById||!document.body.appendChild)return
 var i,j,tBody,Row,od,Do,d,dt
 function cEl(t,p,h,w){
  p.appendChild(t=document.createElement(t))
  if(h)t.innerHTML=h;if(w)t.style.width='27px'
  return t}
function cB(x){with(cld_BlaTek){
  B=0;x==0?R--:x==1?R++:x==2?(!M?(M=11,R--):M--):(M==11?(M=0,R++):M++)}
 }
 with(cld_BlaTek){
  od=Date.UTC(R,M,1);Do=Date.UTC(R,M+1,1)}
 E=document.getElementById(E)
 while(E.childNodes.length)E.removeChild(E.firstChild)
 tBody=cEl('tbody',cEl('table',E))
 tBody.onmouseup=function(){T.focus()}
 tBody.onmousemove=function(){
  if(window.getSelection)window.getSelection().removeAllRanges()}
 Row=cEl('tr',tBody)
 cEl('td',Row,'<<',1).onmousedown=function(){cB(0)}
 cEl('th',Row,cld_BlaTek.R)
 cEl('td',Row,'>',1).onmousedown=function(){cB(1)}
 Row=cEl('tr',tBody)
 cEl('td',Row,'<<',1).onmousedown=function(){cB(2)}
 cEl('th',Row,cld_BlaTek.month[cld_BlaTek.M])
 cEl('td',Row,'>',1).onmousedown=function(){cB(3)}

 tBody=cEl('tbody',cEl('table',E))
 Row=cEl('tr',tBody)
 for(i=0;i<7;i++)
  with(cEl('th',Row,cld_BlaTek.day[i]))
   if(i==6)style.backgroundColor='#f88'

 for(i=od;i<Do;i+=86400000){
  with(new Date(i)){d=getUTCDate();dt=getUTCDay()}
  if(dt==1||i==od)Row=cEl('tr',tBody)
  if(dt!=1&&d==1)for(j=1;j<(dt?dt:7);j++)cEl('th',Row)
  dt=cEl('td',Row,d);dt.onmousedown=function(x){
   x=+this.innerHTML
   with(cld_BlaTek)
   {
    var x_tmp=x;
    x=M+1;
    T.value=R+'-'+((x=M+1)<10?'0'+x:x)+'-'+(x_tmp<10?'0'+x_tmp:x_tmp)
   }
  }
  with(cld_BlaTek)
  if(d==D.getDate()&&M==D.getMonth()&&R==D.getFullYear())
   dt.style.backgroundColor='#fff'
 }
 T.onblur=function(){if(cld_BlaTek.B)E.style.display='none'}
 cld_BlaTek.B=1;E.style.display='block'
}


//global object (You can translate month&day names)
cld_BlaTek={
 day:['pn','wt','śr','cz','pt','so','ni'],
 month:['styczeń','luty','marzec','kwiecień','maj','czerwiec',
 'lipiec','sierpień','wrzesień','październik','listopad','grudzień'],
 D:new Date(),M:new Date().getMonth(),R:new Date().getFullYear()
}

function pokaz(id)
{
  document.getElementById(id).style.display = 'block';
}

function ukryj(id)
{
  document.getElementById(id).style.display = 'none';
}

var ilObrazkow = 0;

function loadImage(sid)
{   
    var il = ++document.forms.uploadImageForm.ilObr.value;
  	var obj = document.getElementById('obrazki');
    
    var d = document.createElement("div");
    d.id='obrazekDiv' + il;
    
 	ie=document.body.filters;
	element=ie?"<img name=''>":"img";
    var img = document.createElement(element);    
    img.src = '/img/loader2.gif';
    img.id = img.name = 'obrazek' + il;
    img.align = 'center'; 
    
    d.appendChild(img);
    d.innerHTML += '<div><input type="image" src="/img/btn_usun_zdj.gif" onClick="javascript:unloadImage(' + il + ', \'' + sid + '\')"></div>'; 
    obj.appendChild(d);  

	
	
	if (il >= 3) document.getElementById('loadImageForm').style.display='none';
}


function unloadImage(k, sid)
{
	window.iFrameUnload.location='/ogloszenia/usunplik/id/' + k + '/sid/' + sid;
	document.getElementById('obrazek'+k).src = '/img/ProgressBar.gif';
	
	var il = --document.forms.uploadImageForm.ilObr.value;
	if (il < 3) document.getElementById('loadImageForm').style.display='block';	
}



