var imagesToLoad = new Array;
imagesToLoad[0] = "data/css/arrowleft.png";
imagesToLoad[1] = "data/css/arrowright.png";
imagesToLoad[2] = "data/css/arrowleft_hover.png";
imagesToLoad[3] = "data/css/arrowright_hover.png";
imagesToLoad[4] = "data/css/contact.png";
imagesToLoad[5] = "data/css/home.png";
imagesToLoad[6] = "data/css/menubg.jpg";
imagesToLoad[7] = "data/css/loading.gif";
imagesToLoad[8] = "data/css/pictures.png";
imagesToLoad[9] = "data/css/text.png";
imagesToLoad[10] = "data/css/brush_top.png";
imagesToLoad[11] = "data/css/about.png";
imagesToLoad[12] = "data/css/waiting.gif";
imagesToLoad[13] = "data/css/arrowleftsmall.png";
imagesToLoad[14] = "data/css/arrowrightsmall.png";
imagesToLoad[15] = "data/css/arrowleft_hoversmall.png";
imagesToLoad[16] = "data/css/arrowright_hoversmall.png";
imagesToLoad[17] = "data/css/play.png";
imagesToLoad[18] = "data/css/stop.png";
imagesToLoad[19] = "data/css/valid.png";
var absolutpath = "http://www.picturelounge.at/";
var hoehe = 0
var breite = 0
var id = 0
var displaywidth = 0
var displayheight = 0
var prop = 0
var slideshow = 0
var values = 0
var kategorie = ''
var lastpic = 0
var firstpic = 0
var thumbsloaded = 0
var seite = ''
var overlay = 0

