var top = null;
var test = null;
var counter = 1;
Ext.onReady(function(){
	 
	Ext.QuickTips.init();

    checkboxenPanel = new Ext.form.FormPanel({
    	id: 'checkboxenPanel',
        labelAlign: 'top',
        frame:true,
        name: 'contact_form',
		width: 717,
		border: false,
		renderTo: Ext.get('wr-checkbox'),
		layout: 'form',

		
        items: [
       			/*new Ext.XTemplate(
        	
        		'<p class=\'text-top\' id=\'text-link\'><a href="javascript:createNewDataFields()">'+getLabelText('de', 'other_watches') +'</p>'
				
			),
			*/
				new Ext.XTemplate(
        	
				'<p class=\'text-top\'>'+getLabelText(lang, 'prefered_dealer')+'<p/>'
			),
			
			{
			 
            layout: 'column',
            bodyStyle: 'padding:0 0 20px 0;',
	        width: 670,  
	                items: [{
			    	layout: 'form',
			    	columnWidth:.4,
			    	items: [
					    	new Ext.form.ComboBox({
					    	fieldLabel: getLabelText(lang, 'country'),
					    	labelSeparator: '',
						    displayField: 'country2',
							valueField: 'id',
							name: 'country2',
						    mode: 'local',
							editable: false,
						    triggerAction: 'all',
							id:'country2',
						    emptyText:getLabelText(lang, 'waehlen'),
						    border: true,
							width: 200,
							listWidth: 200,
							 
					    	store: new Ext.data.SimpleStore({
							     fields: [
							     	{name: 'id'},
							     	{name: 'country2', type:'string'}
							     	
						    	],
								forceSelection: true,
						   		data : prefDealerCountry[lang],
						   	 	autoLoad:true
							}),
							listeners: {
						//  select : ( Ext.form.ComboBox combo, Ext.data.Record record, Number index )  
		               		 select: function(f, n, o){
		                		var dealerCombo = Ext.getCmp('dealer');
		                		dealerCombo.clearValue();
		                		
		                		if(Ext.getCmp('country2').getValue() == getLabelText(lang, 'waehlen')){
		                			
		                			dealerCombo.store.clearFilter();
		                		}
		                		else{
		                			dealerCombo.store.filter('country',Ext.get('country2').getValue() );
		                		}
		                			                		
		
		               	 	}

						}
						})
					]
			    }, {
			    	layout: 'form',
			    	columnWidth:.6,
			    	items: [
					    	new Ext.form.ComboBox({
					    	fieldLabel: getLabelText(lang, 'dealer'),
					    	labelSeparator: '',
						    displayField: 'dealer',
							valueField: 'id',
							mode: 'local',
							editable: false,
						    triggerAction: 'all',
							id:'dealer',
						    emptyText:getLabelText(lang, 'waehlen'),
						    border: true,
							width: 400,
							listWidth: 400,
							lastQuery:'',
							store: new Ext.data.SimpleStore({
							     fields: [
							     	{name: 'id'},
							     	{name: 'dealer', type:'string'},
							     	{name: 'country', type:'string'}
							     	
							     	
						    	],
								forceSelection: true,
						   		data : dealer[lang],
						   	 	autoLoad:true
							})
						})
					]
			    }]
            
			},
            
             
			
			new Ext.XTemplate(
        	
        	'<p class=\'text-top\'>'+getLabelText(lang, 'interests')+'<p/>',
			'<div class=\'lineSpacer\'><img src=\'images/1x1_trans.gif\' height=\'1\' width=\'1\' border=\'0\'></div>'
						
        	),
        	{

                xtype: 'checkboxgroup',
                fieldLabel: getLabelText(lang, 'interested_watches'),
                labelSeparator: '',
                columns: 2,
               	bodyStyle: 'padding:0 10px 0;',
				width:340,
				id:'watch_registration_checkbox',
				//cls:'watch_registration_checkbox',
                vertical: true,

                items: [
                    {boxLabel: getLabelText(lang, 'watchmodel1') , name: 'interested_watches', inputValue: 1},
                    {boxLabel: getLabelText(lang, 'watchmodel2'), name: 'interested_watches', inputValue: 2},
                    {boxLabel: getLabelText(lang, 'watchmodel3'), name: 'interested_watches', inputValue: 3},
                    {boxLabel: getLabelText(lang, 'watchmodel4'), name: 'interested_watches', inputValue: 4},
                    {boxLabel: getLabelText(lang, 'watchmodel5'), name: 'interested_watches', inputValue: 5},
                    {boxLabel: getLabelText(lang, 'watchmodel6'), name: 'interested_watches', inputValue: 6},
                    {boxLabel: getLabelText(lang, 'watchmodel7'), name: 'interested_watches', inputValue: 7},
                    {boxLabel: getLabelText(lang, 'watchmodel8'), name: 'interested_watches', inputValue: 8},
                    {boxLabel: getLabelText(lang, 'watchmodel9'), name: 'interested_watches', inputValue: 9},
                    {boxLabel: getLabelText(lang, 'watchmodel10'), name: 'interested_watches', inputValue: 10},
                    {boxLabel: getLabelText(lang, 'watchmodel11'), name: 'interested_watches', inputValue: 11},
                    {boxLabel: getLabelText(lang, 'other'), name: 'interested_watches', inputValue: 12, id:'other_iw'},
					
                    /*field.on("check", function(self, checked) {                            
                    	if(checked)                      
                    	      
                    	group.fireEvent('change', group, self.getRawValue());  
                    	alert('nin');
                    	}),
                    
                    */
                    {
	                    xtype:'textfield',
	                    hidden:true,
	                    labelSeparator: '',
	                    cls:'other_field',
	                    id:'other_field_iw',
	                    fieldLabel: '',
	                    autoCreate : {tag: 'input', type: 'text', size: '20', maxlength: '25', autocomplete: 'off'},
	                    name: 'other',
	                    width: 100
                	}
                ]
            },
            {	

                xtype: 'checkboxgroup',
                id:'hobbies',
                fieldLabel: getLabelText(lang, 'interested_sport'),
                labelSeparator: '',
                //id:'interested_sport',
                columns: 2,
				bodyStyle: 'padding:0 10px 0;',
				width:340,
                vertical: true,
                //hideLabel: true,
               
                
                items: [
                    {boxLabel: getLabelText(lang, 'leisure1') , name: 'interested_sport', inputValue: 1},
                    {boxLabel: getLabelText(lang, 'leisure2'), name: 'interested_sport', inputValue: 2},
                    {boxLabel: getLabelText(lang, 'leisure3'), name: 'interested_sport', inputValue: 3},
                    {boxLabel: getLabelText(lang, 'leisure4'), name: 'interested_sport', inputValue: 4},
                    {boxLabel: getLabelText(lang, 'leisure5'), name: 'interested_sport', inputValue: 5},
                    {boxLabel: getLabelText(lang, 'leisure6'), name: 'interested_sport', inputValue: 6},
                    {boxLabel: getLabelText(lang, 'other'), name: 'interested_sport', inputValue: 7, id:'other_is'},
                    
                    {
	                    xtype:'textfield',
	                    labelSeparator: '',
	                    hidden:true,
	                    cls:'other_field',
	                    id:'other_field_is',
	                    fieldLabel: '',
	                    autoCreate : {tag: 'input', type: 'text', size: '20', maxlength: '25', autocomplete: 'off'},
	                    name: 'other',
	                    width: 50
                	}
                ]
            },
           
            
            
            {	

                xtype: 'checkboxgroup',
                id: 'otherBrands',
                fieldLabel: getLabelText(lang, 'possession_watches'),
                labelSeparator: '',
                //id:'possession_watches',
                columns: 2,
				bodyStyle: 'padding:0 10px 0;',
				width:340,
                vertical: true,
                
                items: [
                    {boxLabel: getLabelText(lang, 'manufacturer1') , name: 'possession_watches', inputValue: 1},
                    {boxLabel: getLabelText(lang, 'manufacturer2'), name: 'possession_watches', inputValue: 2},
                    {boxLabel: getLabelText(lang, 'manufacturer3'), name: 'possession_watches', inputValue: 3},
                    {boxLabel: getLabelText(lang, 'manufacturer4'), name: 'possession_watches', inputValue: 4},
                    {boxLabel: getLabelText(lang, 'manufacturer5'), name: 'possession_watches', inputValue: 5},
                    {boxLabel: getLabelText(lang, 'manufacturer6'), name: 'possession_watches', inputValue: 6},
                    {boxLabel: getLabelText(lang, 'manufacturer7'), name: 'possession_watches', inputValue: 7},
                    {boxLabel: getLabelText(lang, 'manufacturer8'), name: 'possession_watches', inputValue: 8},
                    {boxLabel: getLabelText(lang, 'manufacturer9'), name: 'possession_watches', inputValue: 9},
                    {boxLabel: getLabelText(lang, 'manufacturer10'), name: 'possession_watches', inputValue: 10},
                    {boxLabel: getLabelText(lang, 'manufacturer11'), name: 'possession_watches', inputValue: 11},
                    {boxLabel: getLabelText(lang, 'manufacturer12'), name: 'possession_watches', inputValue: 12},
                    {boxLabel: getLabelText(lang, 'manufacturer13'), name: 'possession_watches', inputValue: 13},
                    {boxLabel: getLabelText(lang, 'manufacturer14'), name: 'possession_watches', inputValue: 14},
                    {boxLabel: getLabelText(lang, 'manufacturer15'), name: 'possession_watches', inputValue: 15},
                    {boxLabel: getLabelText(lang, 'manufacturer16'), name: 'possession_watches', inputValue: 16},
                    {boxLabel: getLabelText(lang, 'manufacturer17'), name: 'possession_watches', inputValue: 17},
                    {boxLabel: getLabelText(lang, 'manufacturer18'), name: 'possession_watches', inputValue: 18},
                    {boxLabel: getLabelText(lang, 'manufacturer19'), name: 'possession_watches', inputValue: 19},
                    {boxLabel: getLabelText(lang, 'manufacturer20'), name: 'possession_watches', inputValue: 20},
                    {boxLabel: getLabelText(lang, 'other'), name: 'interested_sport', inputValue: 21, id:'other_pw'},
                    {
	                    xtype:'textfield',
	                    labelSeparator: '',
	                    cls:'other_field',
	                    id:'other_field_pw',
	                    hidden:true,
	                    fieldLabel: '',
	                    autoCreate : {tag: 'input', type: 'text', size: '20', maxlength: '25', autocomplete: 'off'},
	                    name: 'other',
	                    width: 70
                	}
                ]
            },
            {
			        xtype:'hidden',
			        name: 'mediacode',
			        id:'mediacode',
			        value:getMediacode('mediacode_user_request')
	   		}
        	 
        ]      	
			 
    });
    
    Ext.getCmp('other_iw').addListener('check', showOtherFieldIW );
    Ext.getCmp('other_is').addListener('check', showOtherFieldIS );
    Ext.getCmp('other_pw').addListener('check', showOtherFieldPW );
   
	function showOtherFieldIW(){
	   	var boxValue = Ext.getCmp('other_iw').getValue();
	  
	   	if(boxValue == true){
	   		Ext.getCmp('other_field_iw').show();
	   	}
	   	else{
	   		Ext.getCmp('other_field_iw').hide();
	   	}
	    
	}
	function showOtherFieldIS(){
	   	var boxValue = Ext.getCmp('other_is').getValue();
	  
	   	if(boxValue == true){
	   		Ext.getCmp('other_field_is').show();
	   	}
	   	else{
	   		Ext.getCmp('other_field_is').hide();
	   	}
	    
	}
	function showOtherFieldPW(){
	   	var boxValue = Ext.getCmp('other_pw').getValue();
	  
	   	if(boxValue == true){
	   		Ext.getCmp('other_field_pw').show();
	   	}
	   	else{
	   		Ext.getCmp('other_field_pw').hide();
	   	}
	    
	}
});
   
  
	
