window.onload = function () {
    moveSky(0);
    rebuildImages();
	silbentrennung();
}



var delay = 100;
var step = 1;

var pos = 0;
function moveSky(id) {
    pos = (pos + step) % 3000;
    document.getElementById('sky' + id).style.backgroundPosition = String(pos)+ "px 0";
    id = 1 - id;
    window.setTimeout("moveSky(" + id + ")", delay);
}

function rebuildImages() {

    var Images = document.getElementsByTagName("img");
    for (var Id in Images) {
        var Img = Images[Id];
        if (Img.className=="shadow" || Img.className=="shadowSmall") {
            var Parent = Img.parentNode;
            var withLink = false;
            if (Parent.tagName == "A") {
                Parent = Parent.parentNode;
//alert(Parent);
                withLink = true;
            }
            // create outer div, get align and width
            var outDiv = document.createElement("div");
//alert(outDiv)
            if (Img.align == "right" || Img.style.cssFloat == "right") {
                outDiv.className = "imgRight";
            } else {
                outDiv.className = "imgLeft";
            }
            outDiv.style.width = String(Img.offsetWidth) + "px"
            if (Img.className=="shadowSmall") {
                outDiv.className += " gallery";
            }
//          Parent.appendChild(outDiv)
            var NewTag = "<img src='" + Img.src + "' alt='" + Img.alt + "' class='" + Img.className + "' width='" + Img.width + "' />";
            
            // insert image copy
/*          var moveImg = document.createElement("img");

            moveImg.src = Img.src;
            moveImg.width = Img.width;
            moveImg.height = Img.height;
            moveImg.alt = Img.alt;
            moveImg.className = Img.className;*/


            if (withLink) {
                var title = Img.parentNode.title + Img.title;
                NewTag = "<a href='" + Img.parentNode.href + "' rel='" + Img.parentNode.rel + "' target='" + Img.parentNode.target + "' class='" + Img.parentNode.className + "' title='" + title + "'>" + NewTag + "</a>"; 
            }
/*              var parentLink = document.createElement("a")
alert(parentLink);
                parentLink.href = Img.parentNode.href;
                parentLink.rel = Img.parentNode.rel;
                parentLink.target = Img.parentNode.target;
                parentLink.classname = Img.parentNode.classname;
                outDiv.appendChild(parentLink);
                parentLink.appendChild(moveImg)
            } else {
                outDiv.appendChild(moveImg);
            }*/
            // insert  title area
            if (Img.title.length > 0) {
                NewTag = NewTag + "<div>" + Img.title.replace(/\|/, "<br />") + "</div>";
/*              var TitleDiv = document.createElement("div");
                TitleDiv.appendChild(document.createTextNode(Img.title))
//              alert(TitleDiv.innerHTML)
                TitleDiv.innerHTML = TitleDiv.innerHTML.replace(/\|/, "<br />")
                outDiv.appendChild(TitleDiv)  */
            }

            // insert edge div
            NewTag = NewTag + "<div class='edge'> </div>";
/*          var EdgeDiv = document.createElement("div")
            EdgeDiv.className = "edge";
            // insert new outer div
alert(Parent);
alert(outDiv);
alert(parentLink);*/
//          outDiv.appendChild(EdgeDiv)
            outDiv.innerHTML = NewTag;
            if (withLink) {
                Parent.insertBefore(outDiv, Img.parentNode);
            } else {
                Parent.insertBefore(outDiv, Img);
            }
            if (withLink) {
                Parent.removeChild(Img.parentNode)
            } else {
                Parent.removeChild(Img)
            }
        }   
    }   
}
    function anotherNode(arr) {
        out = new Object();
        out["parent"] = false;
//      alert(arr["node"].childNodes[0]);
        if (!arr["parent"] && typeof(arr["node"].firstChild) != "undefined") {
            out["node"] = arr["node"].firstChild;
            alert ("child")
            return out;
        }
        if (typeof(arr["node"].nextSibling) != "undefined") {
            out["node"] = arr["node"].nextSibling;
            alert("sibling")
            return  out;
        }
        out["parent"] = true;
        out["node"] = arr["node"].parentNode;
        alert("parent")
        return out;
    }
