// remap jQuery to $
(function($){})(window.jQuery);


/* trigger when page is ready */
$(document).ready(function (){

	
/*	#################### VIDEO #################### */
	$('.br_el a').bind("click", function () {
		$(this).parent().css('display','none');
		$('iframe.youtube').animate({ left: '0' }, 750, 'easeOutCubic' );
	});

/*	#################### GALLERY #################### */
	
	$('.scroll-pane').jScrollPane({
			verticalDragMinHeight:  31,
			verticalDragMaxHeight:  31,
			horizontalDragMinWidth: 92,
			horizontalDragMaxWidth: 92
		}
	);

/*	#################### MENU HOMEPAGE #################### */
	$('#head_bt_back a').bind('click', function(event) {
		event.preventDefault();
		if($(this).hasClass('closed')){
			$("#head_organizza").removeClass("close").addClass("open");
			
			//open the main menu
			$('header aside').animate({height: '441px'}, 800, 'easeOutExpo');
			$("#profilesInterface").animate({height: '95px'}, 800, 'easeOutExpo');
			$("#filtersInterface").animate({height: '206px'}, 800, 'easeOutExpo');
			$(".interfaceHolder").css({"visibility":"visible"});
			$(".mainMenuTitle").css({"visibility":"visible"});
			$('#custom_menu').animate({
					height: '1350px'
				}, 800, 'easeOutExpo', function() {
					$('#head_bt_back a').removeClass('closed').addClass('open');
					$('#head_bt_back a').html('Chiudi il menu');
			});
		}else{
			$('header aside').animate({height: '141px'}, 800, 'easeOutExpo', function(){
				$(".interfaceHolder").css({"visibility":"hidden"});
				$(".mainMenuTitle").css({"visibility":"hidden"});
			});
			$(".interfaceHolder").animate({height: '0'}, 800, 'easeOutExpo');
			$('#custom_menu').animate({height: '0'}, 800, 'easeOutExpo', function() {
					$("#head_organizza").removeClass("open").addClass("close");
					$('#head_bt_back a').removeClass('open').addClass('closed');
					$('#head_bt_back a').html('Apri il menu');
			});
		}

	});

	$('#content #prodotto_box_porzione td span').vAlign();

});

(function ($) {
// VERTICALLY ALIGN FUNCTION
$.fn.vAlign = function() {
  return this.each(function(){
  var ah = $(this).height();
  var ph = $(this).parent().height();
  var mh = parseInt((ph - ah) / 2);
  if(mh>0) {
    $(this).css('top', mh);
  } else {
    $(this).css('top', 0);
  }
});
};
})(jQuery);





/* optional triggers

$(window).load(function() {
	
});

$(window).resize(function() {
	
});

*/
