if(Drupal.jsEnabled){  
  
  var $currentPosition = 380;
  var $totalheight;
  
	
  $(document).ready(function() {	
	$(".view-event .view-content").wrap('<div class="contentwrap" />');	
	$totalheight = $(".view-event .view-content").css('height');
	
	$("a.down").click(function(e){							   
	  downDiv($(this));	  
	});
	$("a.up").click(function(e){							   
	  upDiv($(this));	  
	});
	disableBtn();
	
	//alert($currentPosition+"  "+$totalheight);
  });
 
  function downDiv(evt){
	  $.easing.custom = function (x, t, b, c, d) {
			var s = 3.1547; 
			if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
			return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	  }
	  
	  $(".view-event .view-content").animate({"top": "-=100px", "duration": "fast", "easing": "custom"});
	  $currentPosition = $currentPosition - 100;
	  disableBtn();
	  
  }
  
  function upDiv(evt){
	  $.easing.custom = function (x, t, b, c, d) {
			var s = 3.1547; 
			if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
			return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	  }
	  
	  if($currentPosition >= $totalheight){
        $("a.up").addClass("disabled");
		//alert("first item");
	  }else{
		//alert($currentPosition);
	    $(".view-event .view-content").animate({"top": "+=100px", "duration": "fast", "easing": "custom"});	  
		$currentPosition = $currentPosition + 100;
		disableBtn();
	  }
  }
  
  function disableBtn(){
	if($currentPosition <= 80){
		$("a.down").addClass("disabled");
	}else if($currentPosition >= 380){
		$("a.up").addClass("disabled");
	}
	else{
		$("a.down").removeClass("disabled");
		$("a.up").removeClass("disabled");
	} 	
  }

}






