/******************************************
       Preload-Script (Navi & Intro)
******************************************/

function newImage(arg1)
{
    if (document.images)
    {
        rslt1 = new Image();
        rslt1.src = arg1;
        return rslt1;
    }
}

function changeImages()
{
    if (document.images && (preloadFlag == true))
    {
        for (var i=0; i<changeImages.arguments.length; i+=2)
        {
            document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
        }
     }
}

var preloadFlag = false;

// Allgemeine Preload-Funktion
function preloadImages()
{
    if (document.images)
    {
        navigation_profil_over     = newImage ("images/navigation-profil_over.jpg");
        navigation_galerie_over    = newImage ("images/navigation-galerie_over.jpg");
        navigation_downloads_over  = newImage ("images/navigation-downloads_over.jpg");
        navigation_home_over       = newImage ("images/navigation-home_over.jpg");
        navigation_links_over      = newImage ("images/navigation-links_over.jpg");
        navigation_gaestebuch_over = newImage ("images/navigation-gaestebuch_over.jpg");
        navigation_kontakt_over    = newImage ("images/navigation-kontakt_over.jpg");
        preloadFlag = true;
    }
}

// Intro Preload-Funktion
function preloadIntro(intro_Id)
{
    if (document.images)
    {
        Intro_01_coffeecup_over = newImage ("images/intro/coffeecup_over_"+intro_Id+".jpg");
        preloadFlag = true;
    }
}


/******************************************
             Anti-Frame-Script
******************************************/

if (top != self)
{
    if (window.opera)
    {
        window.onload = opera_befreien;
    }
    else
    {
        top.location = self.location;
    }
}

function opera_befreien ()
{
    document.links["befreien"].click();
}


/******************************************
             Emoticon-Scripts
******************************************/

function emoticon(text)
{
    var txtarea = document.eingabe.message;
    text = ' ' + text + ' ';
    if (txtarea.createTextRange && txtarea.caretPos)
    {
        var caretPos = txtarea.caretPos;
        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
        txtarea.focus();
    }
    else
    {
        txtarea.value  += text;
        txtarea.focus();
    }
}

function emoticon_comments(text)
{
    var txtarea = document.eingabe.comments;
    text = ' ' + text + ' ';
    if (txtarea.createTextRange && txtarea.caretPos)
    {
        var caretPos = txtarea.caretPos;
        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
        txtarea.focus();
    }
    else
    {
        txtarea.value  += text;
        txtarea.focus();
    }
}


/******************************************
             Klappmenü-Script
******************************************/

function fold_out(Id)
{
    var text = document.getElementById('lay'+Id);
    var bild = document.getElementById('pic'+Id);
    var minus="images/minus.gif", plus="images/plus.gif";

    if (text.style.display == 'none')
    {
        text.style.display = 'block';
        bild.src = minus;
    }

    else
    {
        text.style.display = 'none';
        bild.src = plus;
    }
}


/******************************************
             Trash-Script
******************************************/

document.onmousemove = checkPosition;

var mypress=0, divPosX=0, divPosY=0, diffx=0, diffy=0, layer="lay1", lass=0, count=1;

function checkPosition(e)
{
    if(document.all)
    {
        mausX = event.clientX + document.body.scrollLeft;
        mausY = event.clientY + document.body.scrollTop;
    }
    else
    {
        mausX = e.pageX; mausY = e.pageY;
    }
}

function setpress(lay)
{
    layer=lay;
    mypress=1;
    diffx=mausX- divPosX;
    diffy=mausY- divPosY;
    document.getElementById(layer).style.zIndex=999;
}

function unsetpress(lay)
{
    count++;
    layer=lay;
    mypress=0;
    document.getElementById(layer).style.zIndex=count;
}

function Mauskontrolle(Element)
{
    divPosX = Element.offsetLeft;
    divPosY = Element.offsetTop;

    if(mypress==1)
    {
        document.getElementById(layer).style.left=mausX-diffx;
        document.getElementById(layer).style.top=mausY-diffy;
    }
    return true;
}

function auf()
{
    if (lass==0)
    {
        document.getElementById('lay0').style.left=mausX;
        document.getElementById('lay0').style.top=mausY;
        document.getElementById('lay0').style.visibility='visible';
        document.haupt.pm_x.value=mausX;
        document.haupt.pm_y.value=mausY;
        lass=1;
    }

}

function zu()
{
    lass=0;
    document.getElementById('lay0').style.visibility='hidden';
}

function pmloesch(url)
{
    var box=confirm("Wirklich l&ouml;schen?");
    if (box==true)
    location.href=url;
}