/**
 * Provides suggestions for song title
 * @class
 * @scope public
 */
function RemoteSongSuggestions() 
   {
      if (typeof XMLHttpRequest != "undefined") 
         {
            this.http = new XMLHttpRequest();
         } 
      else if (typeof ActiveXObject != "undefined") 
         {
            this.http = new ActiveXObject("MSXML2.XmlHttp");
         } 
      else 
         {
            alert("No XMLHttpRequest object available. This functionality will not work.");
         }
   }

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
RemoteSongSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/, bTypeAhead /*:boolean*/) 
   {
      var oHttp = this.http;
                                                             
      //if there is already a live request, cancel it
      if (oHttp.readyState != 0) 
         {
            oHttp.abort();
         }                 
    
      //build the URL
      var sURL = "/songrequest/suggestions/TITLE?userInput=" + encodeURIComponent(oAutoSuggestControl.textbox.value);
    
      //open connection to states.txt file
      oHttp.open("get", sURL , true);
      oHttp.onreadystatechange = function () 
         {
            if (oHttp.readyState == 4) 
               {
                  //evaluate the returned text JavaScript (an array)
                  var aSuggestions = eval(oHttp.responseText);
        
                  //provide suggestions to the control
                  oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);        
               }    
         };
      oHttp.send(null);
   };

/**
 * Provides suggestions for performer names
 * @class
 * @scope public
 */
function RemoteArtistSuggestions() 
   {
      if (typeof XMLHttpRequest != "undefined") 
         {
            this.http = new XMLHttpRequest();
         } 
      else if (typeof ActiveXObject != "undefined") 
         {
            this.http = new ActiveXObject("MSXML2.XmlHttp");
         } 
      else 
         {
            alert("No XMLHttpRequest object available. This functionality will not work.");
         }
   }

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
RemoteArtistSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/, bTypeAhead /*:boolean*/) 
   {
      var oHttp = this.http;
      var songTitle;
      
      //if there is already a live request, cancel it
      if (oHttp.readyState != 0) 
         {
            oHttp.abort();
         }                 

      if (document.getElementById("SONG_TITLE"))
         {
            songTitle = document.getElementById("SONG_TITLE").value;
         }        
    
      //build the URL
      var sURL = "/songrequest/suggestions/ARTIST?userInput=" + encodeURIComponent(oAutoSuggestControl.textbox.value) + '&songTitle=' + encodeURIComponent(songTitle);
    
      //open connection to states.txt file
      oHttp.open("get", sURL , true);
      oHttp.onreadystatechange = function () 
         {
            if (oHttp.readyState == 4) 
               {
                  //evaluate the returned text JavaScript (an array)
                  var aSuggestions = eval(oHttp.responseText);
        
                  //provide suggestions to the control
                  oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);        
               }    
         };
      oHttp.send(null);    
   };   
/**
 * Provides suggestions for album names
 * @class
 * @scope public
 */
function RemoteAlbumSuggestions() 
   {
      if (typeof XMLHttpRequest != "undefined") 
         {
            this.http = new XMLHttpRequest();
         } 
      else if (typeof ActiveXObject != "undefined") 
         {
            this.http = new ActiveXObject("MSXML2.XmlHttp");
         } 
      else 
         {
            alert("No XMLHttpRequest object available. This functionality will not work.");
         }
   }

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
RemoteAlbumSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/, bTypeAhead /*:boolean*/) 
   {
      var oHttp = this.http;
      var songPerformer;
      var songTitle;

      //if there is already a live request, cancel it
      if (oHttp.readyState != 0) 
         {
            oHttp.abort();
         }                 

      if (document.getElementById("SONG_PERFORMER"))
         {
            songPerformer = document.getElementById("SONG_PERFORMER").value;
         }        

      if (document.getElementById("SONG_TITLE"))
         {
            songTitle = document.getElementById("SONG_TITLE").value;
         }        

      //build the URL
      var sURL = "/songrequest/suggestions/ALBUM?userInput=" + encodeURIComponent(oAutoSuggestControl.textbox.value) + '&songPerformer=' + encodeURIComponent(songPerformer) + '&songTitle=' + encodeURIComponent(songTitle);
    
      //open connection to states.txt file
      oHttp.open("get", sURL , true);
      oHttp.onreadystatechange = function () 
         {
            if (oHttp.readyState == 4) 
               {
                  //evaluate the returned text JavaScript (an array)
                  var aSuggestions = eval(oHttp.responseText);
        
                  //provide suggestions to the control
                  oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);        
               }    
         };
      oHttp.send(null);    
   };   
