function AJAX_GetxmlHttpObject() { 
	var objxmlHttp=null;
	if (window.XMLHttpRequest) {
		objxmlHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		objxmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objxmlHttp
}

function AJAX_LoadElement(fragment_url, element_id, page) {
	var element = document.getElementById(element_id);
	var xmlHttp;
	element.innerHTML = '<div align="center">Loading...<img src="images/loading.gif" border="0"></div>';
	
	xmlHttp = AJAX_GetxmlHttpObject();
	
	if (xmlHttp == null) {
		alert ("Browser does not support HTTP Request")
		return
	}

	if (fragment_url.indexOf("?")!=-1) {
		fragment_url+="&cache="+Math.random();
	} else {
		fragment_url+="?cache="+Math.random();
	}
	xmlHttp.open("GET", fragment_url,true);

	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			element.innerHTML = xmlHttp.responseText;
		}

	}
	xmlHttp.send(null);
}

function ajax_loadData(page, element_id) {
    AJAX_LoadElement(page,element_id);
}

function AJAX_LoadStyle(fragment_url, element_id, page) {
	var element = document.getElementById(element_id);
	var xmlHttp;
	xmlHttp = AJAX_GetxmlHttpObject();
	
	if (xmlHttp == null) {
		alert ("Browser does not support HTTP Request")
		return
	}

	if (fragment_url.indexOf("?")!=-1) {
		fragment_url+="&cache="+Math.random();
	} else {
		fragment_url+="?cache="+Math.random();
	}
	xmlHttp.open("GET", fragment_url,true);

	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			stylist=xmlHttp.responseText;
			stylist=stylist.split(";");
			for (i=0;i<stylist.length;i++) {
				if (stylist[i]!="") {
					tmp=stylist[i].split(":");
					eval('document.getElementById("'+element_id+'").style.'+tmp[0]+'="'+tmp[1]+'"');
					if (tmp[0]=="color") {
						if (document.getElementById('divTitle')) {
						eval('document.getElementById("divTitle").style.'+tmp[0]+'="'+tmp[1]+'"');
						}
						if (document.getElementById('divContent')) {
							eval('document.getElementById("divContent").style.'+tmp[0]+'="'+tmp[1]+'"');
						}
					}
				}
			}
		}

	}
	xmlHttp.send(null);
}

function ajax_loadStyle(page, element_id) {
    AJAX_LoadStyle(page,element_id);
}
