var sort='usera';

function ajaxObject(layer, url) {                                    // This is the object constructor
   var that=this;                                                    // A workaround for some javascript idiosyncrocies
   var updating = false;                                             // Set to true if this object is already working on a request
   this.callback = function() {}                                     // A post-processing call -- a stub you overwrite.

   this.update = function(passData) {                                // Initiates the server call.
      if (updating==true) { return false; }                          // Abort if we're already processing a call.
      updating=true;                                                 // Set the updating flag.
      var AJAX = null;                                               // Initialize the AJAX variable.
      if (window.XMLHttpRequest) {                                   // Are we working with mozilla?
         AJAX=new XMLHttpRequest();                                  //  Yes -- this is mozilla.
      } else {                                                       // Not Mozilla, must be IE
         AJAX=new ActiveXObject("Microsoft.XMLHTTP");                //  Wheee, ActiveX, how do we format c: again?
      }                                                              // End setup Ajax.
      if (AJAX==null) {                                              // If we couldn't initialize Ajax...
         alert("Your browser doesn't support AJAX.");                // Sorry msg.						
         return false;                                               // Return false (WARNING - SAME AS ALREADY PROCESSING!)
      } else {
         AJAX.onreadystatechange = function() {                      // When the browser has the request info..
            if (AJAX.readyState==4 || AJAX.readyState=="complete") { //   see if the complete flag is set.
               LayerID.innerHTML=AJAX.responseText;                  //   It is, so put the new data in the object's layer
															
															// Dale's quick hack
															if (layer == 'rwarning') {
		               if (AJAX.responseText == "")
 	                	document.getElementById(layer).style.display = "none";
 	               else
             		    document.getElementById(layer).style.display = "block";
		             }
															// end of Dale's quick hack
															
															delete AJAX;                                          //   delete the AJAX object since it's done.
               updating=false;                                       //   Set the updating flag to false so we can do a new request
               that.callback();                                      //   Call the post-processing function.
            }                                                        // End Ajax readystate check.
         }                                                           // End create post-process function block.
         var timestamp = new Date();								                       	// Get a new date (this will make the url unique)
									var uri = urlCall+'?';
									if (passData != '')
								  	uri = uri + passData + '&amp;timestamp='+(timestamp*1);
									else
								  	uri = uri + 'timestamp='+(timestamp*1);                   // Append date to url (so the browser doesn't cache the call)
         AJAX.open("GET", uri, true);                                // Open the url this object was set-up with.
         AJAX.send(null);                                            // Send the request.
         return true;                                                // Everything went a-ok.
      }                                                              // End Ajax setup aok if/else block                 
   }
      
   // This area set up on constructor calls.
   var LayerID = document.getElementById(layer);                     // Remember the layer associated with this object.
   var urlCall = url;                                                // Remember the url associated with this object.
}                                                                    // End AjaxObject


function membertable(site,nsort) {
   if (nsort != null) {
      this.sort=nsort;
   } else {
      nsort=this.sort;
   }
   document.getElementById('membertable').innerHTML = "<center><img src=\"./images/ajax-refresh.gif\" alt=\"Refreshing Ajax\"/>&nbsp;Reloading list...</center>";
   memberTable.update("where="+site+"&s="+nsort);
}

function fault_sublist(site) {
   document.getElementById('sublistdiv').innerHTML = "<center><img src=\"./images/ajax-refresh.gif\" alt=\"Refreshing Ajax\"/>&nbsp;Loading...</center>";
   sublistbox.update("where="+site);
}

function fault_subsublist(type) {
   document.getElementById('subsublistdiv').innerHTML = "<center><img src=\"./images/ajax-refresh.gif\" alt=\"Refreshing Ajax\"/>&nbsp;Loading...</center>";
   subsublistbox.update("type="+type);
}

function fault_subsublist2(type) {
   document.getElementById('subsublistdiv').innerHTML = "<center><img src=\"./images/ajax-refresh.gif\" alt=\"Refreshing Ajax\"/>&nbsp;Loading...</center>";
   subsublistbox.update("maintype="+type);
}

function filelisttable(site) {
   filelistTable.update("thesite="+site);

}
function ulookupwarn(fname,sname) {
  if (fname == 'undefined' || sname =='undefined') return;
  strTemp = fname.substring(0, 1).toUpperCase();;
  strTemp2 = fname.substring(1, fname.length);
  fname = strTemp+strTemp2;
  strTemp = sname.substring(0, 1).toUpperCase();;
  strTemp2 = sname.substring(1, sname.length);
  sname = strTemp+strTemp2;
		warnBox.update("fname="+fname+"&sname="+sname);
}

function nameusedwarn(uname) {
  warnBox.update("who="+uname);
}
function newscycle(currentnews) {
   setTimeout('delayedupdate()', 500);
			var id=document.getElementById('newscycle');
   fadeOut(id, .5);
}

function delayedupdate () {
   newsbox.update("current="+currentnews);

}

function processData() {
   if (currentnews == '') {
			    currentnews = newsone;
   } else if (currentnews == newsone) {
							currentnews = newstwo;
			} else if (currentnews == newstwo) {
							currentnews = newsthree;
			} else if (currentnews == newsthree)
			    currentnews = newsfour;
			else
			    currentnews = newsone;
			var id=document.getElementById('newscycle');
   fadeIn(id, .5);
			window.setTimeout("newscycle(currentnews)", 5000);
}
function projecttable() {
   projectTable.update('');
   window.setTimeout("projecttable()", 20000);
}

function forumstable() {
   forumsTable.update('');
   window.setTimeout("forumstable()", 10000);
}

function whoshere() {
   whoTable.update('');
			window.setTimeout("whoshere()", 10000);
}
function chattable() {
   chatTable.update('');
			window.setTimeout("chattable()", 1000);
}
function userstable() {
   usersTable.update('');
			window.setTimeout("userstable()", 1000);
}

function friendson() {
   friendsonline.update('');
   window.setTimeout("friendson()", 5000);
}

function updateY(part, partid) {
   document.getElementById('yholder').src=PREFIX+'../images/ajax-refresh.gif';
			var images = document.getElementById(part+'form').getElementsByTagName("img");
			var simg = document.getElementById(part+'%'+partid).className;
   if (partid < images.length && simg == "yparton")
			   partid=1000;
			for (var i = 0; i < images.length; i++) {
			  images[i].className = "ypartoff";
	  }
			document.getElementById(part+'%'+partid).className="yparton";
  	ygen.update(part+"="+partid);
}

function loadmemberprofile(who,month,year) {
   ajaxob.update("who="+who+"&month="+month+"&year="+year);
			window.scrollTo(0,0);
}

var DHTML = (document.getElementById || document.all || document.layers);

function getObj(name){
if (document.getElementById){
  if (document.getElementById(name)) {
    this.obj = document.getElementById(name);
    this.style = document.getElementById(name).style;
  } else {
    this.obj = null;
    this.style = null;
  }
} else if (document.all){
  if (document.all[name]) {
    this.obj = document.all[name];
    this.style = document.all[name].style;
  } else {
    this.obj = null;
    this.style = null;
  }
} else if (document.layers){
  if (document.layers[name]) {
    this.obj = document.layers[name];
    this.style = document.layers[name];
  } else {
    this.obj = null;
    this.style=null
  }
}
}

function toggle(div){           
 if (!DHTML) return;
 var x = new getObj(div+'form');
 var y = new getObj(div+'old');
 if (x.style.display == 'none') {
   x.style.display='block';
   if (y.obj != null)
      y.style.display='none';
 } else {
   x.style.display='none';
   if (y.obj != null)
      y.style.display='block';
 }
}

