$(document).ready(function(){
	
	$('div.news').innerfade({
				animationtype: 'slide',
				speed: 900,
				timeout: 4500,
				type: 'random',
				containerheight: '1.6em'
			});

	$('#tabelle').tablesorter({
			   	widthFixed: true, 
		        headers: {              
				    9: {sorter: false}}
				, widgets: ['zebra']}).tablesorterPager({container: $("#pager")});

	var timer = 0;
	var multiplier = 1;
	var time = 50;
		
	tooltip();
	$("#jqnavi ul li a").each(function(i)
		{
		$(this).css("marginLeft","-180");
		// updates timer
		timer = (timer*multiplier + time);
		$(this).animate({ marginLeft: "-50" }, timer);
		$(this).animate({ marginLeft: "-20" }, timer);
		$(this).animate({ marginLeft: "-50" }, timer);
	});
	$("#jqnavi ul li a").append("<em></em>");
	$("#slideshow_container").append("<ul id='slideshow'></ul>");
	$("#slideshow").append(images);
	$("#slideshow").innerfade({	speed: 'slow',
								timeout: 4000,
								type: 'sequence',
								containerheight: '177px'
								});
	$(function() {
				
				$("#jqnavi ul li a").hover(
					function(e) {
						$this = $(this);
						$this.children('em').text($(this).attr("title")).stop().show().animate({ left: 45},{queue:false,duration:500});
						$this.animate({marginLeft: "-20"},{queue:false,duration:300});
					}, 
					function() {
							$this = $(this);
							$this.children('em').hide().animate({left: 0},{duration:300}).text('');
							$this.animate({marginLeft: "-50"}, {queue:false,duration:300});
							return false;
					 });
	});
});

//MyCarouselFunctions############################################
function mycarousel_itemLoadCallback(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }
    jQuery.get(
        'dynamic_ajax_php.php',
        {
            first: carousel.first,
            last: carousel.last
        },
        function(xml) {
            mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);
        },
        'xml'
    );
};

function mycarousel_itemAddCallback(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));

    jQuery('image', xml).each(function(i) {
        carousel.add(first + i, mycarousel_getItemHTML(jQuery(this).text()));
    });
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(url)
{
    return '<li><img src="' + url + '" width="237" height="160" alt="" /></li>';
};
