/**
 * @author santosh
 */

Ext.onReady(function(){
	Ext.QuickTips.init();
	Ext.form.Field.prototype.msgTarget = 'side';
    var form = new Ext.form.FormPanel({
				id: 'GameActiveForm',
				baseCls		: 'winGameActive',
				layout: 'form',
				labelWidth: 150,
				defaults : {
					labelStyle : 'width:180px;color:#FFFFFF'
				},
				items : [
					new Ext.form.Label({
				        border    : false,
						style: 'color:#FFFFFF;font-size:12px',
				        html      : 'We\'re looking for active games and you can help!<br><br>'
				    }),
					new Ext.form.Label({
				        border    : false,
						style: 'color:#FFFFFF;font-weight:normal;font-size:12px',
				        html      : 'We\'re looking for ideas on how kids can get healthy with video games. Are there ways you can use your existing game system to get healthier this year? Or maybe your family is already getting fit with video games. You could even describe a fun evening with friends or family playing games as a group where everyone was able to get involved. We want you to share that story with us.<br><br>'
				    }),
					new Ext.form.Label({
				        border    : false,
						style: 'color:#FFFFFF;font-weight:normal;font-size:12px',
				        html      : 'Tell us about it and you could be featured on our web site! Your idea could inspire people to live healthier longer lives!  Click <a href=http://bkfk.com/GameActive/winners.aspx style="color:white;">here</a> to read our featured Game Active ideas.<br><br><br>'
				    }),
				    new Ext.form.TextField({
						id: 'ga_fName',
				        name       : 'ga_fName',
				        fieldLabel : 'First Name',
						width: 300,
				        allowBlank : false
				    }),
				    new Ext.form.NumberField({
				        name       : 'ga_age',
						id			: 'ga_age',
				        fieldLabel : 'Age',
						width: 300,
				        allowBlank : false
				    }),
				    new Ext.form.TextField({
				        name       : 'ga_pEmail',
						id			: 'ga_pEmail',
				        fieldLabel : 'Parent\'s Email Address',
						vtype: 'email',
						width: 300,
				        allowBlank : false
				    }),
				    new Ext.form.TextArea({
				        name       : 'ga_idea',
						id			: 'ga_idea',
						height	: 70,
						width: 300,
				        fieldLabel : 'What is your idea?',
				        allowBlank : false
				    })]
					
			});

    if (!RS.WinGameActive) {
		RS.WinGameActive = new Ext.Window({
			title: 'Game Active',
			width: 600,
			height: 530,
			closeAction: 'hide',
			minWidth: 300,
			minHeight: 200,
			modal: true,
			layout: 'fit',
			plain: true,
			bodyStyle: 'padding:5px;',
			buttonAlign: 'center',
			items: form,
			
			buttons: [{
				text: 'Submit',
				handler: function(){
            		form.getForm().submit({url:'/sept08/processMisc.aspx', 
						params:{cmd:'collectGameActiveData'}, 
						waitMsg:'Saving Data...',
						success : function(){
							RS.WinGameActive.hide();
							Ext.getCmp('ga_fName').setValue('');
							Ext.getCmp('ga_age').setValue('');
							Ext.getCmp('ga_pEmail').setValue('');
							Ext.getCmp('ga_idea').setValue('');
							Ext.MessageBox.show({
								title: 'Idea Submitted',
		           				msg: 'Thank you for submitting your idea to Game Active. <br><br> Would you like to enter the Invent A Game Challenge?',
		           				width:500,
		           				buttons: Ext.MessageBox.YESNO,
								fn: function(e){
									if (e=="yes")
										location.href="/Modules/Competition/Competition.aspx?section=sayit";
								}
							})
						},
						failure: function (result) {
							Ext.MessageBox.show('test');
						}
					});
        		}
			}, {
				text: 'Cancel',
				handler : function (){
					RS.WinGameActive.hide();
				}
			}]
		});
	}

});