// 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 slidable(obj){
	$('#slidebutton a',obj).click(function(){
	    var min = 40;
	    var pos = $(obj).position();
		var left_to = (pos.left == 0 ? $(obj).width()-min : 0);

		if(left_to == 0){
			$('#mask').fadeIn(400);
		    $(obj).animate({'left': '-'+left_to+'px'}, 400, function(){
				$('#slidebutton a.mask').removeClass('mask');
			});
		} else {
			$('#mask').fadeOut(400);
		    $(obj).animate({'left': '-'+left_to+'px'}, 400, function(){
				$('#slidebutton a').addClass('mask');
			});
		}
	    return false;
	});
}

function menu_line(){
	if($.browser.msie == true && $.browser.version <= 6){
	    // hier nichts unternehmen
	} else {
		var margin_to_box = 93;
		var on_first = $('#menu a.on:first');
		var on_last = $('#menu div.on:last');

		if(on_first.length && on_last.length){
			var first_top = $(on_first).offset().top - margin_to_box; // Höhe bis zum Menü abziehen
			var first_bottom = $(on_first).offset().top - margin_to_box + $(on_first).outerHeight(); // Höhe bis zum Menü abziehen

			var last_top = $(on_last).offset().top - margin_to_box; // Höhe bis zum Menü abziehen
			var last_bottom = $(on_last).offset().top - margin_to_box + $(on_first).outerHeight(); // Höhe bis zum Menü abziehen

			if(last_top > first_top){
			    // Von oben nach unten
		        var height = Math.ceil(Math.abs(on_last.offset().top - margin_to_box + on_last.outerHeight() - first_top) /4) *4 -2;
		        $('#menu').prepend('<div style="position:absolute; background:url(images/menu_dot.gif) repeat-y; width:2px; height:'+height+'px; left:152px; top:'+first_top+'px;"></div>');
			} else {
			    // Von unten nach oben
		        var height = Math.ceil(Math.abs(on_first.offset().top - margin_to_box + on_first.outerHeight() - last_top) /4) *4 -2;
		        $('#menu').prepend('<div style="position:absolute; background:url(images/menu_dot.gif) repeat-y; width:2px; height:'+height+'px; left:152px; top:'+last_top+'px;"></div>');
			}
		}
	}
}

$(document).ready(function(){
	fixPng();
	$('.zoombox').zoombox();
	slidable($('#hide'));
	// Schriftgröße beibehalten
	if($.cookie('fontsize') != null) $('#content_scroll').css('font-size',$.cookie('fontsize')+'px');
});

$(window).load(function(){
    menu_line();
});

