// Menu
function changeDisplay(id, parent_id)
{
  tmp1 = id.indexOf("_");
  tmp2 = id.indexOf("_", tmp1+1);

  id1 = parseInt(id.substr(tmp1+1, tmp2-tmp1-1));
  id2 = parseInt(id.substr(tmp2+1));

  tmp = id1 + 1;

  // Pierwsza czesc - zwijamy wszystkie tego poziomu oprocz tego
  foo = document.getElementById(parent_id).getElementsByTagName("ul");;
  for (i=0;i<foo.length;i++){
    if (foo[i].id != "c_"+tmp+"_"+id2) {
      foo[i].style.display = "none";
    }
  }

  // Druga czesc - zmieniamy widocznosc tego elementu
  foo = document.getElementById("c_"+tmp+"_"+id2);
  if (foo && foo.style.display == "block") {
    foo.style.display = "none";
  } else if (foo && foo.style.display == "none") {
    foo.style.display = "block";
  }

}

function imgshow(url, width, height)
{
	LeftPosition=(screen.width)?(screen.width-width)/2:100;
	TopPosition=(screen.height)?(screen.height-height)/2:100;
	var win = window.open(url,'showpic','width=' + width + ',height=' + height + ',top=' + TopPosition + ',left=' + LeftPosition + ',resizable=0,scrollbars=no,menubar=no,toolbar=no,status=no');
}

function FocusPassword( id )  {
  string = $( id ).value;
  if( string == 'password' )
    $( id ).value = '';
  $( id ).type = 'password';
  $( id ).select();
}

function BlurPassword( id )  {
  string = $( id ).value;
  if( string == '' )  {
    $( id ).value = 'password';
    $( id ).type = 'text';
  }
}

function FocusLogin( id )  {
  string = $( id ).value;
  if( string == 'username' )
    $( id ).value = '';
  else
    $( id ).select();
}

function BlurLogin( id )  {
  string = $( id ).value;
  if( string == '' )
    $( id ).value = 'userlogin';
}

function checkAgreement()
{
  if( document.getElementById( "agreement" ).checked == true ) {
    return true;
  } else {
    alert( "Aby się zarejestrować musisz wyrazić\n zgodę na przerwarzanie danych osobowych." );
    return false;
  }
}

function handleKeyPress(e,form){
  var key=e.keyCode || e.which;
  if(key==13) {
    form.submit();
  }
}
