//very thanks Mr.knowmore!
//For you help and for you test
//2008-01-28 lhb

var myHttp=function(){
	var  xmlHttp;
	var  tabID;
}
myHttp.prototype.init=function(tbID,classID,n){
 		this.createXMLHttpRequest();
	this.tabID=tbID;
	var url = "tab.php?tabID=" + this.tabID +"&classID=" + classID;
	this.xmlHttp.open("GET", url, true);
	this.xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	this.xmlHttp.setRequestHeader("charset","gb2312");
	this.xmlHttp.onreadystatechange =this.callback( this );
	this.xmlHttp.send(null);
	
	var ttd=document.getElementById("tab_" + this.tabID).getElementsByTagName("td");
	for(i=0;i<ttd.length;i++){
		ttd[i].className=i==n?"tab_on":"";
	}
}
myHttp.prototype.createXMLHttpRequest=function() {
	if (window.XMLHttpRequest) { // Non-IE...
		this.xmlHttp = new XMLHttpRequest();
		if (this.xmlHttp.overrideMimeType) {
			this.xmlHttp.overrideMimeType('text/plain');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				this.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
}
 
myHttp.prototype.callback=function ( obj ){
	return function(){
		var mes='<table width="200"  height="150" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle"><img src="images/loading.gif" align="absmiddle" width="145" height="15" /></td></tr></table>';
		if ( obj.xmlHttp.readyState == 4 ){
			if ( obj.xmlHttp.status == 200 ) mes = obj.xmlHttp.responseText;
		}
		var tabContent = document.getElementById( "tabContent_" + obj.tabID );
		tabContent.innerHTML = mes;
	};
} 
function setTab(tbID,classID,n){
	var obj=new myHttp();
	obj.init(tbID,classID,n)
}
