 

	 			var d = slashDelimitedToArray("1 Literarni dogodki<*>2 Gledali\u0161ke in operne predstave<*>3 Plesne predstave<*>4 Razstave<*>5 Koncerti<*>6 Delavnice in predavanja<*>7 Konference<*>8 Prireditve na prostem<*>9 Prireditve za otroke in mladino<*>10 Multimedijske postavitve na prostem v mestu<*>11 Projekti s podro\u010dja ekologije in sociale<*>98 Kaj drugega (ANK.: ZAPI\u0160I)<*>99 Ne vem, brez odgovora"); 
	 			var filTmp = '';
	 			var opnTmp = ''.split(':');
	 			//var opnStTmp = opnTmp[0].split('-');
	 			if(filTmp != '')
	 			{
		 			var filArTmp = filTmp.split('<!>');
		 			//in case filter string is not updated and is shorter then questions!
		 			while(filArTmp.length < d.length)
		 				filArTmp.push('0');
		 			for(var i=0;i<d.length;i++)
		 			{
		 				if(filArTmp[i].substring(0,1)==1)
		 				{
		 					d[i].push(true);
						}
						else {d[i].push(false); }
						
						d[i].push( filArTmp[i].substring(1) );
						
						if(opnTmp[0] == d[i][0])
						{
							d[i].push(true);
							//d[i].push(opnStTmp[1]);
							opnTmp.shift();
							
						}
						else 
						{
							d[i].push(false);
						//	d[i].push(0);
						}
						
		 			}
				}
				else
				{
				for(var i=0;i<d.length;i++)
		 			{
		 				d[i].push(false); 
						
						d[i].push( '' );
						//duplicate code for performance!!! :)
							if(opnTmp[0] == d[i][0])
							{
								d[i].push(true);
								//d[i].push(opnStTmp[1]);
								opnTmp.shift();
							}
								else 
								{
									d[i].push(false);
								//	d[i].push(0);
								}
		 			}
		 			
				}
	 			
		 			var ng = ''.split(',');
		 		//	var d = ; 
		 			for(var i=0;i<d.length;i++)
		 			{
		 				if(d[i][0] == ng[0])
		 				{
		 					d[i].push(true);
		 					ng.shift();
						}
						else 
						{
							d[i].push(false);
						}
		 				//console.log(d[i]);
		 			}
		 			// grid1074286051.getStore().loadData(d);
		 			var successFunc = function(resp,opt,close){
					var r = Ext.decode(resp.responseText);
						if(r.error)
						{
							if(r.error == 'hasData')
							{
								Ext.Msg.show({title:'Warning! Data exists',msg:'Do you want to:',buttons:{ ok:'Delete',yes:'Backup' },
						 			fn: function(btn){
						 				if(btn == 'ok') opt.params.updateConfirm = 'delete';
						 				else if(btn == 'yes') opt.params.updateConfirm = 'backup';
						 				else { e.record.set(e.field,e.originalValue);e.record.commit(); return;}
						 				Ext.Ajax.request(opt);
						 			}
						 		});
								return;
							}
						Ext.Msg.alert('Warning',r.error);
		
						}
					 Ext.getCmp('grid1408602956').getStore().reload();
					if(close)
						Ext.getCmp('wcbqTabPanel_Vecer_2012_maj').remove(edit_Vecer_2012_majE2A_Answers); 
					else
						grid1074286051.getStore().commitChanges();
				 };
		

//CREATING DATA STORE MODEL
var ds_model1074286051 = Ext.data.Record.create(
[{ name:"pos" ,type: "int"},{ name:"ans" },{ name:"group" ,type: "int"},{ name:"filter" ,type: "bool"},{ name:"filCnd" },{ name:"open" ,type: "bool"},{ name:"nogo" ,type: "bool"},{ name:"id" }]);

