	$(document).ready(function(){
		$('a.thickbox,td.thickbox').click(function(){
			var t = this.title || this.name || null;
			var a = this.href || this.getAttribute("alt");
			var g = this.rel || false;
			lightbox(a,null,700,440,false);
			this.blur();
			return false;
		});
		$('body').append("<div id='lboverlay'></div>");
		$('#lboverlay').css({ display: "none", position:"absolute", top: "0", left: "0", width: "100%", height: "100%", backgroundColor: "#000000", opacity: "0.8" });
	});
	
	function tb_show(t,a,g,obj)
	{
		lightbox(a,null,700,440,false)
	}
	
	function lightbox(url,html,w,h,modal)
	{
		// fix sizing inside iframes
		if (top.location != document.location)
			$('#lboverlay').css({width: $(document).width(), height: $(document).height()});
		else
			$('#lboverlay').css({ width: "100%", height: "100%" });
		
		var strw = "<div id='lbwindow'><table style='width:100%; height: 100%;' border=0 cellspacing=0 cellpadding=0>";
		if (!modal)
			strw += "<tr id='lbtitle'><td style='height:29; padding-right: 10px; background-image:url(images/vistabar.gif)' align='right'><img src='images/close.gif' style='cursor:pointer;cursor:hand;' onclick='lightboxhide()'></td></tr>";
		strw += "<tr><td id='lbcontent'>&nbsp;</td></tr></table></div>";
		
		$('body').append(strw);
		if (modal)
			$('#lbtitle').css("display","none");
			
		$('#lbwindow').css({ display: "none", position:"absolute", zIndex: "101", backgroundColor: "#333333" });

		
		// use iframe shim for IE6
		if ($.browser.msie && $.browser.version < 7)
		{
			if (html)
				$('body').append("<div id='lbshim' style='padding:4px'><iframe border='0' frameborder='0' style='display:none; position:absolute; width: "+w+"; height: "+h+"; z-index:100;'></div>");
			else
				$('body').append("<iframe id='lbshim' border='0' frameborder='0' style='display:none; position:absolute; width: "+(w)+"; height: "+(h)+"; z-index:100;'>");
		}
		
		// if its a url, use an iframe.. if the user gave us html, put it in a div
		if (url)
			$('#lbcontent').html("<iframe id='lbiframe' src='"+url+"' border='0' onload='lightboxshow("+w+","+h+")' frameborder='0' marginwidth='1' marginheight='1' style='width:100%;height:100%;border:0'>");
		else if (html)
		{
			$('#lbcontent').html("<div class='lbhtml' style='width: 100%;height: 100%;'>"+html+"</div>");
			$('#lbwindow').css({width:w, height: h});
			lightboxshow(w,h);
		}
		
		if (!modal)
			$('#lboverlay').click(lightboxhide);


		
	}

	function lightboxshow(w,h)
	{
		if ($.browser.msie && $.browser.version < 7)
		{
			$('select').css("visibility","hidden");
			document.body.scroll = "no";
		}
		
		
		
		$('#lboverlay').fadeIn('fast',function() 
		{ 
			
			$('#lbwindow,#lbshim').css({ width:w, height: h, left: "50%", marginLeft: (w/2)*-1, marginTop: (h/2)*-1 });
			
			
			if ($('#lbwindow').css("display") == "none")
			{
				$('#lbwindow,#lbshim').css({ top: "48%" });
				$('#lbwindow,#lbshim').animate({ top: "50%" }).show();
			}
			else
				$('#lbwindow,#lbshim').css({ top: "50%" });
		});
		
		cbfunction = null
	}
	
	function lightboxhide()
	{
		if ($.browser.msie && $.browser.version < 7)
		{
			$('select').css("visibility","");
			document.body.scroll = "";
		}
		
		$('#lbwindow,#lboverlay,#lbshim').css({display: "none"});
		$('#lboverlay').unbind('click');
		$('#lbwindow').unbind().remove();
		$('#lbshim').remove();
	}
