/* Author: 

*/

/***********************************************************/ 
/*                    fuseSymbols Plugin                   */ 
/*                      Version: 0.1                       */ 
/*                      Dennis Helfensteller               */ 
/*                 Updated: May 4th, 2011                  */ 
/***********************************************************/ 
(function($){   
     $.fn.docSymbols = function () { 
          $(this).each(function() { 
               if($(this).attr('class') == '') { 
                    var link = $(this).attr('href').toLowerCase(); 
                    if (link.indexOf('.pdf') != -1) { $(this).addClass('dl pdf'); }; 
                    if (link.indexOf('.jpg') != -1) { $(this).addClass('dl jpg'); }; 
                    if (link.indexOf('.doc') != -1) { $(this).addClass('dl doc'); }; 
                    if (link.indexOf('.docx') != -1) { $(this).addClass('dl doc'); }; 
               }; 
          }); 
     }; 
})(jQuery);


    $(function() {
        $("div#controller").jFlow({
            slides: "#slides",
            width: "1000px",
            height: "468px"
        });
    });




$(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */

$('#main ul.dl a').docSymbols();

	/* The number of event sections / years with events */
	var tot=$('.event').length;
	
	$('.eventList li').click(function(e){
			showWindow('<div>'+$(this).find('div.content').html()+'</div>');
	});
	
	/* Each event section is 320 px wide */
	var timelineWidth = 320*tot;
	var screenWidth = $(document).width();
	
	$('#timelineScroll').width(timelineWidth);
	
	/* If the timeline is wider than the screen show the slider: */
	if(timelineWidth > screenWidth)
	{
		$('#scroll,#slider').show();
		$('#centered,#slider').width(120*tot);
		
		/* Making the scrollbar draggable: */
		$('#bar').width((120/320)*screenWidth).draggable({

			containment: 'parent',
			drag: function(e, ui) {
	
				if(!this.elem)
				{
					/* This section is executed only the first time the function is run for performance */
					
					this.elem = $('#timelineScroll');
					
					/* The difference between the slider's width and its container: */
					this.maxSlide = ui.helper.parent().width()-ui.helper.width();

					/* The difference between the timeline's width and its container */
					this.cWidth = this.elem.width()-this.elem.parent().width();
					this.highlight = $('#highlight');
				}
				
				/* Translating each movement of the slider to the timeline: */
				this.elem.css({marginLeft:'-'+((ui.position.left/this.maxSlide)*this.cWidth)+'px'});
				
				/* Moving the highlight: */
				this.highlight.css('left',ui.position.left)
			}
		});
		
		$('#highlight').width((120/320)*screenWidth-3);
	}


   $('.slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		speed: 2800, timeout: 9000,
		pause: 1
	});




	
});

function showWindow(data)
{
	/* Each event contains a set of hidden divs that hold
	   additional information about the event: */
	   
	var title = $('.title',data).text();
	var date = $('.date',data).text();
	var body = $('.body',data).html();
	
	$('<div id="overlay">').css({
								
		width:$(document).width(),
		height:$(document).height(),
		opacity:0.6
		
	}).appendTo('body').click(function(){
		
		$(this).remove();
		$('#windowBox').remove();
		
	});
	
	$('body').append('<div id="windowBox"><div id="titleDiv">'+title+'</div>'+body+'<div id="date">'+date+'</div></div>');

	$('#windowBox').css({
		width:500,
		height:350,
		left: ($(window).width() - 500)/2,
		top: ($(window).height() - 350)/2
	});
	
}

/*lightbox initialisieren */
// Automagically create lightbox links for all images with class lightbox 
jQuery('img.lightbox').each(function(){ 
var link = jQuery(this).attr("src").split("&")[0].split("=")[1]; 
link = link.replace('[(site_url)]',''); 
link = link.replace('_thumb',''); 
jQuery(this).wrap('<a href="'+link+'" class="lightbox" title="'+this.title+'"></a>'); 
}); 

jQuery('a.lightbox').fancybox({ 'hideOnContentClick': true, 'overlayShow': true });

















