﻿function goto(nameAnchor){
	window.location.hash=nameAnchor;
}
function homeH(){
	if($('.home-layout').height()+50>$(window).height()) { $('.home-layout').addClass('home-layout-min'); } else { $('.home-layout').removeClass('home-layout-min'); }
}
function blogH(n){
	if($(window).height()<550){ if(n==1){ $('.box-top .main-vision,.box-top .vision').slideUp(); } else { $('.box-top .main-vision,.box-top .vision').hide(); } } else { $('.box-top .main-vision,.box-top .vision').slideDown(); }
}

$(function(){
	$('.home-layout').each(function(){ homeH(); $(window).resize(function(){ homeH(); }); });
	$('.box-top').each(function(){ blogH(0); $(window).resize(function(){ blogH(1); }); });
	
	$('.h-tab-r').click(function(){ $('.tweet-box').addClass('ht-toggle'); });
	$('.h-tab-l').click(function(){ $('.tweet-box').removeClass('ht-toggle'); });
	
	$('.jsInLink').click(function(){
		if($(this).attr('href') == '#top') { $(window).scrollTop(0); } else { $(window).scrollTop($($(this).attr('href')).offset().top); }
		return false
	});
	if($(window).height()*1.5<$('.all').height()){ $('.box-GoTop, .box-menu:eq(1)').show(); } // hide bottom menu if content small
	
	if($('.box-sMenu').offset()){
		var sScroll = $('.box-sMenu').offset().top;
	}
	
	$('.add-comment h2').click(function(){
		$(this).siblings('form').slideToggle();
	});
	if($('.recaptcha-error').size()){
		$(window).scrollTop($("#respond").offset().top);
		$('.add-comment form').show();
	}
	$('.blog .post').hover(function(){
		//$('.blog .post .entry:visible').hide();
		$('.blog .post:not(.post-visible) .entry:visible').hide();
		$(this).addClass('post-over').find('.entry').slideDown(200);
	},function(){
		$(this).not('.post-visible').removeClass('post-over').find('.entry').hide();
	});
	$('.blog .post .ico-visibility').click(function(){ $(this).parents('.post').toggleClass('post-visible'); return false });
	
	$(window).bind('load scroll',function(){
		if(sScroll){
		if($(window).scrollTop()>sScroll){
			$('.box-sMenu').addClass('box-sMenu-fix');
			} else { $('.box-sMenu').removeClass('box-sMenu-fix'); }
		}
	});
});


