$(document).ready(function() {
 	
	 do_scrolling();
	 
	 $(".car_item").click(function(){
	 	
	 	do_scrolling();
	 
	 });
	  
 });
 
 function do_scrolling()
 {
 	if(!$("#left_column").hasClass("open"))
 	{
	 	var int_height_ScrollBox = $("#left_column").height();
	 	if(int_height_ScrollBox > 0)
	 	{
	 		$("#mcs_container").children(".customScrollBox").height(int_height_ScrollBox);
	 		$("#mcs_container").children(".customScrollBox").children(".dragger_container").height(int_height_ScrollBox-28);
	 	}

	 	if ($("#standardcontent").height() === null){
	 		var int_height = $("#mcs_container").children(".customScrollBox").children(".container").children(".content").children(".tx-maglistpartnerimpress-pi1").height();
	 	}else
	 	{
	 		var int_height = $("#mcs_container").children(".customScrollBox").children(".container").children(".content").children("#standardcontent").height();
	 	}
	 	
	 	int_height = int_height+20;
	 	$("#mcs_container").children(".customScrollBox").children(".container").children(".content").height(int_height);
	  /* 
		malihu custom scrollbar function parameters: 
		1) scroll type (values: "vertical" or "horizontal")
		2) scroll easing amount (0 for no easing) 
		3) scroll easing type 
		4) extra bottom scrolling space (vertical scroll type only)
		5) scrollbar height/width adjustment (values: "auto" or "fixed")
		6) mouse-wheel support (values: "yes" or "no")
		7) scrolling via buttons support (values: "yes" or "no")
		8) buttons scrolling speed (values: 1-20, 1 being the slowest)
		*/
		$("#mcs_container").mCustomScrollbar("vertical",400,"",1.05,"auto","yes","yes",10);
 	}
 	else
 	{
 		$(".dragger_container").hide();
 		$(".scrollUpBtn").hide();
 		$(".scrollDownBtn").hide();
 		$(".customScrollBox").css("height","100%");
 	}
 }
 
 /* function to fix the -10000 pixel limit of jquery.animate */
$.fx.prototype.cur = function(){ 
    if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
      return this.elem[ this.prop ];
    }
    var r = parseFloat( jQuery.css( this.elem, this.prop ) );
    return typeof r == 'undefined' ? 0 : r;
}

