jQuery(document).ready(function($){ 
   
  //-- navigation

  $("#menu-primary").superfish({
    animation: {height: 'show'},
    speed: 'fast',
    delay: 300,
    dropShadows:   false
  }); 
    
  //-- carousels
  
  $('.home-carousel ul').jcarousel({
    scroll: 1,
    wrap: 'both',
    auto: 5,
    // This tells jCarousel NOT to autobuild prev/next buttons
    buttonNextHTML: null,
    buttonPrevHTML: null,
    initCallback: mycarousel_initCallback,
    itemVisibleInCallback: {
      onAfterAnimation: mycarousel_visible
    }
  });
  
  $('.product_menu .page_item > a').click(function() {
    // $(this).parent().addClass('current-menu-parent').siblings().removeClass('current-menu-parent');
    $(this).next().slideToggle();
  });
  

  
  
  var hite = $(window).height() - $('#wrapper').height();
  if (hite > 100) {
	$('#footer').css('height',hite-55); 
	} 
	$(window).resize(function() {
  	  var rehite = $(window).height() - $('#wrapper').height()-55;
			$('#footer').css('height',rehite);  //to account for enormous monitors 
	});

});

function mycarousel_visible(carousel, item, idx, state) {
  jQuery('.home-carousel-control a').removeClass('selected');
  jQuery('.home-carousel-control a').eq(idx-1).addClass('selected');
}

function mycarousel_initCallback(carousel) {
  jQuery('.home-carousel-control a').bind('click', function() {
    carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
    jQuery('.home-carousel-control a').removeClass('selected');
    jQuery(this).addClass('selected');
    return false;
  });
  
  // Pause autoscrolling if the user moves with the cursor over the clip.
  carousel.clip.hover(function() {
    carousel.stopAuto();
  }, function() {
    carousel.startAuto();
  });
}


