// Transparenz-Filter bei PNG-Bilder für IE 5.5 und IE 6 anwenden
// Aufruf bei $(document).ready() oder mit JS-Code vor </body>:
// <script type="text/javascript">
// fixPng();
// </script>
function fixPng()
{
    if($.browser.msie == true && $.browser.version > 5.5 && $.browser.version < 7.0 && document.body.filters)
    {
        $('img').each(function(){
			if(this.src.match(/\.png$/) != null){
				$(this)
					.css({
						filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+$(this).attr('src')+'\', sizingMethod=\'image\')',
						width: $(this).width()+'px',
						height: $(this).height()+'px'
					})
					.attr('src','images/t3_blank.gif');
			}
        });
	}
}

function change_header_pic()
{
	var duration = 1000;
    if($('#imageblock > img').length > 1)
	{
	    var active = $('#imageblock > img:visible');
	    if(active.length == 0) active = $('#imageblock > img:first').show();
	    var next = active.next('img').length ? active.next('img') : $('#imageblock > img:eq(0)');

	    active.css({
				'position': 'absolute',
				'top': '0px',
				'left': '0px'
		}).fadeOut(duration);

	    next.css({
				'position': 'relative',
				'top': '0px',
				'left': '0px'
		}).fadeIn(duration);
	}
}

function imageSwap(objects)
{
	var duration = 200;

	$(objects).each(function(){
		var self = this;
		var active_image = 0;
		var images = $(self).find('.imageswap_item');

		$(images).hide();
		$(self).find('.imageswap_item:eq('+active_image+')').show();

        $(self).find('a.imageswap_back').click(function(){
			self.change(active_image-1);
			return false;
		}).hide();
        $(self).find('a.imageswap_next').click(function(){
			self.change(active_image+1);
			return false;
		}).hide();

		if(active_image > 0){
		    $(self).find('a.imageswap_back').show();
		}
		if(images.length > 1 && active_image <= images.length){
		    $(self).find('a.imageswap_next').show();
		}

		self.change = function(i){
			$(images[active_image]).css('position','absolute').css('z-index','1').fadeOut(duration);

			active_image = i;
			if(active_image >= images.length) active_image = 0;
			if(active_image < 0) active_image = images.length-1;

			$(images[active_image]).css('position','relative').css('z-index','10').fadeIn(duration);

			if(typeof images[active_image+1] == 'undefined')
				$(self).find('a.imageswap_next').hide();
			else
				$(self).find('a.imageswap_next').show();

			if(typeof images[active_image-1] == 'undefined')
				$(self).find('a.imageswap_back').hide();
			else
				$(self).find('a.imageswap_back').show();
		}
	});
}

$(document).ready(function(){
	fixPng();
	$('.zoombox').zoombox();
	setInterval("change_header_pic()", 2500);
	$('.imageswap').zoombox({showNavigation: false, identifyBy: 'a.imageswap_zoom'});
    imageSwap($('.imageswap'));
});


