/**
 * @author Kip
 */
// reference local blank image
Ext.BLANK_IMAGE_URL = 'lib/ext/resources/images/default/s.gif';
 
// create namespace
Ext.namespace('jkcrafts');
 
// create application
jkcrafts.listSignUp = function() {
    // do NOT access DOM from here; elements don't exist yet
    
    // private variables
    
    // private functions
    
    // public space
    return {
        // public properties, e.g. strings to translate
	
        // public methods
        show: function() {
	    Ext.QuickTips.init();
	    var form = new Ext.form.FormPanel({
		    baseCls: 'x-plain',
		    labelWidth: 70,
		    url:'http://www.jkcrafts.com/em/form.php?form=2',
		    defaultType: 'textfield',
		    autoHeight: true,
		    autoWidth: true,
		    labelAlign: 'right',
		    shadow: true,
		    
		    items: [{
			    xtype: 'hidden',
			    name: 'format',
			    value: 'h'
			},
	                {
			    xtype: 'fieldset',
			    title: 'Required',
			    autoHeight: true,
			    defaults: {width: 210},
			    defaultType: 'textfield',
			    items: [{
				    fieldLabel: 'Your Email',
				    name: 'email',
				    vtype:'email',
				    allowBlank: false,
				    msgTarget: 'under',       
				    anchor:'100%'
				},{
				    fieldLabel: 'First Name',
				    name: 'CustomFields[1]',
				    allowBlank: false,
				    msgTarget: 'under',       
				    anchor: '100%',
				    height: 25
				}
				    ]
			},{
			    xtype: 'fieldset',
			    title: 'Interests',
			    autoHeight: true,
			    defaults: {width: 210},
			    defaultType: 'textfield',
			    items: [{
				    xtype:'checkbox',
				    inputType: 'checkbox',
				    hideLabel: true,
				    boxLabel: 'New Product Announcements',
				    name: 'd[2]',
				    checked: true,
				    anchor: '100%'        
				},
	    {
		xtype:'checkbox',
		inputType: 'checkbox',
		hideLabel: true,
		boxLabel: 'Coupons and Special Offers',
		name: 'd[3]',
		checked: true,
		anchor: '100%'        
	    }]        
			}
			      ]
		});
	    var window = new Ext.Window({
		    title: 'JK Crafts List - Sign Up',
		    width: 350,
		    autoHeight: true,
		    minWidth: 300,
		    minHeight: 200,
		    layout: 'fit',
		    modal: true,
		    plain:true,
		    bodyStyle:'padding:5px;',
		    buttonAlign:'center',
		    items: form,
		    
		    buttons: [{
			    text: 'Sign Me Up',
			    handler: function() {
				form.getForm().submit({
					failure : function() {
					    Ext.MessageBox.alert('', 'An error occurred, please try again later.');
					}
				    });
			    }
			}]
		});
	    form.on('actioncomplete', function(form, action) {
		    window.close();
		    Ext.MessageBox.alert('', 'Thank you for signing up!<br><br><b>Your not done yet!</b><br><br><b>1.</b> Please check your inbox for an email from us!<br><br><b>2.</b> Click the link in it to finish your signup.<br><br>Thank You!');
		});
	    form.on('actionfailed', function(form, action) {
		    Ext.MessageBox.alert('', 'Please correct any errors shown, then try again.');
		});
	    window.show();
	}
    };
}(); // end of app
 
// end of file
