var app=angular.module('app', []);

app.controller('Ctrl', function($scope, $http, $timeout){

  $scope.login=function(){
    $http.post('http://192.168.1.109:6443/login', $scope.Account).then(function(res){
      console.log(res);
    })
  }
  $scope.register=function(){
    $http.post('http://192.168.1.109:6443/registersponsor', $scope.Account).then(function(res){
      console.log(res);
    })
  }
  // fade-in &out
  $scope.hiddenreg = true;
  $scope.hidelog = function () {
    $scope.startFadeout = true;
    $scope.startFadein = true;
    $timeout(function(){
      $scope.hiddenlog = true;
      $scope.hiddenreg = false;
    }, 1700);
  };

  $scope.hideregi = function () {
    $scope.startFadeout = false;
    $scope.startFadein = false;
    $timeout(function(){
      $scope.hiddenlog = false;
      $scope.hiddenreg = true;
    }, 100);
  };

  console.log("application load complete...");
});

//  $scope.login=function(){
//   $http.post('http://192.168.1.109:6443/login', $scope.Account).then(function(res){
//    console.log(res);
//    // Error Catching
//    var req = {
//      method: 'POST',
//      url: 'http://192.168.1.109:6443/login',
//      data: $scope.Account
//    }
//    $http(req).then(function(success){
//     console.log(success);
//      }, function(err){
//     console.log(err)
//      }
//    )
//   })
//  };
