/*
 * CVS version control block - do not edit manually
 * $RCSfile: jeanmarcfray.js,v $ - $Name: RELEASE_1_5_2 $
 * $Revision: 1.1 $
 * $Date: 2009/12/01 01:19:39 $
 * $Source: /usr/local/repository/jean-marc-fray/public/javascripts/jeanmarcfray.js,v $
 * Last modifications by $Author: d $
 *
 * Mojo Helpdesk local javascript functions.
 *
 */

function object_is_visible(id)
{
  return (document.getElementById(id).style.display != 'none');
}

var standard_blind_down_options = {duration: "0.25"};
var standard_blind_up_options = {duration: "0.1"};
var standard_appear_options = {duration: "0.5"};
var standard_fade_options = {duration: "0"};

function set_visibility(id, want_visible)
{
  if (want_visible != object_is_visible(id)) {
    if (want_visible) {
      new Effect.BlindDown(id, standard_blind_down_options);
    } else {
      new Effect.BlindUp(id, standard_blind_up_options);
    }
  }
}

function set_visibility2(id, want_visible)
{
  if (want_visible != object_is_visible(id)) {
    if (want_visible) {
      new Effect.Appear(id, standard_appear_options);
    } else {
      new Effect.Fade(id, standard_fade_options);
    }
  }
}

function toggle_visibility(/* id1, id2, ...*/)
{
  for (var i = 0 ; i < arguments.length ; ++i) {
    var id = arguments[i];
    if (object_is_visible(id)) {
      new Effect.BlindUp(id, standard_blind_down_options);
    } else {
      new Effect.BlindDown(id, standard_blind_up_options);
    }
  }
}

function toggle_visibility_no_blind(/* id1, id2, ...*/)
{
  for (var i = 0 ; i < arguments.length ; ++i) {
    var id = arguments[i];
    if (object_is_visible(id)) {
      new Effect.Fade(id, standard_fade_options);
    } else {
      new Effect.Appear(id, standard_appear_options);
    }
  }
}

function toggle_checkbox(id)
{
  checkbox = document.getElementById(id);
  if(checkbox.checked) {
    checkbox.checked = false;
  } else {
    checkbox.checked = true;
  }
}

function empty_checkbox(id)
{
  checkbox = document.getElementById(id);
  checkbox.checked = false;
}

function change_textarea_height(id,minrows,maxrows)
{
  var txtarea = document.getElementById(id);
   if( txtarea.rows<maxrows) {
    txtarea.rows = maxrows;
   } else {
    txtarea.rows = minrows;
   }
}
