/*MAIN INDEX ACTIVE LINKS*/
function active_(remove_class, add_id){
  $("."+remove_class).removeClass("active");
  $("."+remove_class).addClass("custom_inactive");
  $("#"+add_id).addClass("active");

}
/*MAIN INDEX ACTIVE LINKS*/

//Loading spin
function loading(id){
  $("#"+id).html(
    "<p class='text-center loader'></p>"
  ); 
}
//UNIVERSAL POST
function universal_post(form_id,response_id,post_url) {
  $("#"+form_id).submit(function(e) {
      e.preventDefault();
      loading(response_id);
        $.ajax({
          url: post_url, 
          
          type: "POST",
          data:  new FormData(this),
          contentType: false,
          cache: false,
          processData:false,
              success: function(resp) {
                $("#"+form_id).unbind();
                $("#"+form_id).bind('submit');
                if(resp==1){  
                  $("#"+response_id).html("<p id='"+response_id+"Min"+"' class='alert alert-success'>Operation successful</p>");
                   $("#"+response_id+"Min").fadeOut(5000,"swing",null)
                }else if(resp==0){
                  $("#"+response_id).html("<p class='alert alert-warning'>Sorry operation failed, try again later</p>");
                }else if(resp=="exists"){
                  $("#"+response_id).html("<p class='alert alert-warning'>Sorry operation failed, record already exist</p>");
                }else{
                  $("#"+response_id).html(resp);
                }
              },
              error: function(xhr, status, error) {
                //var err = eval("(" + xhr.responseText + ")");
                //alert(err.Message);
              }
        });
    });
}