// ========================================================
// Przydatne funckje

// filterAlphaOpacity na np obrazku
/*	
	if ()
		ImageObj=document.getElementById('send');
		ImageObj.disabled = false; 
		lightup(ImageObj, 100);
	}
	else { 
		ImageObj=document.getElementById('send');
		ImageObj.disabled = true; 
		lightup(ImageObj, 30);
*/
function lightup(imageobject, opacity){
	if (navigator.appName.indexOf("Netscape")!=-1 && parseInt(navigator.appVersion)>=5) {
		imageobject.style.MozOpacity=opacity/100;
	}
	else if (navigator.appName.indexOf("Microsoft")!= -1 && parseInt(navigator.appVersion)>=4) {
		imageobject.filters.alpha.opacity=opacity;
	}
}

// Poprawiona wersja getElementsByName
function getElementsByName_iefix(tag, name) 
{
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}

// dodaje zdarzenie on click do wybranych nazwach
// addOnClick('a', 'blind', function () {return false});
function addOnClick(tag, name, funkcja)
{
	var x = getElementsByName_iefix(tag, name);
	for(var i=0;x[i];i++)
	{
		x[i].onclick = funkcja;
	}
}

// zmienia display block / none
function displaySwitch(nr)
{
	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementById)
	{
		current = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = current;
	}
}

// ==============================================================

function RollAll(tag1, tag2, name1)
{
	x = getElementsByName_iefix(tag1, name1);
	y = getElementsByName_iefix(tag2, 'hidden');
	
	for (var i=0; x[i]; i++)
	{
		if (x[i].getAttribute('class') == 'selected last' || x[i].getAttribute('class') == 'last')
		{
			x[i].setAttribute("class", "last");
		}
		else {
			x[i].setAttribute("class", "");
		}
	}
	
	for (var i=0; y[i]; i++)
	{
		y[i].style.display = 'none';
	}
}

function show(id, obj, stop)
{
	if (obj.constructor == String) { obj = document.getElementById(obj); }
	
	RollAll('li','div','li_box');
	displaySwitch(id);
	obj.setAttribute("class", "selected");
	
	if (stop) { auto_roll_pause(); }
	
	return false;
}

function show_top(id, obj)
{
	RollAll('li','ol','li_top');
	displaySwitch(id);
	obj.setAttribute("class", "selected");
	return false;
}

function show_faq(id, obj)
{
	RollAll('li','div','li_faq');
	displaySwitch(id);
	if (obj.getAttribute('class') == 'last')
	{
		obj.setAttribute("class", "selected last");
	}
	else {
		obj.setAttribute("class", "selected");
	}
	return false;
}

function addtag(id)
{
	xajax_at(id,document.getElementById('inputNewTag').value);
	document.getElementById('inputNewTag').value = '';
}
function art_rel(id)
{
	xajax_ar(id,document.getElementById('inputNewRel').value);
	document.getElementById('inputNewRel').value = '';
}
function cli_rel(id)
{
	xajax_cli_uslugi(id,document.getElementById('inputNewRel').value);
	document.getElementById('inputNewRel').value = '';
}

var ars = -1;
var g_ids = '';
function auto_roll_rst() { if (ars != -1) { clearTimeout(ars); ars = -1; } }
function auto_roll_pause() { auto_roll_rst(); auto_roll(g_ids.join(','), true); }
function auto_roll(ids, long_time)
{
	if (ids.constructor != Array) { ids = ids.split(','); }
	else { current = ids.shift(); ids[ids.length] = current; }
	current = ids.shift(); ids[ids.length] = current;
	g_ids = ids;
	if (ars==-1)
	{
		if (long_time == true) { next_timeout = 12000; } else { next_timeout = 3000; };
		ars = setTimeout('show("htt_'+current+'","list_'+current+'");'
				+'auto_roll_rst();auto_roll("'+ids.join(',')+'");', next_timeout);
	}
}