
   
   // function Login(){
        
$('#loginform').on('submit', function(e){
      e.preventDefault();

      var name = $("#username").val();
      var pass = $("#password").val();
      

      if(name == "") {

         $("#username").closest('.form-group').addClass('has-error');

         noty({
         width: 200,
         text: 'Please Enter the Username',
         type: 'error',
         dismissQueue: true,
         timeout: 3000,
         layout: 'top',
         });

      }else {
         $("#username").closest('.form-group').removeClass('has-error');
         $("#username").closest('.form-group').addClass('has-success');
      }



      if(pass == "") {
         $("#password").closest('.form-group').addClass('has-error');
         noty({
         width: 200,
         text: 'Please Enter the Password',
         type: 'error',
         dismissQueue: true,
         timeout: 3000,
         layout: 'top',
         });
      }else {
         $("#password").closest('.form-group').removeClass('has-error');
         $("#password").closest('.form-group').addClass('has-success');
      }


      if(name && pass ) {
   
            $.ajax({
                  url : 'http://www.keentech.co/projects/goran_api/public/login',
                  type : 'post',
                  data : {username:name,password:pass},
                  dataType : 'json',
                  success : function(response) {
                     
                        if(response.access_token == true) {

                              noty({
                                    width: 200,
                                    text: response.data,
                                    type: 'success',
                                    dismissQueue: true,
                                    timeout: 3000,
                                    layout: 'top',
                              });

                              window.location='index.php';
                        } else {

                              noty({
                                    width: 200,
                                    text: response.data,
                                    type: 'error',
                                    dismissQueue: true,
                                    timeout: 3000,
                                    layout: 'top',
                              });
                        }
                  }

            }); // submit ajax




      }





});


