function getXmlHttp(){
	var xmlhttp;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function changeColors(type) {
 	var xmlHttp = getXmlHttp();
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4)
		{
			document.getElementById('color_area').innerHTML = xmlHttp.responseText;
			showBanner(document.getElementById('color_select').value);
		}
	}
	xmlHttp.open('GET', '/?component=stats&ajax&type='+type, true);
	xmlHttp.send(null);
}

function showBanner(id) {
	document.getElementById("banner_area").innerHTML = "<img src='/?component=stats&banner_preview&id="+id+"'>";
}

function changeSettingsStyle(toggle) {
	document.getElementById("counter_type").disabled = !toggle;
	if (document.getElementById("color_select")) document.getElementById("color_select").disabled = !toggle;
	if (!toggle)
		document.getElementById("banner_area").innerHTML = "";
	else
		changeColors(document.getElementById("counter_type").value);	
}