function Tab(option, type)
{
	this.tabquery = setParam(option,  "tabquery");
	this.event = setParam(option,  "event", "click");
	this.cnoselect = setParam(option, "cnoselect", "");
	this.cselect = setParam(option,   "cselect");
	this.prefix = setParam(option,    "prefix", "a");
	this.contentquery = setParam(option, "contentquery");
	this.showcontentcall = setParam(option, "showcontent", this.showcontent);
	if (type == 'img')
	{
		this.tabchangecall = this.imgchange;
		
	} else {
		this.tabchangecall = this.tabchange;
	}
	$(this.tabquery).bind(this.event, this, this.tabchangecall);
	if (option["select"])
	{
		this.select(option["select"]);
	}

}

Tab.prototype.getCurrent = function(obj, current)
{
    if (typeof obj['id'] == 'string') {
		obj = $("#" + obj['id']);
	} else {
		obj = $(current);
	}
	if (obj == null) return ;
	return obj;
}

Tab.prototype.showcontent = function(tableid)
{
	$(this.contentquery).hide();
	$("#" + tableid).show();
}

Tab.prototype.tabchange = function(event)
{
	var self = event.data;
	$(self.tabquery).attr("class", self.cnoselect);

	current = self.getCurrent(event, this);
	current.attr("class", self.cselect);

	var tableid = current.attr("id") + self.prefix;
    self.showcontentcall(tableid);
}

Tab.prototype.imgchange = function(event)
{
    var self = event.data;
	var tabs = $(self.tabquery);

	for (i = 0; i < tabs.length ; i++)
	{
		var img = tabs.get(i);
		img.src = self.getImgSrc(img.src, self.cnoselect);
	}
    
    current = self.getCurrent(event, this);
	current.attr("src", self.getImgSrc(current.attr("src"), self.cselect));

	var tableid = current.attr("id") + self.prefix;
    self.showcontent(tableid);
}

Tab.prototype.getImgSrc = function(src, flag)
{
	var src = src.split("_");
	return src[0] + "_" + flag + ".jpg";
}

Tab.prototype.select = function(tabid)
{
	if (tabid == '')
	{
		return ;
	}
	var obj = {};
	obj.data = this;
	obj.id   = tabid;
	this.tabchangecall(obj);
}