//Javascript

/**This function returns true, when the browser is Navigator ver 4.x
 */
function isNavigator()
{var nv = (navigator.appName == "Netscape");
 if(nv && (new String(navigator.appVersion)).charAt(0) == "4")
  return true;
 return false;
}

/**nav is true when the browser is Navigator 4.x
 *msie is true when the browswer is Microsoft Internet Explorer
 */
nav = isNavigator();
msie = (navigator.appName == "Microsoft Internet Explorer");


/**Javascript implementation of a queue of objects. The method put
 *inserts the object reference into the queue, the method get returns
 *the object reference from the queue. The method isEmpty returns
 *true when the queue does not contain any objet reference.
 */
function Qnode(a,b)
{this.object = a;
 this.next = b;
}

queue = new Object();
queue.head = null;
queue.tail = null;

queue.put = new Function("obj",
 "if(this.tail == null)" +
 " {this.tail = new Qnode(obj,null);" +
 "  this.head = this.tail;" +
 " } " +
 "else " +
 " {this.tail.next = new Qnode(obj,null); " +
 "  this.tail = this.tail.next; " +
 " }" );

queue.get = new Function(
 "var obj = this.head.object;" +
 "this.head = this.head.next;" +
 "if(this.head == null)" +
 " this.tail = null;" +
 "return obj;");

queue.isEmpty = new Function("return this.head == null;");

/**Folowing code creates method getElementById of the document object.
 *The method is created only when document does not have this method.
 *The method returns object reference for an object whose ID is
 *supplied as string parameter. In the case of Navigator 4.x only
 *references to relatively or absolutely positioned DIV and SPAN 
 *elements are returned.
 */
if(! document.getElementById)
 {if(document.all)
   document.getElementById = new Function("a",
   "var i;" +
   "for(i = 0; i < this.all.length; ++ i) " +
   " if(this.all[i].id == a) return this.all[i];" +
   "return void 0;" );
  else if(document.layers)
   document.getElementById = new Function("a",
    "var x,i;" +
    "queue.head = null; queue.tail = null;" +
    "queue.put(this);" +
    "while(!queue.isEmpty())" +
    "{x = queue.get();" +
    " for(i = 0; i < x.layers.length ; ++ i)" +
    "  {if(x.layers[i].id == a) return x.layers[i];" +
    "   if(x.layers[i].document.layers.length > 0) " +
    "    queue.put(x.layers[i].document);" +
    "  }} return void 0;"); 
  else
   document.getElementById = new Function("a" , "return void 0;");
 }
