

//* Carousel *
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

 $(document).ready(function() {
  //* PopIn, *
  
  $(function() {
    $.nyroModalSettings({
      hideContent: function(elts, settings, callback) {
        elts.contentWrapper
          .fadeOut(function (){
            elts.contentWrapper.hide();
            callback();
          });

      }
    });
  });



  $("div.carousel").jcarousel({
      auto: 2,
      scroll: 5,
      wrap: 'circular',
      animation: 5000,
      initCallback: mycarousel_initCallback
  });

//* Form *
$('#RegionSearchForm > div > select').change(function (){
  $('#RegionSearchForm').submit();
});
$('#newsletterFormSubmit').click(function(){
  $('#NewsletterAddForm').submit();
});
$('#NewsletterEmail').focus(function (){
  $(this).val('');
});
$('#TriForm > select').change(function (){
  $('#TriForm').submit();
});
$("#DeviAddForm").validate(function (){
  alert("test");
});


//* PopIn, *
  
	// Show
	$('.nm_showSwitch').click(function() {
		$(this).css('outline','none');
    var i = '1';
    while($(this).attr('target' + i))
    {
      showSwitch = $(this).attr('target' + i);
		  var id = '#' + $(this).attr('target' + i);
		  var mySwitch = $(this);
		  if (!$(id).hasClass("hide")) {
  		}else{
        $('.showFlag').addClass('hide');
        $('.showFlag').css('display','none');

		    $(id).removeClass('hide');
		    $(id).addClass('showFlag');
		    $(id).css('display','block');
  		}
  		i++;
    }
	});
  $('body').click(function (){
    $('#flashMessage').hide();
  });

  $('a.nyroModal').nyroModal({
    galleryCounts: false
  });
});

