function init()
{
	obrazki = document.getElementsByTagName("img");
	
	for(i=0;i<obrazki.length;i++)
	{
		if(obrazki[i].className=="hover")
		{
			obrazki[i].zrodlo = zrodlo;
			obrazki[i].onmouseover=on;
			obrazki[i].onmouseout=off;
		}
	}
	document.getElementById('kategorie_selectbox').onchange = categoryJump;
}

function categoryJump() {
	sb = document.getElementById('kategorie_selectbox');
	//sid = document.getElementById('sid').value;
	//mpiwowarczykCHANGE - zmiana bazowego linku
	k = sb.options[sb.selectedIndex].value;
	var link = window.location + '';
	if (link.substr(0,5) == 'https') {
		window.location = 'https://eivitanea/category/view'+k+'.html';
	} else {
		window.location = 'http://eivitanea/category/view'+k+'.html';
	}
}

function zrodlo() 
{
	zrodlo = this.src;	
	zrodlo = zrodlo.substr(0,zrodlo.length-5);
	return zrodlo;
}

function on()
{
	this.src = this.zrodlo() + "d.gif";
}

function off()
{
	this.src = this.zrodlo() + "u.gif";
}

function geturl(url)
{
	document.location = url;
}




var aktywna;
var aktywnyobrazek;
var menuover;
var interwal;

function go() {
	document.location.href = 'pl/index.html'
}

function hidelayer() {
	if (aktywna && !(menuover)) {
		showhide(aktywna,"hidden");
		if (aktywna == "menu" + aktywnyobrazek) picoff(aktywnyobrazek);
		clearInterval(interwal);
	}
}

function picoff(obrazek)	{
	plik = obrazek + "1";
//	document[obrazek].src = window[plik].src; 	
}


function showhide(warstwa,funkcja) {
	if (funkcja == "visible") aktywna = warstwa;
	if (document.all) eval('document.all["' + warstwa + '"].style.visibility="' + funkcja + '"');
	if (document.getElementById) eval('document.getElementById("' + warstwa + '").style.visibility="' + funkcja + '"');
	if (document.layers) eval('document.layers["' + warstwa + '"].visibility="' + funkcja + '"');
}


function tree(id)
{
  this.id = id;

  this.click = function ()
  {
    for (var i = 0, el_node; i < this.parentNode.childNodes.length; i++)
    {
      el_node = this.parentNode.childNodes.item(i)
      if (el_node.nodeName.toLowerCase() == 'ul')
      {
        el_node.style.display = el_node.style.display == 'none' ? 'block' : 'none';
        this.parentNode.style.backgroundImage = 'url("' + (el_node.style.display == 'none' ? 'closed' : 'opened') + '.gif")';
        return;
      }
    }
  }

  this.start = function (el)
  {
    for (var i = 0, el_node; i < el.childNodes.length; i++)
    {
      el_node = el.childNodes.item(i);
      if (el_node.nodeName.toLowerCase() == 'a')
      {
        el_node.onclick = this.click;
        for (var j = 0; j < el_node.parentNode.childNodes.length; j++)
        {
          if (el_node.parentNode.childNodes.item(j).nodeName.toLowerCase() == 'ul')
          {
            el_node.parentNode.style.backgroundImage = 'url("closed.gif")';
            el_node.className = (el_node.className ? el_node.className + ' ' : '') + 'folder';
            break;
          }
          if (el_node.parentNode.childNodes.item(j).nodeName.toLowerCase() == 'li') break;
        }
        if (el_node.href && unescape(el_node.href) == unescape(window.location.href))
        {
          el_node.className = 'active';
          var el_parentNode = el_node;
          do
          {
            el_parentNode = el_parentNode.parentNode;
            if (el_parentNode.nodeName.toLowerCase() == 'ul')
            {
              el_parentNode.style.display = 'block';
              if (document.getElementById(this.id) != el_parentNode) el_parentNode.parentNode.style.backgroundImage = 'url("opened.gif")';
            }
          }
          while (document.getElementById(this.id) != el_parentNode)
        }
      }
      else if (el_node.nodeName.toLowerCase() == 'ul') el_node.style.display = 'none';
      this.start(el_node);
    }
  }

  if (document.getElementById && document.childNodes)
  {
    if (document.images)
    {
      new Image().src = 'opened.gif';
      new Image().src = 'document.gif';
    }
    this.start(document.getElementById(this.id));
  }
}

function urlOnlySearch(formId, fieldId, optionsField)
{	
	var formElem = document.getElementById(formId);
	
	if ( formElem )
	{
		
		var fieldElem = document.getElementById(fieldId);
		var optElem = document.getElementById(optionsField);
		if ( fieldElem )
		{
			
			formElem.action += "/" + encodeURI(fieldElem.value);
			
			if ( optElem )
			{
				formElem.action += optElem[optElem.selectedIndex].value;
			}
			window.location.href = formElem.action;
			return false;
		}
	}
	return false;
	
}

function urlAdminOnlySearch(formId, fieldId, productsField, usersField)
{	
	var formElem = document.getElementById(formId);
	
	var fieldElem = document.getElementById(fieldId);
		
	var prodElem = document.getElementById(productsField);
	var userElem = document.getElementById(usersField);

	if ( fieldElem.value != "")
	{
	if ( prodElem.checked)
	{
		formElem.action += "product/admin_search";
	}
			
	if ( userElem.checked)
	{
		formElem.action += "user/admin_search";
	}
			
	formElem.action += "/" + encodeURI(fieldElem.value);
	window.location.href = formElem.action;
	}
	return false;	
}

