/* ======================================================
   file: pgcode.js

   last update: 27.11.06 by Patricia Engelskirchen 
*/


var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;

function setConstants() {
    if (window.opera) {
        OP = 1;
    }
    if(document.getElementById) {
        DHTML = 1;
        DOM = 1;
    }
    if(document.all && !OP) {
        DHTML = 1;
        MS = 1;
    }
   if(document.layers && !OP) {
        DHTML = 1;
        NS = 1;
   }
}


function getElem(p1,p2,p3) {
    var Elem;
    if(DOM) {
        if(p1.toLowerCase()=="id") {
            if (typeof document.getElementById(p2) == "object")
                Elem = document.getElementById(p2);
            else 
                Elem = void(0);
            return(Elem);
        }
        else if(p1.toLowerCase()=="name") {
            if (typeof document.getElementsByName(p2) == "object")
                Elem = document.getElementsByName(p2)[p3];
            else 
                Elem = void(0);
            return(Elem);
        }
        else if(p1.toLowerCase()=="tagname") {
            if (typeof document.getElementsByTagName(p2) == "object" ||
               (OP && typeof document.getElementsByTagName(p2) == "function"))
                Elem = document.getElementsByTagName(p2)[p3];
            else 
                Elem = void(0);
            return(Elem);
        }
        else 
            return void(0);
    }
    else if(MS) {
        if(p1.toLowerCase()=="id") {
            if (typeof document.all[p2] == "object")
                Elem = document.all[p2];
            else 
                Elem = void(0);
            return(Elem);
        }
        else if(p1.toLowerCase()=="tagname") {
            if (typeof document.all.tags(p2) == "object")
                Elem = document.all.tags(p2)[p3];
            else 
                Elem = void(0);
            return(Elem);
        }
        else if(p1.toLowerCase()=="name") {
            if (typeof document[p2] == "object")
                Elem = document[p2];
            else 
                Elem = void(0);
            return(Elem);
        }
        else 
            return void(0);
    }
    else if(NS) {
        if(p1.toLowerCase()=="id" || p1.toLowerCase()=="name") {
            if (typeof document[p2] == "object")
                Elem = document[p2];
            else 
                Elem = void(0);
            return(Elem);
    }
    else if(p1.toLowerCase()=="index") {
        if (typeof document.layers[p2] == "object")
            Elem = document.layers[p2];
        else 
            Elem = void(0);
        return(Elem);
    }
    else 
        return void(0);
    }
}


function getCont(p1,p2,p3) {
    var Cont;
    if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild) {
        if(getElem(p1,p2,p3).firstChild.nodeType == 3)
            Cont = getElem(p1,p2,p3).firstChild.nodeValue;
        else
            Cont = "";
        return(Cont);
    }
    else if(MS && getElem(p1,p2,p3)) 
    {
        Cont = getElem(p1,p2,p3).innerText;
        return(Cont);
    }
    else 
        return void(0);
}


function getAttr(p1,p2,p3,p4) {
    var Attr;
    if((DOM || MS) && getElem(p1,p2,p3)) {
        Attr = getElem(p1,p2,p3).getAttribute(p4);
        return(Attr);
    }
    else if (NS && getElem(p1,p2)) {
        if (typeof getElem(p1,p2)[p3] == "object")
            Attr=getElem(p1,p2)[p3][p4]
        else
            Attr=getElem(p1,p2)[p4]
        return Attr;
    }
    else 
        return void(0);
}


function setCont(p1,p2,p3,p4) {
    if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild)
        getElem(p1,p2,p3).firstChild.nodeValue = p4;
    else if(MS && getElem(p1,p2,p3))
        getElem(p1,p2,p3).innerText = p4;
    else if(NS && getElem(p1,p2,p3)) {
        getElem(p1,p2,p3).document.open();
        getElem(p1,p2,p3).document.write(p4);
        getElem(p1,p2,p3).document.close();
    }
}


