function PatentHelper(){
    // User Story: PROF-36 | VIP-19, enwam001 (advanced patent search)
    // Add additional search parameters.
    this.getEpoUrl = function(query, begin, end, first_name, last_name, organization){
        var url = "http://ops.epo.org/3.2/rest-services/published-data/search/abstract,biblio,full-cycle?q="

        if(begin != undefined && end != undefined){ 
          //url += 'publicationdate%20within%20"'+formatDate(begin).replace(/-/g,"") + '%20' + formatDate(end).replace(/-/g,"") + '"%20and%20';        
          //url += 'pd%3D"'+formatDate(begin).replace(/-/g,"") +"%20"+ formatDate(end).replace(/-/g,"") +'"' + '%20and%20';        
          url += 'pd%20within%20"'+formatDate(begin).replace(/-/g,"")  + '%20' +formatDate(end).replace(/-/g,"") +'"' + '%20and%20';   
        } 

        if (first_name != undefined && first_name.replace(/ +/g, ' ') !==''){
          url+="in%3D" + first_name + "%20and%20";   
        } 
      
        if (last_name != undefined && last_name.replace(/ +/g, ' ') !==''){
          url+="in%3D" + last_name + "%20and%20";   
        }   
      
        if (organization != undefined && organization.replace(/ +/g, ' ') !==''){
         url+="applicant%3D" + organization + "%20and%20";   
        }
      
        if (query == undefined || query.replace(/ +/g, ' ') ==''){
          url = url.slice(0, -9)
        } else {
          url+= 'ti%20all%20"' + query +'"'//"ti%3D" + query;
        }

        url += "&Range=1-100"    
        return url;
    }    

    // User Story: PROF-36 | VIP-19, enwam001 (advanced patent search)
    // Add additional search parameters.
    this.getUsptoUrl = function (query, begin, end, first_name, last_name, organization){
        var fields = '&f=["patent_date","patent_title","patent_number","patent_number","inventor_first_name", "inventor_last_name","patent_type","assignee_organization","assignee_first_name","assignee_last_name","patent_kind","patent_year","cited_patent_title","cited_patent_number","patent_abstract"]';
        var url = 'http://www.patentsview.org/api/patents/query?q={"_and":[';                
        var date_range = '{"_gte":{"patent_date":"';  // sometimes, the search results include patents from 1 year before the start date
        if(begin != undefined && end != undefined){
          date_range += formatDate(begin) + '"}},{"_lte":{"patent_date":"'
          date_range += formatDate(end) + '"}},' 
          url += date_range;        
        } 
      
        if (first_name != undefined && first_name.replace(/ +/g, ' ') !==''){
          var inventor_first_name = '{"inventor_first_name":["' + first_name +'"]},';
          url += inventor_first_name;
        }
      
        if (last_name != undefined && last_name.replace(/ +/g, ' ') !==''){
          var inventor_last_name = '{"inventor_last_name":["' + last_name+'"]},';
          url += inventor_last_name;
        }
        
      
        if (organization != undefined && organization.replace(/ +/g, ' ') !==''){
          var organization_name = '{"assignee_organization":["' + organization +'"]},';
          url += organization_name;
        }
      
        if (query == undefined || query.replace(/ +/g, ' ') ==''){
          url = url.slice(0, -1)  +  ']}';
        } else {
          var title_argument = '{"_text_all":{"patent_title":"' + query.replace(/ +/g, ' ').trim() + '"}}'
          url += title_argument+ ']}';
        }
        url+= '&o={"page":2,"per_page":10000}' + fields;
        return url
    }
    

    // User Story: PROF-35 | VIP-19, croja022 (business search)
    // Returns a properly formated YELP API URL.
    this.getYelpUrl = function(term, location){
      //Yelp does not like front end calls to their API, so a wrapper for a backened is used.
      var url = "https://cors-anywhere.herokuapp.com/https://api.yelp.com/v3/businesses/search?"
      var originalLength = url.length;
      if(term)
        url+= "term=" + term;
      if(term && location)
        url+= "&location=" + location;
      else if(location)
        url+= "location=" + location;
      if (url.length == originalLength)
        return "";
      return url;
    }    
    this.YelpKey = "GNISV2TzAVHyivTMoE9RisamkR3EG9ruuy6U6IPLEVZXtSFRWrnTP6vQLz-4g6Ls-f67NZqraWbaxanC_k1O4DLqzTFPaih3QdK7VudKvzuKDWBQpzPK7ItSH9PQW3Yx";
    this.encodedData = window.btoa('fvbXgzyKWxgjlBIfM7b7ydIBZ0bJ5mq5:THQOA12DnPg2jKmO'); 

    return this;
    }
    
  function formatDate(date) {
    var d = new Date(date),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
        year = d.getFullYear();
    
    if (month.length < 2) month = '0' + month;
    if (day.length < 2) day = '0' + day;
    
    return [year, month, day].join('-');
  }