﻿$(document).ready(function() {


  /* http://nyromodal.nyrodev.com/ */
  $('.nyroModal').nyroModal();


  $.datepicker.setDefaults( $.datepicker.regional[ "de" ] );
	$('#calendar').datepicker({
//    minDate: '-0m',
    minDate: "" + jquery_calendar_start_date + "",
    maxDate: "" + jquery_calendar_end_date + "",
    defaultDate: "" + jquery_calendar_current_date + "",
    hideIfNoPrevNext: true,
    selectOtherMonths: true,
    stepMonths: 1,
    onSelect: function(dateStr) {
      window.location.href = '/spielplan/tag/' + dateStr + '/';
    }
  });


  // Page: index.php / Action: Hide Second Level Navigation
  if(jquery_action != "karten") {
    $('#nav_toggle_abo, #nav_toggle_sitzplan').hide();
  }

  // Page: aktuell_news, spielplan_aktuell, aktuell_gaestebuch / Action: Hide Langtext / Hide Tagesbesetzung / Hide Gästebuch Form
  $('.newsText, .spielplanBesetzung, #guestbook-entry').hide();


  /* Page: aktuell_news, spielplan_aktuell / Action: Toggle */
  $('.showNewsText, .showSpielplanBesetzung, #show-guestbook-entry, #show_nav_toggle_abo, #show_nav_toggle_sitzplan').click(function() {
      var href = $(this).attr("href");
      $(href).toggle(500);
      return false;
    });


  /* Page: index.php / Action: Scroll Banner */
  /*
		$("div#banner").smoothDivScroll({
			autoScroll: "onstart" ,
			autoScrollDirection: "endlessloopright",
			autoScrollStep: 1,
			autoScrollInterval: 70,
			startAtElementId: "startAtMe",
			visibleHotSpots: ""
		});
  */

  /* Logo Slideshow. See: http://jquery.malsup.com/cycle/ */
  $('#logo-slideshow').cycle({
		fx: 'fade',
    timeout: 5000
	});


  $('#banner-carousel').jcarousel({
    start: 2,
    auto: 5,
    animation: 1700,
    scroll: 1,
    wrap: "circular",
    itemLoadCallback: itemLoadCallbackCarousel
    });

    function itemLoadCallbackCarousel(carousel)
  	{
  	  $( "#banner-carousel" ).css("overflow","visible");
  	  $( "#banner-carousel li:empty" ).remove();
  	};


  /* Page: _home_preview.inc.php / Action: Hide scroll arrows if "preview-box" <= 140px */
  var ePreviewBox = document.getElementById("preview-box");
  if (ePreviewBox){
    var iHeight = ePreviewBox.scrollHeight;

    if (iHeight <= 140){
      $('.preview_arrows').hide();
    }
  }

  /* Page: _home_preview.inc.php / Action: Scroll preview */
  $('#preview-scroll-down').hover(function(){
    $(".preview_box").scrollTo("max", 500);
      },function(){
          $(".preview_box").stop();
          // stop on unhover
  });


  $('#preview-scroll-up').hover(function(){
    $(".preview_box").scrollTo('0px', 500);
      },function(){
          $(".preview_box").stop();
          // stop on unhover
  });




  /* Page: index.php / Action: Animate content before leaving the page */
  $('.navigation li a').live('click', function() {
      $('.content')
        .animate({
  			  width: 'hide',
    			opacity: 'hide'
  	  	  }, 'fast');
  });


  /* Page: index / Action: Animated page load
  */
  if(jquery_action == "aktuell")
  {
      $('#content1')
      .addClass("hide")
      .animate({
			  width: 'show',
  			opacity: 'show'
	  	  }, 'slow');

      $('#nav4, #nav5, #nav6')
        .animate({
			    width: 'hide',
  			  opacity: 'hide'
	  	  }, 'slow');
  }

  if(jquery_action == "spielplan")
  {
      $('#content2')
      .addClass("hide")
      .animate({
			  width: 'show',
  			opacity: 'show'
	  	  }, 'slow');

      $('#nav1, #nav6')
        .animate({
			    width: 'hide',
  			  opacity: 'hide'
	  	  }, 'slow');
  }

  if(jquery_action == "programm")
  {
      $('#content3')
      .addClass("hide")
      .animate({
			  width: 'show',
  			opacity: 'show'
	  	}, 'slow');

      $('#nav1, #nav6')
        .animate({
			    width: 'hide',
  			  opacity: 'hide'
	  	}, 'slow');
  }

  if(jquery_action == "ensemble")
  {
      $('#content3')
      .addClass("hide")
      .animate({
			  width: 'show',
  			opacity: 'show'
	  	}, 'slow');

      $('#nav1, #nav6')
        .animate({
			    width: 'hide',
  			  opacity: 'hide'
	  	}, 'slow');
  }

  if(jquery_action == "karten")
  {
      $('#content4')
      .addClass("hide")
      .animate({
			  width: 'show',
  			opacity: 'show'
	  	}, 'slow');

      $('#nav1, #nav2')
        .animate({
			    width: 'hide',
  			  opacity: 'hide'
	  	}, 'slow');
  }

  if(jquery_action == "service")
  {
      $('#content5')
      .addClass("hide")
      .animate({
			  width: 'show',
  			opacity: 'show'
	  	}, 'slow');

      $('#nav1, #nav2')
        .animate({
			    width: 'hide',
  			  opacity: 'hide'
	  	}, 'slow');
  }


  /* Page: index.php / Click: Arrow / Action: Hide content, display navigation */
  $('.hiddenNavigationLeft a, .hiddenNavigationRight a').live('click', function() {

    $('.hiddenNavigationLeft, .hiddenNavigationRight').text('\u00a0');
    $('.navigation li, .navigation li a').removeClass("highlight");
    $('.navigation').removeClass("greyOut");
    $('.navigation').addClass("paddingRight");

    $('.content')
      .animate({
			  width: 'hide',
  			opacity: 'hide'
	  	  }, 'slow');

    $('.navigation')
      .animate({
			  width: 'show',
  			opacity: 'show'
	  	}, 'slow');

    return false;
  });




  // $('.enhanced_toggleResult').appendTo('#content');


});
