﻿/// <reference path="jquery-1.3.2-vsdoc2.js" />

var idCities = "divCities";
var idLocations = "divLocations";
var idPhones = "divPhones";
var idErrors = "lblError";
var idbtnAddLocation = "btnAddLocation";
var idbtnAddLocationAndContinue = "btnAddLocationAndContinue";
//var idbtnContinue = "btnContinue";
var idhnLocationId1 = "hnLocationId1";
var idhnLocationId = "hnLocationId";
var idhnPhoneId = "hnPhoneId";
var idhnStateId = "hnStateId";
var idhnCityId = "hnCityId";
var idhnId = "hnId";
var idhnShowLocation = "hnShowLocation"
var idSelLocations = "divSelLocations";
var idbtnShowMoreNumbers = "btnShowMoreNumbersNext";
var idbtnShowMoreNumbersPrev = "btnShowMoreNumbersPrev";
var idhnOffset = "hnOffset";
var idbtnCancelEdit = "btnCancelEdit";
var idfldsetStates = "fldsetStates";
var idbtnMapIt = "btnMapIt";
var idbtnShowAdditionalStates = "btnShowAdditionalStates";
var idbtnShowAdditionalCities = "btnShowAdditionalCities";
var idbtnShowAdditionalLocations = "btnShowAdditionalLocations";
var idtxtZipCode = "txtZipCode";
var idddlDistance = "ddlDistance";
var idLocationByZip = "LocationByZip";
var idhnCityId1 = "hnCityId1"
var idhnStateId1 = "hnStateId1";
var idbtnRestartSearch = "btnRestartSearch";
var classCities = "cities";
var classLocations = "locations";
var classPhones = "phones";
var classSelLocations = "sellocations";
var errorMessage = "An error occured!";
var selectCityTitle = "Select city";
var selectLocationTitle = "Select location";
var selectedLocationTitle = "Selected location";
var onelocation = false;

var showstates = true;
var showcities = true;

var classSearchoffices = "searchoffices";
var affiliateId = 0;
var text = "Use CC from file";

function RblCreditCardOptionsChanged(value)
{
    
    var selValue = "5";
    var ddlCardType = $("#ddlCardType");
    var txtCardNumber = $("#txtCardNumber");
    var txtNameOnCard = $("#txtNameOnCard");
    if (value == 0) {
        ddlCardType.val(selValue);
        txtCardNumber.val(text);
        txtNameOnCard.val(text);
    }
    else if (value == 1) {
        if (ddlCardType.val() == selValue) ddlCardType.val("");
        if (txtCardNumber.val() == text) txtCardNumber.val("");
        if (txtNameOnCard.val() == text) txtNameOnCard.val(""); 
    }
}

function RestartSearch() {
    ShowElementWithId(idfldsetStates);
    Disable(idbtnRestartSearch);
    HideElementsWithClass(classCities);
    HideElementsWithClass(classLocations);
    HideElementsWithClass(classPhones);
    HideElementWithId(idLocationByZip);  
    CancelEdit(); 
}

function SearchByZip() {
    HideElementWithId(idErrors);
    CancelEdit(); 
    var txt = $("#" + idtxtZipCode);
    if (txt.val().length > 0) {
        var range = $("#" + idddlDistance).val();
        var params = "{zipcode:'" + txt.val() + "', range:'"+ range + "'}";
        ExecuteWebService(
        params,
        "ajax.asmx/SearchByZip",
        function(result) {
            if (result.d.Result) {
                if (result.d.LocationId > 0) {
                    ShowLocation(result.d.LocationId, result.d.CityId, result.d.StateId, 1);
                }
                else {
                    ShowElementWithId(idLocationByZip, result.d.Html);
                }
                HideElementWithId(idfldsetStates);
                HideElementsWithClass(classCities);
                HideElementsWithClass(classLocations);
                HideElementsWithClass(classPhones);
                UnDisable(idbtnRestartSearch);
            }
            else {
                ShowElementWithId(idLocationByZip, result.d.Error);
            }
        },
        onError
      );
    }
    else {
        ShowErrorMessage("<b>ZIP Code</b> is required."); 
    }
}

