jQuery(document).ready(function() {

	if($.jcarousel) {
    jQuery('#eck_carousel').jcarousel({
        scroll: 1,
        itemVisibleInCallback: {
            onBeforeAnimation: getCarouselImageIndex
        }
    });
    
    jQuery('#top_carousel').jcarousel({
        scroll: 1,
        itemVisibleInCallback: {
            onBeforeAnimation: getCarouselImageIndex
        }
    });
    
    jQuery('#row_carousel').jcarousel({
        scroll: 1,
        itemVisibleInCallback: {
            onBeforeAnimation: getCarouselImageIndex
        }
    });
    
    jQuery('#block_carousel').jcarousel({
        scroll: 1,
        itemVisibleInCallback: {
            onBeforeAnimation: getCarouselImageIndex
        }
    });
    }
    
    $('#col1_content').addClass('carousel')
    // Xpath zum grossbild: //ul[@id='eck_carousel']/li/a/@href 
    $("#variant a").click(function(){
    	var title = $(this).attr("title") || '';
    	var pdf = $(this).next('a').attr('href');
        $("#stand_detail").html("<img src=" + $(this).attr("href") + ">" + title);
    $("#download a").attr( 'href', pdf);
        return false;
    });
    $("#download a").click(function() {
    	if(_gaq) {
    		var pdf = $(this).attr('href');
    		_gaq.push(['_setAccount', 'UA-19986695-1']);
    		_gaq.push(['_trackPageview', pdf]);
    	}
    });
    $("#submit_medtec a").click(function() {
    	if(_gaq) {
    		_gaq.push(['_setAccount', 'UA-19986695-1']);
    		_gaq.push(['_trackPageview', 'anfrage_medtec']);
    	}
    });
    $("#submit_tl a").click(function() {
    	if(_gaq) {
    		_gaq.push(['_setAccount', 'UA-19986695-1']);
    		_gaq.push(['_trackPageview', 'anfrage_transportlogistik']);
    	}
    });

});

function getCarouselImageIndex(carousel, item, idx, state){
    var clicked = item.parentNode.id;
    var node_idx = idx -1;
    var image = $('#' + clicked + ' li:eq(' + node_idx + ') a').attr('href');
    var title = $('#' + clicked + ' li:eq(' + node_idx + ') a').attr('title') || '';
    var pdf = $('#' + clicked + ' li:eq(' + node_idx + ') a.pdflink').attr('href');
    $("#download a").attr( 'href', pdf);
    $("#stand_detail").fadeOut("444", function() {
    	$("#stand_detail").html('<img src="' + image + '"><p>' + title + '</p>' ).fadeIn("444");
    });
}


