function checkcode(element) {
    var FS;
    if(!document.getElementById) {return true;}
    if(!document.forms[element.name].code && !document.forms[element.name].securecode) {
        FS = sucheFS(document.forms[element.name].firstChild);
        if(FS) {
            FS.appendChild(document.createElement("br"));
            var spacer = document.createElement("span");

            var codeinp = document.createElement("input");
            codeinp.type="text";
            codeinp.name="code";
            codeinp.id="securecode";
            codeinp.value="Sicherheitscode";
            codeinp.onfocus=function() {removetext(document.getElementById("securecode"), 'Sicherheitscode');};
            codeinp.onblur=function() {restoretext(document.getElementById("securecode"), 'Sicherheitscode');};
            FS.appendChild(codeinp);
            spacer.innerHTML = " ";
            FS.appendChild(spacer.cloneNode(true));

            var codeimg = document.createElement("img");
            codeimg.src="secure.php";
            codeimg.width="80";
            codeimg.height="20";
            codeimg.alt="Sicherheitscode";
            codeimg.id="secpic";
            FS.appendChild(codeimg);
            FS.appendChild(spacer.cloneNode(true));
            
            var codegen = document.createElement("a");
            codegen.href="#newcode";
            codegen.className="button";
            codegen.onclick=function() {document.getElementById('secpic').src='secure.php?' + Math.round(Math.random() * 100); this.blur();};
            codegen.innerHTML="Neuer Code";
            FS.appendChild(codegen);
            
            restoretext(document.getElementById("securecode"), "Sicherheitscode");
        }
        return false;
    }
}

function sucheFS(FS) {
  do {
    if(FS && FS.nodeName == "FIELDSET") return FS;
    if(FS) FS = FS.nextSibling;
  }
  while(FS);
  return false;
}

function removetext(element, standard) {
    if(element.value == standard) {
        element.value="";
        //element.style.color="black";
    }
}

function restoretext(element, standard) {
    if(element.value == "" || element.value == standard) {
        element.value=standard;
        //element.style.color="#888";
    }
}

