// Mailmask
$.fn.noSpam = function() {
	at = '@';
	return this.each(function(){
		e = null;
		$(this).find('span').replaceWith(at);
		e = $(this).text();
		$(this).attr('href', 'mailto:' + e);
	});
};


$.fn.topLink = function(settings) {
	settings = jQuery.extend({fadeSpeed: 200}, settings);
		var scroll_timer;
		var displayed = false;
		var $message = $(this);
		var $window = $(window);
		var top = $(document.body).children(0).position().top;
		$window.scroll(function () {
			window.clearTimeout(scroll_timer);
			scroll_timer = window.setTimeout(function () {
				if($window.scrollTop() <= top)
				{
					displayed = false;
					$message.fadeOut(settings.fadeSpeed);
				}
					else if(displayed == false) 
				{
					displayed = true;
					$message.stop(true, true).fadeIn(settings.fadeSpeed).click(function () { $message.fadeOut(settings.fadeSpeed); });
				}
			}, 100);
		});
};


// CUFON
$(function(){
			  $('a.escape').noSpam();
    $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                return false;
            }
        }
    });
	$('.gototop').topLink({fadeSpeed: 500});
	$("a[rel='lightbox']").colorbox({maxHeight:"90%"});
});