//CREATING A SPECIAL COLUMN TYPE
var SpecColfilter1074286051 = new Ext.grid.CheckColumn({name:"filter",id:"filter",dataIndex : 'filter' ,header : "Filter" ,type : 'bool' ,width : 40 ,RMtable : "ansGrid",idField : "id" }
);

//CREATING A SPECIAL COLUMN TYPE
var SpecColopen1074286051 = new Ext.grid.CheckColumn({name:"open",id:"open",dataIndex : 'open' ,header : "Open" ,type : 'bool' ,width : 40 ,RMtable : "ansGrid",idField : "id" }
);

//CREATING A SPECIAL COLUMN TYPE
var SpecColnogo1074286051 = new Ext.grid.CheckColumn({name:"nogo",id:"nogo",dataIndex : 'nogo' ,header : "Nogo Together" ,type : 'bool' ,RMtable : "ansGrid",idField : "id" }
);

//CREATE THE DATA STORE READER
var Reader1074286051 = new Ext.data.JsonReader({
root:'rows'},
ds_model1074286051
);

//CREATE THE DATA STORE
var Store1074286051 = new Ext.data.Store({
url:'webcati/_ajax/buildQuestionare/ajax.buildQuestionnaire.php',
remoteGroup:true,
//ADDING BASE PARAMS TO STORE
baseParams: {database:'', action : 'select',RMcomp:'grid',RMtable : 'ansGrid'  
,id:35,projName:'Vecer_2012_maj',dataIndex:'odg_sql',id:35 ,id_language:'45'},listeners:{exception : function(m,b,j,k,resp){
		var r  = Ext.decode( resp.responseText);
		if(r.error == 'sessionTimeout')
		{
			CallScript( '_forms/window.sessionTimeout.php',{});
		}
		else
			alert('Grid error: '+  r.error  ); 
	}},reader: Reader1074286051
,remoteSort : true});

