IE4 = (document.all) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
NS6 = (document.getElementById) ? 1 : 0;
VERSION4 = (IE4 | NS4 | NS6) ? 1 : 0;

function add_scroll_position (url)
{
  if (url.indexOf ("?") == -1) url += "?";

  if (IE4)
    url = url + "&scrollX=" + document.body.scrollLeft + "&scrollY=" + document.body.scrollTop;
  else
    url = url + "&scrollX=" + window.scrollX + "&scrollY=" + window.scrollY;
  
  url = url + "&REFERER=" + escape (document.location.href);
  
  return url;
}

function add_scroll_position_without_referer (url)
{
  if (url.indexOf ("?") == -1) url += "?";

  if (IE4)
    url = url + "&scrollX=" + document.body.scrollLeft + "&scrollY=" + document.body.scrollTop;
  else
    url = url + "&scrollX=" + window.scrollX + "&scrollY=" + window.scrollY;

  return url;
}

function popup_open (url, name)
{
  url = add_scroll_position (url);
  window.open (url, 
	       name, 
	       'width=700,height=700,scrollbars=yes,resizable=yes,left=0,top=0,status=no');
}

function insert_link (url, text)
{
  text = text ? text : "Confirmez vous cet ajout ?";
  if (confirm (text))
    {
      window.location = add_scroll_position (url);
    }
  return false;
}

function append_link (url, text)
{
 return insert_link (url, text);
}

function delete_link (url, text)
{
  text = text ? text : "Confirmez vous cette suppression ?";
  if (confirm (text))
    {
      window.location = add_scroll_position (url);
    }
  return false;
}

function state_link (url, text)
{
  text = text ? text : "Confirmez vous cette modification ?";
  if (confirm (text))
    {
      window.location = add_scroll_position (url);
    }
  return false;
}

function event_link (url, text)
{
  if (!text || confirm (text))
    {
      window.location = add_scroll_position (url);
    }
  return false;
}

function select_link (url)
{
  window.location = add_scroll_position (url);
  return false;
}

function reload_opener ()
{
  window.opener.location.reload ();
}

function reload_opener_and_close ()
{
  reload_opener ();
  window.close ();
}

function scroll_page (x, y)
{
  self.scrollTo (x,y);
}


function popup_open_without_scroll (url, name)
{
  window.open (url, 
	       name, 
	       'width=700,height=700,scrollbars=yes,resizable=yes,left=0,top=0,status=no');
  return false;
}


