jQuery.fn.mailto = function() {
	return this.each(function(){
		var email = $(this).html().replace(/\s*\(.+\)\s*/, "@");
		$(this).before('<span class="txt3"><a href="mailto:' + email + '" rel="nofollow" title="Email ' + email + '">' + email + '</a></span>').remove();
	});
};

jQuery.fn.mailto2 = function() {
	return this.each(function(){
		var email = $(this).html().replace(/\s*\(.+\)\s*/, "@");
		$(this).before('<span class="txt2"><a href="mailto:' + email + '" rel="nofollow" title="Email ' + email + '">' + email + '</a></span>').remove();
	});
};



$(document).ready(function() {
		$(".signin").click(function(e) {          
				e.preventDefault();
                $("fieldset#signin_menu").toggle();
				$(".signin").toggleClass("menu-open");
            });
			
			$("fieldset#signin_menu").mouseup(function() {
				return false
			});
			$(document).mouseup(function(e) {
				if($(e.target).parent("a.signin").length==0) {
					$(".signin").removeClass("menu-open");
					$("fieldset#signin_menu").hide();
				}
			});
			
			
			$('.email').mailto();
			$('.email2').mailto2();
			
			
			function resizeWindowFoin( e ) {
				var newWindowHeight = $(window).height();									
				if(newWindowHeight < 775){newWindowHeight=775;}
				
				if(newWindowHeight > 1000){newWindowHeight=1045;}
				
			
				$('#foin').css('top',newWindowHeight-430+'px');
				
			}

			resizeWindowFoin();			
			$(window).bind('resize', resizeWindowFoin);
});
