/**---------------------------------
 * floatlink.js
 *
 * @use jQuery 1.2.6 later?
 ---------------------------------*/
(function($){
	$(function($){
		$("a.floatLink").click(floatLinkOpen);
		
		//floatLink Open
		function floatLinkOpen(){
			var afl = $(this);
			$("select").css("visibility","hidden");
			$("html").css({overflow:"hidden"});
//			$("html").css({overflow:"hidden",width:"100%",height:"100%"});
//			$("body").css({position:"relative",width:"100%",height:"100%"});
//			$("#container").css({width:"100%",height:"100%"});
			$("body").append($("<div id='floatLinkOverlay'></div>").css("opacity", 0));
			$("body").append($("<div id='floatLinkContainer'></div>").css("opacity", 0));
			var flo = $("#floatLinkOverlay").css("height",$(document).height() + "px");
			var flc = $("#floatLinkContainer").bind("resize", function(){
				$(this).css("top",($(document).scrollTop() + ($(window).height() / 2) - ($(this).height() / 2)) + "px");
			});
			flo.fadeTo(1000, 0.5, function(){
				flc.load(
					afl.attr("href") + " div[id^=lightbox]",
					function(){
						flo.add("#floatLinkContainer .floatLinkClose").bind("click", floatLinkClose).css("cursor", "pointer");
						flc.css({
							"top":($(document).scrollTop() + ($(window).height() / 2) - flc.height() / 2) + "px",
							"margin-left":"-"+(flc.width() / 2)+"px"
						}).fadeTo(1000, 1);
					}
				);
			});
			return false;
		}
		
		//floatLink Close
		function floatLinkClose(){
			$("#floatLinkOverlay, #floatLinkContainer").fadeTo(1000, 0, function(){
				$("#floatLinkOverlay, #floatLinkContainer .floatLinkClose").unbind();
				$("#floatLinkOverlay, #floatLinkContainer").remove();
				$("html, select").removeAttr("style");
			});
		}
	});
})(jQuery);
