var lista_pic='';
var t;
var tab_kategorii=new Array();
var currentLi=0;
var xmlhttp3;

var interv;
var uploadPath='http://www.czywiesz.pl/upload/';
var pagePath='http://www.czywiesz.pl/';
var standard_pic='grafika/karty/big_kliknij.gif';
var pic0_max_w=287;
var pic0_max_h=215;
var pic1_max_w=67;
var pic1_max_h=50;

var wynik;
var wolnyNumer=1;
var akt_kategoria=0;
var akt_l_tag=4; //aktualna liczba wpisanych tagów

tab_kategorii[1]=new Array('Historia','czer','#940000','Historia');
tab_kategorii[2]=new Array('Ludzie','ostrypom','#98E0DF','Ludzie');
tab_kategorii[3]=new Array('Natura','nieb','#E297EC','Natura');
tab_kategorii[4]=new Array('Sport','mor','#940000','Sport');
tab_kategorii[5]=new Array('Technika','jasnyziel','#FEBA59','Technika');
tab_kategorii[6]=new Array('Zdrowie','zol','#87E4F3','Zdrowie');
tab_kategorii[7]=new Array('Inne','ziel','#F387D2','Inne');



function sprawdz(ktore_pole)
{
	
	
	var kontrola;
	var licznik;
	var ok=true;
	var er=document.getElementById('error');
	var wynik=true;
	if (ktore_pole=='textlead')
	{
		licznik=document.getElementById('licznik');
		licznik.innerHTML='';
		kontrola=document.getElementById(ktore_pole);
		if ((kontrola.value.indexOf('KLIKNIJ ABY')==-1) && (kontrola.value.length<=87))
		{
			for (var i=0;i<=(kontrola.value.length);i++)
			{
				licznik.innerHTML=licznik.innerHTML+'&nbsp;';
			}
			licznik.innerHTML=licznik.innerHTML+kontrola.value.length+'/87';
			licznik.className='licznik';
		}else 
		if ((kontrola.value.indexOf('KLIKNIJ ABY')==-1) && (kontrola.value.length>87))
		{
			licznik=document.getElementById('licznik');
			for (var i=0;i<=87;i++)
			{
				licznik.innerHTML=licznik.innerHTML+'&nbsp;';
			}
			licznik.innerHTML=licznik.innerHTML+kontrola.value.length+'/87';
			licznik.className='overflow';
			wynik=false;
		}
		return wynik;
		
	} else
	if (ktore_pole=='texttag')
	{
		kontrola=document.getElementById(ktore_pole);
		if ((kontrola.value.indexOf('KLIKNIJ ABY')>-1) || (kontrola.value.length==0))
		{
			er.innerHTML='musisz podaÄ‡ przynajmniej jeden TAG?';
			//er.style.display='inline';
			//setTimeout(function(){er.style.display='none';er.innerHTML='';},5000);
			alert('Czy wiesz, Å¼e musisz podaÄ‡ przynajmniej jeden TAG?');
			return false;
		} else {return true;}
	} else
	if (ktore_pole=='calosc')
	{
		komunikat='';
		er.innerHTML='';
		kontrola=document.getElementById('textlead');
		if ((kontrola.value.indexOf('KLIKNIJ ABY')==-1) && (kontrola.value.length>87))
		{
			komunikat="Czy wiesz, Å¼e przekroczyÅ‚eÅ› maksymalnÄ… liczbÄ™ znakÃ³w poczÄ…tkowego tekstu (87)? \n";
			
			/*er.innerHTML='Czy wiesz, Å¼e przekroczyÅ‚eÅ› maksymalnÄ… liczbÄ™ znakÃ³w poczÄ…tkowego tekstu (87)?';
			er.style.display='inline';
			setTimeout(function(){er.style.display='none';er.innerHTML='';},5000);*/
			ok=false;
		}
		kontrola=document.getElementById('texttag');
		if ((kontrola.value.indexOf('KLIKNIJ ABY')>-1) || (kontrola.value.length==0))
		{
			/*if (er.innerHTML.indexOf('Czy wiesz')>-1) {er.innerHTML=er.innerHTML+'<br><br>';}
			er.innerHTML=er.innerHTML+'<b>Czy wiesz, Å¼e </b><br> musisz podaÄ‡ przynajmniej jeden TAG?';
			er.style.display='inline';
			setTimeout(function(){er.style.display='none';er.innerHTML='';},5000);
			*/
			komunikat=komunikat+"Czy wiesz, Å¼e musisz podaÄ‡ przynajmniej jeden TAG? \n";
			ok=false;
		}
		
		kontrola=document.getElementById('textmain');
		if ((kontrola.value.indexOf('KLIKNIJ ABY')>-1) || (kontrola.value.length==0))
		{
			/*if (er.innerHTML.indexOf('Czy wiesz')>-1) {er.innerHTML=er.innerHTML+'<br><br>';}
			er.innerHTML=er.innerHTML+'<b>Czy wiesz, Å¼e </b><br> musisz coÅ› napisaÄ‡? :-)';
			er.style.display='inline';
			setTimeout(function(){er.style.display='none';er.innerHTML='';},5000);
			*/
			komunikat=komunikat+"Czy wiesz, Å¼e musisz coÅ› napisaÄ‡? :-) \n";
			ok=false;
		}
		
		if (akt_kategoria==0)
		{
			/*if (er.innerHTML.indexOf('Czy wiesz')>-1) {er.innerHTML=er.innerHTML+'<br><br>';}
			er.innerHTML=er.innerHTML+'<b>Czy wiesz, Å¼e</b> <br> musisz wybraÄ‡ kategoriÄ™?';
			er.style.display='inline';
			setTimeout(function(){er.style.display='none';er.innerHTML='';},5000);
			*/
			komunikat=komunikat+"Czy wiesz, Å¼e musisz wybraÄ‡ kategoriÄ™?";
			ok=false;
		}
		
		if (ok==false) {alert(komunikat);}
		return ok;
	} else
	if (ktore_pole=='dopiski')
	{
		er.innerHTML='';
		
		
		
		kontrola=document.getElementById('textmain');
		if ((kontrola.value.indexOf('KLIKNIJ ABY')>-1) || (kontrola.value.length==0))
		{
			/*
			if (er.innerHTML.indexOf('Czy wiesz')>-1) {er.innerHTML=er.innerHTML+'<br><br>';}
			er.innerHTML=er.innerHTML+'<b>Czy wiesz, Å¼e </b><br> musisz coÅ› napisaÄ‡? :-)';
			er.style.display='inline';
			setTimeout(function(){er.style.display='none';er.innerHTML='';},5000);
			*/
			komunikat="Czy wiesz, Å¼e musisz coÅ› napisaÄ‡? :-) \n";
			ok=false;
			alert(komunikat);
		}
		return ok;
	} else
	if (ktore_pole=='dane')
	{
		
		er.innerHTML='';
		if ((document.getElementById('user_pseudo').value=='') && (document.getElementById('user_mail').value!=''))
		{
		
			/*er.innerHTML='<b>Czy wiesz, Å¼e</b><br> podaÅ‚eÅ›nam swÃ³j email, ale nie podaÅ‚eÅ› swojego pseudonimu?';
			er.style.display='inline';
			setTimeout(function(){er.style.display='none';er.innerHTML='';},5000);
			ok=false;
			*/
			komunikat="Czy wiesz, Å¼e podaÅ‚eÅ›nam swÃ³j email, ale nie podaÅ‚eÅ› swojego pseudonimu? \n";
			ok=false;
		}
		
		var poz_at=document.getElementById('user_mail').value.indexOf('@');
		
		if (((poz_at==-1) || (document.getElementById('user_mail').value.indexOf('.',poz_at)==-1)) && (document.getElementById('user_mail').value.length>0))
		{
			/*if (er.innerHTML.indexOf('Czy wiesz')>-1) {er.innerHTML=er.innerHTML+'<br><br>';}
			er.innerHTML=er.innerHTML+'<b>Czy wiesz, Å¼e</b><br> TwÃ³j e-mail wyglÄ…da na ciutkÄ™ nipoprawny?';
			er.style.display='inline';
			setTimeout(function(){er.style.display='none';er.innerHTML='';},5000);
			*/
			komunikat=komunikat+"Czy wiesz, Å¼e TwÃ³j e-mail wyglÄ…da na ciutkÄ™ nipoprawny? \n";
			ok=false;
		}
		return ok;
		
	} else
	if (ktore_pole=='komentarze')
	{
		ok=true;
		if ((document.getElementById('imie').value=='') || (document.getElementById('tekst').value==''))
		{
			/*er.innerHTML=er.innerHTML+'Czy wiesz, Å¼e<br> musisz wypeÅ‚niÄ‡ wszystkie pola?';
			er.style.display='inline';
			setTimeout(function(){er.style.display='none';er.innerHTML='';},5000);
			*/
			alert('Czy wiesz, Å¼e musisz wypeÅ‚niÄ‡ wszystkie pola?');
			ok=false;
		}
		return ok;
	} else 

	if (ktore_pole=='wysylanie_kartki')
	{
		
		ok=true;
		var poz_at=document.getElementById('kartka_mail').value.indexOf('@');
		var poz_at2=document.getElementById('kartka_odbiorca').value.indexOf('@');
		
		
		if ((document.getElementById('kartka_mail').value=='') || (document.getElementById('kartka_imie').value=='') 
		|| (document.getElementById('kartka_odbiorca').value==''))
		{
			
			/*er.innerHTML='Czy wiesz, Å¼e<br> musisz wypeÅ‚niÄ‡ wszystkie pola?';
			er.style.display='inline';
			er.style.marginLeft='-130px';
			er.style.marginTop='20px';
			setTimeout(function(){er.style.display='none';er.innerHTML='';},4000);
			*/
			alert('Czy wiesz, Å¼e musisz wypeÅ‚niÄ‡ wszystkie pola?');
			ok=false;
		} else 
		if ((poz_at==-1) || (document.getElementById('kartka_mail').value.indexOf('.',poz_at)==-1) ||
			(poz_at2==-1) || (document.getElementById('kartka_odbiorca').value.indexOf('.',poz_at)==-1))
		{
			/*er.innerHTML='Czy wiesz, Å¼e<br> podany mail wydaje siÄ™ byÄ‡ niepoprawny?';
			er.style.display='inline';
			setTimeout(function(){er.style.display='none';er.innerHTML='';},4000);
			*/
			alert('Czy wiesz, Å¼e podany mail wydaje siÄ™ byÄ‡ niepoprawny?');
			ok=false;
		}
		
		return ok;
	}
	er='';
	kontrola='';
}

