Ext.onReady(function(){

    var Confirm = Ext.extend(Ext.form.Checkbox, {
        initComponent: function(){
            Confirm.superclass.initComponent.call(this);
        },
        validate: function(){
            if(!this.disabled){
                if (this.checked) {
                    Ext.form.Field.prototype.clearInvalid.call(this); // use implementation from Field as function is deactivated for Checkbox
                }
                else {
                    Ext.form.Field.prototype.markInvalid.call(this, 'You cannot proceed without confirmation of scholarship application.');  // use implementation from Field as function is deactivated for Checkbox
                    Ext.MessageBox.alert('Invalid', 'You cannot proceed without confirmation of scholarship application.');
                    this.focus();
                    return false;
                }
            }
            return true;
        }
    })
    
    Ext.reg('quiz.confirm', Confirm);
    
    var Question = Ext.extend(Ext.form.RadioGroup, {
        allowBlank: false,
        labelStyle: 'font-weight: bold;',
        labelSeparator: '',
        defaults: {
             autoWidth: true
        },
        
        initComponent: function(){
            Question.superclass.initComponent.call(this);
            
            this.addEvents({selectionchange: true})
            
            // revalidate radiogroup on selectionchange
            this.on('selectionchange', function(component){
                component.validate();
            });

            // limit radiogroup width if .columns property are array
            if (Ext.isArray(this.columns)) {
                this.width = function(c){
                    return c[0] + (c.length > 1 ? arguments.callee(c.slice(1)) : 0);
                }(this.columns);
            }

            Ext.each(this.items, function(item){ 
                item.name = this.name
            }, this)

            this.on('render', function(component){
               component.items.each(function(item){
                    item.on('check', function(radio, checked){
                        if (checked) {
                            component.fireEvent('selectionchange', component, radio.getRawValue())
                        }
                    })
                })
            })
        }
    })
    
    Ext.reg('quiz.question', Question);
	  
    var ProgramModules = Ext.extend(Ext.form.CheckboxGroup, {
        allowBlank: true,
        hideParent: true,
        labelStyle: 'font-weight: bold; cursor: pointer;',
        labelSeparator: '',
        columns: 1,
        vertical: true,
        defaults: {
             autoWidth: true
        },
        initComponent: function(){
            ProgramModules.superclass.initComponent.call(this);
            this.toogle = function(type){
                set = true;
                this.items.items.each(function(item){
                     set = item.getValue() && set;
                })

                if(set && counter[type].getValue() == 2){
                    this.reset();
                }
                else
                {
                    counter[type].reset();
                    this.items.items.each(function(item){
                        if(!item.disabled){
                            item.setValue(true);
                        }
                    })
                }
            }
        }
    })

    Ext.reg('quiz.program-modules', ProgramModules);
    
    var QuestionYesNo = Ext.extend(Question, {
        columns: [50, 50],
        initComponent: function() {
            this.items = [{
                boxLabel: 'Yes',  
                inputValue: 'yes'
            }, {
                boxLabel: 'No',
                inputValue: 'no'
            }];

            QuestionYesNo.superclass.initComponent.call(this);
        }
    })

    Ext.reg('quiz.question-yesno', QuestionYesNo);
    var QuestionSet = Ext.extend(Ext.form.FieldSet, {
        labelAlign: 'top',
        autoHeight: true,
        baseCls: 'x-fieldset-noborder',
        initComponent: function(){
            QuestionSet.superclass.initComponent.call(this);

            var question = this.getComponent('question'); 

            if (typeof question !== 'undefined') {
                question.on('selectionchange', function(field, value){
                    field.ownerCt.items.each(function(item){
                        if (item === field) {
                            return;
                        }
                        
                        var disabled = item.allowValues.indexOf(value) === -1;

                        item.setVisible(!disabled);
                    })
                 })
            }

            this.on('beforeshow',function(container){
                container.items.each(function(component){
                    if (component.isXType(container.getXType())) {
                        component.setVisible(false)
                    } else if (component.isXType('quiz.question')) {
                        component.reset()
                        component.setDisabled(false)
                    }
                })
            })

            var disabler = function(container){
                container.items.each(function(component){
                    if (component.isXType(container.getXType())) {
                        // recursively call disabler on all child questionsets
                        disabler(component)
                    } else if (component.isXType('quiz.question')) {
                        component.setDisabled(true)
                    }
                })
            };
            this.on('hide', disabler)
        }
    })

    Ext.reg('quiz.questionset', QuestionSet);

    var personalInformation = new Ext.form.FieldSet({
        itemId: 'personalInformation',
        defaults: {
            anchor: '100%',
            allowBlank: false
        },
        baseCls: 'x-fieldset-noborder',
		cls:'personal-information-form',
        labelWidth: 160,
        width: 445,
        autoHeight: true,
        listeners: {
            render: function(){
                this.getEl().mask('Loading');
            }
        },
        items: [{
            xtype: 'combo',
            fieldLabel: 'Title<b>*</b>',
            hiddenName: 'title',
            store: new Ext.data.SimpleStore({
                fields: ['value'],
                data: [['Mr'], ['Ms'], ['Mrs'], ['Mrs'], ['Dr'], ['Miss']]
            }),
            editable: false,
            valueField: 'value',
            displayField: 'value',
            mode: 'local',
            triggerAction: 'all',
            emptyText: 'Select a title',
            selectOnFocus: true
        }, {
            xtype: 'textfield',
            name: 'first_name',
            fieldLabel: 'First Name<b>*</b>',
            maskRe: /[\w0-9\s]/
        }, {
            xtype: 'textfield',
            name: 'surname',
            fieldLabel: 'Surname<b>*</b>',
            maskRe: /[\w0-9\s]/
        }, {
            xtype: 'phone',
            width: 280,
            name: 'contact_number',
            fieldLabel: 'Telephone Number'
        }, {
            xtype: 'combo',
            fieldLabel: 'Country of Residence<b>*</b>',
            hiddenName: 'residenceCountry',
            store: new Ext.data.JsonStore({
                fields: ['code', 'title', 'iso'],
                root: 'countryNames',
                autoLoad: true,
                url: document.baseURI + 'dictionary/countries'
            }),
            editable: false,
            valueField: 'iso',
            displayField: 'title',
            mode: 'local',
            triggerAction: 'all',
            emptyText: 'Select a country',
            selectOnFocus: true
        }, {
            xtype: 'textfield',
            name: 'email',
            fieldLabel: 'Email<b>*</b>',
            vtype: 'email'
        }, {
            xtype: 'textfield',
            name: 'user_comment',
            fieldLabel: 'Comment',
            allowBlank: true
        }]
    })
    
    var counterItem = function(){}
    
    counterItem.prototype = {
        count:0,
        items:[],
        reset: function(){
            this.items.each(function(el,index){
                el.toggleValue();
            })
        },
        getValue: function(){return this.count},
        setValue: function(checkbox){
            if (checkbox.getValue()){
                this.count += 1;
                this.items.push(checkbox);
            }
            else{
                this.count -= 1;
                this.items.remove(checkbox);
            }
            return this.count;
        }
    }

    var counter = {
    	'MBA': new counterItem(),
    	'MSc_in_Finance': new counterItem(),
    	'MSc_in_Marketing': new counterItem(),
        'Dual_Mba': new counterItem(),
        'Dual_MSCF': new counterItem()
    };
    
    function getModuleElement(el, type) {
    	var items = [];
    	for(var i = 0; i < el.items.length; i++)
    	{
    		items.push( {
    			boxLabel: el.items[i], 
    			name: type + '[' + el.items[i] + (el.sub ? el.sub : '') + ']',
                        disabled: el.disabled && el.disabled[i] ? true : false,
    			listeners: {
    				'check': function(checkbox, value){
    					if (counter[type].setValue(checkbox) > 2) {
    						Ext.Msg.alert('', 'You can only select two electives');
    						checkbox.setValue(false);
    					}
    				}
    			}
    		});
    	}
    	
    	return new Ext.form.FieldSet({
		    defaults: {
		        anchor: '100%',
		        allowBlank: true
		    },
		    //labelAlign: 'top',
		    baseCls: 'x-fieldset-noborder',
                    autoWidth: true,
		    autoHeight: true,
		    items: [{
                        id: type +'_'+ (el.title.replace(/ /g,'_')),
                        fieldLabel : '<span class="program-modules-header" onclick="Ext.getCmp(\''+ type +'_'+ (el.title.replace(/ /g,'_')) +'\').toogle(\''+ type +'\')">' + el.title + '</span>',
                        xtype: 'quiz.program-modules',
                        items: items
                    }]
    	})
    }
    
    
    
    function modulesLineBuildProcess(type, elements, line){
        var i = line;
        var result = [];
        Ext.each(
        	elements, 
        	function(item){
        		if (i = !i)
                            this.push(getModuleElement(item, type))
        	},
        	result 
    	);
        return result;
    }
    
    var MBAModules1 = modulesLineBuildProcess('MBA',InterActive.applicationForm.Data.Modules.mbaModules,0);
    var MBAModules2 = modulesLineBuildProcess('MBA',InterActive.applicationForm.Data.Modules.mbaModules,1);
    var MSCinFinanceModules1 = modulesLineBuildProcess('MSc_in_Finance',InterActive.applicationForm.Data.Modules.MSCinFinance,0);
    var MSCinFinanceModules2 = modulesLineBuildProcess('MSc_in_Finance',InterActive.applicationForm.Data.Modules.MSCinFinance,1);
    var MSCinMarketingModules1 = modulesLineBuildProcess('MSc_in_Marketing',InterActive.applicationForm.Data.Modules.MSCinMarketing,0);
    var MSCinMarketingModules2 = modulesLineBuildProcess('MSc_in_Marketing',InterActive.applicationForm.Data.Modules.MSCinMarketing,1);
    var DualMBAModules1 = modulesLineBuildProcess('Dual_Mba',InterActive.applicationForm.Data.Modules.dualMbaModules,0);
    var DualMSCFModules1 = modulesLineBuildProcess('Dual_MSCF',InterActive.applicationForm.Data.Modules.dualMSCFModules,0);


    var Program = new Ext.form.FieldSet({
        defaults: {
            anchor: '100%',
            allowBlank: false
        },
		id: 'program-panel',
        baseCls: 'x-fieldset-noborder',
        width: 445,
        labelWidth: 160,
        autoHeight: true,
        items: [{
            xtype: 'combo',
            id: 'programme-select-box',
            fieldLabel: 'Program<b>*</b>',
            hiddenName: 'programme',
            allowBlank: false,
            labelStyle: 'font-weight: bold;',
            labelSeparator: '',
            store: new Ext.data.SimpleStore({
                fields: ['value'],
                data: [['MBA'],['Diploma in Business Administration'],['Certificate in Business Administration'],['MSc in Finance'],['Diploma in Finance'],['Certificate in Finance'],['MSc in Marketing'],['Diploma in Marketing'],['Certificate in Marketing'], ['ACCA + MBA in Financial Management'], ['CIMA + MBA in Financial Management'], ['ACCA + MSc in Finance & Accounting'], ['CIMA + MSc in Finance & Accounting']]
            }),
            mode: 'local',
            triggerAction: 'all',
            emptyText: 'Select a program',
            editable: false,
            valueField: 'value',
            displayField: 'value',
            selectOnFocus: true,
            listeners: {
        		'select': function (combo){
                                                record = this.getValue();
//                                                Ext.getDom('programme-placeholder').innerHTML = record;
				        	Ext.getCmp('mba').hide();Ext.getCmp('mba').disable();
				    		Ext.getCmp('mscf').hide();Ext.getCmp('mscf').disable();
				    		Ext.getCmp('mscm').hide();Ext.getCmp('mscm').disable();
				    		Ext.getCmp('dualMba').hide();Ext.getCmp('dualMba').disable();
				    		Ext.getCmp('dualMSCF').hide();Ext.getCmp('dualMSCF').disable();
				    		Ext.getCmp('dualMbaPapers').hide();Ext.getCmp('dualMbaPapers').disable();
				    		Ext.getCmp('dualMSCFPapers').hide();Ext.getCmp('dualMSCFPapers').disable();
			    			Ext.getCmp('mbaCore').hide();
			    			Ext.getCmp('mbaCoreShort').hide();
			    			Ext.getCmp('mscfCore').hide();
			    			Ext.getCmp('mscmCore').hide();
			    			Ext.getCmp('electives').show();
                                                Ext.getCmp('confirm_scolarship_fieldset').hide();
                                                Ext.getCmp('confirm_scolarship').disable();
                                                
                                                switch(record){
                                                    case 'MBA' :
                                                    case 'Diploma in Business Administration'  :
                                                            Ext.getCmp('mbaCore').show();Ext.getCmp('mba').enable();Ext.getCmp('mba').show();
                                                    break;
                                                    
                                                    case 'Certificate in Business Administration' :
                                                            Ext.getCmp('mbaCoreShort').show();Ext.getCmp('electives').hide();
                                                    break;
                                                    
                                                    case 'MSc in Finance':
                                                    case 'Diploma in Finance':
                                                            Ext.getCmp('mscfCore').show();Ext.getCmp('mscf').enable();Ext.getCmp('mscf').show();
                                                    break;
                                                    
                                                    case 'Certificate in Finance':
                                                            Ext.getCmp('mscfCore').show();Ext.getCmp('electives').hide();
                                                    break;
                                                    
                                                    case 'MSc in Marketing':
                                                    case 'Diploma in Marketing':
                                                            Ext.getCmp('mscmCore').show();Ext.getCmp('mscm').enable();Ext.getCmp('mscm').show();
                                                    break;
                                                    
                                                    case 'Certificate in Marketing':
                                                            Ext.getCmp('mscmCore').show();Ext.getCmp('electives').hide();
                                                    break;
                                                    //, ['ACCA + MBA in Financial Management'], ['CIMA + MBA in Financial Management'], ['ACCA + MSc in Finance & Accounting'], ['CIMA + MSc in Finance & Accounting']
                                                    case 'ACCA + MBA in Financial Management':
                                                        Ext.getCmp('confirm_scolarship').enable();Ext.getCmp('confirm_scolarship_fieldset').show();Ext.getCmp('confirm_scolarship').labelEl.update('I confirm I am applying for the ACCA MBA in Financial Management scholarship.');
                                                        
                                                        Ext.getCmp('mbaCore').show();Ext.getCmp('dualMba').enable();Ext.getCmp('dualMba').show();Ext.getCmp('dualMbaPapers').enable();Ext.getCmp('dualMbaPapers').show();
                                                    break;
                                                    
                                                    case 'CIMA + MBA in Financial Management':
                                                        Ext.getCmp('confirm_scolarship').enable();Ext.getCmp('confirm_scolarship_fieldset').show();Ext.getCmp('confirm_scolarship').labelEl.update('I confirm I am applying for the CIMA MBA in Financial Management scholarship.');
                                                        
                                                        Ext.getCmp('mbaCore').show();Ext.getCmp('dualMba').enable();Ext.getCmp('dualMba').show();Ext.getCmp('dualMSCFPapers').enable();Ext.getCmp('dualMSCFPapers').show();
                                                    break;
                                                    
                                                    case 'ACCA + MSc in Finance & Accounting':
                                                        Ext.getCmp('confirm_scolarship').enable();Ext.getCmp('confirm_scolarship_fieldset').show();Ext.getCmp('confirm_scolarship').labelEl.update('I confirm I am applying for the ACCA + MSc in Finance and Accounting scholarship.');
                                                        Ext.getCmp('mscfCore').show();Ext.getCmp('dualMSCF').enable();Ext.getCmp('dualMSCF').show();Ext.getCmp('dualMbaPapers').enable();Ext.getCmp('dualMbaPapers').show();
                                                    break;
                                                    
                                                    case 'CIMA + MSc in Finance & Accounting':
                                                        Ext.getCmp('confirm_scolarship').enable();Ext.getCmp('confirm_scolarship_fieldset').show();Ext.getCmp('confirm_scolarship').labelEl.update('I confirm I am applying for the CIMA + MSc in Finance and Accounting scholarship.');
                                                        Ext.getCmp('mscfCore').show();Ext.getCmp('dualMSCF').enable();Ext.getCmp('dualMSCF').show();Ext.getCmp('dualMSCFPapers').enable();Ext.getCmp('dualMSCFPapers').show();
                                                    break;
                                                }
				    	}
        	}	
        }]
    })
    var ProgramPapers = new Ext.form.FieldSet({
        defaults: {
            anchor: '100%',
            allowBlank: false
        },
        baseCls: 'x-fieldset-noborder',
        cls:'program-modules-wraper',
        autoHeight: true,
        items: [new Ext.form.FieldSet({
		        defaults: {
		            anchor: '100%',
		            allowBlank: false
		        },
		        baseCls: 'x-fieldset-noborder',
		        autoHeight: true,
		        items: [
		                new Ext.Panel({
		        			id: 'mba',
		        			layout: 'column',
		                	items: [{items: MBAModules1, style: 'padding:0 10px 0 0;', columnWidth: .50},
		                	        {items: MBAModules2, columnWidth: .50}],
		                	hidden: true,
				        	disabled: true
		                }),
		                new Ext.Panel({
		        			id: 'mscf',
		        			layout: 'column',
		                	items: [{items: MSCinFinanceModules1, style: 'padding:0 10px 0 0;', columnWidth: .50},
		                	        {items: MSCinFinanceModules2, columnWidth: .50}],
		                	hidden: true,
				        	disabled: true
		                }),
		                new Ext.Panel({
		        			id: 'mscm',
		        			layout: 'column',
		                	items: [{items: MSCinMarketingModules1, style: 'padding:0 10px 0 0;', columnWidth: .50},
		                	        {items: MSCinMarketingModules2, columnWidth: .50}],
		                	hidden: true,
				        	disabled: true
		                }),
		                new Ext.Panel({
		        			id: 'dualMba',
		        			layout: 'column',
		                	items: [{items: DualMBAModules1, style: 'padding:0 10px 0 0;'}],
		                	hidden: true,
				        	disabled: true
		                }),
		                new Ext.Panel({
		        			id: 'dualMSCF',
		        			layout: 'column',
		                	items: [{items: DualMSCFModules1, style: 'padding:0 10px 0 0;'}],
		                	hidden: true,
				        	disabled: true
		                })]
			    })]
    });
    
    var ProgramPapers = new Ext.form.FieldSet({
                defaults: {
                    anchor: '100%',
                    allowBlank: false
                },
                baseCls: 'x-fieldset-noborder',
                cls:'program-modules-wraper',
                autoHeight: true,
                autoWidth: false,
                items: [
                    new Ext.Panel({
                        id: 'dualMbaPapers',
                        disabled: true,
                        autoWidth: false,
                        items: [{
                            xtype: 'label',
                            html: '<h3 class="electives-modules">ACCA Core Modules <br />Please select the ACCA modules to study:</h3><br />'
                        },
                        {
                            xtype: 'appstep.papers',
                            width: 400,
                            Columns: 6,
                            fieldNameFormat: 'papers[%paper%]',
                            Papers: InterActive.applicationForm.Data.Papers.ACCA
                        }
                        ]
                    }),
                    new Ext.Panel({
                        id: 'dualMSCFPapers',
                        disabled: true,
                        autoWidth: false,
                        items: [{
                            xtype: 'label',
                            html: '<h3 class="electives-modules">CIMA Core Modules <br />Please select the CIMA modules to study:</h3><br />'
                        },
                        {
                            xtype: 'appstep.papers',
                            width: 400,
                            Columns: 6,
                            fieldNameFormat: 'papers[%paper%]',
                            Papers: InterActive.applicationForm.Data.Papers.CIMA
                        }
                        ]
                    }),
                    new Ext.form.FieldSet({
                        defaults: {
                            anchor: '100%',
                            allowBlank: true
                        },
                        baseCls: 'x-fieldset-noborder',
                        autoWidth: false,
                        id: "confirm_scolarship_fieldset",
                        width: 800,
                        hidden: true,
                        style: "padding-top: 10px;",
                        autoHeight: true,
                        layout: 'column',
                        items: [
                            {xtype: 'quiz.confirm', boxLabel: 'I confirm I am applying for the CIMA + MSc in Finance and Accounting scholarship.', name: 'apply', id: "confirm_scolarship", disabled: true}
                        ]
                    })
                ]
            });
    
    var ProgramModules = new Ext.form.FieldSet({
        defaults: {
            anchor: '100%',
            allowBlank: false
        },
        baseCls: 'x-fieldset-noborder',
        cls:'program-modules-wraper',
        autoHeight: true,
        items: [new Ext.form.FieldSet({
		        defaults: {
		            anchor: '100%',
		            allowBlank: false
		        },
		        baseCls: 'x-fieldset-noborder',
		        autoHeight: true,
		        items: [
		                new Ext.Panel({
		        			id: 'mba',
		        			layout: 'column',
		                	items: [{items: MBAModules1, style: 'padding:0 10px 0 0;', columnWidth: .50},
		                	        {items: MBAModules2, columnWidth: .50}],
		                	hidden: true,
				        	disabled: true
		                }),
		                new Ext.Panel({
		        			id: 'mscf',
		        			layout: 'column',
		                	items: [{items: MSCinFinanceModules1, style: 'padding:0 10px 0 0;', columnWidth: .50},
		                	        {items: MSCinFinanceModules2, columnWidth: .50}],
		                	hidden: true,
				        	disabled: true
		                }),
		                new Ext.Panel({
		        			id: 'mscm',
		        			layout: 'column',
		                	items: [{items: MSCinMarketingModules1, style: 'padding:0 10px 0 0;', columnWidth: .50},
		                	        {items: MSCinMarketingModules2, columnWidth: .50}],
		                	hidden: true,
				        	disabled: true
		                }),
		                new Ext.Panel({
		        			id: 'dualMba',
		        			layout: 'column',
		                	items: [{items: DualMBAModules1, style: 'padding:0 10px 0 0;'}],
		                	hidden: true,
				        	disabled: true
		                }),
		                new Ext.Panel({
		        			id: 'dualMSCF',
		        			layout: 'column',
		                	items: [{items: DualMSCFModules1, style: 'padding:0 10px 0 0;'}],
		                	hidden: true,
				        	disabled: true
		                })]
			    })]
    })

    var Quiz = Ext.extend(Ext.form.FormPanel, {
        buttonAlign: 'left',
        buttons: [{
            text: 'Submit',
            handler: function(button){
                var form = button.ownerCt.getForm();
                if (form.isValid()) {
                    form.submit({
                        method: 'POST',
                        url: document.baseURI + 'applicationprocess/verify',
                        success: function(form, action){
                            _gaq.push(['_trackPageview','/dashboard-thank-you']);
                            document.location = 'http://www.studyinteractive.org/thank-you/';
                        }
                    })
                    
                    return;
                }
            }
        }],
        initComponent: function(){
            Quiz.superclass.initComponent.call(this);
            
            this.add( {
                xtype: 'label',
                html: '<h1>Application Process</h1>'
                    + '<div id="app-text"><div>Thank you for your interest in the online postgraduate programmes provided by the London School of Business and Finance powered by InterActive.</div> \n\
                        <div>In order to be considered for one of our postgraduate programmes please complete and submit the form below filling all the required fields.  One of our dedicated consultants will be contacting you within 24 business hours providing you with detailed information about the programme and guiding you through the whole application process. </div>\n\
                        <div>Note that fields marked with * <i>must</i> be filled in.</div></div><br>'
            },
            Program,
            {
                cls:'core-modules',
                hidden:true,
                items:[
                {
                    xtype: 'appstep.core-modules',
                    id: 'mbaCore',
                    Modules: InterActive.applicationForm.Data.CoreModules.MBACoreModules
                },
                {
                    xtype: 'appstep.core-modules',
                    id: 'mbaCoreShort',
                    Modules: InterActive.applicationForm.Data.CoreModules.MBACoreModulesShort
                },
                {
                    xtype: 'appstep.core-modules',
                    id: 'mscfCore',
                    Modules: InterActive.applicationForm.Data.CoreModules.MSCinFinanceCoreModules
                },
                {
                    xtype: 'appstep.core-modules',
                    id: 'mscmCore',
                    Modules: InterActive.applicationForm.Data.CoreModules.MSCinMarketingCoreModules
                },
                {
                    id:'electives',
                    hidden: true,
                    items:[{
                        xtype: 'label',
                        html: '<h3 style="padding-bottom: 5px;">Electives Modules:</h3>'
                    },{
                        xtype: 'label',
                        html: '<h3 style="padding-bottom: 10px;">Please choose the electives modules you would like to study:</h3>'
                    }]
                }]
            },
            //ProgramModules,
            //ProgramPapers,
            {
                xtype: 'label',
                html: '<h4 class="personal-information-header"><div>Personal Information</div></h4>'
            }, 
            personalInformation, 
            {
                xtype: 'label',
                html: '<div id="data-protection">'
                     + '<h4>Data Protection</h4>'
                     + '<div>We are committed to protecting the privacy of your personal information, which will be processed in a manner which meets the requirements of the 1998 Data Protection Act. The information we collect on this form will be used with the sole purpose of processing your application and contacting you with relevant information about the programme of your choice. Please note: This application does not guarantee admission.</div>'
                     + '</div>'
            });

            var callback = function(form) {
                form.clearInvalid();
                
                var c = this.getComponent('personalInformation');
                var unmask = function(){
                    c.getEl().unmask();
                }
                
                if (c.rendered) {
                    unmask();
                } else {
                    c.on('render', unmask);
                }
            }

            this.load({
                url: document.baseURI + 'applicationprocess/form',
                method: 'POST',
                success: callback,
                failure: callback,
                scope: this
            })
        }
    });
    
    new Quiz({
        id: 'debug',
        renderTo: 'quiz-form'
    });
    
    Ext.onReady(function(){
        Ext.getCmp('dualMSCFPapers').hide();
        Ext.getCmp('dualMbaPapers').hide();
    });
});

    

