
// Global Vars


$(document).ready(function(){

	 // Must come after the video.js library

    // Add VideoJS to all video tags on the page when the DOM is ready
    VideoJS.setupAllWhenReady();

    /* ============= OR ============ */

    // Setup and store a reference to the player(s).
    // Must happen after the DOM is loaded
    // You can use any library's DOM Ready method instead of VideoJS.DOMReady

    /*
    VideoJS.DOMReady(function(){

      // Using the video's ID or element
      var myPlayer = VideoJS.setup("example_video_1");

      // OR using an array of video elements/IDs
      // Note: It returns an array of players
      var myManyPlayers = VideoJS.setup(["example_video_1", "example_video_2", video3Element]);

      // OR all videos on the page
      var myManyPlayers = VideoJS.setup("All");

      // After you have references to your players you can...(example)
      myPlayer.play(); // Starts playing the video for this player.
    });
    */

    /* ========= SETTING OPTIONS ========= */

    // Set options when setting up the videos. The defaults are shown here.

   /*
    VideoJS.setupAllWhenReady({
      controlsBelow: false, // Display control bar below video instead of in front of
      controlsHiding: true, // Hide controls when mouse is not over the video
      defaultVolume: 0.85, // Will be overridden by user's last volume if available
      flashVersion: 9, // Required flash version for fallback
      linksHiding: true, // Hide download links when video is supported
      height:400
    });
    */

    // Or as the second option of VideoJS.setup

    /*
    VideoJS.DOMReady(function(){
        myPlayer1 = VideoJS.setup("video1", {
          controlsHiding: true,
          controlsBelow: false,
          showControlsAtStart: true
        });
        myPlayer2 = VideoJS.setup("video2", {
            controlsHiding: true,
            controlsBelow: false,
            showControlsAtStart: true
          });
      });
    */

    /* VIDEO OVERLAY*/

    // videos have video js applied to them
    //$("video").VideoJS()

    $(".show-video").click(function ()
    {
    	$(".video-background").show();
    	 if ( $.browser.msie ) {
			 $('.video-background').addClass('bgcover_op');
			 } else {
				 $('.video-background').css({opacity:0}).animate( {opacity:0.5, backgroundColor:'#ccc'} );
			 }
		$('.video-background').css({
			display:'block',
			width: $(window).width(),
			height:$(window).height()
		});
        $(".video-container").fadeIn("fast");
        $(".video-container").css({opacity:1});
        myPlayer1.play();
        myPlayer2.play();
    });
    $(".close-video").click(function ()
    {
        $('.video-background').fadeOut();
        $('.video-container').fadeOut();
        	myPlayer1.pause();
        	myPlayer2.pause();
    });


    	/* TABS */
    	//When page loads...
    	$(".tab_content").hide(); //Hide all content
    	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
    	$(".tab_content:first").show(); //Show first tab content

    	//On Click Event
    	$("ul.tabs li").click(function() {

    		$("ul.tabs li").removeClass("active"); //Remove any "active" class
    		$(this).addClass("active"); //Add "active" class to selected tab
    		$(".tab_content").hide(); //Hide all tab content

    		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
    		$(activeTab).fadeIn(); //Fade in the active ID content
    		return false;
    	});
    	$("#navi li").click(function(){
    		$("#navi li").removeClass("active");
    		$(this).addClass("active");
    	});
	// UI modifikations
	$("#trailer").fancybox({
		'padding'			: 0,
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayOpacity'	: '0.8',
		'autoScale'			: true,
		'width'				: 480,
		'height'			: 856,
		 'onClosed': function() {
			    parent.location.reload(true);
			  }

	});

		$("a[rel=gal]").fancybox({
			'padding'			: 0,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titleShow'			: 'false',
			'width'				: '520',
			'overlayOpacity'	: '0.8',
			'onComplete'		: function() { $('#fancybox-close').css('top','-20px');},
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});
	/*
	$("#programm").fancybox({
		'width'				: '75%',
		'height'			: '75%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	*/
	$("#inhalt").fancybox({
		'padding'			: 0,
		'width'				: 700,
		'height'			: 758,
		'autoScale'			: false,
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayOpacity'	: '0.8'

	});
});
