function getArticle(id){
	var param = "id="+id;
	var d = new Date();
	var time = d.getTime();
	id + "&time="+time;
	res = ajaxUpdate( "contentMain", "test.asp", {
		params:param,
		meth:"post",
		async:true,
		startfunc:"onById('loading')",
		endfunc:"offById('loading'); onById('contentMain')",
		errorfunc:"ajaxError()" }
	);
	return false;
}

function getArticle2(id, elemid, url){
	var param = "id="+id;
	var d = new Date();
	var time = d.getTime();
	id + "&time="+time;
	res = ajaxUpdate( elemid, url, {
		params:param,
		meth:"post",
		async:true,
		startfunc:"onById('loading')",
		endfunc:"offById('loading'); onById('contentMain')",
		errorfunc:"ajaxError()" }
	);
	return false;
}



function onById(id){
	document.getElementById(id).style.display = "block";
}
function offById(id){
	document.getElementById(id).style.display = "none";
}
function ajaxError(){
	alert( "There was an error encountered while performing the request. Please try again later." );
}

/*******************************************************************************
* Author: Justin Barlow - www.netlobo.com
* the ajaxUpdate( ) function tries to make AJAX operations easier by performing
* many common AJAX related operations in one place. The function will request
* the data from the given "url" and inject it into the html element with the
* given "elemid" using the element's innerHTML method. This function is most
* useful when the requested "url" returns html formatted text or plain text. The
* "url" does not have to return XML.
* 
* The "options" parameter is an anonymous object which includes the following
* available options:
* 
* params:    Parameters for the requested url in the format p1=1&p2=0&p3=2
* meth:      The request method. Can be "get" or "post". Default is "post".
* async:     Toggles asynchronous mode. Default is true.
* startfunc: A function or list of functions to be called before the AJAX
*            request is made. A list of functions must be separated by the
*            semi-colon like this: "showLoad(); animateText(); hideDiv('bob')".
*            You can pass parameters into the functions.
* endfunc:   A function or list of functions to be called after a successful
*            AJAX request. Uses the same format as "startfunc".
* errorfunc: A function or list of functions to be called when the AJAX request
*            is unsuccessful. Uses the same format as "startfunc".
* 
* Returns true on success and false on failure.
* 
* Example Usage:
* 
	ajaxUpdate( "rightdiv", "getData.php", {
		params:"id=12&ajax=true",
		meth:"post",
		async:true,
		startfunc:"elemOn('loading')",
		endfunc:"elemOff('loading'); elemOn('rightdiv')",
		errorfunc:"ajaxError()" }
	);
* 
*******************************************************************************/

function ajaxUpdate( elemid, url, options )
{
	var params = options.params || "";
	var meth = options.meth || "post";
	var async = options.mode || true;
	var startfunc = options.startfunc || "";
	var endfunc = options.endfunc || "";
	var errorfunc = options.errorfunc || "";
	var req = false;
	if( window.XMLHttpRequest )
		req = new XMLHttpRequest();
	else if( window.ActiveXObject )
		req = new ActiveXObject( "Microsoft.XMLHTTP" );
	else
	{
		alert( "Your browser cannot perform the requested action. "+
			   "Either your security settings are too high or your "+
			   "browser is outdated. Try the newest version of "+
			   "Internet Explorer or Mozilla Firefox." );
		return false;
	}
	if( startfunc != "" )
		eval( startfunc );
	req.open( meth, url+( params != "" ? "?"+params : "" ), async );
	req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
	req.onreadystatechange =
		function()
		{
			if ( req.readyState == 4 ) 
		    {
		        if ( req.status == 200 )
		        {
/* Purpose: Converts all non-latin based characters to their ASCII entity value
* Usage: [String].encode()
* Arguments: none
* Returns: String
*/
String.prototype.encode = function() {
return this.replace(/([^\x01-\x7E])/g, function(s) { return "&#"+s.charCodeAt(0)+";" });
}

var theString = req.responseText;
var theStringForAjax = theString.encode();

					document.getElementById(elemid).innerHTML = theStringForAjax;
					if( endfunc != "" )
						eval( endfunc );
					return true;
		        }
		        else
		        {
					if( endfunc != "" )
						eval( endfunc );
					if( errorfunc != "" )
						eval( errorfunc );
					return false;
	        	}
		    }
		};
	req.send('var=cat');
}