function putElem(elemId) {
	$('#'+elemId).show();
}

$(document).ready(function(){
	$('HTML').addClass('JS');
	placeBlocks();
})

$(window).resize(function() {
	placeBlocks();
});

$(function(){
	$('body').bind('mousewheel', function(event, delta) {
		if(delta < 0){
			var scrollLength = 100;
		} else {
			var scrollLength = -100;
		};
		var scrollLeft = $('body').scrollLeft();
		scrollLeft = scrollLeft + scrollLength;
		$('body').scrollLeft(scrollLeft);
	});
})

$(function(){
	$('.l-footer').mouseover(function(){
		$(this).stop().animate({opacity: 1}, 300, function() {}).end();
    }).mouseout(function(){
		$(this).stop().animate({opacity: 0.3}, 300, function() {}).end();
	});
})


function placeBlocks() {
	var contentHeight = $('.l-content').height();
	var headerHeight = $('.l-header').height();
	var windowHeight = $(window).height();
	var contentTextHeight = windowHeight - 85 - 50;
	$('body.in_ .con_page').height(contentTextHeight);
	placeFooter('0');
	placeFacebook('0', '-160');
}

function placeFooter (scrollTop) {
	var windowHeight = $(window).height();
	var windowWidth = $(window).width();
	var partnersWidth = 20;
	$('.b-partners-item').each(function() {
		partnersWidth = partnersWidth + $(this).find('img').width();
	});
	var footerHeight = $('.l-footer').height();	
//	if(partnersWidth > windowWidth){
//		footerHeight = footerHeight+50;
//	};
	var footerTop = windowHeight-footerHeight;
	var footerMinTop = $('div.b-box_1').height();
	footerMinTop = 0;
	if(scrollTop == 'NaN' || scrollTop == 'undefined'){
		 resultTop = footerTop;
	} else {
		resultTop = footerTop+parseInt(scrollTop);
	};
	if(resultTop < footerMinTop){
		resultTop = footerMinTop
	};
	$('.l-footer').css({'top':resultTop+'px','bottom':'auto'});
}

function placeFacebook (scrollTop, scrollLeft) {
	if(scrollTop == 'NaN' || scrollTop == 'undefined'){
		 resultTop = 20;
	} else {
		resultTop = 20+parseInt(scrollTop);
	};
	if(resultTop < 20){
		resultTop = 20
	};

	$('.b-facebook').css({'left':-scrollLeft+'px','top':resultTop+'px'});
}

$(function(){
	$('.b-facebook').toggle(function(){
		$(this)
			.stop()
			.find('span.message').css({'display':'block'}).end()
			.find('span.arrow').css({'position':'relative', 'left':'auto'}).end()
			.animate({width: '3000px'}, 1000, function() {
				$(this)
					.find('span.arrow').html('&larr;');
			})
	},
	function(){
		$(this)
			.stop()
			.animate({width: '30px'}, 500, function() {
				$(this)
					.find('span.arrow').css({'position':'absolute', 'right':'0'})
					.html('&rarr;');
			});
    })
})


