/**
 * @author Harry
 */
function replaceDiv (ID, text) {
    document.getElementById('replacement').innerHTML = document.getElementById('Div' + ID).innerHTML;
    document.getElementById("titleBarDiv").innerHTML = text;
    MyDialog.showDialog('link'+ID);
}

function Passed() {
    var msg = "Thank you for taking the time to share your secret sauce.&nbsp; Check back soon to see your recipe for success along with those of others in our community.<br/><br/>My BEST Always,<br/><br/>Lee J. Colan";
    document.getElementById('sauceForm').innerHTML = "<p style='margin: 10px;'>" + msg + "</p>";
}

Screen = function(){
        var layout;
        return {
            init : function(){
				Ext.QuickTips.init();

				// turn on validation errors beside the field globally
				Ext.form.Field.prototype.msgTarget = 'under';

				/*
				* ================  Build the screen  =======================
				*/
			    var simple = new Ext.form.Form({
			        id: 'secretForm',
			        method: 'post',
			        labelWidth: 100, // label settings here cascade unless overridden
			        labelAlign: 'right',
			        url:'sauce_exec.asp'
			    });
			  
			    simple.add(
			        new Ext.form.TextField({
			            fieldLabel: 'First Name',
			            name: 'FirstName',
			            width:250,
			            maxlength: 30,
			            allowBlank:false
			        }),

			        new Ext.form.TextField({
			            fieldLabel: 'Last Name',
			            name: 'LastName',
			            width:250,
			            maxlength: 30,
			            allowBlank:false
			        }),
			        
			        new Ext.form.TextField({
			            fieldLabel: 'Email',
			            name: 'Email',
			            vtype:'email',
			            width:250,
			            maxlength: 50,
			            allowBlank:false,
						disableKeyFilter:true
			        }),
			        
			        new Ext.form.TextField({
			            fieldLabel: 'Company',
			            name: 'Company',
			            width:250,
			            maxlength: 50,
			            allowBlank:false
			        }),
			        
			        new Ext.form.TextField({
			            fieldLabel: 'Position',
			            name: 'CompanyPosition',
			            width:250,
			            maxlength: 50,
			            allowBlank:false
			        }),
			        
			        new Ext.form.TextField({
			            fieldLabel: 'Name of Your Secret Sauce',
			            name: 'Title',
			            width:250,
			            maxlength: 50,
			            allowBlank:false
			        }),
			        
			        new Ext.form.TextArea({
			            fieldLabel: 'Recipe for Success',
			            name: 'Sauce',
			            width:250,
			            grow: true,
			            allowBlank:false
			        })
			    );
			    
			    simple.addButton('Save', function(){
				    simple.submit({
					    waitMsg:'Please Wait...',
					    reset:true,
					    scope:simple,
					    success:function(){
                            Passed();
		                }
				    });
			    }, simple);
			    
			    simple.addButton('Cancel', function (){
			        simple.reset();
			    });

			    simple.render('sauceForm');
			}
     };
       
}();

var MyDialog = function(){
    var dialog, showBtn;
    
    // return a public interface
    return {
        showDialog : function(link){           
            if(!dialog){ // lazy initialize the dialog and only create it once
                dialog = new Ext.BasicDialog("container-dlg", { 
                        autoTabs:true,
                        width:640,
                        height:480,
                        shadow:true,
                        minWidth:640,
                        minHeight:480,
                        proxyDrag: true
                });
                dialog.addKeyListener(27, dialog.hide, dialog);
                dialog.addButton('Close', dialog.hide, dialog);
            }
            showBtn = Ext.get(link);
            dialog.show(showBtn.dom);
        }
    };
}();

//Ext.EventManager.onDocumentReady(Screen.init, Screen, true);
