//
//  Copyright (c) 1998-2000 Steven Champeon. All rights reserved.
// 
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as 
//  published by the Free Software Foundation; either version 2 of the
//  License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this program; if not, write to the Free Software
//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//  The author may be contacted via email at <steve@dhtml-guis.com>;
//  other information may be found on the Web at http://dhtml-guis.com
//
//

var fully_loaded = false; // must set to true when fully loaded

var winHeight;
var winWidth;
var winRelHeight = 0;
var winRelWidth = 0;

var objects;

function debug(m) {
  if( navigator.javaEnabled() &&
      navigator.appName == "Netscape" ) {
    java.lang.System.out.println(m);
  }
}

function set_window_width() {
  if( window.innerWidth ) {
    winHeight = window.innerHeight;
    winWidth = window.innerWidth;
  } else {
    // should this be body.clientHeight? yes
    //winHeight = document.body.scrollHeight;
    winHeight = document.body.clientHeight;
    // should this be body.clientWidth? yes
    //winWidth = document.body.scrollWidth;
    winWidth = document.body.clientWidth;
  }
}

function set_relative_window_width() {
  if( document.body ) {
    winRelHeight = document.body.scrollTop;
    winRelWidth = document.body.scrollLeft;
  } else {
    winRelHeight = window.pageYOffset;
    winRelWidth = window.pageXOffset;
  }
}

// these need to be outside the function body because
// they are referenced by other functions later.
// forms
var form_name = new Array();
var form_count = 0;

// images
var image_name = new Array();
var image_count = 0;

// DIV objects and layers
var object_name = new Array();
// bugfix by Simon E. S¿rensen
var object_count = 0;

// anchor objects
// Jan Van Valen
var anchor_count = 0;
var anchor_name = new Array();
var anchor_number = new Array(); // bugfix 08/13/00

// create base objects
function create_base_objects() {
  if( document.all ) {
    objects = document.all.tags("DIV");
  } else {
    objects = document.layers;
  }

  for( i = 0; i < objects.length; i++ ) {
    current_name = objects[i].id;
    object_name[ current_name ] = new base_object( objects[i] );
  }
}

function base_object( object ) {
  if( object.style ) {
    this.isIE = object;
  } else {
    this.style = object;
  }
  
  object_count++;

  this.name = object.id;

  // handle visibility
  this.conceal = conceal;
  this.reveal = reveal;

  // handle absolute and relative positioning
  this.place = place;
  this.shove = shove;
}

// hide the object
function conceal() {
  if( this.isIE ) {
    this.isIE.style.visibility = "hidden";
  } else {
    this.style.visibility = "hidden";
  }
}

// show the object
function reveal() {
  if( this.isIE ) {
    this.isIE.style.visibility = "visible";
  } else {
    this.style.visibility = "visible";
  }
}

// place object absolutely
function place( x, y ) {
  if( this.isIE ) {
    this.isIE.style.left = x;
    this.isIE.style.top = y;
  } else {
    this.style.moveTo( x, y );
  }
}

// move the object relative to current position
function shove( x, y ) {
  if( this.isIE ) {
    this.isIE.style.left = this.isIE.style.pixelLeft + x;
    this.isIE.style.top = this.isIE.style.pixelTop + y;
  } else {
    //this.style.moveBy( x, y );
    this.style.left += x;
    this.style.top += y;
  }
}
