/*******************************************************************************
* Author: Justin Barlow - www.netlobo.com
*
*******************************************************************************/
function ajaxUpdateComments( elemid, url, options )
{
  var params = options.params || "";
  var meth = options.meth || "post";
  var async = options.async || 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 )
			{
		  document.getElementById(elemid).innerHTML = req.responseText;
		  if( endfunc != "" )
			eval( endfunc );
		  return true;
			}
			else
			{
		  if( endfunc != "" )
			eval( endfunc );
		  if( errorfunc != "" )
			eval( errorfunc );
		  return false;
			}
		}
	};
	req.send(null);
}

function commentspagination(news_id, skip, path, template){
	
	ajaxUpdateComments( "ajaxcomments", path+"/plugins/ajaxcommentspagination/ajaxcommentspagination.php", {params:"news_id=" + news_id + "&skip=" + skip + "&template=" + template, startfunc:"load_ajaxcommentspagination('"+path+"')"});
	

}


function load_ajaxcommentspagination(path){
	var commentdiv = document.getElementById('ajaxcomments');
	commentdiv.style.height = commentdiv.offsetHeight;
	commentdiv.innerHTML = '<img style=\"left:50px\" src=\"' + path  +'/plugins/ajaxcommentspagination/ajax-loader.gif\" border=\"0\" />';
}