Ext.BLANK_IMAGE_URL = 'lib/ext/resources/images/default/s.gif';

var viewport;
Ext.onReady(function(){

	viewport = new Ext.Viewport( {
	  	layout: 'border',
		  items:[ {
		        "region": 'north',
		        "contentEl": 'north',
				"split": false,
				"height": 45, 
				"titlebar": false,
				"baseCls": 'x-panel-header'
		    }, {
		        "region": 'south',
		        "contentEl": 'south',
				"split": false,
				"initialSize": 30,
				"titleBar": false,
				"collapsible": true,
				"baseCls": 'x-panel-footer'
		    }, {
		        "region": 'west',
		        "contentEl": 'west',
				"split": false,
				"width": 150,
				"titlebar": false,
				"collapsible": false,
				"baseCls": 'x-panel-bbar'
		    }, new Ext.Panel({
				"region": 'center',
		        "id": 'center-panel',
		        "layout": 'card',
		        "activeItem": 0,
		        "bodyStyle": 'padding:10px',
		        "baseCls": 'x-panel-body',
				defaults: {
					"split": false,
					"autoScroll": true,
					"titlebar": false,
					"collapsible": false
		    	},
		    	items: [{
					"id": 'cp1',
					"html": "<div id=center1> <p> The Syracuse City School District is committed to providing a safe, civil and orderly school environment where students will receive and district personnel will deliver quality educational services without disruption or interference.  Responsible behavior by students, teachers, other district personnel, parents, and other visitors is essential to achieving this goal. </p><p> Mounting issues related to student behavior and school safety are of concern to the entire Central New York community.  Likewise, resolving such issues will rely on the collaborative efforts of the school district, city residents, local government, law enforcement, community based organizations, social service agencies, higher educatoin institutions, faith-based organizations, and businesses.  With this in mind, the Board of Education invited a broad range of more than 180 community representatives to serve on the Community-Wide Behavior Committee in the spring of 2006.</p><p> A testament to their commitment to high quality education and the City\'s vitality, more than 90 concerned stakeholders attended the first meeting in February 2006.The committee was charged with reviewing all facets of student behavior and adult interventions, and presenting to the Board of Education a series of recommendations that promote positive behavior in our schools and surrounding community.</p><hr /><h1>RECOMMENDATIONS</h1><ol><li>Research, identify, implement and evaluate methods to enhance adult commitment to behavior and discipline and to increase parent presence in school through innovative maeans, such as social events.</li><li>Collaborate with community based partners, businesses and institutions of higher learning to offer high quality, intensive and sustained professional development.</li><li>Review, reevaluate, revise, and consistently enforce the Code of Conduct and SAVE policy.</li><li>Develop and implement strategies and procedures to hold administration, staff, parents, and students accountable for behavior and discipline.</li><li>Establish a concise list of understandable, non-negotiable rules of behavior, translated into as many languages as necessary, and use a variety of media to disseminate the rules.</li><li>Research, identify, consistently implement, and evaluate effective alternative programs and strategies at all grade levels.</li><li>Establish early intervention programs for families and students who are experiencing behavior and/or attendence issues in grades PreK - 5.</li><li>Educate the \'whole\' child, teaching life and social skills through consistent and comprehensive implementation of research-based, effective programs.</li><li>Explore the feasibility of establishing and scheduling time for enhanced collegial interaction among teachers and other professional staff.</li><li>Provide adequate resources to support all behavior-related programs and initiatives.</li></ol><hr /><p>This survey is designed to monitor the progress of the recommendations from the Community-wide Behavior Committee.  The information will be shared with the Superintendent of Schools, the Board of Education, and the Committee. </p><p> Do not write your name on the survey.  The answers you give will be kept confidential.</p><p> Please fill out the survey online here, or print and return to Jaime Alicea, Deputy Superintendent for Operations and Business, Central Offices.</p><p> Thank you for your assistance. </p><button class=x-btn id=loadSurvey>Continue to Survey</button></div>"
					}, {
					"id": 'cp2',
					"html": "<div id=center2><p>ALL fields are required except the additional comments!</p></div>"		
					}, {
					  "id": 'cp3',
					  "html": "<div id=center3><p>Thank you for filling out the survey.  Your response is greatly appreciated!</p></div>"
					}
					
				]
			})]
	}); 
	Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

    var fs = new Ext.FormPanel({
        frame: true,
        title:'Behavior Survey',
        labelAlign: 'top',
        width: '95%',
		waitMsgTarget: true,
        items: [    
					new Ext.form.ComboBox({
                    fieldLabel: 'Building',
                    hiddenName:'building',
                    width: '95%',
                    store: new Ext.data.SimpleStore({
                        fields: ['location', 'building'],
                        data : SCSD.buildings
                    }),
                    valueField:'location',
                    displayField:'building',
                    typeAhead: true,
                    mode: 'local',
                    allowBlank: false,
                    triggerAction: 'all',
                    emptyText:'Select a building...',
                    selectOnFocus:true
                }), {
					xtype:'ux-radiogroup',
					fieldLabel: '1. How long have you been teaching?',
					name:'q1',
                    allowBlank: false,
					horizontal: true,
					radios: [{
						value: 1,
						boxLabel:'1st year'
					}, {
						value: 2,
						boxLabel:'2 - 5 years'
					}, {
						value: 3,
						boxLabel:'6 - 10 years'	
					}, {
						value: 4,
						boxLabel:'11 - 15 years'	
					}, {
						value: 5,
						boxLabel:'16-20 years'	
					}, {
					  	value: 6,
					  	boxLabel: '20 or more years'
					}]
				}, {
					xtype:'ux-radiogroup',
					fieldLabel: '2. Gender',
					name:'q2',
                    allowBlank: false,
					horizontal: true,
					radios: [{
						value: 1,
						boxLabel:'Female'
					}, {
						value: 2,
						boxLabel:'Male'
					}]
				}, {
					xtype:'ux-radiogroup',
					fieldLabel: '3. I am a(n)',
					name:'q3',
					horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Classroom Teacher'
					}, {
						value: 2,
						boxLabel:'Teaching Assistant'
					}, {
						value: 3,
						boxLabel:'Certified Staff (Other than a classroom teacher)'	
					}, {
						value: 4,
						boxLabel:'Administrator'	
					}]
				}, {
					xtype:'ux-radiogroup',
					fieldLabel: '4. I am knowledgeable of the recommendations of the community-wide behavior committee.',
					name:'q4',
					horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Yes'
					}, {
						value: 2,
						boxLabel:'No'
					}]
				}, new Ext.form.FieldSet({
	                title: '5. The student behavior has improved in the building / district during the past year.',
	                autoHeight: true,
	                defaultType: 'ux-radiogroup',
	                items: [{
						fieldLabel: 'a. Building',
						name:'q5a',
						horizontal: true,
                    	allowBlank: false,
						radios: [{
							value: 1,
							boxLabel:'Yes'
						}, {
							value: 2,
							boxLabel:'No'
						}]
					}, {
						fieldLabel: 'b. District',
						name:'q5b',
						horizontal: true,
                    	allowBlank: false,
						radios: [{
							value: 1,
							boxLabel:'Yes'
						}, {
							value: 2,
							boxLabel:'No'
						}]
					}]
	            }),  {
					xtype:'ux-radiogroup',
					fieldLabel: '6. I have a written Class Discipline Plan with clearly defined expectations and consequences for my classroom.',
					name:'q6',
					horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Yes'
					}, {
						value: 2,
						boxLabel:'No'
					}]
				}, {
					xtype:'ux-radiogroup',
					fieldLabel: '7. The parents of the students in my classroom are aware of the Discipline Plan.',
					name:'q7',
					horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Yes'
					}, {
						value: 2,
						boxLabel:'No'
					}]
				}, {
					xtype:'ux-radiogroup',
					fieldLabel: '8. Do you have an active Behavior and Discipline Team in your building? (Contractual Item)',
					name:'q8',
					horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Yes'
					}, {
						value: 2,
						boxLabel:'No'
					}]
				}, {
					xtype:'ux-radiogroup',
					fieldLabel: '9. The team developed a School-wide Behavior Plan',
					name:'q9',
					horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Yes'
					}, {
						value: 2,
						boxLabel:'No'
					}]
				}, {
					xtype:'ux-radiogroup',
					fieldLabel: '10. The plan was communicated to ALL staff members.',
					name:'q10',
					horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Yes'
					}, {
						value: 2,
						boxLabel:'No'
					}]
				}, {
					xtype:'ux-radiogroup',
					fieldLabel: '11. Is the plan being implemented by ALL staff members?',
					name:'q11',
					horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Yes'
					}, {
						value: 2,
						boxLabel:'No'
					}]
				}, {
					xtype:'ux-radiogroup',
					fieldLabel: '12. The students are aware of the school-wide behavior plan.',
					name:'q12',
					horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Yes'
					}, {
						value: 2,
						boxLabel:'No'
					}]
				}, {
					xtype:'ux-radiogroup',
					fieldLabel: '13. The parents are aware of the school-wide behavior plan.',
					name:'q13',
					horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Yes'
					}, {
						value: 2,
						boxLabel:'No'
					}]
				}, new Ext.form.FieldSet({
	                title: '14. How was the school-wide behavior policy communicated to:',
					autoHeight: true,
	                defaultType: 'textfield',
	                items: [{
						fieldLabel: 'a. Staff',
                    	name: 'q14a',
                    	allowBlank: false,
                    	width: '95%'
					}, {
						fieldLabel: 'b. Students',
                    	name: 'q14b',
                    	allowBlank: false,
                    	width: '95%'
					}, {
						fieldLabel: 'c. Parents',
                    	name: 'q14c',
                    	allowBlank: false,
                    	width: '95%'
					}]
	            }), {
					xtype:'ux-radiogroup',
					fieldLabel: '15. Number of students in your class(es) with serious behavior problems this year',
					name:'q15',
					horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'1'
					}, {
						value: 2,
						boxLabel:'2'
					}, {
						value: 3,
						boxLabel:'3'	
					}, {
						value: 4,
						boxLabel:'4'	
					}, {
						value: 5,
						boxLabel:'5 or more'	
					}]
				} , {
                    xtype: 'numberfield',
					labelAlign: 'right',
					fieldLabel: '16. How many students do you have this year?',
                    name: 'q16',
                    allowBlank: false,
                    allowDecimals: false,
                    minValue: 0,
                    width: '95%'
                }, {
                    xtype: 'ux-radiogroup',
					fieldLabel: '17a. I have changed my behavior management approach this year.',
                    name: 'q17a',
                    horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Yes'
					}, {
						value: 2,
						boxLabel:'No'
					}]
                }, {
                    xtype: 'textarea',
					fieldLabel: '17b. Please comment about the reason',
                    name: 'q17b',
                    allowBlank: true,
                    width: '95%'
                }, {
                    xtype: 'ux-radiogroup',
					fieldLabel: '18. I am satisfied with my own classroom and behavior management skills.',
                    name: 'q18',
                    horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Strongly agree'
					}, {
						value: 2,
						boxLabel:'Agree'
					}, {
						value: 3,
						boxLabel:'Disagree'	
					}, {
						value: 4,
						boxLabel:'Strongly Disagree'	
					}]
                }, {
                    xtype: 'ux-radiogroup',
					fieldLabel: '19. Does the staff need more staff development on classroom management?',
                    name: 'q19',
                    horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Yes'
					}, {
						value: 2,
						boxLabel:'No'
					}]
                }, {
                    xtype: 'textarea',
					fieldLabel: '20. Please list your suggestions for staff development.',
                    name: 'q20',
                    allowBlank: false,
                    width: '95%'
                },{
                    xtype: 'ux-radiogroup',
					fieldLabel: '21. Did you complete this survey last year?',
                    name: 'q21',
                    horizontal: true,
                    allowBlank: false,
					radios: [{
						value: 1,
						boxLabel:'Yes'
					}, {
						value: 2,
						boxLabel:'No'
					}]
                }, {
                    xtype: 'textarea',
					fieldLabel: '22. Other Comments:',
                    name: 'q22',
                    width: '95%'
                }
        ]
    });

    // explicit add
    var submit = fs.addButton({
        text: 'Submit',
        handler: function(){
            fs.getForm().submit(
				{
					method: 'POST', 
					waitMsg:'Saving Data...',
					url:'cbcsurvey.php',
					success:function() {
						var cp = Ext.getCmp('center-panel').getLayout().setActiveItem(2);
					},
					failure:function(form,action){
						if(action.failureType == 'server'){
						  obj = Ext.util.JSON.decode(action.response.responseText);
						  Ext.Msg.alert('Ooops!',obj.errors.reason);
						} else {
						  	if (action.failureType == 'client') {
						  		Ext.Msg.alert('Ooops!','Please make sure ALL of the responses are filled in except for the last question, comments.');
						 	}
							else {
						  		Ext. Msg.alert('Ooops!','Please contact Jonathan Mason via e-mail: jmason00@scsd.us to report this problem.');
							}
						}
					}
				});
        }
    });

	
	Ext.get('loadSurvey').on('click',function() {
		var cp = Ext.getCmp('center-panel').getLayout().setActiveItem(1);
		fs.render('center2');
		fs.on({
	        actioncomplete: function(form, action){
	            if(action.type == 'load'){
	                submit.enable();
	            }
	        }
    	});				
	});
});