/**
标签页的页面结构说明：longsys 陈磊
* 将id(例如: 'm_sample') 添加到div.md 中
* 在div.md_hd 中添加ul.mh_tabs，并添加id (例如: 'm_sample_tabs')
							ul中的li下的中的文字要加链接，链接完全相同<a href="" onclick="return changeTag(this.parentNode)"></a>
* 在div.md_bd 添加id m_sample_contents 
						  中添加和标签一样多的div，并给它们添加id，id 命名是 'm_sample_content' ) 除了第一个，其他几个都添加style="display: none;" 属性
*/
var tagFrame=function(){
	this.curTab = null;
	this.ccc = 111;
	return this;
};

tagFrame.prototype.initTabs=function(liobj){
	var frameobj = liobj;
	while (frameobj.tagName != "DIV" || frameobj.id != "m_sample") {
		if (frameobj.parentNode != null) {
			frameobj = frameobj.parentNode;
		} else {
			return;
		}
	}
//	alert(1);
	
	var contents = new Array();
	var l = 0;
	var m_sample_contents = frameobj.getElementsByTagName("DIV");
	for (var j = 0; j < m_sample_contents.length; j++) {
		if (m_sample_contents[j].id == "m_sample_contents") {
			var m_sample_content = m_sample_contents[j].getElementsByTagName("DIV");
			for (var k = 0; k < m_sample_content.length; k++) {
				if (m_sample_content[k].id == "m_sample_content") {
					contents[l] = (m_sample_content[k]);
					l++;
				}
			}
			break;
		}
	}
	var eTabs = liobj.parentNode.getElementsByTagName('li');
	for (var i = 0; i < eTabs.length; i++) {
		if (i == 0) {
			this.curTab = eTabs[i];
		}
		eTabs[i].limodule = this;
		//alert(contents);
		eTabs[i].content = contents[i];
	}
//	alert(3)
};

tagFrame.prototype.show1=function(liobj1) {
	if (this.curTab != null) {
		//alert(1);
		this.curTab.className = "";
		this.curTab.content.style.display = 'none';
	}
	//alert(2);
	liobj1.className = "cur";
	liobj1.content.style.display  = 'block';
	this.curTab = liobj1;
};

function changeTag(liobj) {
	if (liobj.limodule == null) {
		new tagFrame().initTabs(liobj);
	}
	liobj.limodule.show1(liobj);
	return false;
}
