﻿$(document).ready(function() {  
	
	///////////////////////////////// GENERAL /////////////////////////////////
	
	$('html').addClass('js');
	$('#pageFoot .downloads a').attr('target', '_blank');
	$('a.external').attr('target', '_blank');
	
	///////////////////////////////// VIDEO /////////////////////////////////
	
	// Presets
	var imgPreload = new Image();
	imgPreload.src = '../pics/bg_pageBody.jpg';
	
	if(navigator.userAgent.match(/iPad/i)) {
		$('#introVideo').attr('controls', 'controls');
	}
	
	if ($('video').length) {
		new MediaElement('introVideo', {	
			plugins: ['flash'],
			pluginPath: 'swf/',
			flashName: 'flashmediaelement.swf',
			success: function(introVideo) {
				introVideo.play();
				
				introVideo.addEventListener('timeupdate', function() {
					/*if(introVideo.ended) {
						$('#pageBody').css('background-image', 'url(pics/bg_pageBody.jpg)');
						$('#introVideo').fadeOut(500);
					}*/
				}, false);
			}
		});
	}
	
	///////////////////////////////// IMAGE-GALLERY /////////////////////////////////
	
	$('#imageGallery').colorbox({iframe: true, href: "bilder.html", innerWidth: 970, innerHeight: 500}).click(checkIpad);
	
	function checkIpad() {
		if(navigator.userAgent.match(/iPad/i) || (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
			$('video').hide();
		}
	}
	
	if(navigator.userAgent.match(/iPad/i) || (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
		$('#cboxClose').click(function(){
			$('video').show();
		});
	}
	
	if ($('.gallery').length)
	{
		var gallery = $('#thumbs').galleriffic({
			delay:                     3500,
			numThumbs:                 12,
			preloadAhead:              12,
			enableTopPager:            false,
			enableBottomPager:         true,
			maxPagesToShow:            7,
			imageContainerSel:         '#slideshow',
			controlsContainerSel:      '#controls',
			captionContainerSel:       '',
			loadingContainerSel:       '',
			renderSSControls:          true,
			renderNavControls:         true,
			playLinkText:              'Diashow abspielen',
			pauseLinkText:             'Diashow anhalten',
			prevLinkText:              '&lsaquo; Vorheriges Bild',
			nextLinkText:              'Nächstes Bild &rsaquo;',
			nextPageLinkText:          'Weiter &rsaquo;',
			prevPageLinkText:          '&lsaquo; Zurück',
			enableHistory:             false,
			autoStart:                 false,
			syncTransitions:           true,
			defaultTransitionDuration: 500
		});
	}
	
});
