var objHttp = new Array();
var buffer = new String();
var after_func = new Array();

function ajax_init(aid) {
	objHttp[aid] = ajax_object();
	return objHttp[aid];
} // end function ajax_init


function ajax_object() {
	var obj = null;
	if (window.XMLHttpRequest) {
		obj = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
			obj = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				obj = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				obj = null;
			}
		}
	}
	return obj;
} // end function ajax_object


function ajax_send(aid, url, func) {
	if (buffer == '')
		buffer = null;
	after_func[aid] = func;
	objHttp[aid].open("POST", url, true);
	objHttp[aid].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	objHttp[aid].onreadystatechange = function(){ var ajaxid = arguments[0]; return function() { ajax_recv(ajaxid) }; }(aid);
	objHttp[aid].send(buffer);
} // end function ajax_send


function ajax_recv(aid) {
	if (objHttp[aid].readyState == 4 && objHttp[aid].status == 200) {
		var f = after_func[aid];
		f();
	}
} // end function ajax_recv


function ajax_push(name, value) {
	if (buffer != '')
		buffer += '&';
	buffer += name + '=' + encodeURI(value);
} // end function ajax_push


function ajax_clear() {
	buffer = '';
} // end function ajax_clear


function ajax_check(aid) {
	if (objHttp[aid].readyState == 4 && objHttp[aid].status == 200) {
		return true;
	} else {
		return false;
	}
} // end function ajax_check


// initialize
//objHttp = ajax_init();


function ent_quotes(str) {
	str = str.replace(/\\/g, "\\\\");
	str = str.replace(/\'/g, "\\'");
	str = str.replace(/\"/g, "&quot;");
	return str;
}


function xml_get_child(pobj, tname, idx) {
	if (idx == null) {
		idx = 0;
	}
	if (pobj.getElementsByTagName(tname).item(idx).firstChild == null) {
		return "";
	}
	return pobj.getElementsByTagName(tname).item(idx).firstChild.data;
}


function xml_get_attr(pobj, tname, aname, idx) {
	if (idx == null) {
		idx = 0;
	}
	if (pobj.getElementsByTagName(tname).item(idx).getAttributeNode(aname) == null) {
		return "";
	}
	return pobj.getElementsByTagName(tname).item(idx).getAttributeNode(aname).value;
}


var side_div_id = new String();
function sendSideContent(divid, enc)
{
	ajax_init("sendSideContent");

	side_div_id = divid;
	//ajax_send("sendSideContent", "/ajax/test.php?enc=" + enc, resvSideContent);
	ajax_push('enc', enc);
	ajax_send("sendSideContent", "/jajax?task=sidecontent", resvSideContent);
	ajax_clear();

	return false;
}


function resvSideContent()
{
	document.getElementById(side_div_id).innerHTML = objHttp["sendSideContent"].responseText;
}


function sendTopContent()
{
	ajax_init("sendTopContent");

	ajax_send("sendTopContent", "/jajax?task=topcontent", resvTopContent);
	ajax_clear();

	return false;
}


function resvTopContent()
{
	document.getElementById("ossmInner").innerHTML = objHttp["sendTopContent"].responseText;
}



function sendSeasonContent()
{
	ajax_init("sendSeasonContent");

	ajax_send("sendSeasonContent", "/jajax?task=seasoncontent", resvSeasonContent);
	ajax_clear();

	return false;
}


function resvSeasonContent()
{
	document.getElementById("ossmInner").innerHTML = objHttp["sendSeasonContent"].responseText;
}