//CREATE THE GRID ITSELF!!!
var grid1074286051 = new Ext.grid.EditorGridPanel({
getSelectedIds :function(field ){
				if(!field) field = 'id';
				var arr=new Array(),sel = this.selModel.getSelections();
				
				 for(x=0; x<sel.length ;x++){
				    arr.push( sel[x].data[field] );}
				  return arr;
		}, store: Store1074286051
,id: "grid1074286051"
,columns: [

//DEFINING THE COLUMNS FOR THE GRID
{name:"pos",id:"pos",dataIndex : 'pos' ,header : "Value" ,editor : new Ext.form.NumberField() ,type : 'int' ,RMtable : "ansGrid",idField : "id" }
,{name:"ans",id:"ans",dataIndex : 'ans' ,header : "Answer" ,editor : new Ext.form.TextField() ,sortable : false ,RMtable : "ansGrid",idField : "id" }
,{name:"group",id:"group",dataIndex : 'group' ,header : "Group" ,editor : new Ext.form.NumberField() ,type : 'int' ,RMtable : "ansGrid",idField : "id" }
,SpecColfilter1074286051,{name:"filCnd",id:"filCnd",dataIndex : 'filCnd' ,header : "Condition" ,editor : new Ext.form.TextField({listeners:{
						blur:function(fld){
						if(Ext.isIE){
							edit_Vecer_2012_majE2A_Answers_tbar.fCaret = fld.getValue().length;
							
							
						}
						else{  edit_Vecer_2012_majE2A_Answers_tbar.fCaret = getCaretPosition(  fld.getId() );   }  }
						}
	}) ,width : 200 ,RMtable : "ansGrid",idField : "id" }
,SpecColopen1074286051,SpecColnogo1074286051]
,plugins :[this.orderDD = new Ext.ux.dd.GridDragDropRowOrder({scrollable:true}),SpecColfilter1074286051,SpecColopen1074286051,SpecColnogo1074286051,new Ext.ux.grid.ArrowKeys()],clicksToEdit:2,loadMask:true
,tbar:[
//ADDING THE ADD BUTTON
{text:'Add',iconCls:'icon-add-record', handler : function(){ grid1074286051.RMaddRow() }
}
,
//ADDING THE REMOVE BUTTON
{text:'Remove',iconCls:'icon-delete-record', handler:function(){
var sm = grid1074286051.getSelectionModel();if(sm.hasSelection()){
var sel = sm.getSelections();
Ext.Msg.show({ title:'Remove '+sel.length+ ' record'+( sel.length==1 ? '':'s') ,buttons: Ext.MessageBox.YESNO,msg:'Are you sure?',fn: function(btn){if(btn == 'yes'){
						var ids = new Array(); var x; for(x=0; x<sel.length ;x++){grid1074286051.getStore().remove(sel[x]);}    }} }); } }}
,'-',{
			text:'Set rotate from',name:'rotateFrom',handler:function(){ 
			var sel = grid1074286051.selModel.getSelected();
			if(!sel) return;
			var str = grid1074286051.getStore();
			grid1074286051.RMrotFrom = str.indexOf( sel )+1;
			this.setText('Rotate from: <b>'+sel.data.pos + ' - '+sel.data.ans.substr(0,30)+'</b>');
		}
		},'-',{
			text:'Set rotate to',name:'rotateTo',handler:function(){
			var sel = grid1074286051.selModel.getSelected();
			if(!sel) return;
			var str = grid1074286051.getStore();
			grid1074286051.RMrotTo = str.indexOf( sel )+1;
			this.setText('Rotate to: <b>'+sel.data.pos + ' - '+sel.data.ans.substr(0,30)+'</b>');
		}
		},'-',{
			text:'Cancel rotation',handler:function(){
			var sel = grid1074286051.selModel.getSelected();
			var str = grid1074286051.getStore();
			grid1074286051.RMrotFrom = 0;
			grid1074286051.RMrotTo = 0;
			grid1074286051.getTopToolbar().find('name','rotateFrom')[0].setText('Set rotate from');
			grid1074286051.getTopToolbar().find('name','rotateTo')[0].setText('Set rotate to');
			//console.log( grid1074286051.getTopToolbar().find('name','rotateFrom')  );
		}
		},'Up/down rotation:',{
			//xtype:'textfield',
			xtype:'combo',
			store:new Ext.data.JsonStore({
						url:'webcati/_ajax/buildQuestionare/ajax.buildQuestionnaire.php',
						baseParams: { action: 'qCombo',RMtable: 'Vecer_2012_maj' },
						fields: ['id','q_name'],
						autoLoad: true,
						root: 'rows'
				}),
			ref: 'upDownRot',
			tpl:'<tpl for=".">' +
			'<div class="x-combo-list-item">' +
			'{q_name}&nbsp;' +
			'</div></tpl>',
			forceSelection:true,
			triggerAction:'all',
			displayField:'q_name'
		},{ text:'Manage groups',
					iconCls:'RMicon_window_splitter',
					handler: function(){
					
				var grp = grid1074286051.getStore().collect('group');
				var grpData = grid1074286051.groupData.split('<*>');
				
				var items = new Array();
				items.push({
					xtype: 'combo',
					mode: 'local',
					triggerAction:'all',
					editable: false,
					value: grid1074286051.groupLayout,
				    store: new Ext.data.ArrayStore({
				        fields: [
				            'myId',
				            'displayText'
				        ],
				        data: [[1, 'vertical'], [2, 'horizontal'],[3,'custom(template)']]
				    }),
				    value: grid1074286051.groupLayout,
				    valueField: 'myId',
				    displayField: 'displayText',
				    fieldLabel: 'Layout'
					
					});
				var grpIndex = 0;	
				Ext.each( grp,function(tmp){
						var grpTmpData = grpData[grpIndex] ? grpData[grpIndex].split(',') : [];
						items.push(
							{
							xtype: 'fieldset',
							title:'Group '+tmp,
							items:[{
								xtype: 'combo',
								mode: 'local',
								triggerAction:'all',
								editable: false,
								value: grpTmpData[0],
							    store: new Ext.data.ArrayStore({
							         fields: [
							            'myId',
							            'displayText'
							        ],
							        data: [[1, 'vertical'], [2, 'horizontal']]
							    }),
							    valueField: 'myId',
							    displayField: 'displayText',
							    fieldLabel: 'Layout'
							
							},{
								xtype:'textfield',
								fieldLabel:'Spacing',
								value: grpTmpData[1]
							}]
							});
						grpIndex++;
				});
					
						
			var w= new Ext.Window({
				layout:'form', modal:true, padding:'10',
				items: items,
				width:350,
				buttons:[{
				text:'Save',
				handler: function(){
					grid1074286051.groupLayout = w.items.items[0].getValue();
					var grpData = new Array();
					for(var i=0;i<grp.length;i++)
					{
						grpData.push( w.items.items[i+1].items.items[0].getValue() + ',' + w.items.items[i+1].items.items[1].getValue() );
					}
					grid1074286051.groupData = grpData.join('<*>');
					w.close();
			}
		}]
		}).show();
		}
		},{iconCls:'x-tbar-loading', handler:function(){
			Ext.Msg.show({ title:'Restore changes' ,buttons: Ext.MessageBox.YESNO,msg:'Are you sure?',
			fn: function(btn){if(btn == 'yes'){
			 grid1074286051.getStore().reload();
			 }}});
			} }]
//ADDING THE AFTER EDIT LISTENER
,sm: new Ext.grid.RowSelectionModel({singleSelect : true}) , closable : true, autoExpandColumn : 'ans', autoExpandMin : 50, autoExpandMax : 1000, stopEditing : function(cancel){
		        if(this.editing){
		            var ae = this.lastActiveEditor = this.activeEditor;
		            if(ae){
		                ae[cancel === true ? 'cancelEdit' : 'completeEdit']();
		                this.view.focusCell(ae.row, ae.col);
		                
		
		                
		                 if(cancel){
			        	if(ae.record.data.ans=='')
			        	{this.getStore().remove(ae.record);}}
		            }
		            this.activeEditor = null;
		        }
		        this.editing = false;
		       
		    }, onEditComplete : function(ed, value, startValue){
		       
		        Ext.grid.EditorGridPanel.prototype.onEditComplete.call(this,ed,value,startValue);
		        var r = ed.record,
		            field = this.colModel.getDataIndex(ed.col);
		        value = this.postEditValue(value, startValue, r, field);
		        if((field == 'ans' || field == 'pos') && value=='')
		        {
		        	
		        	this.getStore().remove(ed.record);
		        }
		        
		    }, saveFunction : function(close){
			
			
			var p = this.saveGetData();
			if( 'odg_sql' == 'odg_sql' )
			{
				var ud = this.getTopToolbar().upDownRot.getValue();
				if( ud )
				{
					p.upDownRot = ud;
				}
			}
			Ext.Ajax.request(
							{url:'webcati/_ajax/buildQuestionare/ajax.buildQuestionnaire.php',params:Ext.apply(p, {action:'updateAnswers',RMtable:'Vecer_2012_maj',
							id:35,database:'Warpit_Webcati',dataIndex: 'odg_sql'
							,
							rotFrom:grid1074286051.RMrotFrom,
							rotTo:grid1074286051.RMrotTo,
							
							groupLayout: grid1074286051.groupLayout,
							groupData: grid1074286051.groupData,
							id_language:'45'
							})
							,success: function(resp,opt){ successFunc(resp,opt,close); }
							});
			
			}, saveGetData : function(close){
			var str = new Array();
			var ng = new Array();
			var hasFilter = false;
			var filter = new Array();
			var open = new Array();
				var grp = new Array();
			grid1074286051.stopEditing();
			grid1074286051.getStore().each(function(rec){
					str.push(rec.data.pos +' '  + rec.data.ans);
					if(rec.data.nogo)
					{
						ng.push(rec.data.pos);
					}
					if(rec.data.filCnd)
					{
						hasFilter = true;
					}
					filter.push( (rec.data.filter ? '1' : '0')+ (rec.data.filCnd ? rec.data.filCnd : '' )     );
					if(rec.data.open)
					{
						open.push(rec.data.pos);
					}
						grp.push(rec.data.group);
					
				});
			return {
						value:str.join('/'),
						nogo:ng.join() ,filter_answer : hasFilter ? filter.join('<!>'):'',
							open_data : open.join(':'),
							groups:grp.join(),
							};
							
			
			}, RMconn : new RMajax({url:'webcati/_ajax/buildQuestionare/ajax.buildQuestionnaire.php',
	 	params:{'RMtable':'ansGrid',database:'',RMcomp:'grid',id:35,projName:'Vecer_2012_maj',dataIndex:'odg_sql',id:35 ,id_language:'45'} }), useCtrl : true, dateSQL : 'Y-m-d', RMaddRow : function(){var tmpStore =  grid1074286051.getStore(); grid1074286051.RMconn.request({params: {action: 'insert',defaultFields : "pos,ans",defaultValues :"'"+ (tmpStore.getCount() == 0 ? 1 : ( parseInt(tmpStore.getAt(tmpStore.getCount()-1).data.pos) + 1 )) +"',''"},success: function(resp,opt){
					var response  = Ext.decode(resp.responseText);
					if(response.success == false)
					{
						alert('Error: '+response.error);
						return;
					}	var insert_id = Ext.util.JSON.decode(resp.responseText).insert_id;
var lastRow = tmpStore.getCount();tmpStore.insert(lastRow,new ds_model1074286051({id:insert_id , pos: ""+ (tmpStore.getCount() == 0 ? 1 : ( parseInt(tmpStore.getAt(tmpStore.getCount()-1).data.pos) + 1 )) +"", ans: ""}));
;grid1074286051.startEditing(lastRow,1);}});},buttons:[{ text : 'Save',handler: function(){ grid1074286051.saveFunction(false); }  },{ text : 'Save&amp;Close',handler: function(){ grid1074286051.saveFunction(true); }  },{ text : 'Cancel',handler: function(){
				Ext.getCmp('wcbqTabPanel_Vecer_2012_maj').remove(edit_Vecer_2012_majE2A_Answers);
			}  }] ,listeners: {beforeedit:function(e){
						if(e.column == 3){
								edit_Vecer_2012_majE2A_Answers_tbar.gRow = e.row;
								edit_Vecer_2012_majE2A_Answers_tbar.gCell =   e.column;
								edit_Vecer_2012_majE2A_Answers_tbar.cmp = 'grid';
							}
					}}});
