function DVCPWS() {
  $("#new_pass").change(function () {
    if ($.trim($("#new_pass").val()).length < 6 || $("#new_pass").val().toLowerCase().replace(/[^a-z]/g, '').length == 0 || $("#new_pass").val().replace(/[^0-9]/g, '').length == 0) $("#new_passCk").attr("innerHTML", checkfield(false));
    else {
      $("#new_passCk").attr("innerHTML", checkfield(true));
      $("#chgpwdError").attr("innerHTML", "");
    }

    if ($.trim($("#cfnew_pass").val()).length != 0) {
      if ($("#cfnew_pass").val() != $("#new_pass").val()) $("#cfnew_passCk").attr("innerHTML", checkfield(false));
      else {
        $("#cfnew_passCk").attr("innerHTML", checkfield(true));
        $("#chgpwdError").attr("innerHTML", "");
      }
    }
  });

  $("#cfnew_pass").change(function () {
    if ($("#cfnew_pass").val() != $("#new_pass").val()) $("#cfnew_passCk").attr("innerHTML", checkfield(false));
    else $("#cfnew_passCk").attr("innerHTML", checkfield(true));
  });
}

function DVJONS3E() {
  $("#tolevel2Ck").click(function () {
    $("#sign_level2").slideToggle("slow");
  });

  //first name check
  $("#sign_fname").change(function () {
    if ($.trim($("#sign_fname").val()).length == 0) $("#sign_fnameCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_fnameCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }
  });

  //last name check
  $("#sign_lname").change(function () {
    if ($.trim($("#sign_lname").val()).length == 0) $("#sign_lnameCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_lnameCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }
  });

  //email check
  $("#sign_email").change(function () {
    if ($.trim($(this).val()).length != 0 && (ismail($(this).val()))) checkUserData("Email", $(this).val(), "sign_emailCk");
    else $("#sign_emailCk").attr("innerHTML", checkfield(false));

    if ($.trim($("#sign_cfEmail").val()).length != 0) {
      if ($("#sign_email").val() != $("#sign_cfEmail").val()) $("#sign_cfEmailCk").attr("innerHTML", checkfield(false));
      else {
        $("#sign_cfEmailCk").attr("innerHTML", checkfield(true));
        $("#signError").attr("innerHTML", "");
      }
    }
  });

  //confirm email check
  $("#sign_cfEmail").change(function () {
    if ($("#sign_email").val() != $(this).val()) $("#sign_cfEmailCk").attr("innerHTML", checkfield(false));
    else {
      checkUserData("Email", $(this).val(), "sign_cfEmailCk");
      $("#signError").attr("innerHTML", "");
    }
  });

  //password
  $("#sign_pwd").change(function () {
    if ($.trim($(this).val()).length < 6 || $(this).val().toLowerCase().replace(/[^a-z]/g, '').length == 0 || $(this).val().replace(/[^0-9]/g, '').length == 0) $("#sign_pwdCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_pwdCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }

    if ($.trim($("#sign_cfPwd").val()).length != 0) {
      if ($("#sign_pwd").val() != $("#sign_cfPwd").val()) $("#sign_cfPwdCk").attr("innerHTML", checkfield(false));
      else {
        $("#sign_cfPwdCk").attr("innerHTML", checkfield(true));
        $("#signError").attr("innerHTML", "");
      }
    }
  });

  //confirm password
  $("#sign_cfPwd").change(function () {
    if ($("#sign_pwd").val() != $(this).val()) $("#sign_cfPwdCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_cfPwdCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }
  });

  //country
  $("#sign_country").change(function () {
    if ($("#sign_country").val() == "0") $("#sign_countryCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_countryCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }

    if ($("#aba_tr").css("display") == "table-row" || $("#swift_tr").css("display") == "table-row") {
      if ($("#sign_country :selected").text() == "USA") {
        $("#swift_tr").css("display", "none");
        $("#aba_tr").css("display", "table-row");
      } else {
        $("#swift_tr").css("display", "table-row");
        $("#aba_tr").css("display", "none");
      }
    }
  });

  $("#sign_councode").change(function () {
    if ($.trim($("#sign_councode").val()).length == 0 || $.trim($("#sign_areacode").val()).length == 0 || $.trim($("#sign_phone").val()).length == 0) $("#sign_phoneCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_phoneCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }
  });

  $("#sign_areacode").change(function () {
    if ($.trim($("#sign_councode").val()).length == 0 || $.trim($("#sign_areacode").val()).length == 0 || $.trim($("#sign_phone").val()).length == 0) $("#sign_phoneCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_phoneCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }
  });

  $("#sign_phone").change(function () {
    if ($.trim($("#sign_councode").val()).length == 0 || $.trim($("#sign_areacode").val()).length == 0 || $.trim($("#sign_phone").val()).length == 0) $("#sign_phoneCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_phoneCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }
  });

  //aba check
  $("#sign_aba").change(function () {
    if ($.trim($("#sign_aba").val()).length == 0) $("#sign_abaCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_abaCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }
  });

  //swift check
  $("#sign_swift").change(function () {
    if ($.trim($("#sign_swift").val()).length == 0) $("#sign_swiftCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_swiftCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }
  });

  $("#sign_payment_bank").click(function () {
    $("#paypal_tr").css("display", "none");
    $("#transfer_bankname_tr").css("display", "table-row");
    $("#transfer_billacc_tr").css("display", "table-row");
    $("#sign_bankname").focus();
    $("#sign_paymentCk").attr("innerHTML", checkfield(true));
    $("#signError").attr("innerHTML", "");

    if ($("#sign_country :selected").text() == "USA") {
      $("#swift_tr").css("display", "none");
      $("#aba_tr").css("display", "table-row");
    } else {
      $("#swift_tr").css("display", "table-row");
      $("#aba_tr").css("display", "none");
    }
  });

  $("#sign_payment_paypal").click(function () {
    $("#paypal_tr").css("display", "table-row");
    $("#transfer_bankname_tr").css("display", "none");
    $("#transfer_billacc_tr").css("display", "none");
    $("#sign_paypal").focus();
    $("#sign_paymentCk").attr("innerHTML", checkfield(true));
    $("#signError").attr("innerHTML", "");
    $("#swift_tr").css("display", "none");
    $("#aba_tr").css("display", "none");
  });

  $("#sign_paypal").change(function () {
    if ($.trim($("#sign_paypal").val()).length == 0) $("#sign_paypalCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_paypalCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }
  });

  $("#sign_bankname").change(function () {
    if ($.trim($("#sign_bankname").val()).length == 0) $("#sign_banknameCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_banknameCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }
  });

  $("#sign_billacc").change(function () {
    if ($.trim($("#sign_billacc").val()).length == 0) $("#sign_billaccCk").attr("innerHTML", checkfield(false));
    else {
      $("#sign_billaccCk").attr("innerHTML", checkfield(true));
      $("#signError").attr("innerHTML", "");
    }
  });

  $("#sign_councode").numeric();
  $("#sign_areacode").numeric();
  $("#sign_phone").numeric();
  $("#sign_postcode").numeric();
}

function DVMPF() {
  $("#profile_country").change(function () {
    //$("#profile_timezone").val($("#profile_country :selected").attr("item"));
    $.ajax({
      url: "manipulate/handle.php",
      type: "POST",
      cache: false,
      data: ({act:"iniSession"}),
      success: function (data) {
        $.ajax({
          url: serverpath,
          type: "POST",
          data: ({action:"getUserProfileByUserName",username:data}),
          datatype: "JSON",
          success: function (data) {
            if (JSON.parse(data).status == "success") {
              var jsonobj = JSON.parse(data).result;

              if (jsonobj[0].ddegree == 2) {
                if ($("#aba_tr").css("display") == "table-row" || $("#swift_tr").css("display") == "table-row") {
                  if ($("#profile_country :selected").text() == "USA") {
                    $("#swift_tr").css("display", "none");
                    $("#aba_tr").css("display", "table-row");
                  } else {
                    $("#swift_tr").css("display", "table-row");
                    $("#aba_tr").css("display", "none");
                  }
                }
              }
            }
          }
        });
      }
    });
  });

  $("#tolevel2Ck").change(function () {
    openUpgradeDialog();
/*
    if($(this).is(":checked")){
    $("#fname_required").attr("innerHTML","*");
    $("#lname_required").attr("innerHTML","*");
    $("#country_required").attr("innerHTML","*");
    $("#phone_required").attr("innerHTML","*");
    } else {
    $("#fname_required").attr("innerHTML","&nbsp;");
    $("#lname_required").attr("innerHTML","&nbsp;");
    $("#country_required").attr("innerHTML","&nbsp;");
    $("#phone_required").attr("innerHTML","&nbsp;");
    }
    */
  });

  $("#profile_payment_bank").click(function () {
    $("#paypal_tr").css("display", "none");
    $("#bankacc_tr").css("display", "table-row");
    $("#billacc_tr").css("display", "table-row");
    if ($("#profile_country").text() == "USA") $("#aba_tr").css("display", "table-row");
    else $("#swift_tr").css("display", "table-row");
    $("#profile_billacc").focus();
  });

  $("#profile_payment_paypal").click(function () {
    $("#paypal_tr").css("display", "table-row");
    $("#bankacc_tr").css("display", "none");
    $("#billacc_tr").css("display", "none");
    $("#swift_tr").css("display", "none");
    $("#aba_tr").css("display", "none");
    $("#profile_paypal").focus();
  });

  $("#submitdevBtn").click(function () {
    $("#profileError").css("color", "red");

    //first name
    if ($("#fname_required").attr("innerHTML") == "*" && $.trim($("#profile_fname").val()).length == 0) {
      $("#profileError").attr("innerHTML", "Please fill your first name!");
      window.location = "#";
      return;
    }

    //last name
    if ($("#lname_required").attr("innerHTML") == "*" && $.trim($("#profile_lname").val()).length == 0) {
      $("#profileError").attr("innerHTML", "Please fill your last name!");
      window.location = "#";
      return;
    }

    //phone number
    if ($("#phone_required").attr("innerHTML") == "*" && ($.trim($("#profile_coun").val()).length == 0 || $.trim($("#profile_area").val()).length == 0 || $.trim($("#profile_phone").val()).length == 0)) {
      $("#profileError").attr("innerHTML", "Please fill your phone number!");
      window.location = "#";
      return;
    }

    if ($.trim($("#profile_coun").val()).length != 0 || $.trim($("#profile_area").val()).length != 0 || $.trim($("#profile_phone").val()).length != 0) {
      if ($.trim($("#profile_coun").val()).length == 0 || $.trim($("#profile_area").val()).length == 0 || $.trim($("#profile_phone").val()).length == 0) {
        $("#profileError").attr("innerHTML", "Incorrect phone number format!");
        window.location = "#";
        return;
      }
    }

    //country
    if ($("#country_required").attr("innerHTML") == "*" && $("#profile_country").val() == "0") {
      $("#profileError").attr("innerHTML", "Please select your country!");
      window.location = "#";
      return;
    }

    //payment type
    if ($("#payment_type_tr").css("display") != "none") {
      if ((!$("#profile_payment_bank").is(":checked")) && (!$("#profile_payment_paypal").is(":checked"))) {
        $("#profileError").attr("innerHTML", "Please select your payment type!");
        window.location = "#";
        return;
      }

      //payment bank
      if ($("#profile_payment_bank").is(":checked")) {
        if ($.trim($("#profile_billacc").val()).length == 0) {
          $("#profileError").attr("innerHTML", "Please fill your bill account!");
          window.location = "#";
          return;
        }

        if ($.trim($("#profile_bankacc").val()).length == 0) {
          $("#profileError").attr("innerHTML", "Please fill your bank name!");
          window.location = "#";
          return;
        }

        //SWIFT Code
        if ($("#swift_tr").css("display") == "table-row" && $.trim($("#profile_swift").val()).length == 0) {
          $("#profileError").attr("innerHTML", "Please fill your SWIFT Code!");
          window.location = "#";
          return;
        }

        //ABA Code
        if ($("#aba_tr").css("display") == "table-row" && $.trim($("#profile_aba").val()).length == 0) {
          $("#profileError").attr("innerHTML", "Please fill your ABA Code!");
          window.location = "#";
          return;
        }
      }

      //payment paypal
      if ($("#profile_payment_paypal").is(":checked")) {
        if ($.trim($("#profile_paypal").val()).length == 0) {
          $("#profileError").attr("innerHTML", "Please fill your paypal ID!");
          window.location = "#";
          return;
        }
      }
    }


    //Update profile
    $.ajax({
      url: "manipulate/handle.php",
      type: "POST",
      data: ({act:"iniSession"}),
      success: function (data) {
        $.ajax({
          url: serverpath,
          type: "POST",
          data: ({action:"getUserProfileByUserName",username:data}),
          datatype: "JSON",
          success: function (data) {
            if (JSON.parse(data).status == "success") {
              var jsonobj = JSON.parse(data).result;

              var userid = jsonobj[0].user_id;
              var firstname = $("#profile_fname").val();
              var lastname = $("#profile_lname").val();
              var nickname = jsonobj[0].email;
              var email = jsonobj[0].email;
              var company = $("#profile_company").val();
              var address = $("#profile_addr").val();
              var postcode = $("#profile_postcode").val();
              var phonenumber = jsonobj[0].phone_number;
              if ($.trim($("#profile_coun").val()).length != 0 || $.trim($("#profile_area").val()).length != 0 || $.trim($("#profile_phone").val()).length != 0) phonenumber = $("#profile_coun").val() + "-" + $("#profile_area").val() + "-" + $("#profile_phone").val();
              else phonenumber = jsonobj[0].phone_number;
              var paypadid = $("#profile_paypal").val();
              var area = $("#profile_lang").val();
              var sex = "";
              var ddegree = jsonobj[0].ddegree;
              var mdegree = jsonobj[0].mdegree;
              if ($("#tolevel2Ck").is(":checked")) mdegree = 2;
              var picture = jsonobj[0].picture;
              if ($("#profile_img_name").attr("innerHTML") != "") {
                $.ajax({
                  url: "manipulate/handle.php",
                  type: "POST",
                  data: ({act:"move_picture",filename:$("#profile_img_name").attr("innerHTML")}),
                  success: function (data) {}
                });
                picture = userpicpath + $("#profile_img_name").attr("innerHTML");
              }
              var country = "";
              if ($("#profile_country").val() != "0") country = $("#profile_country :selected").text();
              var timezone = "";
              var website = $("#profile_website").val();
              var bankname = $("#profile_bankacc").val();
              var billaccount = $("#profile_billacc").val();
              var bankaba = $("#profile_aba").val();
              var bankswift = $("#profile_swift").val();
              var notice1 = ($("#profile_notice1").is(":checked")) ? 1 : 0;
              var notice2 = ($("#profile_notice2").is(":checked")) ? 1 : 0;
              var status = jsonobj[0].status;
              var paymenttype = 0;
              if ($("#profile_payment_bank").is(":checked")) paymenttype = 1;
              if ($("#profile_payment_paypal").is(":checked")) paymenttype = 2;

              $.ajax({
                url: serverpath,
                type: "POST",
                data: ({action:"setUserProfile",userid:userid,email:email,firstname:firstname,lastname:lastname,nickname:nickname,company:company,phone:phonenumber,timezone:timezone,postcode:postcode,country:country,website:website,bankname:bankname,billaccount:billaccount,notice1:notice1,notice2:notice2,status:status,ddegree:ddegree,mdegree:mdegree,address:address,paypadid:paypadid,area:area,sex:sex,picture:picture,bankaba:bankaba,bankswift:bankswift,paymenttype:paymenttype}),
                datatype: "JSON",
                success: function (data) {
                  if (JSON.parse(data).status == "success") {
/*
                    $("#profileError").attr("innerHTML","Your profile has been updated successfully!");
                    $("#profileError").css("color","green");
                    getMemberProfile();
                    window.location = "#";
                    */
                    alert("Your profile has been updated successfully!");
                    window.location = "DevAc.php?pageid=DVMPF";
                  } else {
                    $("#profileError").attr("innerHTML", "Fail to update your profile, please try again later!");
                    window.location = "#";
                  }
                }
              });
            }
          }
        });
      }
    });
  });

  //upload picture
  new AjaxUpload('file', {
    // Location of the server-side upload script
    // NOTE: You are not allowed to upload files to another domain
    action: 'manipulate/tempImage.php',
    autoSubmit: true,
    responseType: false,
    onSubmit: function (file, extension) {
      if (!(extension && /^(jpg|png|jpeg|gif)$/i.test(extension))) {
        $("#profileError").attr("innerHTML", "Upload only in JPG, GIF, or PNG files!");
        window.location = "#";
        return false;
      } else block_view("Uploading image...");
    },
    onComplete: function (file, response) {
      if (response != "error") {
        $("#profile_img").attr("src", userpicpath + "temp/" + response + "?" + guid());
        $("#profile_img_name").attr("innerHTML", response);
        end_view("Uploading image...");
        $("#cancel_file").css("display", "inline");
        $("#delete_file").css("display", "none");
      }
    }
  });

  //cancel file
  $("#cancel_file").click(function () {
    $.ajax({
      url: "manipulate/handle.php",
      type: "POST",
      cache: false,
      data: ({act:"iniSession"}),
      success: function (data) {
        $.ajax({
          url: serverpath,
          type: "POST",
          data: ({action:"getUserProfileByUserName",username:data}),
          datatype: "JSON",
          success: function (data) {
            if (JSON.parse(data).status == "success") {
              var jsonobj = JSON.parse(data).result;

              if (jsonobj[0].picture != "") {
                $("#profile_img").attr("src", jsonobj[0].picture + "?" + guid());
                $("#delete_file").css("display", "inline");
              }
              else {
                $("#profile_img").attr("src", "images/picture.gif");
              }

              $("#profile_img_name").attr("innerHTML", "");
              $("#cancel_file").css("display", "none");
            }
          }
        });
      }
    });
  });

  //delete 
  $("#delete_file").click(function () {
    $.ajax({
      url: "manipulate/handle.php",
      type: "POST",
      cache: false,
      data: ({act:"iniSession"}),
      success: function (data) {
        $.ajax({
          url: serverpath,
          type: "POST",
          data: ({action:"getUserProfileByUserName",username:data}),
          datatype: "JSON",
          success: function (data) {
            if (JSON.parse(data).status == "success") {
              var jsonobj = JSON.parse(data).result;

              var userid = jsonobj[0].user_id;
              var firstname = jsonobj[0].first_name;
              var lastname = jsonobj[0].last_name;
              var nickname = jsonobj[0].email;
              var email = jsonobj[0].email;
              var company = jsonobj[0].company;
              var address = jsonobj[0].address;
              var postcode = jsonobj[0].postcode;
              var phonenumber = jsonobj[0].phone_number;
              var paypadid = jsonobj[0].paypad_id;
              var area = jsonobj[0].area;
              var sex = jsonobj[0].gender;
              var ddegree = jsonobj[0].ddegree;
              var mdegree = jsonobj[0].mdegree;
              var picture = "";
              var country = jsonobj[0].country;
              var timezone = jsonobj[0].timezone;
              var website = jsonobj[0].website;
              var bankname = jsonobj[0].bankname;
              var billaccount = jsonobj[0].billaccount;
              var bankaba = jsonobj[0].bankABA;
              var bankswift = jsonobj[0].bankSWIFT;
              var notice1 = jsonobj[0].notice1;
              var notice2 = jsonobj[0].notice2;
              var status = jsonobj[0].status;
              var paymenttype = jsonobj[0].paymenttype;

              $.ajax({
                url: serverpath,
                type: "POST",
                data: ({action:"setUserProfile",userid:userid,email:email,firstname:firstname,lastname:lastname,nickname:nickname,company:company,phone:phonenumber,timezone:timezone,postcode:postcode,country:country,website:website,bankname:bankname,billaccount:billaccount,notice1:notice1,notice2:notice2,status:status,ddegree:ddegree,mdegree:mdegree,address:address,paypadid:paypadid,area:area,sex:sex,picture:picture,bankaba:bankaba,bankswift:bankswift,paymenttype:paymenttype}),
                datatype: "JSON",
                success: function (data) {
                  if (JSON.parse(data).status == "success") {
                    alert("Your profile has been updated successfully!");
                    window.location = "DevAc.php?pageid=DVMPF";
                  } else {
                    $("#profileError").attr("innerHTML", "Fail to delete your picture, please try again later!");
                    window.location = "#";
                  }
                }
              });
            }
          }
        });
      }
    });
  });

  $("#profile_coun").numeric();
  $("#profile_area").numeric();
  $("#profile_phone").numeric();
  $("#profile_postcode").numeric();
}

function DVMCOHT() {
  $("#start_date").datepicker({
    dateFormat: 'yy-mm-dd'
  });
  $("#end_date").datepicker({
    dateFormat: 'yy-mm-dd'
  });
}

function DVMAPFO() {
  $("#start_date").datepicker({
    dateFormat: 'yy-mm-dd'
  });
  $("#end_date").datepicker({
    dateFormat: 'yy-mm-dd'
  });
}

function DVUPMAP() {

  $(function () {
    if (jQuery.url.param("app") == undefined || jQuery.url.param("app") == "") {
      $.ajax({
        url: "manipulate/handle.php",
        type: "POST",
        cache: false,
        data: ({act:"iniSession"}),
        success: function (data) {
          $.ajax({
            url: serverpath,
            type: "POST",
            data: ({action:"getUserProfileByUserName",username:data}),
            datatype: "JSON",
            success: function (data) {
              if (JSON.parse(data).status == "success") {
                var jsonobj = JSON.parse(data).result;

                $("#prg_web").val(jsonobj[0].website);
                $("#prg_email").val(jsonobj[0].email);
                
                $("#prg_web_span").attr("innerHTML",jsonobj[0].website);
                $("#prg_mail_span").attr("innerHTML",jsonobj[0].email);

                //jsonobj[0].ddegree=1;
                if (jsonobj[0].ddegree != 2) $("#prg_price").attr("disabled", "true");
              }
            }
          });
        }
      });
    }
  });

  //upload file restriction
  $("#prg_file").change(function () {
    if ($(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "apk") {
      $("#uploadError").attr("innerHTML", "Upload file only restrict to .APK file!");
      $(this).val("");
      window.location = "#";
      return;
    } else $("#uploadError").attr("innerHTML", "");
  });

  //icon restriction
  $("#preview_file").change(function () {
    if ($(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "jpg" && $(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "gif" && $(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "png") {
      $("#uploadError").attr("innerHTML", "Preview icon only restrict to .JPG, .GIF or .PNG file!");
      $(this).val("");
      window.location = "#";
      return;
    } else $("#uploadError").attr("innerHTML", "");
  });

  //screen shot 1
  $("#scn_file1").change(function () {
    if ($(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "jpg" && $(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "gif" && $(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "png") {
      $("#uploadError").attr("innerHTML", "Screenshot image only restrict to .JPG, .GIF or .PNG file!");
      $(this).val("");
      window.location = "#";
      return;
    } else $("#uploadError").attr("innerHTML", "");
  });

  //screen shot 2
  $("#scn_file2").change(function () {
    if ($(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "jpg" && $(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "gif" && $(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "png") {
      $("#uploadError").attr("innerHTML", "Screenshot image only restrict to .JPG, .GIF or .PNG file!");
      $(this).val("");
      window.location = "#";
      return;
    } else $("#uploadError").attr("innerHTML", "");
  });

  //screen shot 3
  $("#scn_file3").change(function () {
    if ($(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "jpg" && $(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "gif" && $(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "png") {
      $("#uploadError").attr("innerHTML", "Screenshot image only restrict to .JPG, .GIF or .PNG file!");
      $(this).val("");
      window.location = "#";
      return;
    } else $("#uploadError").attr("innerHTML", "");
  });

  //screen shot 4
  $("#scn_file4").change(function () {
    if ($(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "jpg" && $(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "gif" && $(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "png") {
      $("#uploadError").attr("innerHTML", "Screenshot image only restrict to .JPG, .GIF or .PNG file!");
      $(this).val("");
      window.location = "#";
      return;
    } else $("#uploadError").attr("innerHTML", "");
  });

  //screen shot 5
  $("#scn_file5").change(function () {
    if ($(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "jpg" && $(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "gif" && $(this).val().split('.')[$(this).val().split('.').length - 1].toLowerCase() != "png") {
      $("#uploadError").attr("innerHTML", "Screenshot image only restrict to .JPG, .GIF or .PNG file!");
      $(this).val("");
      window.location = "#";
      return;
    } else $("#uploadError").attr("innerHTML", "");
  });

  //price digits limit
  $("#prg_price").keydown(function () {
    //alert($(this).val().substring(0,4));
    if ($(this).val().substring(0, 4) == "0.00") {
      $(this).val($(this).val().substring($.trim($(this).val()).length));
      return;
    }

    if ($(this).val().split('.').length == 2) {
      if ($(this).val().split('.')[1].length == 2) $(this).val($(this).val().split('.')[0] + "." + $(this).val().split('.')[1].substring(0, 1));
    }
  });
  
      $("#prg_desc").keyup(function() {
        var max = 1000;
        if ($(this).val().length > max){
          alert("The description of your application exceeds the total description allotment size of 1000 words. Please reduce the description and try again!");
          $(this).val($(this).val().substr(0, max));
          }
      });

  $("#submitdevBtn").click(function (event) {
    //program
    if ($.trim($("#prg_file").val()).length == 0 && (jQuery.url.param("app") == undefined || jQuery.url.param("app") == "")) {
      $("#uploadError").attr("innerHTML", "Please choose your program!");
      window.location = "#";
      event.preventDefault();
      return;
    }

    //preview icon
    if ($.trim($("#preview_file").val()).length == 0 && (jQuery.url.param("app") == undefined || jQuery.url.param("app") == "")) {
      $("#uploadError").attr("innerHTML", "Please choose your preview icon!");
      window.location = "#";
      event.preventDefault();
      return;
    }

    //screen shot
    if ($.trim($("#scn_file1").val()).length == 0 && (jQuery.url.param("app") == undefined || jQuery.url.param("app") == "")) {
      $("#uploadError").attr("innerHTML", "Please choose at least one screenshot!");
      window.location = "#";
      event.preventDefault();
      return;
    }

    //program title
    if ($.trim($("#prg_title").val()).length == 0 && (jQuery.url.param("app") == undefined || jQuery.url.param("app") == "")) {
      $("#uploadError").attr("innerHTML", "Please fill your program title!");
      window.location = "#";
      event.preventDefault();
      return;
    }

    //program description
    if ($.trim($("#prg_desc").val()).length == 0) {
      $("#uploadError").attr("innerHTML", "Please fill your program description!");
      window.location = "#";
      event.preventDefault();
      return;
    }

    //program category
    if ($("#catOption").val() == -1) {
      $("#uploadError").attr("innerHTML", "Please select program category!");
      window.location = "#";
      event.preventDefault();
      return;
    }

    //program price
    if ($.trim($("#prg_price").val()).length == 0) {
      $("#uploadError").attr("innerHTML", "Please fill program price!");
      window.location = "#";
      event.preventDefault();
      return;
    }

    if (isNaN($("#prg_price").val())) {
      $("#uploadError").attr("innerHTML", "Price must be a number!");
      window.location = "#";
      event.preventDefault();
      return;
    }

    //program agreement
    if (!$("#prg_agree").is(":checked") && (jQuery.url.param("app") == undefined || jQuery.url.param("app") == "")) {
      $("#uploadError").attr("innerHTML", "Please check agree!");
      window.location = "#";
      event.preventDefault();
      return;
    }

    if (jQuery.url.param("app") != undefined) {
      if ($.trim($("#prg_file").val()).length == 0 && $.trim($("#preview_file").val()).length == 0 && $.trim($("#scn_file1").val()).length == 0 && $.trim($("#scn_file2").val()).length == 0 && $.trim($("#scn_file3").val()).length == 0 && $.trim($("#scn_file4").val()).length == 0 && $.trim($("#scn_file5").val()).length == 0) {
        event.preventDefault();
        block_view("Updating...");

        var appid = jQuery.url.param("app");
        var description = $("#prg_desc").val();
        var price = $("#prg_price").val();
        var category = $("#catOption").val();
        var lang = $("#prg_lang").val();
        var apkurl = "";
        var screenshot = "";
        var icon = "";
		alert(screenshot);
		
        /* $.ajax({
          url: serverpath,
          type: "POST",
          data: ({action:"update",appid:appid,description:description,price:price,area:lang,apkurl:apkurl,apkhash:"",apksize:"",category:category,version:"",os:"",hardware:"",platform:"",screenshot:screenshot,icon:icon}),
          datatype: "JSON",
          success: function (data) {
            if (JSON.parse(data).status == "success") $("#upload_form").attr("innerHTML", "<table style='margin-left:30px;'><tr><td class=\'error_text\' style='color:green;'>Your program has been updated successfully!</td></tr></table>");
            else $("#upload_form").attr("innerHTML", "<table style='margin-left:30px;'><tr><td class=\'error_text\'>" + JSON.parse(data).result.ErrMsg + "!</td></tr></table>");
            end_view("Updating...");
          }
        }); */
      } else {
        $("#type").val("update");
      }
    }

    block_view("Uploading...");

  });
}

function DVCUS() {
  $.ajax({
    url: "manipulate/handle.php",
    type: "POST",
    cache: false,
    data: ({act:"iniSession"}),
    success: function (data) {
      if (data != "guest") {
        $.ajax({
          url: serverpath,
          type: "POST",
          data: ({action:"getUserProfileByUserName",username:data}),
          datatype: "JSON",
          success: function (data) {
            if (JSON.parse(data).status == "success") {

              var jsonobj = JSON.parse(data).result;

              $("#con_name").val(jsonobj[0].first_name);
              $("#con_mail").val(jsonobj[0].email);
            }
          }
        });
      }
    }
  });
}




function numbersonly(myfield, e, dec) {

  if ($("#prg_price").val() == ".") {
    $("#prg_price").val("");
    return false;
  } else return true;

  var key;
  var keychar;

  if (window.event) key = window.event.keyCode;
  else if (e) key = e.which;
  else return true;
  keychar = String.fromCharCode(key);

  // control keys
  if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27)) return true;

  // numbers
  else if (((".").indexOf(keychar) > -1)) {
    if ($("#prg_price").val().indexOf('.') > 0) return false;
    else return true;
  }

  // numbers
  else if ((("0123456789").indexOf(keychar) > -1)) return true;

  // decimal point jump
  else if (dec && (keychar == ".")) {
    myfield.form.elements[dec].focus();
    return false;
  }
  else return false;
}

function DVFPWS() {
  $("#pws_email").change(function () {
    if ($.trim($(this).val()).length != 0 && (ismail($(this).val()))) checkUserData2("Email", $(this).val(), "pws_emailCk");
    else $("#pws_emailCk").attr("innerHTML", checkfield(false));
  });
}

function DVJONREE() {
  $("#verify_mail").change(function () {
    if ($.trim($(this).val()).length != 0 && (ismail($(this).val()))) checkUserData2("Email", $(this).val(), "verify_mailCk");
    else $("#verify_mailCk").attr("innerHTML", checkfield(false));
  });
}