function setUpAnnotations(url) {
      
       $.ajax({
    	   url: url,
    	   data: {},
         beforeSend: function(xhr) {xhr.setRequestHeader("Accept","text/json")},
    	   success: function(data) {
    		   if(data.exception) {
        		   $('#annotations')[0].innerHTML = '<li>' + data.exception.localizedMessage + '</li>';
    		   } else {
        		   if(data.count == 0) {
    			     $('#annotations')[0].innerHTML = '<li>' + 'no comments' + '</li>';
        		   } else {
        			   var pagerMessage = "Showing " + data.firstRecord + " to " + data.lastRecord + " of " + data.count;
        			   $('#annotations')[0].innerHTML = '<span>' + pagerMessage + '</span>';
        			   for(i in data.records){
        	                var annotation = data.records[i];
        	               
        	                var annotationItem = '<li class=\'annotation\'><ul xmlns:dc=\'http://purl.org/dc/elements/1.1/\' property=\'dc:identifier\' content=\'' + annotation.uuid + '\'>'
                            + '<li class=\'annotation-content\'><span rel=\'dc:type\' href=\'http://purl.org/dc/dcmitype/Text\' property=\'dc:title\'>';

        	                if(annotation.text.length > 80) {
            	                annotationItem = annotationItem + annotation.text.substring(0,80) + "...";
        	                } else {
        	                	annotationItem = annotationItem + annotation.text;
            	            }

        	                var date = jQuery.timeago(annotation.created);
        	                annotationItem  = annotationItem + '</span></li><li class=\'annotation-content\'><a property=\'dc:creator\' href=\'' + '/user/' + annotation.createdBy.username+
        	                '\'>' + annotation.createdBy.username + '</a><span property=\'dc:date\' content=\'' + annotation.created + '\'> ' + date + '</span></li>';
        	               
        	                annotationItem = annotationItem + '<li class=\'annotation-content\'><span>'
        	   
        	                if(annotation.numberOfAnnotations != 1){
        	                    annotationItem = annotationItem + annotation.numberOfAnnotations + " responses | ";
        	                } else {
        	                	annotationItem = annotationItem + annotation.numberOfAnnotations + " response | ";
        	                }
        	                var annotationsUrl = "/" + annotation.annotatedObj.clazz + "/" + annotation.annotatedObj.uuid + "/annotations";
        	                annotationItem = annotationItem + '<a property=\'dc:relation\' href=\'' + annotationsUrl + '\'>more</a>'

        	                annotationItem = annotationItem + '</ul></li>';
        	                $('#annotations').append(annotationItem);
        	            }
            	   }
    		   }
           },
    	   dataType: 'json'
    	 });  
}

function setUpMarkers(url) {
       $.ajax({
    	   url: url,
    	   data: {},
         beforeSend: function(xhr) {xhr.setRequestHeader("Accept","text/json")},
    	   success: function(data) {
    		   if(data.exception) {
        		   $('#markers')[0].innerHTML = '<li>' + data.exception.localizedMessage + '</li>';
    		   } else {
        		   if(data.count == 0) {
    			     $('#markers')[0].innerHTML = '<li>' + 'no tags' + '</li>';
        		   } else {
        			   var pagerMessage = "Showing " + data.firstRecord + " to " + data.lastRecord + " of " + data.count;
        			   $('#markers')[0].innerHTML = '<span>' + pagerMessage + '</span>';
        			   for(i in data.records){
        	                var marker = data.records[i];
        	               
        	                var markerItem = '<li class=\'marker\'><ul xmlns:dc=\'http://purl.org/dc/elements/1.1/\' property=\'dc:identifier\' content=\'' + marker.uuid + '\'>'
                            + '<li class=\'marker-content\'><span rel=\'dc:type\' href=\'http://purl.org/dc/dcmitype/Text\' property=\'dc:title\'>';

        	                if(marker.markerType.titleCache.length > 80) {
            	                markerItem = markerItem + marker.markerType.titleCache.substring(0,80) + "...";
        	                } else {
        	                	markerItem = markerItem + marker.markerType.titleCache;
            	          }
        	                markerItem = markerItem + '</span></li></ul></li>';
        	                $('#markers').append(markerItem);
        	            }
            	   }
    		   }
           },
    	   dataType: 'json'
    	 });  
}

function setUpBHL(url) {
    $.ajax({
 	   url: url,
 	   data: {},
         beforeSend: function(xhr) {xhr.setRequestHeader("Accept","text/json")},
 	   success: function(data) {
 		   if(data.exception) {
     		      $('#bhl')[0].innerHTML = '<li>' + data.exception.localizedMessage + '</li>';
 		   } else {
     		     if(data.count == 0) {
 			     $('#bhl')[0].innerHTML = '<li>' + 'no references' + '</li>';
     		     } else {
     			   var pagerMessage = "Showing " + data.firstRecord + " to " + data.lastRecord + " of " + data.count;
     			   $('#bhl')[0].innerHTML = '<span>' + pagerMessage + '</span>';
     			   for(i in data.records) {
     	                var reference = data.records[i];
     	                var item = reference.items.item[0];
    	                var page = item.pages.page[0];
     	               
     	                var referenceItem = '<li class=\'bhlreference\'><a class=\'external\' href=\'' + page.pageUrl + '\'>' + reference.publicationTitle + " " + item.volumeInfo + " page " + page.number + "</a></li>";
     	                $('#bhl').append(referenceItem);
     	              }
               }
 		   }
        },
 	   dataType: 'json'
 	 });  
   }

function setUpEntrez(url) {
    $.ajax({
 	   url: url,
 	   data: {},
         beforeSend: function(xhr) {xhr.setRequestHeader("Accept","text/json")},
 	   success: function(data) {
 		   if(data.exception) {
     		   $('#entrez')[0].innerHTML = '<li>' + data.exception.localizedMessage + '</li>';
 		   } else {
     		   if(data.count == 0) {
 			     $('#entrez')[0].innerHTML = '<li>' + 'no sequences' + '</li>';
     		   } else {
     			   var pagerMessage = "Showing " + data.firstRecord + " to " + data.lastRecord + " of " + data.count;
     			   $('#entrez')[0].innerHTML = '<span>' + pagerMessage + '</span>';
     			   for(i in data.records){
     	                var sequence = data.records[i];
     	               
     	                var sequenceItem = '<li class=\'entrezsequence\'><a class=\'external\' href=\'http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=nucleotide&val=' + sequence.gi + '\'>' + sequence.caption + " " + sequence.title + "</a></li>";
     	                $('#entrez').append(sequenceItem);
     	            }
         	   }
 		   }
        },
 	   dataType: 'json'
 	 });  
   }