(function(){
    'use strict';

    app.controller('UserAccount', ['$scope', function($scope){
    	$scope.check = "trip";
        $scope.userName = "setTimeout";
        $scope.userNameClick = true;
        $scope.tripName = "Название";
        $scope.tripNameClick = true;

        $scope.gallery = [
            {src: './image/users-photos/image-1.png', desc: 'Image 01'},
            {src: './image/users-photos/image-2.png', desc: 'Image 02'},
            {src: './image/users-photos/image-3.png', desc: 'Image 03'},
            {src: './image/users-photos/image-4.png', desc: 'Image 04'},
            {src: './image/users-photos/image-5.png', desc: 'Image 05'},
            {src: './image/users-photos/image-6.png', desc: 'Image 06'},
            {src: './image/users-photos/image-7.png', desc: 'Image 07'}
        ];

        $scope._Index = 0;

        $scope.isActive = function(index) {
            return $scope._Index === index;
        };

        $scope.showPrev = function() {
            $scope._Index = ($scope._Index > 0) ? --$scope._Index : $scope.gallery.length - 1; 
        };

        $scope.showNext = function() {
            $scope._Index = ($scope._Index < $scope.gallery.length - 1) ? ++$scope._Index : 0;
        };

        $scope.showPhoto = function(index) {
            $scope._Index = index;
        };



        $scope.userNameClickHandler_1 = function() {
            $scope.userNameClick = false;
        };

        $scope.userNameClickHandler_2 = function(keyEvent) {
            if (keyEvent.which === 13) {
                $scope.userNameClick = true;
            }
        };

        $scope.tripNameClickHandler_1 = function() {
            $scope.tripNameClick = false;
        };

        $scope.tripNameClickHandler_2 = function(keyEvent) {
            if (keyEvent.which === 13) {
                $scope.tripNameClick = true;
            }
        };

        setTimeout(function() {
            var list1 = document.getElementById('plane-trip-list1');
            var sortableList1 = Sortable.create(list1, {
                group: 'plane-trip-group',
                animation: 300
            });

            var list2 = document.getElementById('plane-trip-list2');
            var sortableList2 = Sortable.create(list2, {
                group: 'plane-trip-group',
                animation: 300
            });
        }, 1000);

       	$scope.planeTrip = function() {
    		if ($scope.check == "" || $scope.check == "article") {
    			$scope.check = "trip";

               	return;
    		}
    		$scope.check = "";
    		return;
    	};

    	$scope.writeArticle = function() {
    		if ($scope.check == "" || $scope.check == "trip") {
    			$scope.check = "article";
    			return;
    		}
    		$scope.check = "";
    		return;
    	};

        $scope.map = { 
            center: { 
                latitude: 45, 
                longitude: -73 
            }, 
            zoom: 10 
        };

        $scope.bd = {
            northeast: {
                latitude: 51.219053,
                longitude: 4.404418
            },
            southwest: {
                latitude: -51.219053,
                longitude: -4.404418
            }
        };


    }]);

})()

