$(document).ready(initDocumentNews);
				
function initDocumentNews(){	

	var newsListImagesOverDuration=250;
	var newsListImagesOverAlha=0.5;
	$("#newsListContainer a.image").hover(newsListImageMouseOver, newsListImageMouseOut);
	function newsListImageMouseOver(){
		$(this).stop().fadeTo(newsListImagesOverDuration, newsListImagesOverAlha);
		$(this).stop().fadeTo(newsListImagesOverDuration, newsListImagesOverAlha);
	}
	function newsListImageMouseOut(){
		$(this).stop().fadeTo(newsListImagesOverDuration, 1);
		$(this).stop().fadeTo(newsListImagesOverDuration, 1);
	}
		
	var newsVignScrollingDuration=200;
	var newsVignScrollButtonsAmplitude=100;
	$("#newsListContainer").mCustomScrollbar("vertical",newsVignScrollingDuration,"easeOutCirc",1.05,"auto","yes","no",newsVignScrollButtonsAmplitude); 
	$.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;
	}
	
	var imagesBorderInterval=0;
	var imagesBorderIntervalNumber=10;
	var imagesBorderIntervalActualID=0;
	
	
	imagesBorderInterval=setInterval(setNewsImagesBorder, 1000);
	setNewsImagesBorder();
	
	function setNewsImagesBorder(){
		imagesBorderIntervalActualID=imagesBorderIntervalActualID+1;
		if(imagesBorderIntervalActualID==imagesBorderIntervalNumber){ clearInterval(imagesBorderInterval);	}

		if($(".imagesContainer").length!=0){
			for(var i=0; i<$(".imagesContainer .image").length; i++){
				var targetedImage=$($(".imagesContainer .image")[i]);
				$(".top", targetedImage).css("margin-top", "-"+$("img", targetedImage).height()+"px");
				$(".middle", targetedImage).css("margin-top", "-"+($("img", targetedImage).height()-$(".top", targetedImage).height())+"px");
				$(".middle", targetedImage).css("height", ($("img", targetedImage).height()-$(".top", targetedImage).height()-$(".bottom", targetedImage).height())+"px");
				$(".bottom", targetedImage).css("margin-top", "-"+($(".bottom", targetedImage).height())+"px");
			}
		}	
	}	
}	

