function getHTTPObject() {
	var http = false;
	//Use IE's ActiveX items to load the file.
	if(typeof ActiveXObject != 'undefined') {
		try {http = new ActiveXObject("Msxml2.XMLHTTP");}
		catch (e) {
			try {http = new ActiveXObject("Microsoft.XMLHTTP");}
			catch (E) {http = false;}
		}
	//If ActiveX is not available, use the XMLHttpRequest of Firefox/Mozilla etc. to load the document.
	} else if (XMLHttpRequest) {
		try {http = new XMLHttpRequest();}
		catch (e) {http = false;}
	}
	return http;
}

function changeTab(name, id){
	var http = getHTTPObject();
//	var params = 'column='+id+'&name='+name;
	var params = '';
//	http.open("POST", "includes/ajax.html", true);
	http.open("GET", "/includes/widgets/" + name + ".html", true);
	
	var tabs = document.getElementById('tabs'+id);
	var tagArray = tabs.getElementsByTagName("a");
	
	for(var x=0; x<tagArray.length; x++){
		if(name != tagArray[x].id){
			//tagArray[x].style.backgroundColor = '#eaf3ef';
			tagArray[x].className = "normalTab";
		}else{
			//tagArray[x].style.backgroundColor = '#fff';
			tagArray[x].className = tagArray[x].className + " selected";
		}
	}
	
	//Send the proper header infomation along with the request
//	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-type", "text/html");
//	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Content-length", params.length );
	http.setRequestHeader("Connection", "close");
	
	http.onreadystatechange = function(){
		switch(http.readyState){
			case 4:
				if(http.status == 200){
					document.getElementById('contentArea'+id).innerHTML = http.responseText;
				}else{
					document.getElementById('contentArea'+id).innerHTML = 'An error occurred.';
				}
			break;
			case 3:
				document.getElementById('contentArea'+id).innerHTML = 'Loading...';
			break;
		}
	}
	http.send(params);
}

