title: undefined error when calling function from another js sourcefile
body: <p>I have a question that concerns calling a function within another js sourcefile.</p>
  
  <p>I declared the sourcefile before the file with the function that calls that particular
  function.
  I thought this would work, but it gives an undefined error.</p>
  
  <p>I also have a function in a file that calls a function in a later declared sourcefile.
  That would concern the same files but the other way around.</p>
  
  <p>The functions are declared between document ready statements(functions).</p>
  
  <p>Is there a way to avoid the undefined error??</p>
  
  <p>this is how I set it up:</p>
  
  <pre><code>&lt;script type="text/javascript" src="includes/livetabs.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="includes/chat.js"&gt;&lt;/script&gt;
  
  
  //this is in the chat.js file
  $(document).ready(function(){
  
  function chatWith(chatuser) {
      check=iscookieUsername();
      if (!check){
              chatusersuspended=chatuser;
              showchatinlogform();
      }
      createChatBox(chatuser);
      $("#chatbox_"+chatuser+" .chatboxtextarea").focus();
  }
  
  
  });
  
  //this is in the livetabs.js file
  $(document).ready(function(){
  
  function iscookieUsername(){
          if (!tbusername){
  
              return false;
          }
          if (issessionusername){//flag if session has already been set
  
              return true;
          }
          $.ajax({
              url: "includes/livetabs.php", 
              data: ({username: tbusername, action: "setsessionusername"}),
              cache: false,
              type: "POST",
              dataType: "json",
              success: function(data) {
              //store username in php session
              //some personal user preferences returned 
              usernamecookie=data.cookie;
              trackuser=data.track;
              issessionusername=1;
          }});
  
          return true;
      }
  
  });
  </code></pre>
  
  <p>Thanks, Richard</p>