function DEFINEIFNOT(id,val){
  if(!eval(id)) eval(id + '=val;');
}

//extend array prototype
DEFINEIFNOT('Array.prototype.appendArray', function(arr) {
	var s = this.length;
	for (var i = 0; i < arr.length; i++)
    this[s++] = arr[i];
  return s;
});
DEFINEIFNOT('Array.prototype.removeAll',function(obj){
  var delta = 0;
  for (var i = 0; i < this.length; i++){
	this[i]=this[i+delta];
    if(this[i]==obj) {
      delta++;
      i--;
    }
  }
  this.length -= delta;
});
stopPropagation = function(ev){
  ev.cancelBubble = true;
  if(ev.stopPropagation) ev.stopPropagation();
}

//extend string prototype
String.prototype.trim=function(){
  return this.replace(/(^\s+)|\s+$/g,"");
}
Function.prototype.getContent = function(){
  var s = this.toString();
  return s.substring(s.indexOf('{')+1,s.lastIndexOf('}')).trim();
}

//use only for event handler onclick, onmouseover...
EventConcat = function(f1,f2){
//	alert(f1+'\r\nU\r\n'+f2);
  if(f1==null || f1=='undefined') return f2;
  if(f2==null || f2=='undefined') return f1;
  return new Function('event,obj',f1.getContent()+';'+f2.getContent());
}
//onloadpassive must contain function that may be called several times, that do not change adresses etc...
/* Replaced standard 'window.onload' with specifics 'DOMLoadedInit' that's fired when DOM is loaded */
DOMLoadedInit = function(){
  if(window.onloadpassive){
    window.onloadpassive();
  }
}
/*
window.onload = function(){
  if(window.onloadpassive){
    window.onloadpassive();
  }
}
*/
