document.addEvent('domready', function() {
    /*
     * Select all images with a 'rel=lightbox' property and add the '+'
     */
    $$('#main a[rel^=lightbox]').each(function(imageAnchor) {
        var zoomIcon = new Element('img', {
            'class' : 'zoom_icon',
            src : 'tl_files/schwaigerbrothers/images/zoomIcon.png',
            alt : ''
        });
        
        zoomIcon.inject(imageAnchor);
    });
    
    $('top').setProperty('onload', 'init_screen_size();');
    $('top').setProperty('onresize', 'screen_size();');
});

window.addEvent("load", function() {
    var image = $('background');
    image.set('styles', {
            'opacity': 0,
            'visibility': 'visible'
        });
    image.fade('in');
});

/* misc -------------- */

// JavaScript Document
var myImgHeight = 1750;
var myImgWidth = 2625;

function init_screen_size() {
    // get browser width and height
    if(window.innerWidth){
        hoehe = window.innerHeight;
        weite = window.innerWidth;
    } else {
        hoehe = document.documentElement.clientHeight;	
        weite = document.documentElement.clientWidth;
    }
    
    var newHeight = Math.round(myImgHeight / (myImgWidth / weite));
    if( newHeight > hoehe){	
        $('background').setStyle('width', weite + 'px');
    } else {
        $('background').setStyle('height', hoehe + 'px');
    }	
}

function screen_size() {
    if(hoehe != 0) {
        if(window.innerWidth){
            hoehe = window.innerHeight;
            weite = window.innerWidth;
        } else {
            hoehe = document.documentElement.clientHeight;	
            weite = document.documentElement.clientWidth;	
        }
        
        if( weite > 900 ){
            var newHeight = Math.round(myImgHeight/(myImgWidth/weite));
            if( newHeight > hoehe){	
                $('background').setStyle('width', weite + 'px');
                $('background').setStyle('height', 'auto');
            } else {
                $('background').setStyle('height', hoehe + 'px');
                $('background').setStyle('width', 'auto');
            }
        }
    }
}

