$(document).ready(function() {

// special event handler

	var special = jQuery.event.special,
		uid1 = 'D' + (+new Date()),
		uid2 = 'D' + (+new Date() + 1);

	special.scrollstop = {
		latency: 150,
		setup: function() {

			var timer,
				handler = function(evt) {

					var _self = this,
						_args = arguments;

					if (timer)
						clearTimeout(timer);

					timer = setTimeout( function(){

						timer = null;
						evt.type = 'scrollstop';
						jQuery.event.handle.apply(_self, _args);

					}, special.scrollstop.latency);

				};

			jQuery(this).bind('scroll', handler).data(uid2, handler);

		},
		teardown: function() {
			jQuery(this).unbind( 'scroll', jQuery(this).data(uid2) );
		}
	};

// floater

	var $floater = $('#floater');

	if ($floater.length > 0) {

		$floater.css('left',(($(window).width()-$floater.width()-30)+'px'));
		$floater.css('top', $(window).height() + $(window).scrollTop() - 180);
		$floater.show('fast');

		$(window).bind('scrollstop', function(e) {

			var $top = $(window).height() + $(window).scrollTop() - 180;
			$floater.animate({top:$top, left:($(window).width()-$floater.width()-30)},{duration:1000, easing:'easeOutExpo'});

		});

		$('#floater-chat').click(function() {

			window.open('chat.asp', '', 'scrollbars=no, menubar=no, resizable=0, location=no, screenX=50, screenY=100, width=450, height=370');

		});

		$('#floater-close').click(function(e) {

			e.preventDefault();
			$('#floater').hide('fast');

		});

	}

});
