Ext.namespace('DJIndexes');DJIndexes.ContactForm=function(){var form;var config={debugMode:window.debugMode||false,formDiv:'contact-form',fieldWidth:350,dataStore:[],postURL:'/DataProxy/ContactForm.cfc',regions:[['asiaPacific','Asia/Pacific'],['europe','Europe'],['latinAmerica','Latin America'],['middleEast','Middle East'],['northAmerica','North America']],subjects:[['benchmark','Benchmarks for a pension plan'],['custom','Custom indexes'],['ftp','Data available via FTP service'],['data','Data requests'],/*['DJRBP','DJ RBP Indexes'],*/['methodologies','Index methodologies and procedures'],['icb','Industry Classification Benchmark (ICB)'],['marketing','Marketing materials'],['realTime','Real time and delayed index data'],['web','Web site related issues'],['other','Other']],messages:{missing:{email:'Please enter your e-mail address',company:'Please enter your company name',name:'Please enter your full name',region:'Please select the region of the world in which you are located',subject:'Please select the subject of this inquiry',description:'Please enter your question or comment'},invalid:{form:'Please complete the information requested in the highlighted fields.',email:'The e-mail address you have entered is not properly formatted.'},submission:{success:{title:'Thank you',message:'Thank you for your inquiry. We will respond to you as soon as possible.'},failure:{title:'An error has occurred',message:'An error occurred while submitting your request, please try again.'}}}};return{init:function(){Ext.QuickTips.init();Ext.QuickTips.enable();this.createDataStore();this.createForm();},createDataStore:function(){config.dataStore['region']=new Ext.data.SimpleStore({fields:['regionId','regionName'],data:config.regions});config.dataStore['subject']=new Ext.data.SimpleStore({fields:['subjectId','subjectName'],data:config.subjects});},createForm:function(){form=new Ext.form.Form({url:config.postURL,method:'post',labelAlign:'right',baseParams:{method:'webToCase',debug:config.debugMode}});form.add(new Ext.form.TextField({name:'formName',value:'DJI Website Inquiry Form',inputType:'hidden',labelStyle:'display:none;'}),new Ext.form.TextField({fieldLabel:'Full Name',name:'name',allowBlank:false,blankText:config.messages.missing.name,width:config.fieldWidth}),new Ext.form.TextField({fieldLabel:'Email Address',name:'email',allowBlank:false,blankText:config.messages.missing.email,width:config.fieldWidth,validator:this.validateEmail,validationDelay:500}),new Ext.form.TextField({fieldLabel:'Company',name:'company',allowBlank:false,blankText:config.messages.missing.company,width:config.fieldWidth}),new Ext.form.ComboBox({fieldLabel:'Region',name:'region',allowBlank:false,blankText:config.messages.missing.region,width:config.fieldWidth,triggerAction:'all',forceSelection:true,store:config.dataStore.region,displayField:'regionName',valueField:'regionName',emptyText:'select one...'}),new Ext.form.ComboBox({fieldLabel:'Subject',name:'subject',allowBlank:false,blankText:config.messages.missing.subject,width:config.fieldWidth,triggerAction:'all',forceSelection:true,store:config.dataStore.subject,displayField:'subjectName',valueField:'subjectName',emptyText:'select one...'}),new Ext.form.TextArea({fieldLabel:'Comments',name:'description',allowBlank:false,blankText:config.messages.missing.description,width:config.fieldWidth,height:100}));form.addButton({text:'SEND',type:'submit',scope:this,handler:this.validateForm});form.addButton({text:'Cancel',type:'reset',scope:this,handler:this.resetForm});form.on('actioncomplete',function(){this.displayMessage(config.messages.submission.success);this.resetForm();},this);form.on('actionfailed',function(){this.displayMessage(config.messages.submission.failure);},this);form.render(config.formDiv);},validateForm:function(){if(form.isValid()){form.submit();}else{Ext.Msg.alert('Missing Data',config.messages.invalid.form);}},validateEmail:function(emailAddress){var emailRE=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;return(emailRE.test(emailAddress))?true:config.messages.invalid.email;},resetForm:function(){form.reset();},displayMessage:function(o){Ext.Msg.alert(o.title,o.message);}}}();Ext.onReady(DJIndexes.ContactForm.init,DJIndexes.ContactForm);