function changeBodyClass(classe) {
	document.body.className = classe;
}
function changeBodyId(identificador) {
	document.getElementsByTagName('body')[0].id=identificador;
}
// SCROLL SIDEWALK
$(window).load(function() {
visibleHeight=$('#customScrollBox').height();
if($('#customScrollBox  .container').height()>visibleHeight){
totalContent=$('#customScrollBox  .content').height();
minDraggerHeight=$('#dragger').height();
draggerContainerHeight=$('#dragger_container').height();
adjDraggerHeight=totalContent-((totalContent-visibleHeight)*1.3); //adjust dragger height analogous to content
animSpeed=400; //animation speed
easeType='easeOutCirc'; //easing type
//bottomSpace=1.05; //bottom scrolling space
bottomSpace=1.06; //bottom scrolling space
targY=0;
draggerHeight=$('#dragger').height();
$('#dragger').draggable({ 
	axis: 'y', 
	containment: 'parent', 
	drag: function(event, ui) {
		Scroll();
	}, 
	stop: function(event, ui) {
		DraggerOut();
	}
});
//scrollbar click
$('#dragger_container').click(function(e) {
	
	var mouseCoord=(e.pageY - $(this).offset().top);
	var targetPos=mouseCoord+$('#dragger').height();
	if(targetPos<$('#dragger_container').height()){
		$('#dragger').css('top',mouseCoord);
		Scroll();
	} else {
		$('#dragger').css('top',$('#dragger_container').height()-$('#dragger').height());
		Scroll();
	}
});
//mousewheel
$(function($) {
	$('#customScrollBox').bind('mousewheel', function(event, delta) {
		vel = Math.abs(delta*10);
		$('#dragger').css('top', $('#dragger').position().top-(delta*vel));
		Scroll();
		if($('#dragger').position().top<0){
			$('#dragger').css('top', 0);
			$('#customScrollBox .container').stop();
			Scroll();
		}
		if($('#dragger').position().top>$('#dragger_container').height()-$('#dragger').height()){
			$('#dragger').css('top', $('#dragger_container').height()-$('#dragger').height());
			$('#customScrollBox .container').stop();
			Scroll();
		}
		return false;
	});
});
function Scroll(){
	//var scrollAmount=((totalContent-(visibleHeight/bottomSpace))/(draggerContainerHeight-draggerHeight))*1.82;
	var scrollAmount=3.8;
	var draggerY=$('#dragger').position().top;
	targY=-draggerY*scrollAmount;
	var thePos=$('#customScrollBox  .container').position().top-targY;
	$('#customScrollBox .container').stop().animate({top: '-='+thePos}, animSpeed, easeType); //with easing
	//$('#customScrollBox .container').css('top',$('#customScrollBox  .container').position().top-thePos+'px'); //no easing
}
$("#dragger").mouseup(function(){ DraggerOut(); }).mousedown(function(){ DraggerOver(); });
function DraggerOver(){	$('#dragger').css('border', 'none'); }
function DraggerOut(){ $('#dragger').css('border', 'none');	}
	} else { $('#dragger').css('display','none'); $('#dragger_container').css('display','none'); }
});

// SCROLL LOJAS
$(window).load(function() {
visibleHeight=$('#customScrollBox2').height();
if($('#customScrollBox2  .container2').height()>visibleHeight){
totalContent=$('#customScrollBox2  .content2').height();
minDraggerHeight=$('#dragger2').height();
draggerContainerHeight=$('#dragger_container2').height();
adjDraggerHeight=totalContent-((totalContent-visibleHeight)*1.3); //adjust dragger height analogous to content
draggerHeight=$('#dragger2').height();
$('#dragger2').draggable({ 
	axis: 'y', 
	containment: 'parent', 
	drag: function(event, ui) {
		Scroll();
	}, 
	stop: function(event, ui) {
		DraggerOut();
	}
});
//scrollbar click
$('#dragger_container2').click(function(e) {
	
	var mouseCoord=(e.pageY - $(this).offset().top);
	var targetPos=mouseCoord+$('#dragger2').height();
	if(targetPos<$('#dragger_container2').height()){
		$('#dragger2').css('top',mouseCoord);
		Scroll();
	} else {
		$('#dragger2').css('top',$('#dragger_container2').height()-$('#dragger2').height());
		Scroll();
	}
});
//mousewheel
$(function($) {
	$('#customScrollBox2').bind('mousewheel', function(event, delta) {
		vel = Math.abs(delta*10);
		$('#dragger2').css('top', $('#dragger2').position().top-(delta*vel));
		Scroll();
		if($('#dragger2').position().top<0){
			$('#dragger2').css('top', 0);
			$('#customScrollBox2 .container2').stop();
			Scroll();
		}
		if($('#dragger2').position().top>$('#dragger_container2').height()-$('#dragger2').height()){
			$('#dragger2').css('top', $('#dragger_container2').height()-$('#dragger2').height());
			$('#customScrollBox2 .container2').stop();
			Scroll();
		}
		return false;
	});
});
function Scroll(){
	var scrollAmount=(totalContent-(visibleHeight/bottomSpace))/(draggerContainerHeight-draggerHeight);
	var draggerY=$('#dragger2').position().top;
	targY=-draggerY*scrollAmount;
	var thePos=$('#customScrollBox2  .container2').position().top-targY;
	$('#customScrollBox2 .container2').stop().animate({top: '-='+thePos}, animSpeed, easeType); //with easing
}
$("#dragger2").mouseup(function(){ DraggerOut(); }).mousedown(function(){ DraggerOver(); });
function DraggerOver(){	$('#dragger2').css('border', 'none'); }
function DraggerOut(){ $('#dragger2').css('border', 'none'); }
	} else { $('#dragger2').css('display','none'); $('#dragger_container2').css('display','none'); }
});
