toggleList = function(tree_id) {
  $("#parent"+tree_id).slideToggle("medium");
}

$(document).ready(function(){
  $("#boxLoginForm").submit(function(){
	if($("#box_authorize_login").val().length==0)
	{
	  alert("Podaj swoją nazwę użytkownika!");
	  $("#box_authorize_login").focus();
	  return false;
	}
	if($("#box_authorize_password").val().length==0)
	{
	  alert("Wpisz hasło, które służy Ci do logowania się na konto w serwisie!");
	  $("#box_authorize_password").focus();
	  return false;
	}
	return true;
  });
  
  $('a[rel*=lightbox]').fancybox();
});





// OLD
// global
o_current = '';
function o(id)
{
	if (o_current && (o_current!=id))
	{
		var element = document.getElementById("menu_"+o_current);
		if (element) {
			element.style.display = "none";
		}
	}
	
	var element = document.getElementById("menu_"+id);
	if (element) {
		element.style.display = (element.style.display == 'none') ? "block" : "none";
	}
	o_current = id;
}
// local
var d_current = '';
function d(id)
{
	if (d_current && (d_current!=id))
	{
		var element = document.getElementById("budowa_"+d_current);
		if (element) {
			element.style.display = "none";
		}
	}
	
	var element = document.getElementById("budowa_"+id);
	if (element) {
		element.style.display = (element.style.display == 'none') ? "block" : "none";
	}
	d_current = id;
}
// local
var t_current = '';
function t(id)
{
	if (t_current && (t_current!=id))
	{
		var element = document.getElementById("tekst_"+t_current);
		if (element) {
			element.style.display = "none";
		}
	}
	
	var element = document.getElementById("tekst_"+id);
	if (element) {
		element.style.display = (element.style.display == 'none') ? "block" : "none";
	}
	t_current = id;
}



// local
var budowa_current = '';
function budowa(id)
{
	if (budowa_current && (budowa_current!=id))
	{
		var element = document.getElementById("budowa_"+budowa_current);
		if (element) {
			element.className = "ukryj";
		}
	}
	
	var element = document.getElementById("budowa_"+id);
	if (element) {
		element.className = (element.className == 'ukryj') ? "pokaz" : "ukryj";
	}
	budowa_current = id;
}

function powieksz(url, w, h)  {
var w2 = w+10;
var h2 = h+30;
okno=window.open(url,'FullWindow','left=0,top=0,width='+w+',height='+h+',innerheight='+w2+',innerwidth='+h2+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
okno.resizeTo(w2,h2);
okno.focus();
}


iz=0;
function photo(url, w, h)
{
	win=window.open('','win'+iz, 'left=0,top=0,width='+w+',height='+h+',innerheight='+h+',innerwidth='+w+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no')
	win.document.write('<html><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-2"></head>');
	win.document.write('<title>Powiększenie</title><body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	win.document.write('<div align="center"><a href="#" onclick="javascript:self.close();"><img src="'+url+'" title="Zamknij" border="0"></a></div></body></html>');
	win.focus();
	iz+=1;
}


function toggleList(tree_id) {
  var element = document.getElementById("parent"+tree_id);
  
  if (element) {
    if (element.style.display == 'none') {
      element.style.display = 'block';
    }
    else {
      element.style.display = 'none';
    }
  }
}

function valid_vote()
{
	var items = document.getElementById("pollForm").answer;
	var checked = 0;
	var count = 0;
	
	if(items&&!items.length) items=[items] 
	
	if(!items) count=0;
	else count = items.length || 1;
	
	for ( var i=0; i<count; i++ )
	{
		if ( items[i].checked == true ) checked++;
	}
	
	if ( checked == 0 )
	{
		alert("Zaznacz odpowiedź!");
		return false;
	}
	else
	{
		return true;
	}
}
var qa_click = "";
function QA(id)
{
	var element = document.getElementById("a"+id);
	var more = document.getElementById("q"+id);
	
	if (element) {
		if (element.className == 'hide') {
			element.className = 'show';
			more.className = 'minus';
		}
		else {
			element.className = 'hide';
			more.className = 'plus';
		}
	}
	if ( qa_click && qa_click != id )
	{
		document.getElementById("a"+qa_click).className = 'hide';
		document.getElementById("q"+qa_click).className = 'plus';
	}
	qa_click = id;
	pos_y("q"+id);
}
function pos_y(id)
{
	var el = document.getElementById(id);
	var y=0;
	for( var node=el; node; node=node.offsetParent)
	{
		y += node.offsetTop;
	}
	window.scrollTo(0, y);
}