function ShowAdditionalStates() {
    HideElementWithId(idbtnShowAdditionalStates);
    SetValue(idhnShowLocation, 0); 

}
function ShowAdditionalCities() {
    HideElementWithId(idbtnShowAdditionalCities);
    //SetValue(idhnShowLocation, 0);
    LoadCities(GetValue(idhnStateId1), 2);
}
function ShowAdditionalLocations()
{
    HideElementWithId(idbtnShowAdditionalLocations);
    //SetValue(idhnShowLocation, 0);
    LoadLocations(GetValue(idhnCityId1), 2);   
}

function CancelEdit() {
    if (affiliateId > 0) {
        window.location.reload(true);
    }
    Disable(idbtnCancelEdit);
    SetDefaultValues();
    HideElementsWithClass(classCities);
    HideElementWithId(idErrors);
    HideElementsWithClass(classLocations);
    HideElementsWithClass(classPhones);
    HideElementWithId(idCities);
    HideElementWithId(idLocations);
    HideElementWithId(idPhones);
    //HideElementWithId(idLocationByZip);
    HideElementWithId(idbtnCancelEdit);
    if (showstates) {
        SetAnchorUnSelected("astate");
        ToggleClassOnForFieldSetWithId(idfldsetStates);
        ShowElementWithId(idfldsetStates);
    }
}

function ShowMoreNumbers(id, locationId) {
    if (id) {
        LoadPhonesSummary(locationId, id);        
    }
    else {
        LoadPhones(GetValue(idhnLocationId1));  
    }
}
function ShowMoreNumbersPrev() {
    var offset = GetValue(idhnOffset);
    if (offset > 1) {
        SetValue(idhnOffset, offset - 2);   
    }
    LoadPhones(GetValue(idhnLocationId1));
}


function ShowBusy(id) {
    $("#" + id).html('&nbsp;&nbsp;Loading.&nbsp;Please wait...<img src="images/busy.gif" alt="Please wait loading" />');
}
function SetElementVisibilityVisible(className) {
    $('.' + className).css("visibility", 'visible');
}
function ShowElementsWithClass(className) {
    $('.' + className).css("display", 'block'); 
}
function HideElementsWithClass(className) {
    $('.' + className).css("display", 'none'); 
}
function ShowElementWithId(id, text) {
    var element = $('#' + id);
    if (text) {
        element.html(text);   
    }
    element.css("display", 'block'); 
}
function HideElementWithId(id, text) {
    var element = $('#' + id);
    element.css("display", 'none');
    if (text) {
        element.html(text);  
    } 
}

