// JavaScript Document
//Script to manage Bible Module


function chapterList(){
  //Dynamically Loads Chapter List into bible Module
  
  var ajaxObj=new Ajax();
  var myAjax=ajaxObj.handle;
  
  //setup callback function
    myAjax.onreadystatechange=function(){
      if(myAjax.readyState==4 && myAjax.status==200){
        document.getElementById("bibleModule").innerHTML=myAjax.responseText;
      }
    }
  
  //open page and send request
    myAjax.open("POST","ajax_bibleModule.php",true);
    
    //build params string
    var params=encodeURI("cmd=chapterList");
    //alert(params);
      myAjax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      myAjax.setRequestHeader("Content-length", params.length);
      myAjax.setRequestHeader("Connection", "close");
    myAjax.send(params);
    
    
    
  }

function showBook(book,chapter){

  //replaces contents of bible module with the supplied book and chapter
  
  var ajaxObj=new Ajax();
  var myAjax=ajaxObj.handle;
  
  //setup callback function
    myAjax.onreadystatechange=function(){
      if(myAjax.readyState==4 && myAjax.status==200){
        document.getElementById("bibleModule").innerHTML=myAjax.responseText;
      }
    }
  
  //open page and send request
    myAjax.open("POST","ajax_bibleModule.php",true);
    
    //build params string
    var params=encodeURI("cmd=showBook&book="+book+"&chapter="+chapter);
    //alert(params);
      myAjax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      myAjax.setRequestHeader("Content-length", params.length);
      myAjax.setRequestHeader("Connection", "close");
    myAjax.send(params);
    
    
    
  }
  
function showMedia(type){
  //alert(type);
  //replaces contents of bible module with the media list of desired type
  var ajaxObj=new Ajax();
  var myAjax=ajaxObj.handle;
  
  //setup callback function
    myAjax.onreadystatechange=function(){
      if(myAjax.readyState==4 && myAjax.status==200){
        document.getElementById("bibleModule").innerHTML=myAjax.responseText;
      }
    }
  
  //open page and send request
    myAjax.open("POST","ajax_mediaList.php",true);
    
    //build params string
    var params=encodeURI("cmd="+type);
    //alert(params);
      myAjax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      myAjax.setRequestHeader("Content-length", params.length);
      myAjax.setRequestHeader("Connection", "close");
    myAjax.send(params);
    
    
    
  }
  

function showStore(type){
  //alert(type);
  //replaces contents of bible module with the media list of desired type
  var ajaxObj=new Ajax();
  var myAjax=ajaxObj.handle;
  
  //setup callback function
    myAjax.onreadystatechange=function(){
      if(myAjax.readyState==4 && myAjax.status==200){
        document.getElementById("bibleModule").innerHTML=myAjax.responseText;
      }
    }
  
  //open page and send request
    myAjax.open("POST","ajax_mediaList.php",true);
    
    //build params string
    var params=encodeURI("store="+type);
    //alert(params);
      myAjax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      myAjax.setRequestHeader("Content-length", params.length);
      myAjax.setRequestHeader("Connection", "close");
    myAjax.send(params);
    
    
    
  }
  
  
  
  
  

