var winRegistraAsociado;
var id_asociado = '';
var busqueda_asc='';

Ext.QuickTips.init();
	Ext.form.Field.prototype.msgTarget = 'qtip';	
	Ext.BLANK_IMAGE_URL = 'images/s.gif';

////////////////////// functions
function limpiarResetAsoc(){
	id_asociado='';
	dsEstadosAso11.removeAll();
	dsEstadosAso11.reload({
			params: {
				query: 'call spEstadosConsultar();'
			}
		});
	frmVentanaAsociado.getForm().reset();
	txtNombreAso1.focus(true,700);	
	Ext.getCmp('btnAgregarAsociado1').setDisabled(true);
	lblIfeAso1.setValue(false);	
	
}


function camposValidosIngresar(){
		
		if(txtNombreAso1.getValue() == ''){
			txtNombreAso1.focus(true,300);
			txtNombreAso1.markInvalid('Ingrese su nombre previamente');
			return false;
		}
		if(txtApePatAso1.getValue() == ''){
			txtApePatAso1.focus(true,300);	
			txtApePatAso1.markInvalid('Ingrese su apellido previamente');
			return false;
		}
		if(cbxEstadoAso1.getValue() == ''){
			cbxEstadoAso1.focus(true,300);	
			cbxEstadoAso1.markInvalid('Ingrese su estado de origen previamente');
			return false;
		}
		if(cbxCiudadAso1.getValue() == ''){
			cbxCiudadAso1.focus(true,300);	
			cbxCiudadAso1.markInvalid('Ingrese su ciudad de origen previamente');
			return false;
		}
		if(txtTe1Aso1.getValue() == ''){
			txtTe1Aso1.focus(true,300);	
			txtTe1Aso1.markInvalid('Ingrese su teléfono previamente');
			return false;
		}
		
		if(txtNIPAso1.getValue() == ''){
			txtNIPAso1.focus(true,300);	
			txtNIPAso1.markInvalid('Ingrese su NIP previamente');
			return false;
		}
		if(txtNIPAso21.getValue() == ''){
			txtNIPAso21.focus(true,300);	
			txtNIPAso21.markInvalid('Ingrese la confirmación de NIP previamente');
			return false;
		}else{
			if(txtNIPAso21.getValue() != txtNIPAso1.getValue()){
				Ext.MessageBox.alert('Alerta', 'El NIP no coincide con el anterior, por favor verifique');	
				return false;
			}
		}
		if(frmVentanaAsociado.getForm().isValid())  return true;
	}