function SetAnchorSelected(id) {
    var element = $("#" + id)
    element.css("font-weight", "bolder");
    element.css("color", "black");
    element.css("text-decoration", "none"); 
}
function SetAnchorUnSelected(className) {
    var elements = $("." + className)
    elements.css("font-weight", "normal");
    elements.css("color", "#d00032");
    elements.css("text-decoration","underline");
}
function SetLegend(className, text) {
    $('.' + className + " legend").html("<b>"+text+"</b>");
}
function ToggleClassOnForFieldSetWithId(id) {
    $("#" + id).addClass("fieldset_active");
}
function ToggleClassOnForFieldSetWithClass(className) {
    $("." + className).addClass("fieldset_active");
}
function ToggleClassOffForFieldSetWithId(id) {
    $("#" + id).removeClass("fieldset_active");
}
function ToggleClassOffForFieldSetWithClass(className) {
    $("." + className).removeClass("fieldset_active");
}
function LoadCities(stateId, showonlyone, id) {
    ShowBusy(idCities);
    //ShowElementsWithClass(classCities);

    if (!showcities) 
    {
        HideElementsWithClass(classCities);  
    }
    else
    {
       ShowElementsWithClass(classCities);
    }
    
    
    HideElementWithId(idErrors);
    HideElementWithId(idLocationByZip);
    if(showonlyone != 2)
    {
        HideElementsWithClass(classPhones);
        HideElementsWithClass(classLocations);
        HideElementWithId(idPhones);
    }
    if (id) {
        SetAnchorUnSelected("astate");
        SetAnchorSelected(id);
    }
    Disable(idbtnAddLocation);
    Disable(idbtnAddLocationAndContinue);
    var params = "{stateId:'" + stateId + "'}";
    ToggleClassOffForFieldSetWithId(idfldsetStates);
    ToggleClassOnForFieldSetWithClass(classCities);
    var params = "{stateId:'" + stateId;
    if (showonlyone == 1) {
        params += "', cityId:'" + GetValue(idhnCityId);
    }
    else {
        params += "', cityId:'0" ; 
    }
    params += "'}";
    ExecuteWebService(
        params,
        "ajax.asmx/GetCities",
        function(result) {
            if (result.d.Result) {
                ShowElementWithId(idCities, result.d.Html);
                SetLegend(classCities, selectCityTitle + " in " + result.d.State);
                if (showonlyone == 1 && result.d.Count > 1) {
                    ShowElementWithId(idbtnShowAdditionalCities);
                }
                var cityid = GetValue(idhnCityId);
                //SetValue(idhnCityId, 0);
                if (cityid > 0 && showonlyone != 2) {
                    HideElementWithId(idLocations);
                    HideElementsWithClass(classLocations);
                    SetValue(idhnCityId, 0);
                    LoadLocations(cityid, showonlyone, "city_" + cityid);
                }
                if (showonlyone == 2) {
                    cityid = GetValue(idhnCityId1);
                    SetAnchorUnSelected("acity");
                    SetAnchorSelected("city_" + cityid);
                    ToggleClassOffForFieldSetWithClass(classCities);
                }
                else if (result.d.CityId > 0) {
                    cityid = result.d.CityId;
                    SetAnchorUnSelected("acity");
                    SetAnchorSelected("city_" + cityid);
                    ToggleClassOffForFieldSetWithClass(classCities);
                    LoadLocations(cityid, 0, "city_" + cityid);
                }
            }
            else {
                ShowElementWithId(idCities, result.d.Error);
                SetLegend(classCities, selectCityTitle);
            }
        },
        onError
      );
}
function LoadLocations(cityId, showonlyone, id) {
    ShowBusy(idLocations);
    ShowElementsWithClass(classLocations);
    HideElementWithId(idErrors);
    if (id) {
        SetAnchorUnSelected("acity");
        SetAnchorSelected(id);
    }
    if (showonlyone != 2) {
        HideElementsWithClass(classPhones);
        HideElementWithId(idPhones);
        HideElementWithId(idbtnMapIt);
    }
    Disable(idbtnAddLocation);
    Disable(idbtnAddLocationAndContinue);
    ToggleClassOnForFieldSetWithClass(classLocations);
    ToggleClassOffForFieldSetWithClass(classCities);  
    var params = "{cityId:'" + cityId;
    if (showonlyone == 1) {
        params += "', locationId:'" + GetValue(idhnLocationId);
    }
    else {
        params += "', locationId:'0";
    }
    params += "'}";
    ExecuteWebService(
        params,
        "ajax.asmx/GetLocations",
        function(result) {
            if (result.d.Result) {
                ShowElementWithId(idLocations, result.d.Html);
                if (result.d.LocationId > 0) {
                    SetLegend(classLocations, selectedLocationTitle + " in " + result.d.StateAndCity);
                }
                else {
                    SetLegend(classLocations, selectLocationTitle + " in " + result.d.StateAndCity);
                }
                //debugger 
                var locid = GetValue(idhnLocationId);
                if (showonlyone == 1 && result.d.Count > 1) {
                    ShowElementWithId(idbtnShowAdditionalLocations);
                }
                if (locid > 0 && showonlyone != 2) {
                    SetValue(idhnLocationId, 0);
                    LoadPhones(locid, "location_" + locid);
                    if (GetValue(idhnId) > 0) {
                        UnDisable(idbtnCancelEdit);
                        ShowElementWithId(idbtnCancelEdit);
                    }
                }
                if (showonlyone == 2) {
                    locid = GetValue(idhnLocationId1);
                    SetAnchorUnSelected("alocation");
                    SetAnchorSelected("location_" + locid);
                    ToggleClassOffForFieldSetWithClass(classLocations);
                }
                else if (result.d.LocationId > 0) {
                    locid = result.d.LocationId;
                    SetAnchorUnSelected("alocation");
                    SetAnchorSelected("location_" + locid);
                    ToggleClassOffForFieldSetWithClass(classLocations);
                    LoadPhones(locid, "location_" + locid);
                }
            }
            else {
                ShowElementWithId(idLocations, result.d.Error);
                SetLegend(classLocations, selectLocationTitle);
            }
        },
        onError
    );
    }
