function open_chat(url, arg, chat)
{
  window.open(url, 'chat', 'width=800,height=600,left=50,top=50,toolbar=0,location=0,status=0,menubar=0,scrollbars=1');
}

function ConfirmDelete(url, query)
{
  if (confirm(query))
    {
      document.location = url;
    }
}

function affichecacheId(baliseId)
{
  if (document.getElementById && document.getElementById(baliseId) != null)
  {
    if (document.getElementById(baliseId).style.display == 'none')
      {
        document.getElementById(baliseId).style.visibility='visible';
        document.getElementById(baliseId).style.display='block';
      }
    else
      {
        document.getElementById(baliseId).style.visibility='hidden';
        document.getElementById(baliseId).style.display='none';
      }
  }
}

function affichecacheName(baliseId)
{
  if (document.getElementsByName && document.getElementsByName(baliseId) != null)
  {
    var elems = document.getElementsByName(baliseId);

    if(!elems) return;

    for(var x = 0; x < elems.length; x++)
    {
      var e = elems[x];
	
      if (e.style.display == 'none')
        {
          e.style.visibility='visible';
          e.style.display='block';
        }
      else
        {
          e.style.visibility='hidden';
          e.style.display='none';
        }
    }
  }
}


function my_pop_up(url, name, arg)
{

    neww = window.open(url.replace("/index/", "/index.php/"), name, 'toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1'+arg);
    neww.focus();
}

function fenetre_photo(url, arg)
  {
    neww = window.open(url.replace("/index/", "/index.php/"), 'dede', 'width=820,height=700,left=50,top=50,toolbar=0,location=0,status=1,menubar=0,scrollbars=1,resizable=1');
    neww.focus();
  }

function photo_popup(picture)
  {
    neww = window.open('/site/photo.php3?src=' + picture, 'picture', 'width=800,height=600,left=50,top=50,toolbar=0,location=0,status=1,menubar=0,scrollbars=1,resizable=1');
    neww.focus();
  }




function AnySelectedbyname(balisename)
  {
    if (document.getElementsByName && document.getElementsByName(balisename) != null)
      {
	elm = document.getElementsByName(balisename);
        for (i = 0; i < elm.elements.length; i++) {
          if (elm.elements[i].checked) return true;
        }
      }
    return false;
  }


function AllSelectedOrNotbyname(balisename, val)
  {
    if (document.getElementsByName && document.getElementsByName(balisename) != null)
      {
        elm = document.getElementsByName(balisename);
        for (i = 0; i < elm.length; i++) {
	  if (val == -1)
            elm[i].checked = !elm[i].checked;
	  else
            elm[i].checked = val;
        }
      }
  }

function add_to_id(num, name, info)
{
  var num_ = num + 1;

  if (info == undefined)
    info = 0;

  input_text = (info == 0 || info == '0' ? '' : '<div><strong>Legende de la photo:</strong></div><textarea class="picture-info" name="'+name+'_info[]" cols="20" rows="3"></textarea>');

  document.getElementById('file_'+num+'_'+name).innerHTML = '<fieldset><legend>Image '+num+'</legend><input type="file" name="'+name+'[]" size="30" /> '+ input_text +'</fieldset><div id="file_'+num_+'_'+name+'"><a style="cursor: pointer" onclick="javascript:add_to_id('+num_+', \''+name+'\', \''+(input_text == '' ? 0 : 1)+'\');">Ajouter une autre image...</a></div>';
}
