// JavaScript Document
/*!
 * Ext JS Library 3.1.0
 * Copyright(c) 2006-2009 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
Ext.onReady(function(){

    Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

    var bd = Ext.getBody();

/* ===============  Sore de valores =================== */
var data = [['Licenciatura en Gastronomía', 'Licenciatura en Gastronomía'], ['Licenciatura en Ciencia de los Alimentos', 'Licenciatura en Ciencia de los Alimentos'], ['Licenciatura en Hotelería y Sistemas Turísticos', 'Licenciatura en Hotelería y Sistemas Turísticos'], ['Licenciatura en Logística de Eventos y Servicios', 'Licenciatura en Logística de Eventos y Servicios'],['Licenciatura en Logística Integral de Negocios', 'Licenciatura en Logística Integral de Negocios'],['Licenciatura en Nutrición', 'Licenciatura en Nutrición'],['Diplomados, Cursos y Talleres', 'Diplomados, Cursos y Talleres'], ['Otro...', 'Otro...'] ];
var store = new Ext.data.SimpleStore({
     fields:['serCode', 'serName']
    ,data:data
}); 
/* ===============  Sore de citas =================== */
var datacita = [['Departamento de Promoción', 'Departamento de Promoción'], ['Departamento de Admisiones', 'Departamento de Admisiones'], ['Departamento Administrativo', 'Departamento Administrativo'], ['Departamento Docente', 'Departamento Docente'],['Departamento de Administración Escolar', 'Departamento de Administración Escolar'], ['Otro...', 'Otro...'] ];
var storecita = new Ext.data.SimpleStore({
     fields:['serCodecita', 'serNamecita']
    ,data:datacita
}); 


    /*
     * ================  Simple form  =======================
     */
   // bd.createChild({tag: 'h2', html: 'Form 1 - Very Simple'});


    var simple = new Ext.FormPanel({
        labelWidth: 140, // label settings here cascade unless overridden
        url:'enviar.php',
		standardSubmit: true,
		//method: post,
        frame:true,
        title: 'Escríbenos',
        bodyStyle:'padding:5px 5px 0',
        width: 530,
        defaults: {width: 350},
        defaultType: 'textfield',

        items: [
                new Ext.form.DisplayField({
				contentEl: 'texto',
				htmlEncode:true
										  }),
				new Ext.form.ComboBox({
				store: store,
				fieldLabel: 'Deseo Información de',
				name: 'servicio',
                allowBlank:false ,
				emptyText:'Selecciona una Opción...',
				 mode: 'local',
				 triggerAction: 'all',
				valueField: 'serCode' ,
				displayField: 'serName'
								   })
            ,{
                fieldLabel: 'Nombre completo',
                name: 'nombre',
                allowBlank:false
            },{
                fieldLabel: 'Email',
				allowBlank:false,
                name: 'email',
                vtype:'email'
            }, {
                fieldLabel: 'Teléfono Casa',
                name: 'telefono_casa',
				allowBlank:true				
            },{
			    fieldLabel: 'Teléfono Movil',
                name: 'telefono_movil',
				allowBlank:true
			},{
				fieldLabel: 'Teléfono Oficina',
                name: 'telefono_oficina',
				allowBlank:true
			}/*,  new Ext.form.DisplayField({
				html: 'Domicilio',
				htmlEncode:true
			})*/,{
				fieldLabel: 'Dirección, Calle y número',
                name: 'direccion',
				allowBlank:false
			},{
				fieldLabel: 'Colonia',
                name: 'colonia',
				allowBlank:false
			},
				new Ext.form.NumberField({
				fieldLabel: 'Código Postal',
                name: 'cp',
				allowBlank:false
			}), 
			new Ext.form.DisplayField({
				html: 'Si desea concertar una cita, por favor seleccione:',
				htmlEncode:true
			}),
			new Ext.form.ComboBox({
				store: storecita,
				fieldLabel: 'Concertar cita con',
				name: 'cita',
                allowBlank:true ,
				emptyText:'Selecciona una Opción...',
				 mode: 'local',
				 triggerAction: 'all',
				valueField: 'serCodecita' ,
				displayField: 'serNamecita'
								   }),
			new Ext.form.DateField({
                fieldLabel: 'Fecha preferida',
				allowBlank:true,
				// disable Sunday and Saturday:
				disabledDays:  [0],
                name: 'fecha'
            }),
			new Ext.form.TimeField({
			fieldLabel:'Hora preferida',
			allowBlank:true,
			name:'hora',
			initDate: new Date(),
			minValue: '9:00 AM',
			maxValue: '6:30 PM',
			increment: 30
			}),
			
           //{xtype:'htmleditor',
            new Ext.form.TextArea({
			name:'mensaje',
			allowBlank:false,
            fieldLabel:'Mensaje',
            height: 140
								  })],
		   //}],

        buttons: [{
            text: 'Enviar',
			 handler: function(){
            var fp = this.ownerCt.ownerCt,
                form = fp.getForm();
            if (form.isValid()) {
                // check if there are baseParams and if
                // hiddent items have been added already
                if (fp.baseParams && !fp.paramsAdded) {
                    // add hidden items for all baseParams
                    for (i in fp.baseParams) {
                        fp.add({
                            xtype: 'hidden',
                            name: i,
                            value: fp.baseParams[i]
                        });
                    }
                    fp.doLayout();
                    // set a custom flag to prevent re-adding
                    fp.paramsAdded = true;
                }
                form.submit(fp);
            }
			 }
        }/*,{
            text: 'Cancelar'
        }*/]
    });

    simple.render(document.body);
	onReady: setTimeout(function(){
    Ext.get('loading').remove();    
    //Ext.get('loading-mask').fadeOut({remove:true});
}, 250); 
});