function MapIt() {
    var locationId = GetValue(idhnLocationId1);
    window.open("http://www.cesvirtualoffices.com/gmap1.php?locid=" + locationId, "wndMapIt", "location=0,status=0,scrollbars=0, width=820, height=620");   
}
function LoadPhones(locationId, id) {
    ShowBusy(idPhones);
    ShowElementsWithClass(classPhones);
    HideElementWithId(idErrors);
    Disable(idbtnShowMoreNumbers);
    Disable(idbtnShowMoreNumbersPrev);
    ShowElementWithId(idbtnMapIt);   
    if (id) {
        SetAnchorUnSelected("alocation");
        SetAnchorSelected(id);
        SetValue(idhnOffset, 0);
    }
    Disable(idbtnAddLocation);
    Disable(idbtnAddLocationAndContinue);
    Disable(idbtnAddLocationAndContinue);
    ToggleClassOnForFieldSetWithClass(classPhones);
    ToggleClassOffForFieldSetWithClass(classLocations); 
    var params = "{locationId:'" + locationId + "', offset:'" + GetValue(idhnOffset) +"'}";
    ExecuteWebService(
        params,
        "ajax.asmx/GetPhoneNumbers",
        function(result) {
            if (result.d.Html) {
                ShowElementWithId(idPhones, result.d.Html);
                UnDisable(idbtnShowMoreNumbers);
                if (result.d.Offset > 1)
                {
                     UnDisable(idbtnShowMoreNumbersPrev);
                }                                
            }
            else {
                ShowElementWithId(idPhones, result.d.Error);
            }
            SetValue(idhnOffset, result.d.Offset);
        },
        onError
    );
    //for show more phones only
    SetValue(idhnLocationId1, locationId);
}
function SetPhone(phoneId, locationId, id) {
    HideElementWithId(idErrors);
    if (id) {
        SetAnchorUnSelected("aphone");
        SetAnchorSelected(id);
    }
    ToggleClassOffForFieldSetWithClass(classPhones);  
    if (!onelocation) UnDisable(idbtnAddLocation);
    UnDisable(idbtnAddLocationAndContinue);
    SetValue(idhnPhoneId, phoneId);
    SetValue(idhnLocationId1, locationId);
    SetValue(idhnLocationId, 0); 
}
function UnDisable(id) {
    $("#" + id).removeAttr("disabled");
}
function Disable(id) {
    $("#" + id).attr("disabled","disabled");
}
function onError(XMLHttpRequest, textStatus, errorThrown) {
    ShowErrorMessage(errorMessage)
}

function ExecuteWebService(params, url, callbackSuccess, callbackError) {
    $.ajax({
        type: "POST",
        url: url,
        cache: false,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: params,
        success: callbackSuccess,
        error: callbackError
    });
}
function AddLocation() {
     //debugger
     HideElementWithId(idErrors, '');
     var params = "{locationId:'" + GetValue(idhnLocationId1) + "', phoneId:'" + GetValue(idhnPhoneId) + "', id:'" + GetValue(idhnId) + "'}";
     ExecuteWebService(
        params,
        "ajax.asmx/AddLocation",
        function(result){
             //LoadPhones(GetValue(idhnLocationId1));
             if (result.d.Result) {
                 CancelEdit(); 
                 LoadSelectedLocations();
             }
             else {
                 ShowErrorMessage(result.d.Error);
             }    
        },
        onError
    );
 }
 function ShowErrorMessage(message) {
     var message =  '<ul><li>' + message + '</li></ul><br>';
     ShowElementWithId(idErrors, message);
 }
 function SetValue(id, value) {
     $("#" + id).val(value);
 }
 function GetValue(id) {
     return $("#" + id).val();
 }
 function AddLocationAndContinue(locationId, phoneId) {
    var params = "{locationId:'" + GetValue(idhnLocationId1) + "', phoneId:'" + GetValue(idhnPhoneId) + "', id:'" + GetValue(idhnId) + "'}";
    ExecuteWebService(
        params,
        "ajax.asmx/AddLocation",
        function(result) {
            if (result.d.Result) {
                Continue();
                SetDefaultValues();
                LoadSelectedLocations();
            }
            else {
                ShowErrorMessage(result.d.Error);
                LoadPhones(locationId);
            }
        },
        onError
    );
}

