/* Finds an element and returns the element as an object. */
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if(n&&(p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

/* A general function that associates an object instance with an event
   handler. The returned inner function is used as the event handler.
   The object instance is passed as the - obj - parameter and the name
   of the method that is to be called on that object is passed as the -
   methodName - (string) parameter.
   
   More information at: http://jibbering.com/faq/faq_notes/closures.html */
function associateObjWithEvent(obj, methodName){
  /* The returned inner function is intended to act as an event 
	 handler for a DOM element:- */
  return (function(objEvent) {
	/* The event object that will have been parsed as the - e -
	   parameter on DOM standard browsers is normalised to the IE
	   event object if it has not been passed as an argument to the
	   event handling inner function:- */
	objEvent = objEvent || window.event;
	
	/* The event handler calls to method of the object - obj - with
	   the name held in the string - methodName - passing the now
	   normalised event object and a reference to the element to
	   which the event handler has been assigned using the - this -
	   (which works because the inner function is executed as a
	   method of that element because it has been assigned as an
	   event handler):-*/
        return obj[methodName](objEvent, this);
  });
}

/* Defines the DOM node type constants. */
if(!window.Node){
  var Node = {
    ELEMENT_NODE : 1,
    ATTRIBUTE_NODE : 2,
    TEXT_NODE : 3,
    CDATA_SECTION_NODE : 4,
    ENTITY_REFERENCE_NODE : 5,
    ENTITY_NODE : 6,
    PROCESSING_INSTRUCTIONS_NODE : 7,
    COMMENT_NODE : 8,
    DOCUMENT_NODE : 9,
    DOCUMENT_TYPE_NODE : 10,
    DOCUMENT_FRAGMENT_NODE : 11,
    NOTATION_NODE : 12
  }
}

/* The push function dynamically adds content to an array. This 
   function is used only if the push function is not supported. */
if(!Array.push) {
  Array.prototype.push = function() {
	for(var i = 0; i != arguments.length; i++)
	  this[this.length]=arguments[i];
	
	return this.length;
  }
}

/* Checks if the input is undefined. */
function IsUndefined(varTest) { return typeof varTest == 'undefined'; }

/* Checks if the input is an object. */
function IsObject(varTest) { return (varTest && typeof varTest == 'object') || isFunction(varTest); }

/* Checks if the input is an number. */
function isNumber(a) { return typeof a == 'number' && isFinite(a); }

/* Checks if the argument is an anchor by checking if the object is a
   link tag with no href attribute property. */
function IsAnchor(objTest) {
  if((objTest.tagName).toLowerCase() == "a" && !objTest.href)
	return true;
  else
	return false;
}