text: 'use strict';
  //var jQuery = require('jquery');
  //Start by defining the main module and adding the module dependencies
  angular.module(ApplicationConfiguration.applicationModuleName, ApplicationConfiguration.applicationModuleVendorDependencies);
  
  // Setting HTML5 Location Mode
  //angular.module(ApplicationConfiguration.applicationModuleName).config(['$locationProvider', '$httpProvider', '$animateProvider',
  //  function ($locationProvider, $httpProvider, $animateProvider) {
  angular.module(ApplicationConfiguration.applicationModuleName).config(['$locationProvider', '$httpProvider',
      function ($locationProvider, $httpProvider) {
          $locationProvider.html5Mode(true).hashPrefix('!');
          $httpProvider.interceptors.push('authInterceptor');
  
    }
  ]);
  
  angular.module(ApplicationConfiguration.applicationModuleName).run(function ($rootScope, $state, Authentication, $animate) {
  
    // Check authentication before changing state
    $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
      if (toState.data && toState.data.roles && toState.data.roles.length > 0) {
        var allowed = false;
        toState.data.roles.forEach(function (role) {
          if (Authentication.user.roles !== undefined && Authentication.user.roles.indexOf(role) !== -1) {
            allowed = true;
            return true;
          }
        });
  
        if (!allowed) {
          event.preventDefault();
          if (Authentication.user !== undefined && typeof Authentication.user === 'object') {
            $state.go('forbidden');
          } else {
            $state.go('authentication.signin').then(function () {
              storePreviousState(toState, toParams);
            });
          }
        }
      }
    });
  
    // Record previous state
    $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
      storePreviousState(fromState, fromParams);
    });
  
    // Store previous state
    function storePreviousState(state, params) {
      // only store this state if it shouldn't be ignored 
      if (!state.data || !state.data.ignoreState) {
        $state.previous = {
          state: state,
          params: params,
          href: $state.href(state, params)
        };
      }
    }
  });
  
  //Then define the init function for starting up the application
  angular.element(document).ready(function () {
    //Fixing facebook bug with redirect
    if (window.location.hash && window.location.hash === '#_=_') {
      if (window.history && history.pushState) {
        window.history.pushState('', document.title, window.location.pathname);
      } else {
        // Prevent scrolling by storing the page's current scroll offset
        var scroll = {
          top: document.body.scrollTop,
          left: document.body.scrollLeft
        };
        window.location.hash = '';
        // Restore the scroll offset, should be flicker free
        document.body.scrollTop = scroll.top;
        document.body.scrollLeft = scroll.left;
      }
    }
  
    //Then init the app
    angular.bootstrap(document, [ApplicationConfiguration.applicationModuleName]);
  });
  
  //angular.module(ApplicationConfiguration.applicationModuleName).animation('.slide', [function () {
          
  //        var elementPosition = 0;
          
  //        var _move = function (element, doneFn) {
  //            console.log('_move');
  //            //jQuery(element).fadeIn(1000, doneFn);
  //            //elementWidth = $(element).css('width', 'auto').width();
  //            //$(element).animate({ width: 0 }, 600)
  //            element.css({ left: '100%' });
  //            element.animate({ "margin-left": elementPosition }, 600, doneFn);
  
  //        };
          
  //        var raiseZIndx = function (element, doneFn) {
  //            console.log('raiseZIndx');
  //            element.css({ 'z-index': '21' });
  //            console.log('new zindex: ' + element.css("z-index"));
  
  //        }
          
  //        var _enter = function (element, doneFn) {
  //            console.log('_enter');
  //            element.css({ "position": 'relative', "left": '+=2500px', 'z-index': '1' });
  //            //$(element).animate({ left: $('#slide').position.left }, 600, doneFn);
              
  //            elementPosition = $('.slide').position();
  //            console.log(elementPosition);
  //            console.log(elementPosition.left);
              
  //            //element.css({ "left": '1500' });
  //            element.animate({ "left": '-=2500px', 'top': '50px', 'z-index': '21' }, 600, doneFn);
  
  //        };
          
  //        var _leave = function (element, doneFn) {
  //            console.log('_leave');
  //            element.css({ "position": 'relative', 'z-index': '20' });
  //            //$(element).animate({ left: $('#slide').position.left }, 600);
              
  //            element.animate({"position": "absolute", "left": '-=2500px', 'top': '50px'  }, 600, doneFn);
  
  //            //};
  
  //            //return returnObject;
  //            //return {
  //            //    move: move,
  //            //    enter: enter,
  //            //    leave: leave
  //            //};
  
  //        }
  //        return {
  //            enter: _enter,
  //            move: _move,
  //            leave: _leave
  //        }
  
  //    }]);