function Continue() {
    window.document.location = 'stepadditionalpackages.aspx'; 
}
function LoadSelectedLocations() {
    ExecuteWebService(
        "{}",
        "ajax.asmx/GetSelectedLocations",
        function(result) {
            if (result.d != null) {
                ShowBusy(idSelLocations);
                ShowElementsWithClass(classSelLocations);
                ShowElementWithId(idSelLocations, result.d);
                //UnDisable(idbtnContinue);
            }
            else {
                HideElementsWithClass(classSelLocations);
                HideElementWithId(idSelLocations);
                //Disable(idbtnContinue);
            }    
        },
        onError
    );
}
function DeleteLocation(id) {
    var result = window.confirm("Are you sure?");
    if (result) {
        //Disable(idbtnContinue);
        var params = "{id:'" + id + "'}";
        ExecuteWebService(
        params,
        "ajax.asmx/DeleteLocation",
        function(result) {
            if (result.d) {
                LoadSelectedLocations();
            }
            else {
                //UnDisable(idbtnContinue);
                ShowErrorMessage(errorMessage);
            }
            CancelEdit();
        },
        onError
    );    
    }
}
function EditLocation(id, stateId, cityId, locationId) {
    SetValue(idhnId, id);
    SetValue(idhnStateId, stateId);
    SetValue(idhnCityId, cityId);
    SetValue(idhnLocationId, locationId);
    SetValue(idhnPhoneId, 0);
    SetValue(idbtnAddLocation, "Edit Location");
    SetValue(idbtnAddLocationAndContinue, "Continue");
    HideElementWithId(idbtnShowAdditionalCities);
    HideElementWithId(idbtnShowAdditionalLocations);
    HideElementWithId(idbtnShowAdditionalStates);
    LoadCities(stateId, 0, "state_" + stateId);
    
}
function ShowLocationByZip(locationId, cityId, stateId, showonlyone, id) {
    //5, 7, 10, 1, this.id
    SetDefaultValues();
    //SetValue(idhnStateId1, stateId);
    //SetValue(idhnCityId1, cityId);
    //SetValue(idhnLocationId1, locationId);
    //SetValue(idhnStateId, stateId);
    //SetValue(idhnCityId, cityId);
    //SetValue(idhnLocationId, locationId);
    if (id) {
        SetAnchorUnSelected("aziplocation");
        SetAnchorSelected(id);
    }
    SetValue(idhnPhoneId, 0);
    SetValue(idhnShowLocation, showonlyone);
    LoadPhones(locationId)
    //LoadCities(stateId, showonlyone, "state_" + stateId);
}
function ShowLocation(locationId, cityId, stateId, showonlyone, id) {
    //5, 7, 10, 1, this.id
    SetDefaultValues();
    SetValue(idhnStateId1, stateId);
    SetValue(idhnCityId1, cityId);
    SetValue(idhnLocationId1, locationId);
    SetValue(idhnStateId, stateId);
    SetValue(idhnCityId, cityId);
    SetValue(idhnLocationId, locationId);
    if (id) {
        SetAnchorUnSelected("aziplocation");
        SetAnchorSelected(id);
    }
    SetValue(idhnPhoneId, 0);
    SetValue(idhnShowLocation, showonlyone);
    if (!showstates) {
        HideElementWithId(idfldsetStates);
    }
    LoadCities(stateId, showonlyone, "state_" + stateId);
}
function SetDefaultValues() {
    SetValue(idhnId, 0);
    SetValue(idhnStateId, 0);
    SetValue(idhnStateId1, 0);
    SetValue(idhnCityId, 0);
    SetValue(idhnCityId1, 0);
    SetValue(idhnLocationId, 0);
    SetValue(idhnLocationId1, 0);
    SetValue(idhnPhoneId, 0);
    SetValue(idbtnAddLocation, "Add Another location");
    SetValue(idbtnAddLocationAndContinue, "Continue");
    Disable(idbtnAddLocation);
    Disable(idbtnAddLocationAndContinue);
    if (affiliateId > 0) {
        HideElementsWithClass(classSearchoffices);
        HideElementWithId(idbtnRestartSearch);
        if (onelocation) {
            HideElementWithId(idbtnAddLocation);
            HideElementWithId("idSpanOr"); 
        }
    } 
}
//// StepEditSummary begin
function AttemptReLock(phoneId, faxId, stepId, locationId) {
    var params = "{phoneId:'" + phoneId + "', faxId:'" + faxId + "', stepId:'" + stepId + "'}";
    SetValue(idhnId, stepId);
    SetValue(idhnLocationId, locationId);
    ShowBusy("lockphone_" + stepId);
    HideElementWithId(idErrors);
    ExecuteWebService(
        params,
        "ajax.asmx/AttemptReLock",
        function(result) {
            if (result.d.Result) {
                ShowElementWithId("lockphone_" + stepId, result.d.Html);
            }
            else {
                ShowElementWithId("lockphone_" + stepId, result.d.Html);
                LoadPhonesSummary(locationId, stepId);
            }      
        }
        ,
        onError
    );
}
function LoadPhonesSummary(locationId, stepId) {
    ShowBusy(idPhones + "_" + stepId);
    ShowElementsWithClass(classPhones + "_" + stepId);
    HideElementWithId(idErrors);
    Disable(idbtnShowMoreNumbers + "_" + stepId);
    var params = "{stepId:'" + stepId + "', locationId:'" + locationId + "', offset:'" + GetValue(idhnOffset + "_" + stepId) + "'}";
    ExecuteWebService(
          params,
          "ajax.asmx/GetPhoneNumbersSummary",
          function(result) {
            if (result.d.Html) {
                ShowElementWithId(idPhones + "_" + stepId, result.d.Html);
                UnDisable(idbtnShowMoreNumbers + "_" + stepId);
            }
            else {
                ShowElementWithId(idPhones + "_" + stepId, result.d.Error);
            }
            SetValue(idhnOffset + "_" + stepId, result.d.Offset);           
          },
          onError
      );
}
function SetPhoneSummary(stepId, phoneId, locationId) {
    HideElementWithId(idErrors);
    var params = "{stepId:'" + stepId + "', phoneId:'" + phoneId + "', locationId:'" + locationId + "'}";
    SetValue(idhnId, stepId);
    SetValue(idhnLocationId, locationId);
    ExecuteWebService(
          params,
          "ajax.asmx/SetPhone",
          function(result) {
            if (result.d.Result) {
                  HideElementsWithClass(classPhones + "_" + stepId);
                  ShowElementWithId("lockphone_" + stepId, result.d.Html);  
              }
              else {
                  LoadPhonesSummary(locationId, stepId);
                  ShowElementWithId(idErrors, result.d.Error);
              }
          },
          onError
        );
}
//// StepEditSummary end
var no_errors = true;
function ValidateCbxAgree(source, args) {
    var cbx = document.getElementById('cbxAgree');
    if (cbx && cbx.checked) {
        args.IsValid = true;
    }
    else args.IsValid = false;
}
function ValidateDdlHowDid(source, args) {
    switch (args.Value) {
        case "Mailing":
        case "Magazine Ad":
        case "Newspaper Ad":
        case "Other":
            {
                var txt = document.getElementById('txtHowDidComments');
                if (!(txt && txt.value && txt.value.length > 0)) {
                    args.IsValid = false;
                }
                break;
            }
        default:
            args.IsValid = true;
    }

}
function showPleaseSpecify() {
    if (!document.getElementById('ddlHowDid')) {
        return;
    }
    how_did = document.getElementById('ddlHowDid').value;
    block = document.getElementById('please_specify');

    switch (how_did) {
        case "Mailing":
        case "Magazine Ad":
        case "Newspaper Ad":
        case "Other":
            {
                block.style.display = "block";
                break;
            }
        default:
            {
                block.style.display = "none";
            }
    }
}
function ValidateCreditCardNumber(source, args) {
    var ddlCardType = document.getElementById('ddlCardType');
    if (args.Value == text) {
        args.IsValid = true;
        return;
    }
    if (ddlCardType && ddlCardType.value > 0 && args.Value > 0) {
        var type = ddlCardType.value;
        var number;
        var digits = 16;
        switch (type) {
            case "1":
                number = 4;
                break;
            case "2":
                number = 5;
                break;
            case "3":
                number = 6;
                break;
            case "4":
                number = 3;
                digits = 15;
                break;
            default:
                args.IsValid = false;
                return false;

        }
        var re = new RegExp("^" + number, "g");
        if (re.test(args.Value) && args.Value.length == digits) {
            args.IsValid = true;
        }
        else {
            args.IsValid = false;
        }
    }
    else args.IsValid = false;
}