function getxmlhttp()
{	

	xmlhttp3 = false;
	
	try 
	{
		xmlhttp3 = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try 
		{
			xmlhttp3 = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp3 = false;
		}
	}
	
	if (!xmlhttp3 && typeof XMLHttpRequest != 'undefined') 
	{
		xmlhttp3 = new XMLHttpRequest();
	}
	return xmlhttp3;
}

function daj(co_zrobic,var1,var2,var3,var4)
{
	var co;
	
	if (co_zrobic=='odswiezaj_pokaz_fotke') {co='sesja';}
	else if ((co_zrobic=='daj_wolny_numer') && (var1!='')){co='wolny_numer&id='+var1;}
	else if ((co_zrobic=='daj_wolny_numer') && (var1=='')){wolnyNumer='1';}
	else if (co_zrobic=='powiazane') {co='daj_powiazane&tagi='+var1;}
	else if (co_zrobic=='kartka') {co='wyslij_kartke&id='+var1+'&mail='+var2+'&imie='+var3+'&odbiorca='+var4;}
	else if (co_zrobic=='niepokazuj_tutorial_poziom') {co='niepokazuj_tutorial_poziom';}
	
	var http=getxmlhttp();
	var skrypt=pagePath+'pytania.php'
	var parametry='co='+co;
	
	if (co!='')
	{
		http.open("POST",skrypt,true);
		http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		
		
		http.onreadystatechange = function ()
		{
			
			if (http.readyState==4 && http.status==200)
			{
				
				wynik=http.responseText; 
				
				if (co=='sesja') 
				{
					//clearInterval(interv);
					//interv=setInterval(function(){pokaz_fotke(wynik,var1,var2);},5000);	
				} else
				if (co.indexOf('wolny_numer')==0)
				{
					
					wolnyNumer=wynik;
					
					if (document.getElementById('f_wart_pic'))
					{
						document.getElementById('f_wart_pic').value=wolnyNumer;
					}
					
					//daj('odwiez_pokaz_fotke','pic0','0');
					//pokaz_fotke(id,'pic0','0');
				} else
				if (co_zrobic=='powiazane') {document.getElementById('grupa_powiazane').innerHTML=wynik;}
				if (co_zrobic=='kartka') 
				{
					zamknij('mail_form');
					zamknij('mail_wysylany');
					
					if (wynik=='spam')
					{
						
						document.getElementById('mail_wyslany_tresc').innerHTML='Cieszymy sie, Å¼e chcesz tyle osÃ³b<br>powiadomiÄ‡ o ciekawostce,<br> ale prosimy, byÅ› poczekaj kilka minut<br><br>';
					}else 
					{
						document.getElementById('mail_wyslany_tresc').innerHTML='Czy wiesz, Å¼e<br>mail zostaÅ‚ wysÅ‚ny?<br><br>'; 
					}
					pokaz('mail_wyslany');
					
				}/*document.getElementById('mail_form').innerHTML='<br><br>Czy wiesz, Å¼e<br>mail zostaÅ‚ wysÅ‚any?<br><br><span class="kartka_zamknij" onclick=zamknij("mail")>Zamknij</span>';}*/
				
			} else 
			{
				
			}
		}	
		http.send(parametry);
	}
}


