/* 
	AJAX & window library routines
	bx]l[ab 2007
*/

function xmlObj(){
	if (window.XMLHttpRequest){
		var obj = new XMLHttpRequest();
	} else {
		var obj = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return obj;
}

function getEl(el){
	if (document.getElementById) {
		return document.getElementById(el);
	} else if (document.all) {
		return document.all[id];
	}
}

function setEl(el, content){
	if (document.getElementById) {
		var obj = document.getElementById(el);
		obj.innerHTML = content;
	} else if (document.all) {
		var obj = document.all[id];
		obj.innerHTML = content;
	}
}

function setFormEl(el, content){
	if (document.getElementById) {
		var obj = document.getElementById(el);
		obj.value = content;
	} else if (document.all) {
		var obj = document.all[id];
		obj.value = content;
	}
}

function showWindow(title){
	var obj=getEl("window");
	obj.style.visibility="visible";
	setEl('title','<b>'+title+'</b>');
}

function hideWindow(){
	var obj=getEl("window");
	obj.style.visibility="hidden";
}
/*
	set element  
*/

function ajaxSetEl(url, el){
	var obj = xmlObj();
	obj.onreadystatechange=function(){
		if (obj.readyState==4) {
			if (obj.status==200) {
				setEl(el,obj.responseText);
			} else {
				alert("warning: ajax request returned "+obj.status+"\r\nRequest: "+url);
			}
		}
	}
	obj.open("GET",url,true);
	obj.send(null);
}

function ajaxGetDoc(url, callbackFunc, param){
	var obj = xmlObj();
	obj.onreadystatechange=function(){
		if (obj.readyState==4) {
			if (obj.status==200) {
				callbackFunc(obj.responseText, param);
			} else {
				alert("warning: ajax request returned "+obj.status+"\r\nRequest: "+url);
			}
		}
	}
	obj.open("GET",url,true);
	obj.send(null);
}

function ajaxSetFormEl(url, el){
	var obj = xmlObj();
	obj.onreadystatechange=function(){
		if (obj.readyState==4) {
			if (obj.status==200) {
				setFormEl(el,obj.responseText);
			} else {
				alert("warning: ajax request returned "+obj.status+"\r\nRequest: url");
			}
		}
	}
	obj.open("GET",url,true);
	obj.send(null);
}

function ajaxPostForm(url){
	var obj = xmlObj();
	obj.onreadystatechange=function(){
		if (obj.readyState==4) {
			if (obj.status==200) {
				//alert(obj.responseText+' element: '+ el);
			} else {
				alert("warning: ajax request returned "+obj.status+"\r\nRequest: "+url);
			}
		}
	}
	obj.open("POST",url,true);
	obj.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	obj.send(null);
}

