/*
if (!document.getElementById) window.location="http://www.webstandards.org/upgrade";
*/
var w  = window;
var d  = document;
var px = document.layers || window.opera ? "" : "px";
var ww,wh;

function undef(v) {
  var u;
  return v==u;
  };

function mgobject(name) {
  this.e = document.getElementById ? document.getElementById(name) : document.all ? document.all[name] : null;
  if (!this.e) return null;
  
  this.css  = this.e.style;
  this.name = name+'Object'; eval(this.name+'=this');
  
  this.x = this.e.offsetLeft   ? this.e.offsetLeft   : 0;
  this.y = this.e.offsetTop    ? this.e.offsetTop    : 0;
  this.w = this.e.offsetWidth  ? this.e.offsetWidth  : 0;
  this.h = this.e.offsetHeight ? this.e.offsetHeight : 0;
  
  this.opaq = 100;
  };

mgobject.prototype.show = function() {
  this.css.visibility = "visible";
  };

mgobject.prototype.hide = function() {
  this.css.visibility = "hidden";
  };

mgobject.prototype.moveto = function(x,y) {
  if (x != null) {
    x = Math.round(x);
    this.x = x;
    this.css.left = x + px;
    };
  if (y != null) {
    y = Math.round(y);
    this.y = y;
    this.css.top = y + px;
    };
  };
mgobject.prototype.moveby = function(x,y) {
  this.moveto(this.x + x, this.y + y);
  };

mgobject.prototype.getw = function() {
  if (this.e.offsetWidth) return this.e.offsetWidth;
  else if (parseInt(this.css.width)) return parseInt(this.css.width);
  else return 0;
  };
mgobject.prototype.geth = function() {
  if (this.e.offsetHeight) return this.e.offsetHeight;
  else if (parseInt(this.css.height)) return parseInt(this.css.height);
  else return 0;
  };
mgobject.prototype.setw = function(pixel) {
  this.css.width = pixel + px;
  };
mgobject.prototype.seth = function(pixel) {
  this.css.height = pixel + px;
  };
mgobject.prototype.changebg=function(image) {
  this.css.backgroundImage='url('+image+')';
  };
mgobject.prototype.setz = function(z) {
  this.z=z;
  this.css.zIndex = this.z;
  };
mgobject.prototype.addevent = function addEvent(evType,fn,useCapture) {
  if (this.e.addEventListener) {
    this.e.addEventListener(evType, fn, useCapture);
    return true;
  } else if (this.e.attachEvent) {
    var r = this.e.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler kann nicht angehängt werden");
  };
}; 
mgobject.prototype.remevent = function(evType,fn,useCapture) {
  if (this.e.removeEventListener) {
    this.e.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (this.e.detachEvent) {
    var r = this.e.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler konnte nicht entfernt werden");
  };
}; 

mgobject.prototype.seto = function(o) {
  if (!undef(this.css.MozOpacity)) this.css.MozOpacity=(o/100);
  else if (this.e.filters) this.css.filter='alpha(opacity='+o+')';
  this.opaq=o;
  };
mgobject.prototype.geto = function() {
  if (!undef(this.css.MozOpacity)) return this.css.MozOpacity*100;
  else if (this.e.filters) return this.e.filters.alpha.opacity;
  };


mgobject.prototype.fadeto = function(target,step,time) {
  clearTimeout(this.fadetimer);
  this.fade(target,step,time);
  };
mgobject.prototype.fade = function(target,step,time) {
  if (target > this.opaq) this.seto(this.opaq + step);
  else this.seto(this.opaq - step);
  if (Math.abs(target-this.opaq) > step) {
    this.fadetimer=setTimeout(this.name+'.fade('+target+','+step+','+time+')',time);
    }
  else {
    this.seto(target); clearTimeout(this.fadetimer);
    };
  };

function getwd() {
  wh = w.innerHeight ? w.innerHeight : d.documentElement.clientHeight;
  ww = w.innerWidth  ? w.innerWidth  : d.documentElement.clientWidth;
  };
  
function nolinkoutlines() {
  var lnks = document.links ? document.links : document.getElementsByTagName ? document.getElementsByTagName("a") : null;
  if (lnks) {
    for (var m = 0; lnks[m]; m++) {
      lnks[m].onfocus = function(){
        this.blur();
        };
      };
    };
  };