function zadaj_zdjecia(fotoId,id_ciekawostki,wolny)
{
	
	if (wolny==null){wolny=wolnyNumer;}
	
	if (wolny==wolnyNumer)
	{
		var neww=window.open('upload.php?id_ciekawostki='+id_ciekawostki+'&fotoid='+wolny+fotoId,'foto','width=488,height=339');
	} else
	{
		var neww=window.open('upload.php?id_ciekawostki='+id_ciekawostki+'&fotoid='+wolny+fotoId+'&zastap=1','foto','width=320,height=220');
	}
	
	//daj('odswiezaj_pokaz_fotke',nodeId,fotoId);
	
}


/*
function pokaz_fotke(sesjaId,nodeId,fotoId)
{
	document.getElementById(nodeId).setAttribute('src',uploadPath+sesjaId+'/'+wolnyNumer+fotoId+'.jpg?='+Math.random());
	document.getElementById('usun_'+nodeId).style.display='inline';
}*/


//<li class=dodaj_link><textarea id="l1" onclick=zaznacz('l1','http://')  onkeydown="dodajLi('lista_l')">http://KLIKNIJ ABY DOPISAÆ LINK</textarea></li>
function keyNum(e)
//zwraca keynum klawisza
{
	var keynum;
	var keychar;
	var numcheck;

	if (e!=null)
	{
		if(window.event) // IE
		  {
		  keynum = e.keyCode;
		  }
		else if(e.which) // Netscape/Firefox/Opera
		  {
		  keynum = e.which;
		  }
		keychar = String.fromCharCode(keynum);
		numcheck = /\d/;

		return keynum;
	} else {return -1;}
}

