window.addEvent('domready',function(){
	/*var myDropdown = new drMenu('menu',{
		'hideTime':300,          // Zeit in millisekunden
		'fixIESBB':true,         // InternetExplorer SelectBox Bug fixen?
		'hideBoxOnHover':false,  // DropdownBox ausgeblenden bei link-hover
		'setBoxMinWith':true     // setzt die Breite auf die breite des Links
	});*/
	if($$('#mainimg a.thumb').length){
        var intervalId = (function(){
            var activeImage = 0;
            $$('#mainimg a.thumb').each(function(el, i){
                if(el.hasClass('thumbActive')){
                    activeImage = i;
                    el.removeClass('thumbActive');
                }
            });
            activeImage++;
            if(!$$('#mainimg a.thumb')[activeImage]){
                activeImage = 0;
            }
            $(document.body).getElement('#mainimg .img').src = $$('#mainimg a.thumb')[activeImage].href;
            $$('#mainimg a.thumb')[activeImage].addClass('thumbActive');
        }).periodical(6000);
		$$('#mainimg a.thumb').each(function(el){
			el.addEvent('click', function(e){
                $clear(intervalId);
				$(document.body).getElement('#mainimg .img').src = el.href;
                $$('#mainimg a.thumb').each(function(el2){
                    el2.removeClass('thumbActive');
                });
                this.addClass('thumbActive');
				new Event(e).stop();
			});
		});
		var imgpopup = new ImgPopup();
		$(document.body).getElement('#mainimg .img').addEvent('click',function(){
			var videoPath = '/www_1995/1_big.jpg';
			var imgSrc = $(document.body).getElement('#mainimg .img').src;
			if(imgSrc.substr(imgSrc.length-videoPath.length,videoPath.length) == videoPath){
				imgpopup.addSection([{
					url:'videos/video.htm',
					element:'iframe',
					width:600,
					height:475
				}]);
				imgpopup.start('videos/video.htm');
			}
		});
	}
    (function(){
        if($$('a[rel=imgpopup]').length>0){
            var imgpopup = new ImgPopup();
            var imgsection = [];
            $$('a[rel=imgpopup]').each(function(el){
                el.addEvent('click',function(e){
                    imgpopup.start(this.getProperty('href'));
                    if(e){
                        e.stop();
                    }
                }.bindWithEvent(el));
                imgsection.push({
                    url:el.getProperty('href'),
                    caption:el.getProperty('title')
                });
            });
            imgpopup.addSection(imgsection);
        }
    })();
	/*if(typeof slideShowImages != 'undefined'){
		var mySlideShow = new slideShow($$('#mainimg img')[0],{
			slidetime: 2,                    
			swaptime: 5,                       
			transition: Fx.Transitions.Quad.easeInOut, 
			path: '',                          
			imgs: slideShowImages,             
			random: false                     
		});
	}*/
	windowOnResize();
});

var windowOnResize = function(){
	var windowW = window.getSize().size.x;
	var windowH = window.getSize().size.y;
	var windowProp = windowW/windowH;
	var img = $('bgImage').getElement('img');
	var imgW = 1920;
	var imgH = 1200;
	var imgProp = imgW/imgH;
	if(windowProp>=imgProp){
		img.setStyle('width',windowW);
		img.setStyle('height',(windowW/imgProp));
		img.setStyle('margin-top',(windowH-(windowW/imgProp))/2);
		img.setStyle('margin-left',0);
	}
	else{
		img.setStyle('height',windowH);
		img.setStyle('width',(windowH*imgProp));
		img.setStyle('margin-left',(windowW-(windowH*imgProp))/2);
		img.setStyle('margin-top',0);
	}
}
window.addEvent('resize',windowOnResize);
