         function ajaxload(is_nav_link, link_object, event_object)
         {
            // create new hash
            hash = link_object.pathname;
            // format the hash
            hash = hash.replace('/', '');

            if (!hash)
            {
               // add home as new history item
               $.history.load('home');
            }
            else
            {
               // add new history item based on hash
               $.history.load(hash);
            }
            
            // hide current page content
            $('.all_content').hide();
            // retrieve page content from new page
            $('.all_content').load('/' + hash + ' .main_content');
            // remove active link class for all links
            $('.nav_main a').removeClass('nav_main_current');
            // change the class of the new active link
            if (is_nav_link)
            {
               $(link_object).addClass('nav_main_current');
            }
            else
            {
               $('.nav_icon_' + hash).addClass('nav_main_current');
            }
            // used in place of 'return false;' as suggested by http://docs.jquery.com/Events_%28Guide%29
            event_object.preventDefault();
         }

         // loads page content based on hash variable
         function pageload(hash)
         {
            // hide current page content
            $('.all_content').hide();
            hash = hash.replace('/', '');

            // hash doesn't contain the first # character.
            if ((!hash) || (hash == 'home')) 
            {
               $('.all_content').load('/ .main_content');
               // start page
               hash = 'home';
            }
            else
            {
               // retrieve page content from new page
               $('.all_content').load('/' + hash + ' .main_content');
            }
            
            // remove active link class for all links
            $('.nav_main a').removeClass('nav_main_current');
            // change the class of the new active link
            $('.nav_icon_' + hash).addClass('nav_main_current');
            // set new page title from hash
            document.title = 'Bryan Rocco: ' + hash.substr(0,1).toUpperCase() + hash.substr(1);
         }
         $(document).ready(
            function() {
               // init history fix
               $.history.init(pageload);
               var hash;

               // links for the nav tabs.
               // clicking on an anchor hides the content, loads new content, and fades the new in.
               // this function also changes the class of the tabs and prevents the browser from loading the href
               $('.nav_main a').click(
                  function(event)
                  {
                     ajaxload(true, this, event);
                  }
               );
            }
         );
         $().ajaxSend(
            function(r,s)
            {
               $('.content_loading').show();
            }
         );
         $().ajaxStop(
            function(r,s)
            {
               // hide loading animation
               $('.content_loading').hide();
               // fade in page content
               $('.all_content').fadeIn(500);
               // init FancyBox for portfolio
               $("div.fbox a.fbox_img").fancybox({
                  'hideOnContentClick': true,
                  // 'zoomSpeedIn': 500,
                  // 'zoomSpeedOut': 500,
                  // 'easingIn': 'easeOutBack',
                  // 'easingOut': 'easeInBack'
               });
               $("div.fbox a.fbox_swf1").fancybox({
                  'hideOnContentClick': true,
                  'frameWidth': 775,
                  'frameHeight': 525
               });
               $("div.fbox a.fbox_swf2").fancybox({
                  'hideOnContentClick': true,
                  'frameWidth': 790,
                  'frameHeight': 164
               });
               $("div.fbox a.fbox_swf3").fancybox({
                  'hideOnContentClick': true,
                  'frameWidth': 570,
                  'frameHeight': 320
               });
               $('.ajax_link').click(
                  function(event)
                  {
                     ajaxload(false, this, event);
                  }
               );
            }
         );

