$(document).ready(function(){
	
	$.fn.alignCenter = function() {
		var elem = $(window);
		var left = parseInt(elem.width()/2 + elem.scrollLeft() - $(this).width()/2) + 'px';
		var top = parseInt(elem.height()/2 + elem.scrollTop() - $(this).height()/2) + 'px';
		return $(this).css({'left':left, 'top':top});
	};

	
	
	
	
	$('a#loginbtn').click(function(){
		$('#jslogin').fadeToggle();
		return false;
	});

	$('#jslogin').bind('click', function(event){
		  event.stopPropagation();
	});
	$('body').click(function(){
		if ($('#jslogin').css('display') != 'none') $('#jslogin').fadeOut();
		if ($('#jsnot_auth').length && $('#jsnot_auth').css('display') != 'none') {
			$('#jsnot_auth').fadeOut();
		}
	});
	
	$('.not_auth').click(function(){
		if (!$('#jsnot_auth').length) $('body').append('<div id="jsnot_auth"><div>');
		var offset = $(this).offset();
		$('#jsnot_auth').alignCenter().fadeIn();
		return false;
	});
	
	$('#socnet a').hover(
			function(){
				$(this).prevAll('a').css({'border-bottom': '5px solid #F2EDF0'});
				$(this).css('border-bottom', '5px solid #F2EDF0');
			},
			function(){
				$(this).prevAll('a').css({borderBottom: 'none'});
				$(this).css('border', 'none');
			}
	);

});
