$(document).ready(function () {
$('body').append('
');
$('.btn-to-top').click(function () {
$("html, body").animate({
scrollTop: 0
}, 600);
return false;
});
$(window).scroll(function(){
if ($(this).scrollTop() >= $(window).height()) {
$('.btn-to-top').addClass('in');
}else{
$('.btn-to-top').removeClass('in');
}
});
var menu = $('#topo');
var init_here = $('#destaque').offset().top;
$(window).scroll(function(){
if ($(this).scrollTop() >= init_here) {
menu.addClass('fixed');
}else{
menu.removeClass('fixed');
}
});
var _click = $('.mymenuitem0 ul a');
$(window).bind('load',function(){
if ($('body').hasClass('body_home')){
if (window.location.href.indexOf('#') != -1) scrollTo(window.location.hash);
}
});
_click.click(function(e){
if ($(this).attr('href').indexOf('#') != -1){
e.preventDefault();
scrollTo($(this).attr('href'));
return false;
}else{
return true;
}
});
function scrollTo(element) {
if (!$(element).length){
var newElement = element.replace('#','.');
element = '.'+$(newElement).attr('class');
if (!$(element).length){
console.log('Error: '+element+' does not exist')
return false;
}
}
$('html, body').animate({
scrollTop: ($(element).offset().top)-1
}, 1000);
}
});