                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 

isc.defineClass("RegistrationForm", "DynamicForm").addProperties({
    width: 638,
    numCols: 4,
    colWidths:[150, 150, 150, 150],
    autoFocus: true,
    showErrorText:true,
    errorOrientation:"top",

    defaultItems : [
        {name: "firstname", title: "First name", required: true, titleVAlign:"bottom", validators: [
            {type: "lengthRange", max: 25}
        ]},
        {name: "lastname", title: "Last name", required: true, titleVAlign:"bottom", validators: [
            {type: "lengthRange", max: 25}
        ]},
        {name: "email", title: "Email", required: true, titleVAlign:"bottom", validators: [
            {type: "lengthRange", max: 100},
            {type: "regexp", 
             errorMessage: "Must be in the form name@host.com",
             expression:"^([a-zA-Z0-9_.\\-+])+@(([a-zA-Z0-9\\-])+\\.)+[a-zA-Z0-9]{2,4}$"}
        ]},
        {name: "username", title: "User Name", required: true, titleVAlign:"bottom", validators: [
            {type: "lengthRange", max: 100}
        ]},
        {name: "organization", title: "Company/Organization", required: true, titleVAlign:"bottom", validators: [
            {type: "lengthRange", max: 40}
        ]},
        {name: "phone", title: "Phone", titleVAlign:"bottom", validators: [
            {type: "lengthRange", max: 20}
        ]},
        {name: "title", title: "Job title", titleVAlign:"bottom", validators: [
            {type: "lengthRange", max: 40}
        ]},
        {name: "url", title: "URL", titleVAlign:"bottom", validators: [
            {type: "lengthRange", max: 100}
        ]},
        {name: "password", title: "Password", required: true, type: "password", titleVAlign:"bottom", validators: [
            {type: "matchesField", otherField: "password2", errorMessage: "Passwords don't match"},
            {type: "lengthRange", max: 32}
        ]},
        {name: "password2", title: "Password again", required: true, type: "password", titleVAlign:"bottom", validators: [
            {type: "matchesField", otherField: "password", errorMessage: "Passwords don't match"},
            {type: "lengthRange", max: 32}
        ]},
        {name: "accept", title: "<nobr>I accept the terms of the "
         +"<a href='/licenses/isc_www_license.html' target='_blank'>Software License Agreement</a></nobr>",
         showTitle:false,
         type: "checkbox", colSpan: "*", width: "*", titleVAlign:"bottom", validators: [
            {type: "custom", errorMessage: "You must check the box to accept the terms of the License Agreement",
             condition: function (item, validator, value) {
                if (value != true) return false;
                return true;
            }}
         ]
        },
        {name: "register", title: "Register", type: "button", height: 26, click: "this.form.register()"}
    ],

    register : function () {
        if (!this.validate()) return false;

        this.getField("register").disable();
        var accountData = this.getValues();

        isc.DMI.call({
            appID: "devCenterOperations",
            className: "registration",
            methodName: "createAccount",
            arguments: [accountData],
            callback : this.getID()+".createAccountCallback(data)"
        });
    },

    createAccountCallback : function (data) {
        if (isc.isAn.Object(data)) {
            delete data.recordPath;
            this.setErrors(data, true);
            this.getField("register").enable();
            return;
        }

        if (window.urchinTracker) urchinTracker("/newUserRegistered");
        this.accountCreated(data);
    },
    
    accountCreated: "url"
});

isc.RegistrationForm.registerStringMethods("accountCreated");

