
var galleries = []

function initializeAddressPlugin()
{
  $.address.state( '/' );

  $.address.init( function( event ) {

      // Initializes the plugin
      $( '.navigation a' ).address();

      if( location.pathname == '/' )
      {
        $.address.path( '/news/' )
      }

    } );

  $.address.change( function( event ) {

      var url = $.address.state().replace( /^\/$/, '' ) + event.value;

      // Selects the proper navigation link
      $( '.navigation a' ).each( function() {

        href = $( this ).attr( 'href' );

        if( href == url.substring( 0, href.length ) )
        {
          $( this ).addClass( 'selected' ).focus();
        }
        else
        {
            $( this ).removeClass( 'selected' );
        }
        $( this ).blur();

        $( 'a.subnav' ).address();
    } );

    var settings = {
      cache: false,
      type: 'GET',
      complete: function( XMLHttpRequest, textStatus ) {
        $( '.content' ).html( XMLHttpRequest.responseText );
      }
    };

    $.ajax( url, settings );

  } );
}


