;

if(window.opera){
  Array.prototype.concat = function(){
    var array = [];
    for(var i = 0, length = this.length; i < length; i++) array.push(this[i]);
    for(var i = 0, length = arguments.length; i < length; i++) {
      if(arguments[i].constructor == Array) {
        for(var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
          array.push(arguments[i][j]);
      } else {
        array.push(arguments[i]);
      }
    }
    return array;
  }
}

if (typeof(Object.extend) != "function") {
	Object.extend = function(destination, source) {
	  for (var property in source) {
		destination[property] = source[property];
	  }
	  return destination;
	}
}

if (typeof(Function.prototype.bind) != "function")
{
	Function.prototype.bind = function(object) {
	  var func = this;
	  return function() { return func.apply(object, arguments); }
	}
}

Function.prototype.bindAsEventListener = function(object) {
	var __method = this;
	return function(event) {
		__method.call(object, event || window.event);
	}
}

var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}

function getElementsByClassName(node, classname)
{
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

function removeAllChildren(node) {
	
	var childNodes = node.childNodes;
	if (node.childNodes.length == 0)
		return;
	
	for (var i = 0; i < childNodes.length ; i++ )
	{
		var childNode = childNodes[i];
		if (typeof(childNode) == "object")
			node.removeChild(childNode);
	}
}

/* SE1.0.3.1: getElementCoordinates(element) : start. */
// gets the absolute position of an element
function getElementCoordinates(element) {
	var coord = new Object();
	coord.x = 0;
	coord.y = 0;
	
	// IE work-around
	coord.w = (element.clientWidth > 0) ? element.clientWidth : element.offsetWidth;
	coord.h = (element.clientHeight > 0) ? element.clientHeight : element.offsetHeight;
	
	while (element) {
		coord.x += element.offsetLeft;
		coord.y += element.offsetTop;
		element = element.offsetParent;
	}
	coord.x1 = coord.x;
	coord.y1 = coord.y;
	coord.x2 = coord.x1 + coord.w;
	coord.y2 = coord.y1 + coord.h;
	
	coord.xc = (coord.x1 + coord.x2) / 2;
	coord.yc = (coord.y1 + coord.y2) / 2;
	
	/* addition functions */
	coord.toString = function () {
		var str = "coord\n";
		for (var i in this) {
			if (typeof(this[i]) != "function") {
				str += "\t" + i + ": " + this[i] + "\n";
			}
		}
		return str;
	}
	
	coord.shrink = function (by) {
		this.x1 += by;
		this.y1 += by;
		this.x2 -= by;
		this.y2 -= by;
		return computeWidthAndCenters(this);
	}
	
	coord.expand = function (by) {
		this.x1 -= by;
		this.y1 -= by;
		this.x2 += by;
		this.y2 += by;
		return computeWidthAndCenters(this);
	}
	/* */
	
	return computeWidthAndCenters(coord);
	
	
}
/* SE1.0.3.1: getElementCoordinates(element) : end. */

/* SE1.0.3.1: computeWidthAndCenters(coord) : start. */
// updates the width and center of a coordinate box
function computeWidthAndCenters(coord) {
	coord.x = coord.x1;
	coord.y = coord.y1;
	coord.w = coord.x2 - coord.x1;
	coord.h = coord.y2 - coord.y1;
	coord.xc = (coord.x1 + coord.x2) / 2;
	coord.yc = (coord.y1 + coord.y2) / 2;
	
	return coord;
}
/* SE1.0.3.1: computeWidthAndCenters(coord) : end. */

/* SE1.0.3.1: Number.prototype.toPixels : start. */
// returns the value of a number as a CSS-style pixel value
Number.prototype.toPixels = function () { return this + "px"; }
/* SE1.0.3.1: Number.prototype.toPixels : end. */

