/*
AJAX dynamic content loader for Login
Author: Tabor Ellison
Date: 3/29/2007
*/


/*Ajax page load process*/
/*The dynamic content loading function courtesy of DynamicDrive.com*//*Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)This notice MUST stay intact for legal use Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code*/
var bustCache=1; //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedObj="";
var rootDmn="http://"+window.location.hostname;
var bustCacheParam="";

function ajaxPage(url, containerid){
  var pgReq = false;
  
  if (window.XMLHttpRequest){ 
    pgReq = new XMLHttpRequest();
  }else if (window.ActiveXObject){ 
    try {
      pgReq = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e){
      try{
        pgReq = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e){}
    }
  }else{
    return false;
  }
  
  pgReq.onreadystatechange=function(){
    loadPage(pgReq, containerid);
  }
  
  if (bustCache){
    bustCacheParam=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime();
  }
    
  pgReq.open('GET', url+bustCacheParam, true);
  pgReq.send(null);
}


function loadPage(pgReq, containerid){
  if (pgReq.readyState == 4 && (pgReq.status==200 || window.location.href.indexOf("http")==-1)){
    document.getElementById(containerid).innerHTML=pgReq.responseText;
  }
}

function loadObjs(){
  if (!document.getElementById){
    return;
  }
  
  for (i=0; i<arguments.length; i++){
    var file=arguments[i];
    var fileref="";
    if (loadedObj.indexOf(file)==-1){ //Check to see if object already added to page before proceeding
      if (file.indexOf(".js")!=-1){ //If object is a js file
        fileref=document.createElement('script');
        fileref.setAttribute("type","text/javascript");
        fileref.setAttribute("src", file);
      }
      else if (file.indexOf(".css")!=-1){ //If object is a css file
        fileref=document.createElement("link");
        fileref.setAttribute("rel", "stylesheet");
        fileref.setAttribute("type", "text/css");
        fileref.setAttribute("href", file);
      }
    }
    if (fileref!=""){
      document.getElementsByTagName("head").item(0).appendChild(fileref);
      loadedObj+=file+" "; //Remember this object as being already added to page
    }
  }
}
/*end ajax page load*/


/*event loader and init*/
function addEvent(obj, evType, fn){ 
    if (obj.addEventListener){ 
        obj.addEventListener(evType, fn, false); 
        return true; 
    } else if (obj.attachEvent){ 
        var r = obj.attachEvent("on"+evType, fn); 
        return r; 
    } else { 
        return false; 
    } 
}

addEvent(window, 'load', init);

function init(){
  ajaxPage('dynamicMessage.html','textArea'); 
}
/*end event loader*/
