var winH;
var winW;


$(document).ready(function () {
		winH = $(window).height();
		winW = $(window).width();
		$('#coda-slider-1').codaSlider({
				dynamicTabs: false,
				autoSlide: true,
				autoSlideInterval: 6000,
				autoSlideStopWhenClicked: true,
				dynamicArrows: false,
				dynamicArrowLeftText: '<img src="fileadmin/tmpl/gfx/btnZurueck.gif" alt="zurück" width="120" height="21" border="0" />',
				dynamicArrowRightText: '<img src="fileadmin/tmpl/gfx/btnWeiter.gif" alt="weiter"  width="120" height="21" border="0" />'
		});
		
		$(".coda-nav-left a, .coda-nav-right a").css({ opacity: .7 }).hover(
			function () {
				$(this).css({ opacity: 1 });
			},
			function () {
				$(this).css({ opacity: .7 });
			}
		);

		
		// IE 6 (hope this Browser will pass away soon - it's a reason for my nightmares)
		if ($.browser.msie && parseFloat($.browser.version) < 7){
			// handle Styles
			$("body").addClass("msie6");
			// PNG-Fix
			$(".arrowDown, img[src$=.png], #bgPageLeft, #bgPageRight, #page").addClass("ie6TransparencyPngBug");
			DD_belatedPNG.fix('.ie6TransparencyPngBug');
		}
		
		
		$("#backgroundWrap img").setSizeAndPositionOfBackgroundImage();
});

$(window).resize(function () {
		winH = $(window).height();
		winW = $(window).width();
		$("#backgroundWrap img").setSizeAndPositionOfBackgroundImage();
});


(function($) {
	$.fn.setSizeAndPositionOfBackgroundImage = function(options) {
		var defaults = {
			imgW: 2067,
			imgH: 1462,
			imgMinW: 1034,
			imgMinH: 731
		};
		var c = $.extend(defaults, options);
		var obj;
		this.each(function() {
				obj = $(this);
				
				if(winW / winH > c.imgW / c.imgH) {
					newW = winW;
					newH = winW/c.imgW*c.imgH;
				} else {
					newW = winH/c.imgH*c.imgW;
					newH = winH;
				}
				
				// test minsize
				if (newW < c.imgMinW && newH < c.imgMinH) {
					newW = c.imgMinW;
					newH = c.imgMinH;
				}
				
				// set imagesize
				obj.width(newW);
				obj.height(newH);
				
				// set position
				obj.css({
						position: 'absolute',
						top: winH/2-newH/2,
						left: winW/2-newW/2
				});
		});
		return this;
	};
	
})(jQuery);



