
initSlider = function(){	
	var posy;	
	var hline_height = $('div.scrol').height() - 40; 	
	var sdvig_h = $('div.post-content').height() - $('div.post').height();
	var content_mar = $('div.post-content');	
	var grad_c = ($('div.post-content').height() / $('div.post').height());	
	var cont_h = $('div.post').height() * (-1);
	var cont_post = $('div.post-content').height() * (-1);
	if(cont_h < cont_post) 
		$('div.scrol').hide();
	
	var grad_s = hline_height / grad_c;
	grad_c = sdvig_h / grad_c * (-1);	
	$('div.scrol strong.down').click(function(){								
		var this_margin = parseInt(content_mar.css("marginTop"));
		var this_top = $('div.scrol div span').position().top;
	
		if((this_top + grad_s) < hline_height){		
			content_mar.css("marginTop",this_margin + grad_c);
			$('div.scrol div span').css('top',this_top + grad_s);
		}
		else{			
			content_mar.css("marginTop",cont_post + 100);
			$('div.scrol div span').css('top',hline_height);
		}
	});
	$('div.scrol strong.up').click(function(){			
		var this_margin = parseInt(content_mar.css("marginTop"));
		var this_top = $('div.scrol div span').position().top;	
		if((this_top - grad_s) > 0){		
			content_mar.css("marginTop",this_margin - grad_c);
			$('div.scrol div span').css('top',this_top - grad_s);
		}
		else{
			content_mar.css("marginTop",0);
			$('div.scrol div span').css('top',0);
		}
	});
	$('div.scrol div span').draggable({
		axis: 'y',
		containment: $('div.scrol div'),				
		drag: function(){		
			var pos_y = $('div.scrol div span').position().top;
			var proc = (pos_y * 100)/hline_height;
			var margin_top = (sdvig_h * proc)/100 * (-1);
			content_mar.css("marginTop",margin_top);
			posy = pos_y;
		},
		stop: function(e,ui){
			var pos_y = $('div.scrol div span').position().top;
			var proc = (pos_y * 100)/hline_height;
			var margin_top = (sdvig_h * proc)/100 * (-1);
			content_mar.css("marginTop",margin_top);
			posy = pos_y;
		}
	});
}
initSlider2 = function(){	
	var posy;	
	var hline_height = $('div.scrol2').height() - 40; 	
	var sdvig_h = $('div.post-content2').height() - $('div.post2').height();
	var content_mar = $('div.post-content2');	
	var grad_c = ($('div.post-content2').height() / $('div.post2').height());	
	var cont_h = $('div.post2').height() * (-1);
	var cont_post = $('div.post-content2').height() * (-1);
	if(cont_h < cont_post) 
		$('div.scrol2').hide();
	
	var grad_s = hline_height / grad_c;
	grad_c = sdvig_h / grad_c * (-1);	
	$('div.scrol2 strong.down').click(function(){								
		var this_margin = parseInt(content_mar.css("marginTop"));
		var this_top = $('div.scrol2 div span').position().top;
	
		if((this_top + grad_s) < hline_height){		
			content_mar.css("marginTop",this_margin + grad_c);
			$('div.scrol2 div span').css('top',this_top + grad_s);
		}
		else{			
			content_mar.css("marginTop",cont_post + 100);
			$('div.scrol2 div span').css('top',hline_height);
		}
	});
	$('div.scrol2 strong.up').click(function(){			
		var this_margin = parseInt(content_mar.css("marginTop"));
		var this_top = $('div.scrol2 div span').position().top;	
		if((this_top - grad_s) > 0){		
			content_mar.css("marginTop",this_margin - grad_c);
			$('div.scrol2 div span').css('top',this_top - grad_s);
		}
		else{
			content_mar.css("marginTop",0);
			$('div.scrol2 div span').css('top',0);
		}
	});
	$('div.scrol2 div span').draggable({
		axis: 'y',
		containment: $('div.scrol2 div'),				
		drag: function(){		
			var pos_y = $('div.scrol2 div span').position().top;
			var proc = (pos_y * 100)/hline_height;
			var margin_top = (sdvig_h * proc)/100 * (-1);
			content_mar.css("marginTop",margin_top);
			posy = pos_y;
		},
		stop: function(e,ui){
			var pos_y = $('div.scrol2 div span').position().top;
			var proc = (pos_y * 100)/hline_height;
			var margin_top = (sdvig_h * proc)/100 * (-1);
			content_mar.css("marginTop",margin_top);
			posy = pos_y;
		}
	});
}
$(document).ready(function(){
	initSlider();
	initSlider2();
});