// 21.05.2003
function myDHTML(theDocument)
{   this.DHTML  = false;
    this.DOM    = false;
    this.MS     = false;
    this.NS     = false;
    this.OP5    = false;
    this.OPevent= false;
    this.Elem   = null;
    this.Cont   = null;
    this.Attr   = null;
    this.Style  = null;
    this.getElem    = getElem;
    this.getE       = getIdElement;
    this.getS       = getIdStyle;
    this.setStyle   = setStyle;
    this.setXY      = setXY;
    this.setWH      = setWH;
    this.addEvent   = addEvent;
    if (typeof theDocument == "object")
    {   this.theDoc = theDocument;
    } else {
        this.theDoc = document;
    }
    if (window.opera)
    {   this.OP5     = true;
        this.OPevent = true;
    }
    if(this.theDoc.getElementById)
    {   this.DHTML = true;
        this.DOM = true;
    }
    if(this.theDoc.all && !this.OP5)
    {   this.DHTML = true;
        this.MS = true;
    }
    if(window.netscape && window.screen && !this.DOM && !this.OP5)
    {   this.DHTML = true;
        this.NS = true;
    }
}
function setStyle(p1, p2, p3)
{   var x = this.getE(p1);
    if (!this.NS)
    {	eval('x.style.' + p2 + ' = \"' + p3 + '\"');
        return(true);
    } else {
        if (p3.indexOf('px', 0)>0)
        {   tmp = p3.substr(0, p3.indexOf('px', 0));
        } else {
            tmp = p3;
        }
        eval('x.' + p2 + ' = ' + tmp);
        return(true);
    }
}
function setXY(id, x, y)
{   var xx = this.getE(id);
    if (this.DOM)
    {   xx.style.left    = x + 'px';
        xx.style.top     = y + 'px';
    }
    if (this.NS)
    {   xx.left          = x;
        xx.top           = y;
    }
}
function setWH(id, w, h)
{   var xx = this.getE(id);
    if(this.DOM && !this.MS && !this.OP5)
    {   xx.style.width   = w + 'px';
        xx.style.height  = h + 'px';
    } else if (this.DOM)
    {   xx.style.pixelWidth   = w;
        xx.style.pixelHeight  = h;
    } else
    {   xx.width         = w;
        xx.height        = h;
    }
}
function addEvent(id, typ, func)
{   var xx = this.getE(id);
    if (this.DOM && !this.OP5 && !this.MS)
    {   xx.addEventListener(typ, func, true);
    } else if(this.DOM && this.MS && !this.OP5)  {
        xx.attachEvent('on'+typ, func);
    }
}
function getIdElement(p1)
{   return(this.getElem("id", p1, null));
}
function getIdStyle(p1)
{   this.Style = this.getElem("id", p1, null).style;
    return (this.Style);
}
function getElem(p1,p2,p3) {
if(this.DOM) {
    if(p1.toLowerCase()=="id") {
        if (typeof this.theDoc.getElementById(p2) == "object")
            this.Elem = this.theDoc.getElementById(p2);
        else this.Elem = void(0);
        return(this.Elem);
    }
    else if(p1.toLowerCase()=="name") {
        if (typeof this.theDoc.getElementsByName(p2) == "object")
            this.Elem = this.theDoc.getElementsByName(p2)[p3];
        else this.Elem = void(0);
        return(this.Elem);
    }
    else if(p1.toLowerCase()=="tagname") {
        if (typeof this.theDoc.getElementsByTagName(p2) == "object" || (this.OP5 && typeof this.theDoc.getElementsByTagName(p2) == "function"))
            this.Elem = this.theDoc.getElementsByTagName(p2)[p3];
        else this.Elem = void(0);
        return(this.Elem);
    }
    else return void(0);
 }
 else if(this.MS) {
    if(p1.toLowerCase()=="id") {
        if (typeof this.theDoc.all[p2] == "object")
            this.Elem = this.theDoc.all[p2];
        else this.Elem = void(0);
        return(this.Elem);
    }
    else if(p1.toLowerCase()=="tagname") {
        if (typeof this.theDoc.all.tags(p2) == "object")
            this.Elem = this.theDoc.all.tags(p2)[p3];
        else this.Elem = void(0);
        return(this.Elem);
    }
    else if(p1.toLowerCase()=="name") {
        if (typeof document[p2] == "object")
            this.Elem = document[p2];
        else this.Elem = void(0);
        return(this.Elem);
    }
    else return void(0);
 }
 else if(this.NS) {
    if(p1.toLowerCase()=="id" || p1.toLowerCase()=="name") {
        if (typeof document[p2] == "object")
            this.Elem = document[p2];
        else this.Elem = void(0);
        return(this.Elem);
    }
    else if(p1.toLowerCase()=="index") {
        if (typeof this.theDoc.layers[p2] == "object")
            this.Elem = this.theDoc.layers[p2];
        else this.Elem = void(0);
        return(this.Elem);
    }
    else return void(0);
 }
}


