/* Copyright (c) 2006-2009 Romain Bezut
   Programme sous Licence GPL (voir le fichier LICENSE) */
/* Javascript associe a l'affichage des articles */

function show(element)
{
  if(document.getElementById(element)) {
    if(document.getElementById(element).style.display == 'none' || document.getElementById(element).style.display == '')
      document.getElementById(element).style.display = 'block';
    else
      document.getElementById(element).style.display = 'none';
  }
}

function smiley(valeur, cp)
{
  if (cp === 1)
    var Champ = document.forms.article.message;
  else
    var Champ = document.forms.commentaires.message;

  //IE support
  if (document.selection) {
    Champ.focus();
    sel = document.selection.createRange();
    sel.text = valeur;
  }
  //MOZILLA/NETSCAPE support
  else if (Champ.selectionStart || Champ.selectionStart == 0) {
    var startPos = Champ.selectionStart;
    var endPos = Champ.selectionEnd;
    Champ.value = Champ.value.substring(0, startPos) + valeur + Champ.value.substring(endPos, Champ.value.length);
  }
  else
    Champ.value += valeur;
}

function lang_toogle(aAnchor)
{
  var parent = aAnchor.parentNode;
  var anchor = parent.firstChild;
  var allLangs = [];
  while (anchor) {
    if (anchor.nodeType == 1) {
      anchor.className = "";
      allLangs.push(anchor.getAttribute("xml:lang"));
    }
    anchor = anchor.nextSibling;
  }

  aAnchor.className = "selected";
  var targetLang = aAnchor.getAttribute("xml:lang");
  var tabpanel = parent.nextSibling;
  while (tabpanel) {
    if (tabpanel.nodeType == 1) {
      var l = tabpanel.getAttribute("xml:lang");
      tabpanel.className = "langcontent";
      if (l == targetLang)
        tabpanel.className = "selected " + tabpanel.className;
    }
    tabpanel = tabpanel.nextSibling;
  }

  return false;
}
