function clear_this() { 
  document.getElementById('send-to-input').value="";
}

function fill_this() {
  if(document.getElementById('send-to-input').value == "") {
    document.getElementById('send-to-input').value="Type your friends name";
  }
}



function resend_activation_code() {
  var mobile_no=document.getElementById('mobile_no').value;

  if(mobile_no == "") {
    alert("Mobile no. is empty");
    return false;
  }

  if(isNaN(mobile_no)||mobile_no.indexOf(" ")!=-1) {
    alert("Enter numeric value")
    return false;
  }

  if (mobile_no.length>10) {
    alert("enter 10 characters");
    return false;
  }
  if (mobile_no.charAt(0)!="9") {
    alert("it should start with 9 ");
    return false
  }

  resend_data={
              action:"bp_resend_activation",
              mobile_no:mobile_no
              };

  jQuery.ajax( {
                 data:resend_data,
                 type:"POST",
                 url:ajaxurl,
                 success:request_status
              });
}


function resend_activation_code_again() {
    var mobile_no=document.getElementById('mobile').value;

  if(mobile_no == "") {
    alert("Mobile no. is empty");
    return false;
  }

  if(isNaN(mobile_no)||mobile_no.indexOf(" ")!=-1) {
    alert("Enter numeric value")
    return false;
  }

  if (mobile_no.length>10) {
    alert("enter 10 characters");
    return false;
  }
  if (mobile_no.charAt(0)!="9") {
    alert("it should start with 9 ");
    return false
  }

  resend_data={
              action:"bp_again_resend_activation",
              mobile_no:mobile_no
              };

  jQuery.ajax( {
                 data:resend_data,
                 type:"POST",
                 url:ajaxurl,
                 success:request_status_again
              });
}

function request_status_again (response) { 
  window.location=response;
}

function request_status(response) {  
 window.location=response;
}

function show_resend_div() {
  document.getElementById('resend_activation_code').style.display='block';
}

function clear_this_mobile() { 
document.getElementById('mobile').value="";
}

function fill_this_mobiles() { 
  if(document.getElementById('mobile').value=="") {
    document.getElementById('mobile').value="Type your friends name";
  }
}

jQuery(document).ready(function() {

    jQuery('#field_1').bind('keyup', function() {
    var user_name=jQuery('#field_1').val();
    if(user_name == "" ) {
      //jQuery("#field_1").css("background-color","red");
      jQuery('#mes').html("name can not be empty");
      jQuery("#mes").css("background-color","red");
      document.getElementById('profile-group-edit-submit').disabled=true;
    } else {
      jQuery("#field_1").css("background-color","white");
      jQuery('#mes').html("");
      jQuery("#mes").css("background-color","white");
      document.getElementById('profile-group-edit-submit').disabled=false;
    }
  });

  jQuery('#field_2').bind('keyup', function(e) {
    if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)) {
      jQuery("#mes").html("Digits Only");
      document.getElementById('profile-group-edit-submit').disabled=true;
    } else {
      document.getElementById('profile-group-edit-submit').disabled=true;
      jQuery("#mes").html("");
    }

    var mobile_no=jQuery('#field_2').val();
    if(mobile_no.length < 10) {
     // jQuery("#field_2").css("background-color","red");
      document.getElementById('profile-group-edit-submit').disabled=true;
      return false;
    }
    ValidateMobileNumber(mobile_no);
  } );
});

function ValidateMobileNumber(number) {
  var ErrorMsg;
  document.getElementById('profile-group-edit-submit').disabled=true;
  if (number.length>10) {
//     jQuery("#field_2").css("background-color","red");
     jQuery("#mes").css("background-color","red");
    document.getElementById('profile-group-edit-submit').disabled=true;
    if(number.length==12) {
      if(number.substring(0,2)!="91") {
        ErrorMsg="Number should begin with 91";
//        jQuery("#field_2").css("background-color","red");
      } else {
        ErrorMsg="";
        jQuery("#field_2").css("background-color","white");
      }
    } else {
        ErrorMsg="Invalid Mobile Number "; 
//        jQuery("#field_2").css("background-color","red");
    }
  } else {
    ErrorMsg="";
            jQuery("#field_2").css("background-color","white");
  }

  if (ErrorMsg.length>0) {
    jQuery('#mes').html("Enter valid number");
    jQuery("#mes").css("background-color","red");
    document.getElementById('profile-group-edit-submit').disabled=true;
//    jQuery("#field_2").css("background-color","red");
    return false;
  } else {
      jQuery('#mes').html("");
      jQuery("#mes").css("background-color","white");
      document.getElementById('profile-group-edit-submit').disabled=false;
  }
}
