function GetControl(controlName){
	var i;
	var theControl;
	for(i=0;i<myArray.length;i++){
		if(myArray[i].name==controlName) {
			theControl = myArray[i];
			break;
		}
	}
	if(theControl){
		return theControl;
	}
}

var ajaxArray=new Array();

function LoadAjaxPage(url,elementid,scrollid){
	document.getElementById(elementid).innerHTML = "<p align=center><br><br>Loading...</p>";
	setTimeout("DoLoadPage('" + url + "','" + elementid + "','" + scrollid + "')",1);
}

function DoLoadPage(url,elementid,scrollid){
	ajaxinclude(url,elementid,scrollid);
}

var rootdomain="http://"+window.location.hostname

function ajaxObject(url,elementid,scrollid) {
  var that=this;
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  }
  this.update = function(passData,postMethod) { 
    if (that.updating) { return false; }
    that.AJAX = null;               
    if (window.XMLHttpRequest) {
      that.AJAX=new XMLHttpRequest();
    } else {
      that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (that.AJAX==null) {                             
      return false;                               
    } else {
      that.AJAX.onreadystatechange = function() {  
        if (that.AJAX.readyState==4) {             
          that.updating=false;                
          that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
          that.AJAX=null;                                         
        }                                                      
      }                                                        
      that.updating = new Date();                              
      if (/post/i.test(postMethod)) {
        var uri=urlCall+'?'+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        that.AJAX.setRequestHeader("Content-Length", passData.length);
        that.AJAX.send(passData);
      } else {
        //var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
		var uri=urlCall;
        that.AJAX.open("GET", uri, true);                     
        that.AJAX.send(null);                        
      }              
      return true;                                             
    }                                                                           
  }
  var urlCall = url;        
  this.callback = function (responseText, responseStatus, responseXML) {
	document.getElementById(elementid).innerHTML=responseText;
	if(scrollid){
		CSBfleXcroll(scrollid); 
	}
  }
}

function ajaxinclude(url,elementid,scrollid) {

	var i;
	i = ajaxArray.length;
	ajaxArray[i]=new ajaxObject(url,elementid,scrollid);
	ajaxArray[i].update();
	
}


function writecontent(page_request){
	if (window.location.href.indexOf("http")==-1 || page_request.status==200)
	document.write(page_request.responseText)
}