function sendKey(aKey, aTarget) 
{
  keyName = "DOM_VK_" + aKey.toUpperCase();
 
   if (!KeyEvent[keyName]) {
     throw "Unknown key: " + keyName;
   }
 
   return __doEventDispatch(aTarget, 0, KeyEvent[keyName], false);
}

 function __doEventDispatch(aTarget, aCharCode, aKeyCode, aHasShift) {
   if (aTarget === undefined) {
     aTarget = "target";
   }
 
   // Make our events trusted
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
   var event = document.createEvent("KeyEvents");
   event.initKeyEvent("keydown", true, true, document.defaultView,
                      false, false, aHasShift, false,
                      aKeyCode, 0);
   var accepted = $(aTarget).dispatchEvent(event);
 
   // Cancelling keydown cancels keypress too
   if (accepted) {
     event = document.createEvent("KeyEvents");
     if (aCharCode) {
       event.initKeyEvent("keypress", true, true, document.defaultView,
                          false, false, aHasShift, false,
                          0, aCharCode);
     } else {
       event.initKeyEvent("keypress", true, true, document.defaultView,
                          false, false, aHasShift, false,
                          aKeyCode, 0);
     }
     accepted = $(aTarget).dispatchEvent(event);
   }
 
   // Always send keyup
   var event = document.createEvent("KeyEvents");
   event.initKeyEvent("keyup", true, true, document.defaultView,
                      false, false, aHasShift, false,
                      aKeyCode, 0);
   $(aTarget).dispatchEvent(event);
   return accepted;
 }



