/****************************
 FloatAdv

****************************/

function FloatAdv() {
	this.DURATION = 4000;
	this.STYLE_BOX = 
		"position:absolute;top:0;left:0;display:none;border:1px solid #333;z-index:50;background-color:#FFF;";
	this.STYLE_BTN = 
		"position:absolute;top:0;left:0;background-color:#000;display:block;color:#FFF;font-family:'Verdana';font-size:9px;font-weight:bold;padding:2px;text-decoration:none;";
	
	FloatAdv.prototype.box = $("<div></div>")
		.attr("style", this.STYLE_BOX);
	
	FloatAdv.prototype.open = function (content) {
		if (content)
			if (!content.is(":visible"))
				content.show();
		this.box.append(content);
		this.box.fadeIn();
		this.update();
		FloatAdv.prototype.timer = window.setTimeout(this.close, this.DURATION);
	}
	
	FloatAdv.prototype.close = function () {
		FloatAdv.prototype.box.fadeOut();
		window.clearTimeout(this.timer);
	}

	FloatAdv.prototype.update = function () {
		if (this.box.is(":visible"))
		{
			this.box.css({
				left:($(window).width() - this.box.width()) + $(window).scrollLeft() - 5,
				top:($(window).height() - this.box.height()) + $(window).scrollTop() - 5
			});
		}
	}
	
	$("<a>CLOSE</a>")
		.attr("style", this.STYLE_BTN)
		.attr("href", "javascript:void(0);")
		.click(this.close)
		.appendTo(this.box);

	$("body").append(this.box);	

	$(window)
		.resize(function (){
			FloatAdv.prototype.update();
		})
		.scroll(function (){
			FloatAdv.prototype.update();
		});
}

$(window).ready(function (){
	$.FloatAdv = new FloatAdv();
});
