﻿var GR = GR || {};
 
GR.Toc = function(id) {
	this.target = $("#"+id);
	this.target.hitch("click",this.show,this);
	this.container = $("<div class='tocp'></div>").appendTo("#content").hide(); 
	this.close = $("<img src='/images/close.png' alt='close' style='float:right'/>");
	this.close.appendTo(this.container).hitch("click",this.hide,this);
	var me = this;
	$.get("toc.html","",function(data){
        	$(data).appendTo(me.container);                                           
	});           
}
GR.Toc.prototype.show = function()
{	
	var pos = this.target.parent().position();
	var wi = this.target.outerWidth();
	var wd = this.container.outerWidth();
	var top = (pos.top - 6) + "px";
	var left = (pos.left + wi - wd + 20) + "px";
	this.target.parent().hide();
	this.container.css({ "top": top, "left": left }).slideDown("fast");
}
GR.Toc.prototype.hide = function()
{
	this.container.slideUp("fast");
	this.target.parent().show();
}
