// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
var hash = "";
var section_id = 1;

function check_all_with_classname(classname) {
  process_all_with_classname(classname, true);
}

function uncheck_all_with_classname(classname) {
  process_all_with_classname(classname, false);
}

function process_all_with_classname(classname, checked) {
  elements = document.getElementsByClassName(classname);
  for (var i=0; i<elements.length; i++) {
    elements[i].checked = checked;
  }  
}

function show_indicator() {
  Element.show('indicator');
}

function hide_indicator() {
  Element.hide('indicator');
}

	function swap_img(id,ac) {
		var ha = (ac == 0) ? '':'h';
		document.getElementById('link_img_'+id).src='/images/layout/top_link_'+id+ha+'.gif';
	}

  function get_folder_name() {
    return "new_folder=" + window.prompt('Podaj nazwę dla nowego folderu');
  }

  function change_active(id) {
    actives = $$('#menu .active')
    actives.each(function(item) {
      Element.removeClassName(item, 'active');
    });
    if(id != "")
      Element.addClassName(id, 'active');
    return true;
  }

  function remove_flash() {
    if($('headerFlash')) {
      $('headerFlash').hide();
    }
    return true;
  }

  // TODO remove_actives
  
  
function clearOnInitialFocus ( fieldName ) {
  var clearedOnce = false;
  document.getElementById( fieldName ).onfocus = (function () {
    if (clearedOnce == false) {
      this.value = '';
      clearedOnce = true;
    }
  })
}

function submit_on_key_press(fieldName) {
  document.getElementById(fieldName).setAttribute('onsubmit', $('submit_form').getAttribute('onclick'));
}

function check_form() {
  if($('contact_mail').value == '') {
    alert('Należy wypełnić wszystkie pola.');
    return false; 
  }
  return true;
}


function lightbox_startowy (){
  $('lightbox_startowy').style.display = "";
  return true;
}