//////////////////////////////////////////////////////////////////////Ds 1
var dsEstadosAso11= new Ext.data.JsonStore({
	url: 'php/mysqljsongrid.php',
    method: 'POST',
    totalProperty: 'totalRows',
    root: 'data',
    fields: [{
        name: 'clave',
        type: 'string' 
	}, {
        name: 'estado',
        type: 'string'
 	}]
});
var dsCiudadesAso11 = new Ext.data.JsonStore({
   url: 'php/mysqljsongrid.php',
   method: 'POST',
   id: 'id_ciudad',
   totalProperty: 'totalRows',
   baseParams:{
		query: 'call spCiudadesConsultar("{0}");'
	},
   replaceParams: 'cbxEstadoAso1.getValue()', 
   root: 'data',
   fields: [{
        name: 'id_ciudad',
        type: 'string'
    }, {
        name: 'ciudad',
        type: 'string'
    }, {
        name: 'prefijo',
        type: 'string'
    }]
});
/////////////////////////////////////////////////////////////////////////////// Ds 2
var dsCVE= new Ext.data.JsonStore({
	url: 'php/mysqljsongrid.php',
    method: 'POST',
    totalProperty: 'totalRows',
    root: 'data',
    fields: [{
        name: 'cve_larga',
        type: 'string' 
	}]
});
//////////////////////////////////////////////////////////////////////////////////////////LISTA DE LABEL
var lblAst1 = new Ext.form.Label({
	text: '*',
	style: 'color: #800000',
	x:12,
	y:20
});
var lblNomAso1 = new Ext.form.Label({
	text: 'Nombre:',
	x:20,
	y:20
});
var lblNomAso11 = new Ext.form.Label({
	text: 'Domicilio:',
	x:340,
	y:20
});
var lblAst2 = new Ext.form.Label({
	text: '*',
	style: 'color: #800000',
	x:12,
	y:50
});
var lblApePatAso1 = new Ext.form.Label({
	text: 'Apellido Paterno:',
	x: 20,
	y: 50
});
var lblApeMatAso1 = new Ext.form.Label({
	text: 'Apellido Materno:',
	x: 20,
	y: 80
});
var lblAst3 = new Ext.form.Label({
	text: '*',
	style: 'color: #800000',
	x:330,
	y:80
});
var lblApeMatAso11 = new Ext.form.Label({
	text: 'Estado:',
	x: 340,
	y: 80
});
var lblAst4 = new Ext.form.Label({
	text: '*',
	style: 'color: #800000',
	x:330,
	y: 110
});
var lblCiudadAso1 = new Ext.form.Label({
	text: 'Ciudad:',
	x: 340,
	y: 110
});
var lblFecNacAso1 = new Ext.form.Label({
	text: 'Fecha de Nacimiento:',
	x: 20,
	y: 110
});
var lblAst5 = new Ext.form.Label({
	text: '*',
	style: 'color: #800000',
	x:12,
	y: 140
});
var lblTel1Aso1 = new Ext.form.Label({
	text: 'Teléfono:',
	x: 20,
	y: 140
});
var lblTel2Aso1 = new Ext.form.Label({
	text: 'Confirmar Teléfono:',
	x: 340,
	y: 140
});
var lblMailAso1 = new Ext.form.Label({
	text: 'E-mail:',
	x: 340,
	y: 140
});
var lblMailAso11 = new Ext.form.Label({
	text: 'Confirmar E-mail:',
	x: 340,
	y: 170
});
//////////////////////// Labels 2

