/* jFly 0.2
 * $Date: 2008-09-09 $
 * $Rev:  ·$
 * $Author: ashuai $
 */
(function($) {
	$.fn.fly = function(options) { //by ashuai@gmail.com
		var self = this;
		self.css({position:'fixed', top:0, left:0, display: 'block', zindex:8000});
		var w = $(window).width() - self.width();
		var h = $(window).height() - self.height();
		if( $.browser.msie ){ // Only IE
			self.css('position','absolute');
			h=document.documentElement.clientHeight;
		}
		var xo,yo=xo='++';
		var x,y;
		var t=1; // Only IE
		x=Math.round(Math.random()*w);
		y=Math.round(Math.random()*h)
		var f = function() {
			w = $(window).width() - self.width();
			h = $(window).height() - self.height();
			if( $.browser.msie ){
				w = document.documentElement.clientWidth-self.width();
				h=document.documentElement.clientHeight-self.height();
				t=document.documentElement.scrollTop;
			}
			eval('x'+xo);
			eval('y'+yo);
			if(x>=w) xo='--';
			if(x<=1) xo='++';
			if(y>=h) yo='--';
			if(y<=1) yo='++';
			self.css('left', x + 'px');
			self.css('top', y+t + 'px');
			setTimeout(f, 20);
		}
		f();
		return this;
	}
})(jQuery);