﻿// this tells jquery to run the function below once the DOM is ready
$(document).ready(function() {
// choose text for the show/hide link
var showText="Show details";
var hideText="Hide details";
// write showText variable text into the anchor link with id of toggle-details
$('a#toggle-details').text(showText);
// write hideText variable text into the anchor link with id of internal-hide-link
$('a#internal-hide-link').text(hideText);

// hide the content
$('#details').hide();
   
    // function that changes the text of the toggle link and references the hide content function
    function activate() {
      // change the link text
    if ($('a#toggle-details').text()==showText) {
    $('a#toggle-details').text(hideText);
    }
    else {
    $('a#toggle-details').text(showText);
    }
    
    // toggle the display
    $('#details').toggle('slow');
    
    // return false so any link destination is not followed
    return false;
    }

    // triggers the activate function when the toggle link is clicked
    $('a#toggle-details').click(function () {
    activate();  
    });
    
    // triggers the activate function when the internal hide link in the details content is clicked
    $('a#internal-hide-link').click(function () {
    activate();
    });
    
});
 

// Scroll to anchor code by Karl Swedberg using JQuery 

$(document).ready(function() {
  $('a[@href*=#]').click(function() {
 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
   && location.hostname == this.hostname) {
    var $target = $(this.hash);
    $target = $target.length && $target || $('[@name=' + this.hash.slice(1) +']');
    if ($target.length) {
     $target.ScrollTo(400);
     return false;
    }
 };
  });
});