var lblIfeAso1 = new Ext.form.Checkbox({
		labelSeparator: '',
		enable: false,
		x: 20,
		y: Ext.isIE ? 225 : 225,
		selectOnFocus: true,
		tabIndex: 16,
		boxLabel : 'Credencial Elector:',  
		width: 300,
		name : 'checkbox',
		inputValue : "cbvalue",
		listeners: {
			check: function(e,chk){
				if(chk == true){
					txtIfeAso1.setDisabled(false);
					txtIfeAso11.setDisabled(false);
					txtIfeAso1.focus(true, 200);
				}
				else{
					
					txtIfeAso1.setDisabled(true);
					txtIfeAso11.setDisabled(true);
					txtIfeAso1.setValue("");
					txtIfeAso11.setValue("");
					
				}
			}
		}
});
var lblIfeAso11 = new Ext.form.Label({
	text: 'Confirmar Credencial Elector:', 
	x: 330,
	y: Ext.isIE ? 225 : 230
});
var lblLicenciaAso1 = new Ext.form.Checkbox({
		labelSeparator: '',
		enable: false,
		x: 20,
		y: Ext.isIE ? 255 : 255,
		selectOnFocus: true,
		tabIndex: 16,
		boxLabel : 'Licencia Conducir:',
		width: 300,
		name : 'checkbox',
		inputValue : "cbvalue",
		listeners: {
			check: function(e,chk){
				if(chk == true){
					txtLicenciAso1.setDisabled(false);
					txtLicenciAso11.setDisabled(false);
					txtLicenciAso1.focus(true, 200);
				}
				else{
					txtLicenciAso1.setDisabled(true);
					txtLicenciAso11.setDisabled(true);
					txtLicenciAso1.setValue("");
					txtLicenciAso11.setValue("");
				}
			}
		}
});
var lblLicenciaAso11 = new Ext.form.Label({
	text: 'Confirmar Licencia Conducir:',
	x: 330,
	y: Ext.isIE ? 255 : 255
});
var lblOtraAso1 = new Ext.form.Checkbox({
		labelSeparator: '',
		enable: false,
		x: 20,
		y: Ext.isIE ? 285 : 285,
		selectOnFocus: true,
		tabIndex: 16,
		boxLabel : 'Otra Identificación:',
		width: 300,
		name : 'checkbox',
		inputValue : "cbvalue",
		listeners: {
			check: function(e,chk){
				if(chk == true){
					txtOtroAso1.setDisabled(false);
					txtOtroAso11.setDisabled(false);
					txtOtroAso1.focus(true, 200);
				}
				else{
					txtOtroAso1.setDisabled(true);
					txtOtroAso11.setDisabled(true);
					txtOtroAso1.setValue("");
					txtOtroAso11.setValue("");
				}
			}
		}
});
var lblOtraAso11 = new Ext.form.Label({
	text: 'Confirmar Otra Identificación:',
	x: 330,
	y: Ext.isIE ? 285 : 285
});
var lblAst6 = new Ext.form.Label({
	text: '*',
	style: 'color: #800000',
	x:12,
	y: 170
});
var lblNIPAso1 = new Ext.form.Label({
	text: 'NIP:',
	x: 20,
	y: 170
});
var lblNIPAso21 = new Ext.form.Label({
	text: 'Confirmar NIP:',
	x: 340,
	y: 170
});
var lblInvitadoAso1 = new Ext.form.Label({
	text: 'Invitado por:',
	x: 20,
	y: 200
});
var lblInvitadoRequerido = new Ext.form.Label({
	text: 'Seleccione Asociado que lo invitó.(OPCIONAL)',
	style: 'color: #800000',
	x: 330,
	y: 200
});
/*
var lblPinAsoAgre1 = new Ext.Panel({
	x:290,
	y:195,
	items:{	
		tooltip:'Seleccione Asociado quï¿½ lo invitï¿½.',							 
		xtype: 'button',
		icon: 'imagenes/user_add.png',
		iconCls: 'x-btn-text-icon',
    	minWidth: 20,
		handler: function(){
			buscarAsociado('asoFuera');			
		}
	}
});
*/
/////////////////////////////////////////////////////////////////////////////////////////////LISTA DE TEXT
var txtNombreAso1 = new Ext.form.TextField({
	width: 180,
	x: 130,
	y: 15,
	enableKeyEvents: true,
	selectOnFocus: true,
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtApePatAso1.focus();
			}
		}
	}
});
var txtDomAso1 = new Ext.form.TextArea({
	hideLabel: true,
	width: 180,
	height:50,
	x: 445,
	y: 15,
	enableKeyEvents: true,
	selectOnFocus: true
});
var txtApePatAso1 = new Ext.form.TextField({
	hideLabel: true,
	width: 180,
	x: 130,
	y: 45,
	enableKeyEvents: true,
	selectOnFocus: true,
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtApeMatAso1.focus();
			}
		}
	}
});
var cbxEstadoAso1 = new Ext.form.ComboBox({
	id:'cbxEstadoAso1',
	store: dsEstadosAso11,
	name: 'cve_estado',									   
	displayField: 'estado',
	valueField: 'clave',
	width: 180,
	minListWidth: 175,
	typeAhead: true,
    mode: 'local',
	lazyInit: false,
    forceSelection: true,
    triggerAction: 'all',
    emptyText: 'Seleccione un Estado...',
	selectOnFocus: true,		
	/////////////plugin combo ligado///////////////////////
	linkedCombo: 'cbxCiudadAso1',
	plugins: new Ext.ux.plugins.linkedCombo(),
	/////////////fin de plugin combo ligado////////////////
		
	hideLabel: true,
	x: 445,
	y: 75,
	enableKeyEvents: true,
	listeners: {
		select: {
			fn: function(combo){
				cbxCiudadAso1.focus(true, 100);
			}
		},
		keyup: {
			fn: function(t, e){
				if (e.getKey() == 13) {
					cbxCiudadAso1.focus(true, 100);
					if(t.getValue()=='') t.setValue("");
				}
			}
		}
	}
});
var cbxCiudadAso1 = new Ext.form.ComboBox({
	id:'cbxCiudadAso1',
	store: dsCiudadesAso11,
	name: 'id_ciudad',									   
	displayField: 'ciudad',
	valueField: 'id_ciudad',
	lazyInit: false,
	width: 180,
	minListWidth: 175,
	typeAhead: true,
    mode: 'local',
    forceSelection: true,
    triggerAction: 'all',
    emptyText: 'Seleccione una Ciudad...',
	selectOnFocus: true,			
	hideLabel: true,
	x: 445,
	y: 105,
	enableKeyEvents: true,
	 listeners: {
		select: {
			fn: function(combo){
				txtTe1Aso1.focus(true, 100);
			}
		},
		keyup: {
			fn: function(t, e){
				if (e.getKey() == 13) {
					txtTe1Aso1.focus(true, 100);
				}
			}
		}
	}
});
var txtApeMatAso1 = new Ext.form.TextField({
	hideLabel: true,
	width: 180,
	x: 130,
	y: 75,	
	enableKeyEvents: true,
	selectOnFocus: true,
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtFechaNac1.focus();
			}
		}
	}
});
var txtFechaNac1 = new Ext.form.DateField({
	name: 'fecha_nac',
	format: 'd/m/Y',
	maxValue: new Date(),
	hideLabel: true,
	width: 95,
	x: 130,
	y: 105,
	enableKeyEvents: true,
	selectOnFocus: true,
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtDomAso1.focus();
			}
		}
	}
});
var txtTe1Aso1 = new Ext.form.NumberField({
	hideLabel: true,
	width: 180,
	x: 130,
	y: 135,
	minLength: 10,
	minLengthText: 'El teléfono deben ser 10 dígitos incluyendo la clave Lada. Ejemplo: 6691234567',
	maxLength: 10,
	maxLengthText: 'El teléfono deben ser 10 dígitos incluyendo la clave Lada. Ejemplo: 6691234567',
	autoCreate : {tag: "input", type: "text", size: "10", autocomplete: "off", maxlength: "10"},
	enableKeyEvents: true,
	selectOnFocus: true,
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtMailAso1.focus();
			}
		}
	}
});
var txtTe12Aso1 = new Ext.form.NumberField({
	hideLabel: true,
	width: 180,
	x: 445,
	y:135,	
	minLength: 10,
	minLengthText: 'El teléfono deben ser 10 dígitos incluyendo la clave Lada. Ejemplo: 6691234567',
	maxLength: 10,
	maxLengthText: 'El teléfono deben ser 10 dígitos incluyendo la clave Lada. Ejemplo: 6691234567',
	autoCreate : {tag: "input", type: "text", size: "10", autocomplete: "off", maxlength: "10"},
	enableKeyEvents: true,
	selectOnFocus: true,
	validator: function(v){
		if(v==txtTe1Aso1.getValue()){
			return true;
		}
		return 'El dígitos ingresado no coincide con el anterior, por favor verifique.';
		},
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtMailAso1.focus();
			}
		}
	}
});
var txtMailAso1 = new Ext.form.TextField({
	hideLabel: true,
	width: 180,
	x: 445,
	y:135,
	vtype: 'email',
	vtypeText: 'Este campo debe ser un correo electrónico en el formato "correo@dominio.com"',
	enableKeyEvents: true,
	selectOnFocus: true,
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtNIPAso1.focus();
			}
		}
	}
});
var txtMailAso11 = new Ext.form.TextField({
	hideLabel: true,
	width: 180,
	x: 445,
	y:165,
	vtype: 'email',
	vtypeText: 'Este campo debe ser un correo electrónico en el formato "correo@dominio.com"',
	enableKeyEvents: true,
	selectOnFocus: true,
	validator: function(v){
		if(v==txtMailAso1.getValue()){
			return true;
		}
		return 'El e-mail ingresado no coincide con el anterior, por favor verifique.';
		},
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				tabRegistro.activate(1);
				txtIfeAso1.focus(true,100);
			}
		}
	}
});
//////////////////// txt y chks 2
var txtIfeAso1 = new Ext.form.NumberField({
	hideLabel: true,
	width: 180,
	x: 133,
	y: Ext.isIE ? 221 : 223,
	enableKeyEvents: true,
	selectOnFocus: true,
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtIfeAso11.focus();
			}
		}
	}
});
var txtIfeAso11 = new Ext.form.NumberField({
	hideLabel: true,
	width: 180,
	x: 473,
	y: Ext.isIE ? 221 : 223,	
	enableKeyEvents: true,
	selectOnFocus: true,
	autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: "13"},
	autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: "13"},
	validator: function(v){
		if(v==txtIfeAso1.getValue()){
			return true;
		}
		return 'El número ingresado no coincide con el anterior, por favor verifique.';
		},
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtLicenciAso1.focus();
			}
		}
	}
});
var txtLicenciAso1 = new Ext.form.TextField({
	name: 'licencia',
	hideLabel: true,
	width: 180,
	x: 133,
	y: Ext.isIE ? 251 : 253,
	autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: "10"},	
	enableKeyEvents: true,
	selectOnFocus: true,
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtOtroAso1.focus();
			}
		}
	}
});
var txtLicenciAso11 = new Ext.form.TextField({
	hideLabel: true,
	width: 180,
	x: 473,
	y: Ext.isIE ? 251 : 253,	
	enableKeyEvents: true,
	autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: "10"},
	selectOnFocus: true,
	validator: function(v){
		if(v==txtLicenciAso1.getValue()){
			return true;
		}
		return 'La identificación ingresada no coincide con la anterior, por favor verifique.';
		},
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtOtroAso1.focus();
			}
		}
	}
});
var txtOtroAso1 = new Ext.form.TextField({
	name: 'otro',
	hideLabel: true,
	width: 180,
	x: 133,
	y: Ext.isIE ? 281 : 283,	
	enableKeyEvents: true,
	selectOnFocus: true,
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtNIPAso1.focus();
			}
		}
	}
});
var txtOtroAso11 = new Ext.form.TextField({
	name: 'licencia',
	hideLabel: true,
	width: 180,
	x: 473,
	y: Ext.isIE ? 281 : 283,
	enableKeyEvents: true,
	selectOnFocus: true,
	validator: function(v){
		if(v==txtOtroAso1.getValue()){
			return true;
		}
		return 'La identificación ingresada no coincide con la anterior, por favor verifique.';
		},
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtOtroAso1.focus();
			}
		}
	}
});
var txtNIPAso1 = new Ext.form.TextField({
	name: 'nip',
	hideLabel: true,
	inputType:'password', 
	width: 95,
	x: 130,
	y:165,
	minLength: 4,
	minLengthText: 'El NIP deben ser 4 caracteres como mínimo',
	maxLength: 8,
	maxLengthText: 'El NIP deben ser 8 caracteres',
	autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: "8"},
	enableKeyEvents: true,
	selectOnFocus: true,
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				txtNIPAso21.focus();
			}
		}
	}
});
var txtNIPAso21 = new Ext.form.TextField({
	name: 'nip2',
	hideLabel: true,
	inputType:'password', 
	width: 95,
	x: 445,
	y:165,
	allowBlank: false,
	blankText: 'Este campo no puede ir vacío, por favor confirme el NIP.',
	minLength: 4,
	minLengthText: 'El NIP deben ser 4 caracteres como mínimo',
	maxLength: 8,
	maxLengthText: 'El NIP deben ser 8 caracteres',
	autoCreate: {tag: "input", type: "text", autocomplete: "off", maxlength: "8"},
	enableKeyEvents: true,
	selectOnFocus: true,
	validator: function(v){
		if(v==txtNIPAso1.getValue()){
			return true;
		}
		return 'El NIP no coincide con la anterior, por favor verifique.';
		},
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
			//	lblPinAsoAgre1.focus();
			}
		}
	}	
});
var dsBusquedaAsociadoNuevo= new Ext.data.JsonStore({
			url: 'php/request.php',
			method: 'POST',
			baseParams:{
				code: 'CATASOCINVITO',
				cve: "",
				start:0,
				limit: 0,
				busqueda: '@ALL001X23b'
		},
			totalProperty: 'totalRows',
			root: 'data',
			idProperty: 'id_asociado',
			//autoDestroy: true,
			//autoLoad:true,
			fields: [{
		        name: 'id_asociado', type: 'string' }, {
		        name: 'consecutivo', type: 'int' }, {
				name: 'clave',	  	 type: 'string' }, {	
		        name: 'nombre',	  	 type: 'string' }, {
				name: 'completo', 	 type: 'string' }, {
				name: 'otro',	  	 type: 'string' }, {
				name: 'domicilio',	 type: 'string' }, {	    
				name: 'ciudad',	  	 type: 'string' }, {
				name: 'estado',	  	 type: 'string' }, {
				name: 'cve_estado',	 type: 'string' }, {
				name: 'id_ciudad',	 type: 'string' }, {
				name: 'tel',	  	 type: 'string' }, {
				name: 'tel2',	  	 type: 'string' }, {	
				name: 'ife',	  	 type: 'string' }, {
				name: 'licencia',	 type: 'string' }
		    ],
			listeners:{
				beforeload:function(t){
					if(t.baseParams.busqueda == ''){
						t.baseParams.busqueda = '@ALL001X23b';
					}
				}	
			}
		});

	var tplNuevo= new Ext.XTemplate(
		'<tpl for="."><div class="search-item">', 
						'<div style="width:360px; float:left;">', 
							'<h3 style="min-width:0;">{consecutivo} - {completo:ellipsis(200)}</h3>', 
							'<p style="min-width:0;">{[values.ciudad+", "+values.estado]}</p>',
				 	'</div>', 
					'<div style="width:25px; float:left; height:28px; margin-left:2px;">{clave}', 
				 	'</div>', 
				 	'<div style="clear:both;"></div>', '</div></tpl>' 
		);	
		
		
	var txtInvitoAso1 = new Ext.form.ComboBox({
			autoCreate: {maxlength: "200", tag: "input", type: "text", autocomplete: "off"},
			store: dsBusquedaAsociadoNuevo,
			tpl: tplNuevo,
			itemSelector: 'div.search-item',
			displayField: 'completo',
			valueField: 'id_asociado',
			queryDelay: 500,
			x: 130,
			y:195,
			pageSize: 10,
			itemStyle:'clear:both;',
			enableKeyEvents:true,
			queryParam: 'busqueda', 
			minChars: 0,
			triggerClass:'x-form-search-trigger',
			loadingText: 'Buscando...',
			width: 180,
			listWidth: 450,
			selectOnFocus:true,
			forceSelection: true,
			maskRe:/[^\\\/"']/,			
			onTriggerClick : function(){
				if(this.disabled){
					return;
				}
				this.expand();
				if (this.getRawValue()!='') {
					this.doQuery(this.getRawValue());
				}else{
					this.doQuery('@ALL001X23b');
					
				}
				this.el.focus();
			},
			listeners: {
				keyup:function(t,e){
					if (e.getKey() == 114 && e['ctrlKey'] && !e['altKey']) {
					
						if(this.disabled)	return;
						this.expand();
						this.el.focus();
						if(this.getRawValue()!='')	this.doQuery(this.getRawValue());
						else this.doQuery('@ALL001X23b');
						this.el.focus();
					}
					
				},
				keypress: function(t, e){
					if (e['altKey'] || (e['shiftKey'] && e.getKey() == 34) || e.getKey() == 39) {				
						e.stopEvent();	
					}
				
					
				},
				blur: function(t){
					t.collapse();
				},
				beforequery: function(qe){
					delete qe.combo.lastQuery;
					
				}
			}
	});

/*
var txtInvitoAso1 = new Ext.form.TextField({
	name: 'completo',
	hideLabel: true,
	width: 153,
	x: 130,
	y:195,
	enableKeyEvents: true,
	readOnly: true,
	selectOnFocus: true,
	listeners: {
		keyup: function(t,e){
			if(e.getKey()==13){
				btnAgregarAsociado1.focus();
			}
		}
	}
});*/
var lblClausulasAso1 = new Ext.form.Label({ 										 
	html: '<img src="imagenes/contrato.png" title="Leer Cláusulas y Contrato de Afiliación" style="cursor: pointer">',
	x:45,
	y:290,
	listeners: {
   		render: function() {
      		Ext.fly(this.el).on('click', function(e, t) {
				var h = (window.screen.availHeight)-30;
				var w = (window.screen.availWidth)-10;		
				window.open('pdf/CONTRATO_SOCIO.pdf',"","width=" + w + ", height=" + h + ",Resizable=yes, scrollbars,top=0, left=0");
      		});
    	}
	}
});
var lblRegistroAsterisk = new Ext.form.Label({
	style: 'color: #800000',
	text: 'Los campos marcados con * son requeridos.',
	x: 10,
	y: 245
});
var lblRegistroConfi = new Ext.form.Label({
	style: 'color: #800000',
	x: 380,
	y: 245
});
var lblContratoRequerido = new Ext.form.Label({
	text: 'Para completar el registro es requerido leer y aceptar las condiciones del contrato de Afiliación',
	style: 'color: #800000',
	x: 380,
	y: 300
});
var ckeckWinAceptarContrato = new Ext.form.Checkbox({
		labelSeparator: '',
		enable: false,
		x: 130,
		y: 300,
		selectOnFocus: true,
		tabIndex: 16,
		boxLabel : "He leído y acepto las condiciones del Contrato",  
		width: 300,
		name : 'checkbox',
		inputValue : "cbvalue",
		listeners: {
			check: function(e,chk){
				if(chk == true){
					Ext.getCmp('btnAgregarAsociado1').setDisabled(false);
					
				}
				else{
					Ext.getCmp('btnAgregarAsociado1').setDisabled(true);
				}
			}
		}
});


/////////////////////////////////////////////////////////////////////////////////////////LISTA DE FRAME
var framePersonales = new Ext.form.FieldSet({
	title:'Datos Generales',
	width: 660,
	height: Ext.isIE ? 220 : 230,
	x: 5,
	y: 0
});

var frameContrato = new Ext.form.FieldSet({
	title:'Cláusulas y Contrato de Afiliación',
	width: 660,
	height: Ext.isIE ? 65 : 75,
	x: 5,
	y: 270
});
var btnAgregarAsociado1 = new Ext.Panel({
	x: 415,
	y: 350,
	html:'<script type="text/javascript" src="js/layout.js">',
	items:{								 
		xtype: 'button',
		text: 'Aceptar',
		id: 'btnAgregarAsociado1',
    	minWidth: 80,
		icon: 'images/tick.png',
		iconCls: 'x-btn-text-icon',
		selectOnFocus: true,
		handler: function(){
			if (camposValidosIngresar()){
				frmVentanaAsociado.getForm().submit({
					url: 'php/mysqljson.php',
					method: 'POST',
					waitMsg: 'Guardando...',
					params: {
						query: 'call spAsociadosAgregar("","' + txtApePatAso1.getValue() + '","' + txtApeMatAso1.getValue() + '","' + txtNombreAso1.getValue() + '","' + new Date(txtFechaNac1.getValue()).format('Y-m-d') + '","' + txtDomAso1.getValue() + '","' + cbxEstadoAso1.getValue() + '","' + cbxCiudadAso1.getValue() + '","' + txtTe1Aso1.getValue() + '","' + txtTe1Aso1.getValue() + '","","' + txtMailAso1.getValue() + '","","","","'+ txtInvitoAso1.getValue()+'","'+txtNIPAso1.getValue() +'","El mismo");'
					},
					success: function(form, action){
						id_asociado = '';
						frmVentanaAsociado.getForm().reset();
						Ext.MessageBox.alert('Registro Exitoso!', 'Anote su No. de socio: <b>'+" "+action.result.msg+"</b><br>Posteriormente se le solicitarán datos necesarios para la elaboración de la tarjeta de débito que le suministrará el banco.",function(){winRegistraAsociado.hide(); });	
					
					},
					failure: function(form, action){
						Ext.MessageBox.alert('Resumen', action.result.msg);
					}
				});				
			}
		}
	}
});
var btnLimpiarAsociado1a = new Ext.Panel({
	x: 500,
	y: 350,
	items:{								 
		xtype: 'button',
		text: 'Limpiar',
		icon: 'imagenes/limpiar.png',
		iconCls: 'x-btn-text-icon',
    	minWidth: 80,
		handler: function(){
			limpiarResetAsoc();
		}
	}
});
var btnSalirAsociado1 = new Ext.Panel({
	x: 585,
	y: 350,
	items:{								 
		xtype: 'button',
		text: 'Cancelar',
		icon: 'imagenes/salir.png',
		iconCls: 'x-btn-text-icon',
    	minWidth: 80,
		handler: function(){
			winRegistraAsociado.hide();
		}
	}
});
var lblBlinkBlink = new Ext.form.Label({ 										 
	html: '<img src="images/invitar.gif">',
	x:20,
	y:355
});
var frmVentanaAsociado = new Ext.FormPanel({
		id: 'frmVentanaAsociado',
		layout: 'absolute',
		frame: true,
		border: false,	
		items: [framePersonales,lblAst1,lblAst2,lblAst3,lblAst4,lblAst5,lblAst6,
		lblNomAso1,txtNombreAso1,lblApePatAso1,txtApePatAso1,lblApeMatAso1,txtApeMatAso1,lblFecNacAso1,txtFechaNac1,lblNomAso11,txtDomAso1,lblApeMatAso11,lblCiudadAso1,cbxEstadoAso1,cbxCiudadAso1,lblTel1Aso1,txtTe1Aso1,lblMailAso1,txtMailAso1,btnLimpiarAsociado1a,lblBlinkBlink,
		frameContrato,
		lblNIPAso1,txtNIPAso1,
		lblNIPAso21,txtNIPAso21,
		lblInvitadoAso1,txtInvitoAso1,
		btnAgregarAsociado1,btnLimpiarAsociado1a,btnSalirAsociado1,lblRegistroAsterisk,
		lblRegistroConfi,
		lblClausulasAso1,ckeckWinAceptarContrato,
		lblInvitadoRequerido,lblContratoRequerido
		]
	});	

/////////////////////////////////////////////////////////////////////////Ventana
function registrate(){
	if (!winRegistraAsociado) {
		winRegistraAsociado= new Ext.Window({
			id:'winRegistraAsociado',
			layout: 'fit',
			title: 'Registro en Línea',
			resizable: false,
			minimizable: false,
			width: 700,
			height: 420,
			closeAction: 'hide',
			modal:true,
			plain: true,
			items: [frmVentanaAsociado],
			listeners:{
				show:function(){
					txtNombreAso1.focus(true,500);
				}
			}
		});
		winRegistraAsociado.show();
		lblRegistroConfi.setText("<b> Los datos proporcionados serán confidenciales.</b>",false);
		limpiarResetAsoc();
		winRegistraAsociado.minimizeWidth = 200;
		winRegistraAsociado.restoreWidth = 700;
		winRegistraAsociado.on({'minimize': minimizeWin});
		winRegistraAsociado.minimized = false;
		winRegistraAsociado.on({'minimize': minimizeWin});		
	}
	if(winRegistraAsociado.minimized){
		winRegistraAsociado.setWidth(winRegistraAsociado.restoreWidth);	
	}
	else{
		winRegistraAsociado.setWidth(winRegistraAsociado.restoreWidth);
		winRegistraAsociado.setHeight(420);
		winRegistraAsociado.collapse(false);
		winRegistraAsociado.expand(false);
	}
	winRegistraAsociado.show();
	winRegistraAsociado.minimized = false;	
		
}
