var req1;
var doesNotSupport1 = true;
function check_distributor_code(url,c){
    //alert(url);

    if(window.XMLHttpRequest) {
       req1 = new XMLHttpRequest;
    } else if (window.ActiveXObject) {
       req1 = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(req1) {

       url=url+"?code="+c;
       req1.open("POST",url, true);
       req1.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

       var postvalues="";
       postvalues="code="+c;
       //alert(postvalues);
       req1.send(postvalues);
       req1.onreadystatechange = processReqChange1;

    } else {
       alert("Please use latest version of the current browser to function properly");
       doesNotSupport1 = false;
    }
}

function processReqChange1() {

   //alert(req1.readyState);

    if(req1.readyState == 4) {
       //alert(req1.status);
       if(req1.status == 200) {
          var aa=req1.responseText;

          //alert(aa);
          if(aa == "N"){
             alert("Distributor code should be valid");
             document.form1.distributor_id.value="";
          }
          if(aa == "-1"){
             alert("Distributor code  should be in numeric");
             document.form1.distributor_id.value="";
          }
          if(aa == "1"){
             alert("Distributor code already exists, please select an different Distributor code");
          }
          if(aa == "0"){
             alert("Distributor code not exists, you can use this Distributor code");
          }
      }
  }

}