function getPageSize()
{
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY)
    {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    }
    else if (document.body.scrollHeight > document.body.offsetHeight)
    {
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    }
    else
    {
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight)
    {
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    {
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    }
    else if (document.body)
    {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    if (yScroll < windowHeight)
    {
        pageHeight = windowHeight;
    }
    else
    {
        pageHeight = yScroll;
    }
    if (xScroll < windowWidth)
    {
        pageWidth = windowWidth;
    }
    else
    {
        pageWidth = xScroll;
    }
    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
    return arrayPageSize;
}
var image =
{
    refreshAd: function ()
    {
        var d = document.getElementById('ad');
        if (d)
        {
            var s = d.getElementsByTagName('iframe');
            if (s && s.length)
            {
                s[0].src = s[0].src + '&' + new Date().getTime();
            }
        }
        return true;
    },
    shownavigation: function ()
    {
        if (kategorie != '')
        {
            if (lastpic == 0)
            {
                $('arrowright').appear(
                {
                    duration: 0.3
                });
                if (slideshow == 1)
                {
                    $('stopbutton').appear(
                    {
                        duration: 0.3
                    });
                }
                else
                {
                    $('playbutton').appear(
                    {
                        duration: 0.3
                    });
                }
            }
            if (id > 1) $('arrowleft').appear(
            {
                duration: 0.3
            });
            if ((id > 0) && (kategorie != '')) $('arrowleft').appear(
            {
                duration: 0.3
            });
        }
    },
    shownavigation2: function ()
    {
        if (kategorie != '')
        {
            if (lastpic == 0)
            {
                $('arrowright_overlay').appear(
                {
                    duration: 0.3
                });
				
				 if (slideshow == 1)
                {
                    $('stopbutton_overlay').appear(
                    {
                        duration: 0.3
                    });
                }
                else
                {
                    $('playbutton_overlay').appear(
                    {
                        duration: 0.3
                    });
                }
            }
            if (id > 1) $('arrowleft_overlay').appear(
            {
                duration: 0.3
            });
            if ((id > 0) && (kategorie != '')) $('arrowleft_overlay').appear(
            {
                duration: 0.3
            });
        }
    },
    hidenavigation: function ()
    {
        $('arrowright').hide();
        $('arrowleft').hide();
        if (slideshow == 1)
        {
            $('stopbutton').hide(
            {
                duration: 0.3
            });
        }
        else
        {
            $('playbutton').hide(
            {
                duration: 0.3
            });
        }
        $('stopbutton').hide();
    },
	
	  hidenavigation2: function ()
    {
        $('arrowright_overlay').hide();
        $('arrowleft_overlay').hide();
        if (slideshow == 1)
        {
            $('stopbutton_overlay').hide(
            {
                duration: 0.3
            });
        }
        else
        {
            $('playbutton_overlay').hide(
            {
                duration: 0.3
            });
        }
        $('stopbutton_overlay').hide();
    },
	
    next: function (imagelocation)
    {  
	
	if (imagelocation!="overlay"){imagelocation="imagecontainer";}
        id++;
        image.appearLoading();
        request = new Ajax.Request(absolutpath + 'a.php', {
            method: 'post',
            postBody: 'id=' + id + '&kategorie=' + kategorie,
            onSuccess: function (response)
            {
                image.processinformation(response.responseText,imagelocation);
                location.replace('#' + kategorie + '_' + seite + '_' + id);
            },
            onCreate: function ()
            {
            }
        });
    },
    getImage: function (i)
    {
        if (id == i) return;
        if (i == "first")
        {
            id = 0
        }
        else
        {
            id = i;
        }
        image.appearLoading();
        request = new Ajax.Request(absolutpath + 'a.php', {
            method: 'post',
            postBody: 'id=' + id + '&kategorie=' + kategorie,
            onSuccess: function (response)
            {
                if (id == "picofday")
                {
                    kategorie = '';
                }
                else
                {
                    if (kategorie != '')
                    {
                        if (((window.location.href).search(/\go..+/)) == (-1))
                        {
                            location.replace('#' + kategorie + '_' + seite + '_' + i);
                        }
                    }
                }
                image.processinformation(response.responseText);
            },
            onCreate: function ()
            {
            }
        });
    },
    previous: function ()
    {
        id--;
        image.appearLoading();
        request = new Ajax.Request(absolutpath + 'a.php', {
            method: 'post',
            postBody: 'id=' + id + '&kategorie=' + kategorie,
            onSuccess: function (response)
            {
                image.processinformation(response.responseText);
                location.replace('#' + kategorie + '_' + seite + '_' + id);
            },
            onCreate: function ()
            {
            }
        });
    },
    getContent: function (content, page)
    {
        seite = page;
        id = 0;
        kategorie = content;
        if ((startimage == '') || (startimage == 'picofday'))
        {
            if (seite > 1)
            {
                image.getImage(8 * (seite - 1));
                idd = 8 * (seite - 1);
            }
            else
            {
                image.getImage("first");
                idd = 'first';
                seite = 1;
            }
        }
        else
        {
            image.getImage(startimage);
            idd = startimage;
            startimage = '';
        }
        request = new Ajax.Request(absolutpath + 'content.php', {
            method: 'post',
            postBody: 'content=' + content + '&page=' + seite,
            onSuccess: function (response)
            {
                document.title = "www.picturelounge.at | " + content;
                image.showGallery(response.responseText);
                new Effect.Fade('loadingcontent', {
                    duration: 1.0
                });
            },
            onCreate: function ()
            {
                new Effect.Appear('loadingcontent', {
                    duration: 1.0
                });
            }
        });
        pageTracker._trackPageview('/' + content + '/' + page);
    },
    getGuestbook: function (page)
    {
        seite = page;
        id = 0;
        kategorie = 'Guestbook';
        image.getImage("first");
        request = new Ajax.Request(absolutpath + 'guestbook.php', {
            method: 'post',
            postBody: 'page=' + seite,
            onSuccess: function (response)
            {
                if (seite == undefined)
                {
                    image.showContent(response.responseText);
                }
                else
                {
                    image.showGBs(response.responseText);
                }
                new Effect.Fade('loadingcontent', {
                    duration: 1.0
                });
                document.title = "www.picturelounge.at | Guestbook";
            },
            onCreate: function ()
            {
                new Effect.Appear('loadingcontent', {
                    duration: 1.0
                });
            }
        });
        pageTracker._trackPageview("/guestbook");
    },
    getAbout: function (content)
    {
        if (content != 'Home')
        {
            kategorie = content;
            id = 0;
        }
        if (content == 'Home')
        {
            kategorie = '';
            image.getImage("picofday");
        }
        if (content != "Home")
        {
            image.getImage("first");
        }
        request = new Ajax.Request(absolutpath + 'about.php', {
            method: 'post',
            postBody: 'content=' + content,
            onSuccess: function (response)
            {
                document.title = "www.picturelounge.at | " + content;
                if (content != "Message")
                {
                    image.showGallery(response.responseText);
                }
                else
                {
                    image.showContent(response.responseText);
                }
                new Effect.Fade('loadingcontent', {
                    duration: 1.0
                });
            },
            onCreate: function ()
            {
                new Effect.Appear('loadingcontent', {
                    duration: 1.0
                });
            }
        });
        pageTracker._trackPageview("/about/" + content);
    },
    showGallery: function (response)
    {
        slideshow = 0;
        new Effect.Opacity('innercontent', {
            from: 1.0,
            to: 0.0,
            duration: 0.3,
            afterFinish: function ()
            {
                $('innercontent').innerHTML = response;
                new Effect.Opacity('innercontent', {
                    from: 0.3,
                    to: 1.0,
                    duration: 0.8
                });
                var box = $("innercontent");
                var imagesinbox = box.getElementsByTagName("img");
                var anzahl = imagesinbox.length;
                if (anzahl > 0)
                {
                    for (i = 0; i < anzahl; i++)
                    {
                        $('thumbloading' + i).setStyle(
                        {
                            'top': image.getPosition('thumbbox' + i)
                        });
                    }
                    new PeriodicalExecuter(function (pe)
                    {
                        image.checkthumbs(anzahl);
                        if (thumbsloaded == anzahl)
                        {
                            pe.stop();
                            for (i = 0; i < anzahl; i++)
                            {
                                $('thumbloading' + i).hide();
                            }
                            thumbsloaded = 0;
                        }
                    }, 0.4);
                }
            }
        });
    },
    showContent: function (response)
    {
        new Effect.Opacity('innercontent', {
            from: 1.0,
            to: 0.0,
            duration: 0.3,
            afterFinish: function ()
            {
                $('innercontent').innerHTML = response;
                new Effect.Opacity('innercontent', {
                    from: 0.3,
                    to: 1.0,
                    duration: 0.8
                });
            }
        });
    },
    replaceFont: function ()
    {
        sIFR.replace(font1, {
            wmode: 'transparent',
            selector: '.h1main',
            css: '.sIFR-root { color: #FFFFFF; background-color:#000000; }'
        });
        sIFR.replace(font1, {
            wmode: 'transparent',
            selector: '.h2main',
            css: '.sIFR-root { color: #FFFFFF; background-color:#000000; }'
        });
    },
    showGBs: function (response)
    {
        new Effect.Opacity('entrycontainer', {
            from: 1.0,
            to: 0.0,
            duration: 0.3,
            afterFinish: function ()
            {
                $('entrycontainer').innerHTML = response;
                new Effect.Opacity('entrycontainer', {
                    from: 0.3,
                    to: 1.0,
                    duration: 0.8
                });
            }
        });
    },
    checkthumbs: function (anzahl)
    {
        for (i = 0; i < anzahl; i++)
        {
            name = "image" + i;
            document.images[name].onload = function ()
            {
            }
            if (document.images[name].complete == true)
            {
                thumbsloaded++;
                $('thumbloading' + i).hide();
            }
        }
    },
    appearLoading: function ()
    {
        new Effect.Appear('loading', {
            duration: 0.5,
            afterFinish: function ()
            {
            }
        });
    },
    processinformation: function (response)
    {
        values = response.split(":");
        hoehe = values[1];
        breite = values[2];
        if (breite > hoehe)
        {
            $('imagecontainer').setAttribute("width", "100%");
        }
        displaywidth = $('imagelayer').getWidth() - 20;
        if (displaywidth == 0)
        {
            displaywidth = $('imagelayer').getWidth() - 20;
        }
        if ((breite < hoehe) && (displaywidth > breite))
        {
            displaywidth = breite;
        }
        prop = breite / displaywidth;
        displayheight = hoehe / prop;
			 $('imagecontainer').setStyle({
					 marginTop:'-'+displayheight+'px',
				
					 
					 });
					 
					  $('imagecontainer2').setStyle({
				
					 'width': displaywidth + 'px',
           'height': displayheight + 'px'
					 
					 });  
					 
					   
        picture = new Image();
        picture.src = values[0];
        new PeriodicalExecuter(function (pp)
        {
            if (picture.complete)
            {
                pp.stop();
                image.alertSuccess();
            }
        }, 0.01);
		
	
    },
    alertSuccess: function ()
    { 	
					 
        new Effect.Opacity('infobox', {
            from: 1.0,
            to: 0.0,
            duration: 0.1,
            afterFinish: function ()
            {
                $('infobox').removeAttribute("style");
                $('infobox').hide();
                $('imagetitel').innerHTML = values[3];
                $('imagefotograf').innerHTML = values[5];
                $('imagedetails').innerHTML = values[6];
                values[3] = '';
                values[6] = '';
                if (values[6] == '')
                {
                    $('imagedetails').hide();
                }
                if ((values[6] != '') && ($('imagedetails').style.display == 'none'))
                {
                    $('imagedetails').show();
                }
                if (values[5] == '')
                {
                    $('imagefotograf').hide();
                }
                if ((values[5] != '') && ($('imagefotograf').style.display == 'none'))
                {
                    $('imagefotograf').show();
                }
                if (values[3] == '')
                {
                    $('imagetitel').hide();
                }
                if ((values[3] != '') && ($('imagetitel').style.display == 'none'))
                {
                }
                if (values[3] != '')
                {
                    pageTracker._trackPageview('image/' + values[3]);
                }
                lastpic = values[7];
                if (lastpic == 1)
                {
                    $('arrowright').hide();
                    $('arrowright_overlay').hide();
                }
                if (!$('infobox').hasClassName('info' + values[4]))
                {
                    $('infobox').className = 'info' + values[4];
                }
                if ((values[4] == 1) || (values[4] == 3))
                {
                    infoalign = 'right';
                }
                else
                {
                    infoalign = 'left';
                }
                if (id == 1 && kategorie == '')
                {
                    $('arrowleft').hide();
					 $('arrowleft_overlay').hide();
                }
                if (id == 0 && kategorie != '')
                {
                    $('arrowleft').hide();
					 $('arrowleft_overlay').hide();
                } 
				$('loading').fade();
			
			if (overlay==1){	
			
					    new Effect.Morph('overlay', {
            style: 'width:' + values[2]  + 'px; height:' + values[1] + 'px; margin-left: -' + (values[2]/2 + 20) + 'px; margin-top:-' + (values[1]  / 2 + 20) + 'px;',
            duration: 0.4,
            afterFinish: function ()
            {
                $('imagecontainer_overlay').innerHTML = "<img alt=\"" + values[0] + " | " + values[5] + "\"  src=\"" + values[0] + "\" width=\"100%\" />";
            }});}
			
			
				 $('imagecontainer2').innerHTML = "<img onclick=\"image.showoverlay(" + values[2] + "," + values[1] + ")\" alt=\"" + values[0] + " | " + values[5] + "\"  src=\"" + values[0] + "\" width=\"100%\" />";  
				 
				 new Effect.Parallel([
//  new Effect.Morph('imagecontainer2', { sync: true,  style: 'height:' + displayheight + 'px; width:' + displaywidth + 'px; z-index:200; top:0px;'}), 
    new Effect.Morph('imagecontainer', { sync: true,  style: ' height:' + displayheight + 'px; width:' + displaywidth + 'px; '}), 
  new Effect.Opacity('imagecontainer2', { sync: true, from: 0.0, to: 1.0 }),
   new Effect.Opacity('imagecontainer', { sync: true, from: 1.0, to: 0.0 }) 
], { 
  duration: 0.9,
   afterFinish: function ()
                    {  $('imagecontainer').innerHTML = "<img onclick=\"image.showoverlay(" + values[2] + "," + values[1] + ")\" alt=\"" + values[0] + " | " + values[5] + "\"  src=\"" + values[0] + "\" width=\"100%\" />";
					
		
				   new Effect.Opacity('imagecontainer', {
            from: 0.0,
            to: 1.0,
            duration: 0.1,
			afterFinish:function(){    new Effect.Opacity('imagecontainer2', {duration:0.1,  from: 1.0, to: 0.01 });  new Effect.Morph('infobox', {
                                    style: infoalign + ':' + $('imagecontainer').offsetLeft + 'px; z-index:400; ',
                                    duration: 0.0,
                                    afterFinish: function ()
                                    {		
				 if ($('infobox').style.display == 'none')
                                        {
                                            $('infobox').appear();
                                        } }
                                });
						
								 }
        });
					}
});
				 
					 
				
			
                            }
                                });
			  
    },
    getPosition: function (obj)
    {
        obj = $(obj);
        var absolutetop = 0,
            absoluteleft = 0;
        while (obj)
        {
            absolutetop += obj.offsetTop;
            absoluteleft += obj.offsetLeft;
            obj = obj.offsetParent;
        }
        return absolutetop - 50;
    },
    morphimage: function ()
    {
        if (breite > hoehe)
        {
            $('imagecontainer').setAttribute("width", "100%");
        }
        displaywidth = $('imagelayer').getWidth() - 20;
        if ((breite < hoehe) && (displaywidth > breite))
        {
            displaywidth = breite;
        }
        prop = breite / displaywidth;
        displayheight = hoehe / prop;
        if (displaywidth < 350)
        {
            $('infobox').fade();
        }
        if ((displaywidth > 350) && ($('infobox').style.display == 'none'))
        {
            $('infobox').appear();
        }
        new Effect.Morph('imagecontainer', {
            style: 'height:' + displayheight + 'px; width:' + displaywidth + 'px;',
            duration: 0.4
        });
    },
    fadein: function ()
    {
        new Effect.Opacity('infobox', {
            from: 0.3,
            to: 1.0,
            duration: 0.1
        });
        new Effect.Opacity('imagecontainer', {
            from: 0.3,
            to: 1.0,
            duration: 0.2
        });
    },
    showoverlay: function (w, h)
    {
		overlay =1 ;
        $("fill").setStyle(
        {
            'width': getPageSize()[0] + 'px',
            'height': getPageSize()[1] + 50 + "px"
        });
        $("fill").show();
        $("overlay").setStyle(
        {
            'width': 0,
            'height': 0
        });
        $("overlay").show();
        new Effect.Morph('overlay', {
            style: 'width:' + w + 'px; height:' + h + 'px; margin-left: -' + (w / 2 + 20) + 'px; margin-top:-' + (h / 2 + 20) + 'px;',
            duration: 0.4,
            afterFinish: function ()
            {
                $('imagecontainer_overlay').innerHTML = "<img alt=\"" + values[0] + " | " + values[5] + "\"  src=\"" + values[0] + "\" width=\"100%\" />";
            },
            afterUpdate: function (effect)
            {
                $(effect.element).setOpacity(effect.position);
            }
        });
           Event.observe('arrowright_overlay', 'click', image.next.bindAsEventListener(image));
        Event.observe('arrowleft_overlay', 'click', image.previous.bindAsEventListener(image));
    },
    hideoverlay: function ()
    {
		overlay=0;
        $("fill").hide();
        $('imagecontainer_overlay').innerHTML = " ";
        $('overlay').removeAttribute("style");
        $("overlay").hide();
        $('overlay').setStyle(
        {
            'overflow': 'visible'
        })
    },
    keynavigation: function (evt)
    {
        evt = (evt) ? evt : ((window.event) ? window.event : "");
        Key = evt.keyCode;
        switch (Key)
        {
        case Event.KEY_LEFT:
            if (id > 1)
            {
                image.previous();
            }
            return false;
            break;
        case Event.KEY_RIGHT:
            if (lastpic == 0)
            {
                image.next();
            }
            return false;
            break;
        }
        return true;
    },
    preloading: function (arr)
    {
        geladen = 0;
        var img = new Array();
        for (var i = 0; i < arr.length; i++)
        {
            img[i] = new Image();
            img[i].onload = function ()
            {
                geladen++;
                if (geladen == arr.length) image.preloaded();
            }
            img[i].src = arr[i];
            if (document.all && img[i].complete) img[i].onload();
        }
    },
    preloaded: function ()
    {
        $('mainloading').fade(
        {
            duration: 0.1,
            afterFinish: function ()
            {   $("hide").setStyle(
                        {
                            'width': getPageSize()[0] - 30 + 'px',
                            'height': getPageSize()[1] + "px"
                        });
                $('hide').appear(
                {
                    duration: 0.3,
                    afterFinish: function ()
                    {
                     
                        if (startcontent == 'Guestbook')
                        {
                            image.getGuestbook()
                        }
                        if (startcontent == 'Home')
                        {
                            image.getAbout('Home');
                        }
                        if ((startcontent == 'Jan') || (startcontent == 'Matthias') || (startcontent == 'Referenzen') || (startcontent == 'Message') || (startcontent == 'Bockmas') || (startcontent == 'Clains')|| (startcontent == 'Impressum'))
                        {
                            image.getAbout(startcontent);
                        }
                        if ((startcontent == 'Macro') || (startcontent == 'Landscape') || (startcontent == 'People') || (startcontent == 'Events'))
                        {
                            image.getContent(startcontent, startpage);
                            if (startimage != '')
                            {
                                image.getImage(startimage);
                            }
                        }
                        image.setListeners();
                    }
                });
            }
        });
    },
    menuout: function (id)
    {
        name = 'menu' + id + 'Container';
        if (id == 1)
        {
            id2 = 2;
            id3 = 3;
        }
        if (id == 2)
        {
            id2 = 1;
            id3 = 3;
        }
        if (id == 3)
        {
            id2 = 1;
            id3 = 2;
        }
        new Effect.Morph(name, {
            style: 'width:170px;',
            duration: 0.3
        });
        if (image.ismenuout(id2))
        {
            image.menuhide(id2);
        }
        if (image.ismenuout(id3))
        {
            image.menuhide(id3);
        }
        Event.observe(name, 'mouseout', image.menuin.bindAsEventListener(image));
    },
    ismenuout: function (id)
    {
        name = 'menu' + id + 'Container';
        width = $(name).getWidth();
        if (width > 169)
        {
            return true
        }
        if (width < 169)
        {
            return false
        }
    },
    menuin: function (e)
    {
        if (!e) var e = window.event;
        var tg = (window.event) ? e.srcElement : e.target;
        if (tg.nodeName != 'DIV') return;
        var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
        while (reltg != tg && reltg.nodeName != 'BODY')
        reltg = reltg.parentNode
        if (reltg == tg) return;
        if (image.ismenuout(1))
        {
            window.setTimeout("image.menuhide(1);", 500);
        }
        if (image.ismenuout(2))
        {
            window.setTimeout("image.menuhide(2);", 500);
        }
        if (image.ismenuout(3))
        {
            window.setTimeout("image.menuhide(3);", 500);
        }
    },
    menuhide: function (id)
    {
        name = 'menu' + id + 'Container';
        new Effect.Morph(name, {
            style: 'width:25px;',
            duration: 0.3
        });
    },
    startslide: function ()
    {
        new PeriodicalExecuter(image.next, 5);
    },
    menuon: function (id)
    {
        new Effect.Opacity(id, {
            from: 1.0,
            to: 0.6,
            duration: 0.2
        });
    },
    menuoff: function (id)
    {
        new Effect.Opacity(id, {
            from: 0.6,
            to: 1.0,
            duration: 0.2
        });
    },
    validate_mail: function (input)
    {
        if (($(input).value != '')&&($(input).value.length >6))
        {
            if (!$(input).value.match(/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i))
            {
                $('inf_' + input).innerHTML = '<img src="data/css/invalid.png" /><span style="font-size:10px;"> invalid mail</span>';
                return false;
            }
            else
            {
                $('inf_' + input).innerHTML = '<img src="data/css/valid.png" />';
                return true;
            }
        }
    },
    validate: function (input)
    {
        if ($(input).value.length > 2)
        {
            $('inf_' + input).innerHTML = '<img src="data/css/valid.png" />';
            $(input).valid = true;
            if (($('entry').valid) && ($('from').valid))
            {
                $('submit').disabled = false;
                $('submit').removeClassName('disabled');
            }
            else
            {
                $('submit').disabled = true;
                if (!$('submit').hasClassName('disabled'))
                {
                    $('submit').addClassName('disabled');
                }
            }
            return true;
        }
        if ($(input).value.length < 3)
        {
            $('inf_' + input).innerHTML = '<img src="data/css/invalid.png" />';
            $(input).valid = false;
            $('submit').disabled = true;
            if (!$('submit').hasClassName('disabled'))
            {
                $('submit').addClassName('disabled');
            }
            return false;
        }
    },
    postGB: function ()
    {
        new Ajax.Request(absolutpath + 'addgb.php', {
            method: 'post',
            postBody: 'name=' + $F('from') + '&email=' + $F('email') + '&entry=' + $F('entry'),
            onSuccess: function (response)
            {
                image.updateGuestbook(response.responseText);
                if ($('submit').hasClassName('disabled'))
                {
                    $('submit').removeClassName('disabled');
                }
                $('submit').disabled = false;
            },
            onCreate: function ()
            {
                if (!$('submit').hasClassName('disabled'))
                {
                    $('submit').addClassName('disabled');
                }
                $('submit').disabled = true;
            }
        });
    },
    sendMail: function ()
    {
        new Ajax.Request(absolutpath + 'sendmail.php', {
            method: 'post',
            postBody: 'name=' + $F('from') + '&email=' + $F('email') + '&entry=' + $F('entry'),
            onSuccess: function (response)
            {
                image.mailResponse(response.responseText);
                if ($('submit').hasClassName('disabled'))
                {
                    $('submit').removeClassName('disabled');
                }
                $('submit').disabled = false;
            },
            onCreate: function ()
            {
                if (!$('submit').hasClassName('disabled'))
                {
                    $('submit').addClassName('disabled');
                }
                $('submit').disabled = true;
            }
        });
    },
    mailResponse: function (response)
    {
        $('response').innerHTML = '<div id="responsetext" style="display: none;">' + response + '</div>';
        new Effect.Appear('responsetext', {
            delay: 0.5
        });
    },
    updateGuestbook: function (response)
    {
        new Insertion.Top('entrycontainer', '<div id="newentry" style="display: none;">' + response + '</div>');
        new Effect.Appear('newentry', {
            delay: 0.5
        });
    },
    getScroll: function ()
    {
        var scrOfX = 0,
            scrOfY = 0;
        if (typeof(window.pageYOffset) == 'number')
        {
            scrOfY = window.pageYOffset;
            scrOfX = window.pageXOffset;
        }
        else if (document.body && (document.body.scrollLeft || document.body.scrollTop))
        {
            scrOfY = document.body.scrollTop;
            scrOfX = document.body.scrollLeft;
        }
        else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop))
        {
            scrOfY = document.documentElement.scrollTop;
            scrOfX = document.documentElement.scrollLeft;
        }
        return [scrOfX, scrOfY];
    },
    startslideshow: function ()
    {
        slideshow = 1;
        new PeriodicalExecuter(function (slide)
        {
            if (slideshow == 1)
            {
                if (lastpic == 0)
                {
                    image.next();
                }
                if (lastpic == 1)
                {
                    slide.stop();
                    slideshow = 0;
                }

            }
            if (slideshow == 0)
            {
                slide.stop
            }
        }, 7.0);
        $('playbutton').hide();
        $('stopbutton').appear();
		if (overlay==1){ $('playbutton_overlay').hide();
        $('stopbutton_overlay').appear();}

    },

    stopslideshow: function ()
    {
        slideshow = 0;
        $('stopbutton').hide();
        $('playbutton').appear();

    },



    posimage: function ()
    {
        scrollpos = image.getScroll();
        new Effect.Morph('clearlayer', {
            style: 'top:' + scrollpos[1] + 'px',
            duration: 0.4
        });
    },
    setListeners: function ()
    {
        Event.observe('imagelayer', 'mouseover', image.shownavigation.bindAsEventListener(image));
        Event.observe('arrowright', 'click', image.next.bindAsEventListener(image));
        Event.observe('arrowleft', 'click', image.previous.bindAsEventListener(image));
        Event.observe('content', 'mouseover', image.hidenavigation.bindAsEventListener(image));
		Event.observe('fill', 'mouseover', image.hidenavigation2.bindAsEventListener(image));
        Event.observe('footer', 'mouseover', image.hidenavigation.bindAsEventListener(image));
        Event.observe(window, 'resize', image.morphimage.bindAsEventListener(image));
        Event.observe(window, 'scroll', image.posimage.bindAsEventListener(image));
        Event.observe(document, 'keydown', image.keynavigation.bindAsEventListener(image));
        Event.observe('overlaycontent', 'mouseover', image.shownavigation2.bindAsEventListener(image));
    }
}
