Ext.namespace('DJIndexes');DJIndexes.ContactForm=function(){var form,_form;var config={debugMode:window.debugMode||false,title:'Historical Performance Data',downloadDiv:'file-download',downloadURL:'./index.cfm?go=historicalDownload',formDiv:'contact-form',formWidth:500,fieldWidth:350,dataStore:[],postURL:'/DataProxy/ContactForm.cfc',hiddenFields:[{name:'type',value:'lead'},{name:'subject',value:'Data request'},{name:'formName',value:'Download Historical Performance Data'},{name:'orgid',value:'00D3000000008RR'}],additionalParams:[{name:'lead_source',value:'web'},{name:'00N60000001ManW',value:'Portfolio Indexes'}],messages:{missing:{email:'Please enter your e-mail address',company:'Please enter your company name',firstname:'Please enter your first name',lastname:'Please enter your last name',title:'Please enter your job title'},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.'}}}};try{var downloadFrame=Ext.getDom(config.downloadDiv);}catch(a){}return{init:function(){Ext.QuickTips.init();Ext.form.Field.prototype.msgTarget='side';this.createDataStores();this.createForm();},createDataStores:function(){},createForm:function(){form=new Ext.form.FormPanel({renderTo:config.formDiv,url:config.postURL,method:'post',baseParams:{method:'webToLead',debug:config.debugMode},frame:true,title:config.title,width:config.formWidth,defaults:{width:config.fieldWidth},items:this.createFormFields(),buttons:this.createButtons()});_form=form.getForm();_form.on('actioncomplete',function(){this.displayMessage(config.messages.submission.success);this.resetForm();this.downloadFile();},this);_form.on('actionfailed',function(){this.displayMessage(config.messages.submission.failure);},this);},createButtons:function(){var buttons=[new Ext.Button({minWidth:80,text:'SEND',type:'submit',scope:this,handler:this.validateForm}),new Ext.Button({minWidth:80,text:'Cancel',type:'reset',scope:this,handler:this.resetForm})];return buttons;},createFormFields:function(){var formFields=[new Ext.form.TextField({fieldLabel:'First Name',name:'first_name',allowBlank:false,blankText:config.messages.missing.firstname}),new Ext.form.TextField({fieldLabel:'Last Name',name:'last_name',allowBlank:false,blankText:config.messages.missing.lastname}),new Ext.form.TextField({fieldLabel:'Email Address',name:'email',vtype:'email',allowBlank:false,blankText:config.messages.missing.email}),new Ext.form.TextField({fieldLabel:'Company',name:'company',allowBlank:false,blankText:config.messages.missing.company}),new Ext.form.TextField({fieldLabel:'Job Title',name:'title',allowBlank:false,blankText:config.messages.missing.title})];var hf=config.hiddenFields;for(var i=0;i<hf.length;i++){formFields.push(new Ext.form.TextField({name:hf[i].name,value:hf[i].value,inputType:'hidden',labelStyle:'display:none;'}));};var ap=config.additionalParams;var apString='';for(var i=0;i<ap.length;i++){apString+=ap[i].name+'='+ap[i].value+'|';}formFields.push(new Ext.form.TextField({name:'params',value:apString,inputType:'hidden',labelStyle:'display:none;'}));return formFields;},validateForm:function(button,e){if(_form.isValid()){_form.submit();}else{Ext.Msg.alert('Missing Data',config.messages.invalid.form);}},resetForm:function(button,e){_form.reset();},displayMessage:function(o){Ext.Msg.alert(o.title,o.message);},downloadFile:function(){top.location=config.downloadURL;},debug:function(){console.debug(arguments);}}}();Ext.onReady(function(){if(!Ext.isEmpty(Ext.get('contact-form'))){try{DJIndexes.ContactForm.init();}catch(err){}}});