// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

/* FRONTEND */

function setVisible(id){
      $(id).style.visibility='visible';
}

function setInvisible(id){
      $(id).style.visibility='hidden';
}

function textHelperTgl(){
  if ( $('help-format').style.display == 'none' ){
      new Effect.BlindDown('help-format', {duration: 0.2});
  }
  else {
      new Effect.BlindUp('help-format', {duration: 0.2});
  }
}

/* ADD OR REMOVE CLASS */

function addClass(target, classValue)
{
  var pattern = new RegExp("(^| )" + classValue + "( |$)");

  if (!pattern.test(target.className))
  {
    if (target.className == "")
    {
      target.className = classValue;
    }
    else
    {
      target.className += " " + classValue;
    }
  }

  return true;
}

function removeClass(target, classValue)
{
  var removedClass = target.className;
  var pattern = new RegExp("(^| )" + classValue + "( |$)");

  removedClass = removedClass.replace(pattern, "$1");
  removedClass = removedClass.replace(/ $/, "");

  target.className = removedClass;

  return true;
}

/* ADMIN */

function changeBg(classname,color) {
      allNodes = document.getElementsByClassName(classname);
      
      for(i = 0; i < allNodes.length; i++) {
          allNodes[i].style.backgroundColor = color;
      }
}