function aEmail() {
    var link = "lea"+"-"+"patricia";
    link=link+"@";
    link=link+"web.de";
    document.write("<a href='mailto:"+link+"'>"); 
}


function hEmail() {
    var link = "kon"+"takt";
    link=link+"@";
    link=link+"patricia";
    link=link+"-enge";
    link=link+"lskirchen.de";
    var name = "kontakt ";
    name=name+"<img src=\"./pic/kla.gif\" border=\"0\"";
    name=name+" alt=\"AT\">";
    name=name+" patricia-engelskirchen";
    name=name+".de";
    document.write("<a href='mailto:"+link+"'>"+name+"</a>");
}


function gfxChange(gfxNo,gfxObject) {
    window.document.images[gfxNo].src = gfxObject.src;
}


function changeTwoFrames(URI1,F1,URI2,F2) {
    Frame1=eval("parent."+F1);
    Frame2=eval("parent."+F2);
    Frame1.location.href = URI1;
    Frame2.location.href = URI2;
}


function getWindowWidth() {
    if (window.innerWidth) {
        return window.innerWidth;
    }
    else if (document.body && document.body.offsetWidth) {
        return document.body.offsetWidth;
    }
    else {
        return 0;
    }
}


function getWindowHeight() {
    if (window.innerHeight) {
        return window.innerHeight;
    }
    else if (document.body && document.body.offsetHeight) {
        return document.body.offsetHeight;
    }
    else {
        return 0;
    }
}


function openInfoWin(url,name,w,h) {
    window.open(url,name,"dependent=yes,menubar=no,width="+w+",height="+h+",resizable=no,scrollbars=yes,status=no,directories=no,location=no,menubar=no,toolbar=no");
}


function openPhotoWin() {
    if (MS == 1) {
        openInfoWin('pexamples1.html','Photographien',790,620);
    }
    else {
        openInfoWin('pexamples1.html','Photographien',770,600);
    }
}


function openPresentationWin(url, title){
    if (MS == 1) {
        openInfoWin(url,title,685,650);
    }
    else {
        openInfoWin(url,title,665,630);
    }
}


function writePrintButton() {
    document.writeln("<form onsubmit=\"javascript:window.print();return false;\">");
    document.writeln("<input ");
    document.writeln("    class=\"button\" ");
    document.writeln("    type=\"submit\" ");
    document.writeln("    value=\"Drucken\">");
    document.write("</form>");
}


function confirmFormreset()
{
    return window.confirm("Möchen Sie Ihre Eingaben wirklich löschen?");
}


function chkEmailAdr(adr)
{
    var result = true;
    var text = document.forms[0].elements[0].value;
    var regX;

    if (adr == '')
    {
        result = false
    }
    else
    {
        regX = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)(\\@)([a-zA-Z0-9\\-\\.]+)(\\.)([a-zA-Z]{2,4})$');
        if (!regX.test(adr))
        {
            result = false;
        };
    }
    return result
}


function chkMailFields()
{
    var sndEmail=document.EmailForm.Email.value;
    var subj=document.EmailForm.Subject.value;
    var mess=document.EmailForm.Message.value;
    var usrMess="";
    var doSubmit=true;
    
    if (chkEmailAdr(sndEmail)==false)
    {
        doSubmit=false;
        usrMess=usrMess+"\nDie Email-Adresse ist leer bzw. nicht korrekt.";
    }
    if (subj=="")
    {
        doSubmit=false;
        usrMess=usrMess+"\nDas Feld \"Betreff\" ist leer.";
    }
    if (mess=="")
    {
        doSubmit=false;
        usrMess=usrMess+"\nDas Feld \"Nachricht\" ist leer.";
    }
    if (doSubmit==false)
    {
        alert("Leider sind Ihre Eingaben noch nicht vollständig:\n"+usrMess);
    }
    return doSubmit;
}


/* ======================================================
   Initialisierung */

setConstants();

/* Topframe-Pruefung */
if(top!=self)
    top.location=self.location;