grid1074286051.on('render', function(cmp){cmp.getStore().reload(); });grid1074286051.store.on('load',function(){
					var groupData = this.reader.jsonData.groupData.split('<|>');
					grid1074286051.groupLayout = groupData[0] || '';
					grid1074286051.groupData = groupData[1] || '';
					
					var updown = this.reader.jsonData.upDownRot;
					grid1074286051.getTopToolbar().upDownRot.setValue(updown);});grid1074286051.on('afterrender',function(){
				grid1074286051.RMdd = new Ext.wc.DropQuestion(grid1074286051.el,{RMconn:Ext.getCmp('grid1408602956').RMconn,grid:grid1074286051,field:grid1074286051,cmp:'grid' ,ddGroup:'wcqbGroup',textVar:'qName'
				,notifyDrop: function(dds,e,data) {
					if(dds.ddGroup == 'GridDD')
					{
						return grid1074286051.plugins[0].target.notifyDrop(dds,e,data);
					}
					elTargt =  e.getTarget('div.x-grid3-cell-inner');
					this.elTarget = elTargt;
					if(elTargt)
					{
						this.elTargCmp = 'cell';
						var gv = grid1074286051.getView();
						var row = gv.findRowIndex(elTargt);
						var cell = gv.findCellIndex(elTargt);
						var rec = grid1074286051.getStore().getAt(row);
						this.gRow=row;
						this.gCell = cell;
						if(gv.cm.getColumnId(cell) == 'filCnd')
						{
							//if column is condition we call the basic add data
							return this.myNotifyDrop(dds,e,data);
							
							var text = rec.get('filCnd');
							if(text.length != 0 && text.charAt(text.length - 1) != ' ')
							{
								text+=' ';
							}
							rec.set('filCnd',text+'$'+data.node.attributes.text);
							grid1074286051.startEditing(row,cell);
							
						}
						return true;
					}
					elTargt =  e.getTarget('input.x-form-text');
					if(elTargt)
					{
					var ae = grid1074286051.activeEditor;
			
					this.gRow = ae.row;
					this.gCell = ae.col;
					this.fCaret= getCaretPosition(  ae.field.getId() );
					this.elTargCmp = 'editor';
					return this.myNotifyDrop(dds,e,data);;
					
						field =  grid1074286051.activeEditor.field;
					var pos= getCaretPosition(  field.getId() );
					var t = field.getValue();
					var addT = ' $'+data.node. attributes.text+' ';
					
					field.setValue( t.substring(0,pos) +addT+t.substring(pos,t.length) );
					//field.setValue('aa');
					
					setCaretPosition(field.getId(),pos+addT.length);
					return true;
					}
					
					
					}
				,notifyOver: function(dds,e,data){
					if(dds.ddGroup == 'GridDD')
						{
							return grid1074286051.plugins[0].target.notifyOver(dds,e,data);
						}
					var elTargt = e.getTarget('div.x-grid3-cell-inner');
					if(	elTargt )
					{
						var cell = grid1074286051.getView().findCellIndex(elTargt);
						if(cell == 4)
							return Ext.dd.DropZone.prototype.dropAllowed;
							
					}
					return Ext.dd.DropZone.prototype.dropNotAllowed;
					
				
					
					},
		 updateField:function(dds,e,val){ 
				 	//elTargt =  e.getTarget('div.x-grid3-cell-inner');
				 	
					if(this.elTargCmp == 'cell')
					{
						var gv = grid1074286051.getView();
						var row = gv.findRowIndex(this.elTarget);
						var cell = gv.findCellIndex(this.elTarget);
						var rec = grid1074286051.getStore().getAt(row);
						if(gv.cm.getColumnId(cell) == 'filCnd')
						{
							var text = rec.get('filCnd');
							if(text.length != 0 && text.charAt(text.length - 1) != ' ')
							{
								text+=' ';
							}
							rec.set('filCnd',text+val);
							grid1074286051.startEditing(row,cell);
							
						}
						return true;
					}
					//elTargt =  e.getTarget('input.x-form-text');
					if(this.elTargCmp == 'editor')
					{
					
					
					wcbqAddTextField(this,val,true);
					
					return true;
					}
				 }
				
				}   ); });
				grid1074286051.on('beforedestroy',function(){
			grid1074286051.RMdd.destroy();
			grid1074286051.plugins[0].target.destroy();
				});grid1074286051.on('afteredit',function(e){
				//e.record.commit();
				if(e.column == 1 && e.value != '')
				{
					if(e.originalValue  == '')
					{
					
						grid1074286051.RMaddRow.defer(100);
					}
				}
				
				
			} );
			var edit_Vecer_2012_majE2A_Answers_tbar = new Ext.ux.CalcTBar();
				edit_Vecer_2012_majE2A_Answers_tbar.grid = grid1074286051;
			var edit_Vecer_2012_majE2A_Answers = new Ext.Panel({
			title:'E2A - Answers',iconCls:'RMicon_edit_record',layout:'fit',closable:true,items:[grid1074286051 ]
			,tbar:edit_Vecer_2012_majE2A_Answers_tbar ,id:'edit_Vecer_2012_majE2A_Answers'
			});
			Ext.getCmp('wcbqTabPanel_Vecer_2012_maj').add(edit_Vecer_2012_majE2A_Answers).show();