function usun(co)
{
	var pom=document.getElementById(co).parentNode;
	pom.removeChild(document.getElementById(co));
}

function zmienFocus(co,naco,ev)
{
	if (keyNum(ev)==13)
	{
		document.getElementById(co).value=document.getElementById(co).value+' ';
		document.getElementById(naco).focus();
	}
}


function dodajLi(gdzie,po,ev)
//dodaje kolejny element do listy GDZIE i uzupelnia go wartoscia z PO 
{
	
	currentLi=document.getElementById('f_l_linki').value;
	if ((keyNum(ev)==13) || (ev==null))
	{
			
		if (gdzie)
		{
			if (po=='te_0')
			{
				currentLi++;
				var po_pom=document.getElementById(po);
				//var text=po_pom.value;
				
				if (po_pom.value!='http://KLIKNIJ ABY DOPISAÄ† LINK')
				{
					
					
					var pom=document.getElementById(gdzie);
		
					var ta=document.createElement('input');
					ta.setAttribute('id','te_'+currentLi);
					ta.setAttribute('name','te_'+currentLi);
					ta.setAttribute('type','text');
					
					
					//ta.setAttribute('onkeydown',"dodajLi('lista_l','tli_'"+currentLi+",event);");
					ta.value=po_pom.value;
					if (ta.value.indexOf('http://'))
					{
						ta.value='http://'+ta.value;
					}
					var em=document.createElement('div');
					em.className='link';
					AttachEventParams(em,'click',usun,'"tli_'+currentLi+'"');
				
					
					em.innerHTML='<b><i>UsuÅ„<b></i>';
					
					document.getElementById('f_l_linki').value=currentLi;
						
					var div=document.createElement('div');
					div.className='link';
					
					var li=document.createElement('li');
					li.setAttribute('id','tli_'+currentLi);
					li.appendChild(div);
					div.appendChild(ta);
					li.appendChild(em);
					
					pom.appendChild(li);
					po_pom.value='http://KLIKNIJ ABY DOPISAÄ† LINK';
					
					ta='';
					li='';
					pom='';
					em='';
				} 
			}else
			{
			}
		} else {}
	}
	
}

//*** AttachEvent(window,'load',MyFunctionNameWithoutParenthesis,false);
function AttachEvent(obj,evt,fnc,useCapture){
	if (!useCapture) useCapture=false;
	if (obj.addEventListener){
		obj.addEventListener(evt,fnc,useCapture);
		return true;
	} else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
	else{
		MyAttachEvent(obj,evt,fnc);
		obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
	}
} 
/*
function AttachEventParams( obj, type, fn, p )
{  
  obj["e"+type+fn] = fn;
  if (obj.addEventListener){
    eval( 'obj.addEventListener( type, function(event){obj["e"+type+fn](event, ' + p + ')}, false );' );
  }  else if (obj.attachEvent){
    alert(p);
	obj[type+fn] = function (){eval('fn (p)');} 
    obj.attachEvent("on"+type, obj[type+fn]);
  }
}*/

function AttachEventParams( obj, type, fn, p ){  
  
  obj["e"+type+fn] = fn;
  if (obj.addEventListener){
    eval( 'obj.addEventListener( type, function(event){obj["e"+type+fn](' + p + ')}, false );' );
	
  }  else if (obj.attachEvent){
    obj[type+fn] = function() { eval ( 'obj["e"+type+fn](' + p + ');' ); }
    obj.attachEvent("on"+type, obj[type+fn]);
	 
  }
 
}

function zwin(co)
{
	
	var el=document.getElementById(co);
	AttachEvent(el,'mouseout',zwin_kategorie,true);
	el='';
}

function ramka(co)
{
	document.getElementById(co);
	co.border=5;
}

function zaznacz(co)
//zaznacza text w textarea CO, o ile wpisany jest tam jeszcze KLIKNIJ ABY DOPISAC i pomija w zaznaczenu TEXT
{
	var pom=document.getElementById(co)
	if (pom.value.indexOf('KLIKNIJ ABY')>=0) 
	{
			pom.select();
	}
	pom='';
}

function daj_koncowke(text,znak,ile)
//zwraca ciag znakow z TEXT, wystepujacy po n-tym (LICZBA) wystapieniu ZNAKU

