//Rozwiniecie menu lewego z produktami finansowymi
function rollmenu(id)
{
  var menu = document.getElementById('prod_fin_'+id);
  var submenu = document.getElementById('prod_fin_hd_'+id);

  if (submenu.style.display == 'block')
  {
    submenu.style.display='none';
    menu.className = 'prodfinsubsub';
  } else
     {
       rollupall();
       submenu.style.display = 'block';
       menu.className = 'prodfinsubsubrolled';
     }
}


//Zwiniecie wszystkich menu
function rollupall()
{
  var hidden_divs = getElementsByClass('pf_hidden', null, 'div');
  for (var n = 0; n < hidden_divs.length; n++)
  {
    var div = hidden_divs[n];
    div.style.display='none';
  }

  var mainMenues = getElementsByClass('prodfinsubsubrolled', null);
  for (var n = 0; n < mainMenues.length; n++)
  {
    var tag = mainMenues[n];
    tag.className = 'prodfinsubsub';
  }
}

//Pobranie elementow wedlug nazwy klasy styli
function getElementsByClass(searchClass,node,tag)
{
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

//Przekierowanie stronu po wybramiu pola z menu rozwijanego 'Fundi na skroty'
function fundiQuickReload()
{
  var selectbox = document.getElementById('fds');
  if (selectbox)
  {
   var id = selectbox.options[selectbox.selectedIndex].value;
   var numeric=/^[1-9][0-9]*$/i;
   if (numeric.test(id) == true)
   {
     if (id == 1)
       location.href = 'http://www.fundi.pl/index.php?action=notowania';
     if (id == 2)
       location.href = 'http://www.fundi.pl/index.php?action=notowaniaofe';
     if (id == 3)
       location.href = 'http://kursy-walut.fundi.pl';
     if (id == 4)
       location.href = 'http://www.fundi.pl/index.php?action=list&id=120';
     if (id == 5)
       location.href = 'http://www.fundi.pl/index.php?action=list&id=139';
     if (id == 6)
       location.href = 'http://cf.fundi.pl';
   }
  }
}

//Wyswietlenie dostosowania notowan dla indeksu
function display_dostNotIndexPopup()
{
  window.open('http://www.fundi.pl/index.php?action=dostNotIndex', '', 'width=800, height=600, resizable=yes, scrollbars=yes, status=yes, location=no');
  return false;
}

//Przelowanie parent window dla dostosowania notowan
function reloadParent(confirmed)
{
  if (confirmed == 'yes')
  {
    window.opener.location = window.opener.location;
    self.close();
  }
}

//Funkcja pokazuje lub ukrywa opis notowan na stronie glownej analiz
function notdescription()
{
  var visible = document.getElementById('not_desc_details');
  var showLink = document.getElementById('ndl_show');
  var hideLink = document.getElementById('ndl_hide');
  if (visible.style.display == 'block')
  {
    visible.style.display = 'none';
    showLink.style.display = 'block';
    hideLink.style.display = 'none';
  } else
    {
      visible.style.display = 'block';
      showLink.style.display = 'none';
      hideLink.style.display = 'block';
    }
  return false;
}

//Funkcja sprwdza ile walorow zostalo zaznaczonych
//Jesli jest ich wiecej niz 10 to nie pozwala na zaznaczenie
function checkSelected(element)
{
  var funds = document.getElementsByName('comparewith[]');
  var currencies = document.getElementsByName('currenciesKeys[]');
  var stock_idx = document.getElementsByName('stockIndexesKeys[]');
  var world_idx = document.getElementsByName('worldIndicesKeys[]');
  var totalLength = 0;
  for (var i = 0; i < funds.length; i++)
  {
    if (funds[i].checked)
      totalLength++;
  }
  for (var i = 0; i < currencies.length; i++)
  {
    if (currencies[i].checked)
      totalLength++;
  }
  for (var i = 0; i < stock_idx.length; i++)
  {
    if (stock_idx[i].checked)
      totalLength++;
  }
  for (var i = 0; i < world_idx.length; i++)
  {
    if (world_idx[i].checked)
      totalLength++;
  }

  if (totalLength > 10)
  {
    alert ('Nie możesz zaznaczyć więcej niż 10 walorów');
    element.checked = false;
  }
}


