anchor.diff:      }
   
       function draw_graph_top_searches() {
  -        var sortStates = [0, 0, 0, 0]
  -            dataInt = Globals.Data,
  -            oldHeight = Globals.Height;
  -
  +        // General Variables
  +        var svg;            // SVG to contain graph
  +        var dataInt;        // Internal reference to graph dataset
  +        var sortStates;     // Array indicating the currently selected sort state
  +        var key;            // Key function to maintain object constancy
  +        var triangle;       // Triangle object for sort buttons
  +        // Dimension Variables
  +        var margin;         // Blank space around edge of SVG left as margin
  +        var rowHeight;      // Height of each row of data
  +        var width;          // Drawable width of SVG (not including margins)
  +        var height;         // Drawable height of SVG (not including margins)
  +        var oldHeight;      // Previous height of SVG
  +        var textPadding;    // Padding around text elements
  +        var barHeight;      // Height of data bars
  +        var rankWidth;      // Width of rank column
  +        var categoryWidth;  // Width of category column
  +        var countWidth;     // Width of count column
  +        var percentWidth;   // Width of percent column
  +        var cumPercentWidth;// Width of cumulative percent column
  +        var percBarCenter;  // Center x for count/percent data bar
  +        var cumPercBarStart;// Beginning x for cumulative percent data bar
  +        var triangleSpacing;// Space around triangular sort buttons
  +        // Scale Variables
  +        var percScale;      // Scale for count/percent data bar
  +        var cumPercScale;   // Scale for cumulative percent data bar
  +        // Selection Variables
  +        var groupEnter;     // Entry selection for gAll
  +        var gAll;           // Group containing all elements
  +        var headGroupEnter; // Entry selection for headRow
  +        var headRow;        // Group containing all head elements
  +        var headEnter;      // Entry selection for all head elements
  +        var triangles;      // Sort triangles
  +        var dataGroupEnter; // Entry selection for dataRows
  +        var dataRows;       // Group containing all data elements
  +        var dataRects;      // Background rectangles
  +        var dataRanks;      // Rank text
  +        var dataLabels;     // Label text
  +        var dataClicks;     // Click text
  +        var dataPercents;   // Percent text
  +        var dataCumPercents;// Cumulative percent text
  +        var percBar;        // Count/percent data bar
  +        var cumPercBar;     // Cumulative percent data bar
  +        var lightBorder;    // Light border (surrounds all elements)
  +        var darkBorder;     // Dark border (surrounds data elements)
  +
  +        // Initialize General Variables ///////////////////////////////////////////////////////////
  +        svg = d3.select("#graph_top_searches");
  +
  +        dataInt = Globals.Data;
  +
  +        sortStates = [0, 0, 0, 0];
           sortStates[Globals.Sort] = 1;
   
  -        var svg = d3.select("#graph_top_searches"),
  -            margin = {
  -                top: 20,
  -                right: 20,
  -                bottom: 20,
  -                left: 20
  -            },
  -            width = +svg.attr("width") - margin.left - margin.right,
  -            textPadding = 5,
  -            rowHeight = 35,
  -            barHeight = 25,
  -            rankWidth = 2 * width / 16,
  -            categoryWidth = 4 * width / 16,
  -            countWidth = 2 * width / 16,
  -            percentWidth = 3 * width / 16,
  -            cumPercentWidth = 5 * width / 16,
  -            percBarCenter = rankWidth + categoryWidth + countWidth + 13 * d3.max(dataInt, function(d) {
  -                return d.count.toString().length;
  -            }),
  -            cumPercBarStart = rankWidth + categoryWidth + countWidth + percentWidth + 3 * textPadding + 13 * d3.max(dataInt, function(d) {
  -                return d.cum_percentage.toString().length;
  -            }),
  -            height = (dataInt.length + 1) * rowHeight,
  -            triangleSpacing = 15,
  -            key = function(d) {
  -                return d.key;
  -            };
  -
  +        key = function(d) {
  +            return d.key;
  +        };
  +
  +        triangle = d3.symbol().type(d3.symbolTriangle).size(20);
  +
  +        // Initialize Dimension Variables /////////////////////////////////////////////////////////
  +        margin = {
  +            top: 20,
  +            right: 20,
  +            bottom: 20,
  +            left: 20
  +        };
  +        rowHeight = 35;
  +        width = +svg.attr("width") - margin.left - margin.right;
  +        height = (dataInt.length + 1) * rowHeight;
  +        oldHeight = Globals.Height;
  +        textPadding = 5;
  +        barHeight = 25;
  +        rankWidth = 2 * width / 16;
  +        categoryWidth = 4 * width / 16;
  +        countWidth = 2 * width / 16;
  +        percentWidth = 3 * width / 16;
  +        cumPercentWidth = 5 * width / 16;
  +        percBarCenter = rankWidth + categoryWidth + countWidth + 13 * d3.max(dataInt, function(d) {
  +            return d.count.toString().length;
  +        });
  +        cumPercBarStart = rankWidth + categoryWidth + countWidth + percentWidth + 3 * textPadding + 13 * d3.max(dataInt, function(d) {
  +            return d.cum_percentage.toString().length;
  +        });
  +        triangleSpacing = 15;
  +
  +        // Initialize Scale Variables /////////////////////////////////////////////////////////////
  +        percScale = d3.scaleLinear().rangeRound([0, countWidth + percentWidth - 100]);
  +        percScale.domain([0, d3.max(dataInt, function(d) {
  +            return d.cum_percentage
  +        })]);
  +
  +        cumPercScale = d3.scaleLinear().rangeRound([0, countWidth + percentWidth - 100]);
  +        cumPercScale.domain([0, d3.max(dataInt, function(d) {
  +            return d.cum_percentage
  +        })]);
  +
  +        // Misc ///////////////////////////////////////////////////////////////////////////////////
  +        // Transition the svg height depending on previous height
           svg.transition().delay(function(d) {
                   if (oldHeight > height) {
                       return 500;
  
positive.code:             .attr("width", width)
              .attr("height", height);;
  
          var darkBorder = gAll.selectAll(".darkBorder").data([dataInt]);
  
          darkBorder.transition().delay(function(d) {
                  if (oldHeight > height) {
  
negative.code:                 return cumPercScale(d.cum_percentage);
              });
  
          // Add borders ////////////////////////////////////////////////////////////////////////////
          lightBorder = gAll.selectAll(".lightBorder").data([dataInt]);
  
          lightBorder.transition().delay(function(d) {
                  if (oldHeight > height) {
  