{
	text=text.substr(text.indexOf(znak)+1,text.length-text.indexOf(znak));
	text=text.substr(text.indexOf(znak)+1,text.length-text.indexOf(znak));
	text=text.substr(text.indexOf(znak)+1,text.length-text.indexOf(znak));
	return text;
}

function addStyleSheetRule(sIndex, selector, rule)
{
	if (document.styleSheets)
	{
		var oStyleSheet = document.styleSheets[sIndex];

		if (oStyleSheet.addRule) 
		{ // Internet Explorer
		
			
			
			if ((oStyleSheet.rules[oStyleSheet.rules.length-1].selectorText.indexOf(selector)>=0)
			|| (oStyleSheet.rules[oStyleSheet.rules.length-2].selectorText.indexOf(selector)>=0))
			{
				oStyleSheet.removeRule(oStyleSheet.rules.length-1);
				oStyleSheet.addRule(selector, rule, oStyleSheet.rules.length);
				
			}else
			{
				oStyleSheet.addRule(selector, rule, oStyleSheet.rules.length);
			
			};
		} else 
		{ // w3c complient
			
			if ((oStyleSheet.cssRules[oStyleSheet.cssRules.length-1].cssText.indexOf(selector)>=0)
				|| (oStyleSheet.cssRules[oStyleSheet.cssRules.length-2].cssText.indexOf(selector)>=0))
			{
				
				if (oStyleSheet.cssRules[oStyleSheet.cssRules.length-1].cssText.indexOf(selector)>=0)
				{oStyleSheet.deleteRule(oStyleSheet.cssRules.length-1);
				oStyleSheet.insertRule(selector + '{' + rule + '}',oStyleSheet.cssRules.length);}
				else
				{oStyleSheet.deleteRule(oStyleSheet.cssRules.length-2);
				oStyleSheet.insertRule(selector + '{' + rule + '}',oStyleSheet.cssRules.length);}
				
			}else
			{
				oStyleSheet.insertRule(selector + '{' + rule + '}',oStyleSheet.cssRules.length);
			
			};
		}
		
	}
	
}

function rozwin_kategorie()
{
	document.getElementById('rozwiniete').style.display='inline';
	
}


function zwin_kategorie(wybrana)
{
	
	if (wybrana>=1)
	{
		document.getElementById('edycja').className='edycja_'+tab_kategorii[wybrana][1]+' edycja';
		document.getElementById('karta_big').className='karta_big_'+tab_kategorii[wybrana][1]+' karta_big';
		document.getElementById('karta_big').className='karta_big_'+tab_kategorii[wybrana][1]+' karta_big';
		document.getElementById('kategoria').innerHTML=tab_kategorii[wybrana][0]+'â–¼';
		
		/*var pom=document.getElementById('karta_big');

		pom=pom.firstChild;
		
		if (pom.className)
		//IE
		{
			
			var pom2;
		
			while (pom.className.indexOf('linki')==-1)
			{
				
				if (pom.className.indexOf('karta_big')>-1)
				{
					pom2=pom.className;
					pom2='karta_big_'+tab_kategorii[wybrana][1]+'_'+daj_koncowke(pom2,'_',3);
					
					pom.className=pom2;
				}	
				pom=pom.nextSibling;
			}	
			
			var pom2=document.getElementById('big_kategoria');
			pom2=pom2.firstChild.nodeValue=tab_kategorii[wybrana][0];
			
		}
		else
		//ff
		{
			pom=pom.nextSibling;
			
			var pom2;
		
			while (pom.className.indexOf('linki')==-1)
			{
				if (pom.className.indexOf('karta_big')>-1)
				{
					pom2=pom.className;
					pom2='karta_big_'+tab_kategorii[wybrana][1]+'_'+daj_koncowke(pom2,'_',3);
					pom.className=pom2;
				}
				pom=pom.nextSibling;
				pom=pom.nextSibling;
			}	
			
			var pom2=document.getElementById('big_kategoria');
			pom2=pom2.firstChild.nodeValue=tab_kategorii[wybrana][0];
		}
		addStyleSheetRule(0,'.linki a', 'color:red'/*+tab_kategorii[wybrana][2]*//*);*/
		//document.getElementById('textlead').className='textlead_'+tab_kategorii[wybrana][1];
		if (document.getElementById('textmain')!=null){document.getElementById('textmain').className='textmain_'+tab_kategorii[wybrana][1];}
		//document.getElementById('texttag').className='texttag texttag_'+tab_kategorii[wybrana][1];
		//document.getElementById('rozwiniete').className='rozwiniete rozwiniete_'+tab_kategorii[wybrana][1];
		//document.getElementById('linki').className='linki linki_'+tab_kategorii[wybrana][1];
		akt_kategoria=wybrana;
		document.getElementById('f_kat').value=tab_kategorii[wybrana][0];
		document.getElementById('f_pl_kat').value=tab_kategorii[wybrana][3];
		
		//alert(tab_kategorii[wybrana][2]);
	
	} 
	if (document.getElementById('rozwiniete')!=null)
	{document.getElementById('rozwiniete').style.display='none';}
}


