function updateDisplay(url, target, image, alttext)
{
    new Ajax.Request(
        url,{
            method: 'GET',
            parameters:
            {
            },
            evalScripts: true,
            onSuccess: function(response){
                document.getElementById('flash').style.zIndex = '0';
                Element.show("photo");
                Element.show("boxMP");
                $(target).innerHTML = response.responseText;
                $("photo").innerHTML = '<img src="/images/' + image + '" width="203" height="142" alt="'+ alttext +'" />';
                toTop(target);
            }
        });
}
function displayGallery(url, target)
{
    Element.hide("photo");
    Element.hide("boxMP");
    document.getElementById('flash').style.zIndex = '10';

/*new Ajax.Request(
        url,{
            method: 'GET',
            parameters:
            {
            },
            evalScripts: true,
            onSuccess: function(response){
                $(target).innerHTML = response.responseText;
            }
        });*/
}
/*
	Show layer for contact form
*/
function show_layer(status,form,bild)
{
    var filename;
    if(status ==1)
    {
        var params = "?name="+form.name.value+"&email="+form.email.value+"&phone="+form.phone.value+"&subject="+form.subject.value+"&message="+encodeURIComponent(form.message.value)+"&subject="+form.subject.value;
        xmlhttp.open("GET", "/includes/send.php"+params, true);
        xmlhttp.onreadystatechange = function () {
            if(xmlhttp.readyState < 4)
            {
                addWidget( '<div style="padding:5px;width:200px;height:100px;border:1px solid black;background:#FFFFFF;"><center><br>Ihre Anfrage wird bearbeitet.<br>Einen Moment bitte.<br><br><img src="/images/ajax-loader.gif"/></center></div>');
            }
            else if (xmlhttp.readyState == 4)
            {
                if(xmlhttp.responseText == "error")
                {
                    addWidget( '<div style="padding:5px;width:220px;height:120px;border:1px solid black;background:#FFFFFF;"><center>Ihre Anfrage konnte nicht bearbeitet werden.<br>Bitte versuchen Sie es später noch einmal.<br><br><a href="#" onclick="backToStart()" style="background-color:#ff9b5d">Schliessen</a></center></div>');
                }
                else if(xmlhttp.responseText == "missing")
                {
                    addWidget( '<div style="padding:5px;width:220px;height:120px;border:1px solid black;background:#FFFFFF;"><center>Es wurden nicht alle Felder ausgefüllt.<br><br><a href="#" onclick="backToStart()" style="background-color:#ff9b5d">Schliessen</a></center></div>');
                }
                else if(xmlhttp.responseText == "bademail")
                {
                    addWidget( '<div style="padding:5px;width:220px;height:120px;border:1px solid black;background:#FFFFFF;"><center>Ihr Emailadresse ist ungültig.<br><br><a href="#" onclick="backToStart()" style="background-color:#ff9b5d">Schliessen</a></center></div>');
                }
                else
                {
                    addWidget( '<div style="padding:5px;width:200px;height:100px;border:1px solid black;background:#FFFFFF;"><center>Ihre Anfrage wurde weitergeleitet.<br>Vielen Dank.<br><br><a href="#" onclick="backToStart()" style="background-color:#ff9b5d">Schliessen</a></center></div>');
                    setTimeout("backToStart()",5000);
                }
            }
        }
        xmlhttp.send(null);
    }
    else if (status == 0)
    {
        filename = "/includes/contact.php";
        xmlhttp.open("GET", filename,true);
        xmlhttp.onreadystatechange=function()
        {
            if (xmlhttp.readyState==4)
            {
                addWidget( '<div style="padding:5px;width:400px;height:440px;border:1px solid black;background:#FFFFFF;">'+xmlhttp.responseText+'</div>');
            }
        }
        xmlhttp.send(null);
    }
    else if (status ==3)
    {
        filename = "/images/gallery/orig/"+bild;
        xmlhttp.open("GET", filename,true);
        xmlhttp.onreadystatechange=function() {
            if (xmlhttp.readyState==4) {
                addWidget( '<div style="padding:10px;border:3px solid green;background:#FFFFFF;text-align: center"><img src="' + filename +'" width="40%" height="40%" onclick="close_widget()"></div><div style="width: 100%; height: 100%, z-index: 100"/>');
            }
        }
        xmlhttp.send(null);
    }
}

function backToStart()
{
    window.location.href="/";
}

/*
	Form validation
*/

function validate_required(field,alerttxt)
{
    with (field)
    {
        if (value==null||value=="")
        {
            alert(alerttxt);
            return false;
        }
        else{
            return true
        }
        }
}

function validate_form(thisform)
{
    with (thisform)
    {
        if (validate_required(name,"Name muss ausgefüllt werden")==false)
        {
            name.focus();
            return false;
        }
        if (validate_required(email,"Email muss ausgefüllt werden")==false)
        {
            email.focus();
            return false;
        }
        if (validate_email(email,"Bitte geben Sie eine gültige Emailadresse an.")==false)
        {
            email.focus();
            return false;
        }
        if (validate_required(subject,"Betreff muss ausgefüllt werden")==false)
        {
            subject.focus();
            return false;
        }
        if (validate_required(message,"Bitte teilen Sie und Ihr Anliegen mit.")==false)
        {
            message.focus();
            return false;
        }
        show_layer(1,thisform)
        return true;
        }
}
function validate_email(field,alerttxt)
{
    with (field)
    {
        apos=value.indexOf("@");
        dotpos=value.lastIndexOf(".");
        if (apos<1||dotpos-apos<2)
        {
            alert(alerttxt);
            return false;
        }
        else {
            return true;
        }
        }
}

function mouseover(id,bgcolor,color)
{
   document.getElementById(id).style.backgroundColor=bgcolor;
    document.getElementById(id).style.color=color;
}
function mouseout(id,color)
{
    document.getElementById(id).style.backgroundColor='';
    document.getElementById(id).style.color=color;
} 

function go(page)
{
    window.location.href= page;
}
scrollStep=1

timerUp=""
timerDown=""

function toTop(id){
    document.getElementById(id).scrollTop=0
}

function scrollDivDown(id){
    clearTimeout(timerDown)
    document.getElementById(id).scrollTop+=scrollStep
    timerDown=setTimeout("scrollDivDown('"+id+"')",20)
}

function scrollDivUp(id){
    clearTimeout(timerUp)
    document.getElementById(id).scrollTop-=scrollStep
    timerUp=setTimeout("scrollDivUp('"+id+"')",20)
}

function toBottom(id){
    document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight
}

function stopMe(){
    clearTimeout(timerDown)
    clearTimeout(timerUp)
}
function blinkFont()
{
  document.getElementById("news").style.color="#ffffff"
  setTimeout("setblinkFont()",2000)
}

function setblinkFont()
{
  document.getElementById("news").style.color="#808080"
  setTimeout("blinkFont()",1000)
}

