// IEizm
if (typeof(window.external) != 'undefined' && document.attachEvent)
{
     document.getElementsByName = function(name, tag) {
           if(!tag) tag = '*';
           var elems=document.getElementsByTagName(tag),x=elems.length,i,res=[];
           for(i=0;i<x;i++){
                 att = elems[i].getAttribute('name');
                 if(att == name) res.push(elems[i]);
           }
           return res;
     }
}

// włącz dział, jeśli jest wyłączony
function enableh(id)
{
	try
	{
		// znajdź H4
		hs = document.getElementsByName(id);
		
		if (hs.length > 0) h4 = hs[0];
		else return true;
				
		// dojdź do H3
		if (h4.parentNode.previousSibling.previousSibling && h4.parentNode.previousSibling.previousSibling.tagName.match('H3'))
			h = h4.parentNode.previousSibling.previousSibling;
		else if (h4.parentNode.previousSibling && h4.parentNode.previousSibling.tagName.match('H3'))
			h = h4.parentNode.previousSibling;
	}
	catch(e) { h = false; }

		
	// kliknij
	if (h && h.className.match(/folded/))
	{
		try
		{
			if (h.nextSibling.nextSibling && h.nextSibling.nextSibling.tagName.match('DIV'))
				div = h.nextSibling.nextSibling;
			else if (h.nextSibling && h.nextSibling.tagName.match('DIV')) 
				div = h.nextSibling;
		}
		catch(e){ div = false; }
		
		try 
		{	
			toggleh(h, div);
		}	
		catch(e){}
	}
	
	return true;
}

/*
	 Modyfikacja skryptu "pornpops" podpisanego komentarzem:

	 Skrypt jest darmowy, poki ten komentarz w nim pozostaje.
	 Released under Creative Commons License
	 http://creativecommons.org/licenses/by/2.0/

	 Original author: Kornel Lesinski
	 http://pornel.net/pups/
*/

function toggleh(h, el)
{
	if (el.style.display == 'none')
	{
		h.className = h.className.replace(/folded/, '');
		h.className += ' expanded';
		el.style.display = 'block';
	}
	else
	{
		h.className = h.className.replace(/expanded/, '');
		h.className += ' folded';
		el.style.display = 'none';
	}
}

var arth =
{
	init: function(element)
	{
		// wymagany jest element i obsluga DOM
		if (!element || !element.getElementsByTagName) {return false;}

		// dodaj kotwice do h4
		var as = element.getElementsByTagName('h4');
		for(var i=0;i<as.length;i++)
		{
			try
			{
				anchor = document.createElement('<A name="' + as[i].getAttribute('name') + '_anchor' + '">');
			}
			catch(e)
			{
				anchor = document.createElement("A");
				anchor.setAttribute("name", as[i].getAttribute('name') + '_anchor');
			}
			as[i].appendChild(anchor);
		}
		
		// dodaj chowanie i kotwice do h3
		var as = element.getElementsByTagName('h3');
		var fst = true;
		for(var i=0;i<as.length;i++)
		{			
			try
			{
				anchor = document.createElement('<A name="' + as[i].getAttribute('name') + '_anchor' + '">');
			}
			catch(e)
			{
				anchor = document.createElement("A");
				anchor.setAttribute("name", as[i].getAttribute('name') + '_anchor');
			}
			as[i].appendChild(anchor);

			var el = false;
			try 
			{
				if (as[i].nextSibling.nextSibling && as[i].nextSibling.nextSibling.tagName.match('DIV'))
					el = as[i].nextSibling.nextSibling;
				else if (as[i].nextSibling && as[i].nextSibling.tagName.match('DIV')) 
					el = as[i].nextSibling;
				else
					el = false
			}
			catch(e) { el = false; }
					
			if (el)
			{
				as[i].onclick = this.click;
				as[i].onmouseover = this.onmouseover;
				as[i].onmouseout = this.onmouseout;
				if (fst) as[i].className += ' expanded';
				else toggleh(as[i], el);
				
				fst = false;
			}
		}

		return true;
	},

	click: function(ev)
	{
		ev = ev||event; /* IEizm */

		if (this.nextSibling.nextSibling && this.nextSibling.nextSibling.tagName.match('DIV'))
			el = this.nextSibling.nextSibling;
		else if (this.nextSibling && this.nextSibling.tagName.match('DIV')) 
			el = this.nextSibling;
		
		try 
		{	
			toggleh(this, el);
		}	
		catch(e){}
		
		return true;
	},

	onmouseover: function(ev)
	{
		ev = ev||event; /* IEizm */

		if (this.nextSibling.nextSibling && this.nextSibling.nextSibling.tagName.match('DIV'))
			el = this.nextSibling.nextSibling;
		else if (this.nextSibling && this.nextSibling.tagName.match('DIV')) 
			el = this.nextSibling;
		
		try 
		{	
			this.className += ' hmover';
			el.className += ' hmover';
		}	
		catch(e){}
		
		return true;
	},
	
	onmouseout: function(ev)
	{
		ev = ev||event; /* IEizm */

		if (this.nextSibling.nextSibling && this.nextSibling.nextSibling.tagName.match('DIV'))
			el = this.nextSibling.nextSibling;
		else if (this.nextSibling && this.nextSibling.tagName.match('DIV')) 
			el = this.nextSibling;
		
		try 
		{	
			this.className = this.className.replace(/hmover/, '');
			el.className = el.className.replace(/hmover/, '');
		}	
		catch(e){}
		
		return true;
	},

	initNow: function()
	{
		this.init(document.body);
	},

	initLoad: function()
	{
		var oldOnload = window.onload;
		var that = this;
		window.onload = function()
		{
			if (oldOnload) try{oldOnload();}catch(e){}
			that.initNow();
		}
	}
};

arth.initLoad();
arth.initNow();