function refresh_powiazane(tagi)
{
	
	var pom=tagi;
	pom=pom.replace(';',' ');
	pom=pom.replace('.',' ');
	pom=pom.replace(',',' ');
	pom=pom.split(' ');
	
	if ((pom.length!=akt_l_tag) || (tagi.charAt(tagi.length-1)==' ') || (tagi.length==0))
	{
		
		if (tagi.indexOf('KLIKNIJ ABY')==-1)
		{
			
			akt_l_tag=pom.length;
			daj('powiazane',tagi);
		}
	}
}

function usun_usun(id,wolny)
//usuwa USUN pod zdjeciami i przywraca zdjeciom standardowy ekran ('Kliknij aby dodac')
{
	if (wolny==''){wolny=wolnyNumer;}
	document.getElementById(id).setAttribute('src',standard_pic);
	if (id=='pic0')
	{
		document.getElementById(id).setAttribute('width',pic0_max_w);		
		document.getElementById(id).setAttribute('height',pic0_max_h);
	}else 
	{
		document.getElementById(id).setAttribute('width',pic1_max_w);		
		document.getElementById(id).setAttribute('height',pic1_max_h);
	}
	document.getElementById('usun_'+id).style.display='none';
	
	id=id+';';
	us='us-'+id[3]+';';
	
	lista_pic=lista_pic.replace(id,'');
	lista_pic=lista_pic+us;
	document.getElementById('f_lista_pic').value=lista_pic;
	
}

function wylosuj_czywiesz()
{
	var http2=getxmlhttp();
	var skrypt=pagePath+'pytania.php';
	

	http2.open("POST",skrypt,true);
	
	http2.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	
	http2.onreadystatechange = function ()
	{
		if (http2.readyState==4 && http2.status==200)
		{
			wynik=http2.responseText; 
			document.getElementById('karty_med').innerHTML=wynik;
			
			http2='';
			
		} else 
		{
			
		}
	}	
	
	http2.send("co=daj_czywiesz");
}

function ukryj_koment(i)
{
	if  (document.getElementById('ukryj'+i).innerHTML=="[ - ]")
	{
		document.getElementById('pelny'+i).style.display="none";
		document.getElementById('skrot'+i).style.display="block";
		document.getElementById('ukryj'+i).innerHTML="[ + ]";
	} else if  (document.getElementById('ukryj'+i).innerHTML=="[ + ]")
	{
		document.getElementById('pelny'+i).style.display="block";
		document.getElementById('skrot'+i).style.display="none";
		document.getElementById('ukryj'+i).innerHTML="[ - ]";
	}
}

function zamknij(id)
{
	document.getElementById(id).style.display='none';
}

function pokaz(id)
{
	document.getElementById(id).style.display='block';
}

function czysc(id)
{
	document.getElementById(id).value='';
}

function wyslij_kartke(id)
{
	var mail=document.getElementById('kartka_mail').value;
	var imie=document.getElementById('kartka_imie').value;
	var odbiorca=document.getElementById('kartka_odbiorca').value;
	
	daj('kartka',id,mail,imie,odbiorca);
	zamknij('przyciski');
	pokaz('mail_wysylany');
}

function initPics()
{
	lista_pic=document.getElementById('f_lista_pic').value;
	
}

function show_pic(pic_name,pic_width,pic_height) 
{
 window.open(pic_name,'Czy wiesz, ¿e...','width='+pic_width+',height='+pic_height+',resizable=1,scrollbars=0,menubar=no,top=162,left=185,dependent=yes');
}

