function TabGroup() {
	var tabs = new Array();
	
	this.addTab = function(tab, defaultTab){
		tabs.push(tab);
		tab.setGroup(this);
		if(defaultTab) tab.show();
	};
	
	this.hideAll = function() {
		var numTabs = tabs.length;
		for(var tc = 0; tc < numTabs; tc++) {
			tabs[tc].hide();
		}
	}
}

function TabContent() {	
	this.group;
	this.link;
	this.container;
	this.classname;
	
	this.init = function(linkId, tabId) {
		this.link = document.getElementById(linkId);
		this.linkcss = this.link.className.split("_")[0];		
		this.container = document.getElementById(tabId);
		this.containercss = this.container.className.split("_")[0];
		
		this.link._obj = this;
		this.link.onclick = function() {
			this._obj.group.hideAll();
			this._obj.show();
			return false;
		}
	};
	
	this.setGroup = function(tabgroup){
		this.group = tabgroup;
	}
	
	this.show = function() {};
	
	this.hide = function() {};
}

/**
 * TabDefault
 */
function TabDefault(linkId, tabId) {
	this.init(linkId, tabId);
}

TabDefault.prototype = new TabContent();

TabDefault.prototype.show = function() {
	this.link.className = this.linkcss + "_active";
	this.container.className = this.containercss + "_active";
};

TabDefault.prototype.hide = function() {
	this.link.className = this.linkcss;
	this.container.className = this.containercss;
};



function TabClick(linkId, tabId) {
	this.init(linkId, tabId);
	this.link.onclick = function() {};
}

TabClick.prototype = new TabContent();

TabClick.prototype.show = function() {
	this.link.className = this.linkcss + "_active";
	this.container.className = this.containercss + "_active";
};

TabClick.prototype.hide = function() {
	this.link.className = this.linkcss;
	this.container.className = this.containercss;
};


function TabRemote(linkId, tabId, cntUrl) {
	this.loaded = false;
	this.url = cntUrl;
	
	this.init(linkId, tabId);
	
	this.addContent = function(_obj, status, responseText) {
		if(status == 200) {		
			_obj.loaded = true;
			_obj.container.innerHTML = responseText;
			_obj.container.className = _obj.containercss + "_active";
		} else {
			_obj.loaded = false;
			_obj.container.className = _obj.containercss + "_error";			
		}
	}
}

TabRemote.prototype = new TabContent();

TabRemote.prototype.show = function() {
	this.link.className = this.linkcss + "_active";
	if(this.loaded) {
		this.container.className = this.containercss + "_active";
	} else {
		this.loaded = true;
		this.container.className = this.containercss + "_loading";
		AJAXRemote.addJob(this, this.url, this.addContent);
	}
};

TabRemote.prototype.hide = function() {
	this.link.className = this.linkcss;
	this.container.className = this.containercss;
};


/*


		tabgroup[groupId]['tabs'][tabId]['http'] = getHTTPObject();
		tabgroup[groupId]['tabs'][tabId]['http'].open("GET", tabgroup[groupId]['tabs'][tabId]['url'], true);
		tabgroup[groupId]['tabs'][tabId]['http'].onreadystatechange = tabInitRemote();
		tabgroup[groupId]['tabs'][tabId]['http'].send(null);


	if (http.readyState == 4) {
		if(http.status == 200) {
			alert(http.responseText);
	 	} else {
	 		alert("jodel");		
	 	}
	}
}*/

/*
var http = getHTTPObject(); // We create the HTTP Object

function dosomething() {
	http.open("GET", "?ans=sml", true);
    http.onreadystatechange = handleHttpResponse;
    http.send(null);
}

function handleHttpResponse() {
	teast = "lol";
	alert(teast + " ¦ " + http.readyState);
	if (http.readyState == 4) {
		if(http.status == 200) {
			alert(http.responseText);
	 	} else {
	 		alert("jodel");		
	 	}
	}
}*/
