


function replaceIt(string,suchen,ersetzen) {
    var ausgabe = "" + string;
    var pos = null;
    while (ausgabe.indexOf(suchen)>-1)   {
        pos = ausgabe.indexOf(suchen);
        ausgabe = "" + (ausgabe.substring(0, pos) + ersetzen + 
        ausgabe.substring((pos + suchen.length), ausgabe.length));
    }
    return ausgabe;
}

function objToString() {
    var ret = "";
    for(p in this) {
    if (typeof this[p] == "function") continue;
    if (ret.length >0)
        ret += ";";
    ret += p + "->" + this[p];
    }
    return ret;
}

function /*object*/ getLayerRef(/* String*/ id, /*String [optional]*/ document) {
    if(!document)
        document = window.document;
      
    if (document.all) {
        return document.all[id];
    }
    else if (document.getElementById) {
        return document.getElementById(id);
    }
}


function setLayerPos(/*Object*/ objLayer, /*Object*/ coords) {
    if (window.opera) {
        objLayer.style.top = coords.y;
        objLayer.style.left = coords.x;
    }
    else if (document.all) {
        objLayer.style.top = coords.y + document.body.scrollTop;
        objLayer.style.left = coords.x + document.body.scrollLeft;
    }
    else if (document.getElementById) {
        objLayer.style.top = coords.y + 'px';
        objLayer.style.left = coords.x + 'px';
    }
}

function setLayerZIndex(/*String*/ id, /*String*/ z) {
    var oL = getLayerRef(id);
    var oLzIndex = oL.style.zIndex;
    oLzIndex = z;
}


function setLayerVisibility(/*Object*/ objLayer, /*String*/ visible) {
    objLayer.style.visibility = (visible == true) ? 'visible' : 'hidden';
}


function setLayerVisibilityByPrefix(/*String*/ prefix, /*String*/ visible, /*String [optional]*/ d) {
    if (!d)
        d = window.document;
      
    if (document.all) {
        var layers = document.all.tags("div");
        for (var i=0; i <layers.length; i++) {
        if (layers[i].id.substr(0, prefix.length) == prefix)
            setLayerVisibility(document.all.tags("div")[i], visible)
        }
    }
    else if (document.getElementByTagName) {
        var layers = document.getElementByTagName("div");
        for (var i=0; i <layers.length; i++) {
        if (layers[i].id.substr(0, prefix.length) == prefix)
            setLayerVisibility(layers[i], visible)
        }
    }
}


function getLayerCanvas(/*String*/ id) {
    var objLayer = getLayerRef(id);
    var objC = new Canvas();
      
    if (window.opera) {
        objC.x = objLayer.style.left;
        objC.y = objLayer.style.top;
        objC.width = objLayer.style.width;
        objC.height = objLayer.style.height;
    }
    else if (document.all) {
        var o = objLayer;
        objC.width = objLayer.offsetWidth;
        objC.height = objLayer.offsetHeight;
        while(o.offsetParent) {
        objC.y += parseInt(o.offsetTop);
        objC.x += parseInt(o.offsetLeft);
        o = o.offsetParent;
        }
    }
    else if (document.getElementById) {
        var o = document.defaultView.getComputedStyle(objLayer, '');
        objC.x = parseInt(o.getPropertyValue('left'));
        objC.y = parseInt(o.getPropertyValue('top'));
        objC.width = parseInt(o.getPropertyValue('width'));
        objC.height = parseInt(o.getPropertyValue('height'));
    }
    return objC;  
}


function getImageRef(/*String*/ id, /*String [optional]*/ document) {
    if(!document)
        document = window.document;
      
    if (document.images) {
        return document.images[id];
    }
    else if (document.getElementById) {
        return document.getElementById(id);
    }
    else {
        return null;
    }
}


function getImagePos(/*Object*/ img) {
    var canvas = new Canvas(0, 0, img.width, img.height);
    while (img) {
        canvas.x += img.offsetLeft;
        canvas.y += img.offsetTop;
        img = img.offsetParent;
    }
    if (document.all && !window.opera) {
        /* WICHTIG: Menu wird sonst nicht korrekt platziert
           Opera stellt es auch nicht sauber da wenn es sich als MSIE 6.0 ausgibt :) */
        canvas.x = canvas.x - document.body.scrollLeft;
        canvas.y = canvas.y - document.body.scrollTop;
    }
    return canvas;
}

function Coord(/*Int*/ x, /*Int*/ y) {
    this.x = (!x) ? 0 : x;
    this.y = (!y) ? 0 : y;
    this.toString = objToString;
}

function Canvas(/*Int*/ x, /*Int*/ y, /*Int*/ width, /*Int*/ height) {
    this.Coord = Coord;
    this.Coord(x, y);
    this.width = (!width) ? 0 : width;
    this.height = (!height) ? 0 : height;
}

function changeLayerContent(/*Object*/objLayer, /*String*/content) {
	if(navigator.appName.indexOf("Netscape") >= 0 && document.getElementById) {
		var rng	= document.createRange();
		rng.setStartBefore(objLayer);
		var newContent = rng.createContextualFragment(content);

		while(objLayer.hasChildNodes())
			objLayer.removeChild(objLayer.lastChild);
			objLayer.appendChild(newContent);
	}
	if(document.getElementById) {
		objLayer.innerHTML = content;
	}
}


