var Tufi = function(){
	var tufiSelectedMedia, mediaDlg, tufiGridMedia, tufiGridLeft, tufiGridRight, tufiColModelMedia, tufiColModelMediaS, tufiDsMedia, 
		tufiDataLeft, tufiDsMediaLeft, tufiDataRight, tufiDsMediaRight;
	var temperatureDlg, temperature, temperatureUnit, mediaPost="";
	var contentStore,resultStore,tufiColResult,tufiGridResult,resultPost;
	var validationDlg,validation1Post=false,validation2Post=false,validation3Post=false,
	    validation4Post=false,validation5Post=false,validation6Post=false,validation7Post=false;
	var sterilDlg,steril1Post=false,steril2Post=false,steril3Post=false,
	    permeaDlg,permeaPost=false,pumpableDlg,pumpablePost=false,lifetimeDlg,lifetimePost=false;
    var colourDlg,colourPost,tufiGridColour,tufiColModelColour,colourStore;
    var dimDlg,dimPost="",tufiGridDim,tufiColModelDim,dimStore,dimUnit="mm";
    var pressureDlg,pressurePost="",resultWindow="";
	return {
		init : function(){
            this.contentStore = new Ext.data.Store({
	            proxy: new Ext.data.HttpProxy({url: 'contentList.asp?lang='+lang}),
	            reader: new Ext.data.XmlReader({
		            record: 'content',
		            id: 'id'
		            }, [
		            'name'
	            ])
            });
            pointeur = this;
            this.contentStore.load({callback: this.display});
        },
		display : function(r, options, success){
			if (!success) 
                return Ext.Msg.alert('erreur', 'erreur!');
			tufiSelectedMedia = [];
		    temperature = "";
		    temperatureUnit = "C";
			var tb = new Ext.Toolbar('toolbar');
            // add a combobox to the toolbar
            language = [
                ["EN","English"],
                ["FR","French"],
                ["DE","German"]
            ];
            var languageStore = new Ext.data.SimpleStore({
                fields: ['abbr', 'lang'],
                data : language
            });
            var comboLanguage = new Ext.form.ComboBox({
                store: languageStore,
                editable: false,
                valueField: 'abbr',
                displayField:'lang',
                mode: 'local',
                emptyText:'Select a language...',
                width:135
            });
            comboLanguage.on("select",
                function(field){
                    window.location.replace(window.location.pathname+"?lang="+field.getValue());
            });
            comboLanguage.applyTo('languageCombo');
            tb.add(
	            new Ext.Toolbar.Separator(),
	            new Ext.Toolbar.Button({
		            text: pointeur.contentStore.getById("menu02").get("name"), handler: pointeur.showMediaDialog, scope: pointeur
	            }),
	            new Ext.Toolbar.Separator(),
	            new Ext.Toolbar.Button({
		            text: pointeur.contentStore.getById("menu03").get("name"), handler: pointeur.showTemperatureDialog, scope: pointeur
	            }),
	            new Ext.Toolbar.Separator(),
	            new Ext.Toolbar.Button({
		            text: pointeur.contentStore.getById("menu04").get("name"), handler: pointeur.showDimDialog, scope: pointeur
	            }),
	            new Ext.Toolbar.Separator(),
	            new Ext.Toolbar.Button({
		            text: pointeur.contentStore.getById("menu05").get("name"), handler: pointeur.showPressureDialog, scope: pointeur
	            }),
	            new Ext.Toolbar.Separator(),
	            new Ext.Toolbar.Button({
		            text: pointeur.contentStore.getById("menu06").get("name"), handler: pointeur.showValidationDialog, scope: pointeur
	            }),
	            new Ext.Toolbar.Separator(),
	            new Ext.Toolbar.Button({
		            text: pointeur.contentStore.getById("menu07").get("name"), handler: pointeur.showPermeaDialog, scope: pointeur
	            }),
	            new Ext.Toolbar.Separator(),
	            new Ext.Toolbar.Button({
		            text: pointeur.contentStore.getById("menu08").get("name"), handler: pointeur.showPumpableDialog, scope: pointeur
	            }),
	            new Ext.Toolbar.Separator(),
	            new Ext.Toolbar.Button({
		            text: pointeur.contentStore.getById("menu09").get("name"), handler: pointeur.showColourDialog, scope: pointeur
	            })
	            // new Ext.Toolbar.Separator(),
	            // new Ext.Toolbar.Button({
		            // text: pointeur.contentStore.getById("menu10").get("name"), handler: pointeur.showLifetimeDialog, scope: pointeur
	            // }),
	            // new Ext.Toolbar.Separator(),
	            // new Ext.Toolbar.Button({
		            // text: pointeur.contentStore.getById("menu11").get("name"), handler: pointeur.showColourDialog, scope: pointeur
	            // })
            );
            document.getElementById("criteria").innerHTML = pointeur.contentStore.getById("criteria").get("name");
            document.getElementById("results").innerHTML = pointeur.contentStore.getById("result").get("name");
            document.getElementById("legal").innerHTML = pointeur.contentStore.getById("legal").get("name");
            document.getElementById("intro").innerHTML = pointeur.contentStore.getById("intro").get("name");
            document.getElementById("news").innerHTML = pointeur.contentStore.getById("news").get("name");
			tufiDsMedia = new Ext.data.Store({
				proxy: new Ext.data.MemoryProxy(tufiSelectedMedia),
				reader: new Ext.data.ArrayReader({}, [{name: 'media'},{name: 'id'}])
			});
			tufiDsMedia.load();
			tufiColModelMedia = new Ext.grid.ColumnModel([
				{id:'media',header: pointeur.contentStore.getById("menu02").get("name"), width: 160, dataIndex: 'media'}
			]);
			tufiColModelMediaS = new Ext.grid.ColumnModel([
				{id:'media',header: pointeur.contentStore.getById("selection").get("name"), width: 160, dataIndex: 'media'}
			]);
			tufiGridMedia = new Ext.grid.Grid('tufi-grid-media', {
				ds: tufiDsMedia,
				cm: tufiColModelMedia,
				enableColumnMove: false,
				selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),
				autoExpandColumn: 'media'
			});
			Ext.BorderLayout.create({
				center: {
					margins:{left:3,top:3,right:3,bottom:3},
					panels: [new Ext.GridPanel(tufiGridMedia)]
				}
			}, 'tufiGridPanelMedia');
			tufiGridMedia.render();
            resultStore = new Ext.data.Store({
	            proxy: new Ext.data.HttpProxy({url: 'resultList.asp'}),
	            reader: new Ext.data.XmlReader({
		            record: 'result'
		            }, [
		            'id','name', 'formulation'
	            ])
            });
			pointeur.checkCriteria();
            pointeur.updateResult();
/*	        resultPost = "";
			resultStore.load({params:{lang : lang},
			    callback: function(r, options, success) {
				    if (success) {
                        document.getElementById("number").innerHTML=r.length;
                        for (i=0;i<r.length;i++)
            			    resultPost += r[i].id+"_";}
				    else Ext.Msg.alert('Cookie Alerte', 'Erreur result!');
			    }
			});*/
			tufiColResult = new Ext.grid.ColumnModel([
				{id:'result',header: pointeur.contentStore.getById("result14").get("name"), width: 160, dataIndex: 'name'},
				{header: pointeur.contentStore.getById("result13").get("name"), width: 110, dataIndex: 'formulation'}
			]);
			tufiGridResult = new Ext.grid.Grid('tufi-grid-result', {
				ds: resultStore,
				cm: tufiColResult,
					selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),
				enableColumnMove: false,
				autoExpandColumn: 'result'
			});
			Ext.BorderLayout.create({
				center: {
					margins:{left:3,top:3,right:3,bottom:3},
					panels: [new Ext.GridPanel(tufiGridResult)]
				}
			}, 'tufiGridPanelResult');
			tufiGridResult.render();
            var formNewButton = new Ext.form.Form({
                buttonAlign : "right",
                labelWidth: 75 // label settings here cascade unless overridden
            });
            newButton = formNewButton.addButton(pointeur.contentStore.getById("nsearch").get("name"));
            newButton.on("click",
                function(){
                    window.location.reload();
            });
            formNewButton.render('formNewButton');
            var formResultButton = new Ext.form.Form({
                buttonAlign : "right",
                labelWidth: 75 // label settings here cascade unless overridden
            });
            ResultButton = formResultButton.addButton(pointeur.contentStore.getById("results").get("name"));
            ResultButton.on("click",
                function(){
                    if (resultWindow!="") resultWindow.close();
                    resultWindow = window.open ('result.asp?lang='+lang+'&resultGet='+resultPost, '', 
                        config='height=500, width=700, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no');
            });
            formResultButton.render('formResultButton');
            window.setTimeout(function() {document.getElementById("tufiGridPanelMedia").style.display="none";}, "10");
            
		},
		showMediaDialog : function(e){
			if(!mediaDlg){ // lazy initialize the dialog and only create it once
				mediaDlg = new Ext.LayoutDialog("tufiMediaDlg", { 
					autoTabs:true,
					width:500,
					title:pointeur.contentStore.getById("menu02").get("name"),
					collapsible:false,
					resizable:false,
					height:420,
					width:600,
					modal:true,
					shadow:true,
					minWidth:300,
					minHeight:250,
					proxyDrag: true,
					center: {}
				});
				document.getElementById("tufiMediaContent").innerHTML = pointeur.contentStore.getById("media1").get("name");
				var mediaDlgLayout = mediaDlg.getLayout();
				mediaDlg.addKeyListener(27, mediaDlg.hide, mediaDlg);
				mediaDlg.addButton(pointeur.contentStore.getById("validate").get("name"), this.updateMediaList, mediaDlg);
				mediaDlg.addButton(pointeur.contentStore.getById("cancel").get("name"), mediaDlg.hide, mediaDlg);
				tufiDataLeft = [];
				tufiDataLeft = tufiDataMedia;
				tufiDsMediaLeft = new Ext.data.Store({
					proxy: new Ext.data.MemoryProxy(tufiDataLeft),
					reader: new Ext.data.ArrayReader({}, [{name: 'media'},{name: 'id'}])
				});
				tufiDsMediaLeft.load();
				// create the tufiGridLeft
				tufiGridLeft = new Ext.grid.Grid('tufi-grid-left', {
					ds: tufiDsMediaLeft,
					cm: tufiColModelMedia,
    				enableColumnMove: false,
					autoExpandColumn: 'media'
				});
				mediaDlgLayout.add('center',
					new Ext.ContentPanel("tufiMediaDlgCenter",{})
				);
				Ext.BorderLayout.create({
					center: {
						margins:{left:3,top:3,right:3,bottom:3},
						panels: [new Ext.GridPanel(tufiGridLeft)]
					}
				}, 'tufiGridPanelLeft');
		    	tufiGridLeft.on("rowdblclick", this.tufiDbleClkLeft);
				tufiGridLeft.render();
				tufiDataRight = [];
				tufiDsMediaRight = new Ext.data.Store({
					proxy: new Ext.data.MemoryProxy(tufiDataRight),
					reader: new Ext.data.ArrayReader({}, [{name: 'media'},{name: 'id'}])
				});
				tufiDsMediaRight.load();
				// create the Grid
				tufiGridRight = new Ext.grid.Grid('tufi-grid-right', {
					ds: tufiDsMediaRight,
					cm: tufiColModelMediaS,
    				enableColumnMove: false,
					autoExpandColumn: 'media'
				});
				Ext.BorderLayout.create({
					center: {
						margins:{left:3,top:3,right:3,bottom:3},
						panels: [new Ext.GridPanel(tufiGridRight)]
					}
				}, 'tufiGridPanelRight');
				tufiGridRight.on("rowdblclick", this.tufiDbleClkRight);
		        tufiGridRight.render();
				new Ext.Button("tufiButtonRight", { 
					text:">",
					minWidth:50,
					handler:this.tufiToRight
				});
				new Ext.Button("tufiButtonLeft", { 
					text:"<",
					minWidth:50,
					handler:this.tufiToLeft
				});
		
				new Ext.Button("tufiButtonRemoveAll", { 
					text:"<<",
					minWidth:50,
					handler:this.tufiGridRemoveAll
				});
			}
			tufiDsMediaLeft.load();
			tufiDsMediaRight.load();
			mediaDlg.show(e.getEl());
		},
		checkCriteria : function(){
		    document.getElementById("bottom").style.top = Math.max(190+document.getElementById("criteriaZone").offsetHeight+20,525)+"px";
//		    criteriaZone
//		    bottom 580px
		},
		updateMediaList : function(e){
			if (tufiDsMediaRight.getCount()>0) {
			    document.getElementById("tufiGridPanelMedia").style.display="block";
			    document.getElementById("tufiMediaBR").innerHTML = "<br />";
                document.getElementById("mediaTrash").innerHTML = "<img style=\"cursor:hand\" onclick=\"pointeur.removeAllMedia();\" src=trash2.jpg alt=\""+pointeur.contentStore.getById("trash").get("name")+" "+pointeur.contentStore.getById("menu02").get("name")+"\" />";
			}
			else {
			    document.getElementById("tufiGridPanelMedia").style.display="none"; 
			    document.getElementById("tufiMediaBR").innerHTML="";
                document.getElementById("mediaTrash").innerHTML = "";
			}
			tufiSelectedMedia = [];
			tufiDataLeft = [];
			tufiDataRight = [];
			mediaPost = "";
			tufiDsMediaRight.each(function (record) {
				tufiSelectedMedia.push([record.get("media"),record.get("id")]);
				tufiDataRight.push([record.get("media"),record.get("id")]);
    			mediaPost += record.get("id")+"_";
			});
			tufiDsMediaLeft.each(function (record) {
				tufiDataLeft.push([record.get("media"),record.get("id")]);
			});
			tufiDsMedia = new Ext.data.Store({
				proxy: new Ext.data.MemoryProxy(tufiSelectedMedia),
				reader: new Ext.data.ArrayReader({}, [{name: 'media'},{name: 'id'}])
			});
			tufiDsMediaLeft = new Ext.data.Store({
				proxy: new Ext.data.MemoryProxy(tufiDataLeft),
				reader: new Ext.data.ArrayReader({}, [{name: 'media'},{name: 'id'}])
			});
			tufiDsMediaRight = new Ext.data.Store({
				proxy: new Ext.data.MemoryProxy(tufiDataRight),
				reader: new Ext.data.ArrayReader({}, [{name: 'media'},{name: 'id'}])
			});
			tufiDsMedia.load();
			tufiGridMedia.reconfigure(tufiDsMedia, tufiColModelMedia);
			tufiGridLeft.reconfigure(tufiDsMediaLeft, tufiColModelMedia);
			tufiGridRight.reconfigure(tufiDsMediaRight, tufiColModelMediaS);
			mediaDlg.hide();
			pointeur.checkCriteria();
            pointeur.updateResult();
//			alert(mediaPost);
		},
		removeAllMedia : function () {
			tufiDataRight = [];
			tufiDataLeft = tufiDataMedia;
			tufiDsMediaLeft = new Ext.data.Store({
				proxy: new Ext.data.MemoryProxy(tufiDataLeft),
				reader: new Ext.data.ArrayReader({}, [{name: 'media'},{name: 'id'}])
			});
			tufiDsMediaRight = new Ext.data.Store({
				proxy: new Ext.data.MemoryProxy(tufiDataRight),
				reader: new Ext.data.ArrayReader({}, [{name: 'media'},{name: 'id'}])
			});
			tufiDsMediaLeft.load();
			tufiDsMediaRight.load();
			tufiGridLeft.reconfigure(tufiDsMediaLeft, tufiColModelMedia);
			tufiGridRight.reconfigure(tufiDsMediaRight, tufiColModelMediaS);
			mediaPost = "";
		    document.getElementById("tufiGridPanelMedia").style.display="none"; 
		    document.getElementById("tufiMediaBR").innerHTML="";
            document.getElementById("mediaTrash").innerHTML = "";
            pointeur.updateResult();
		},
		tufiDbleClkLeft : function (source,rowIndex,e){
			selectedEl = tufiDsMediaLeft.getAt(rowIndex);
			tufiDsMediaRight.add(selectedEl);
			tufiDsMediaRight.sort("media","ASC");
			tufiDsMediaLeft.remove(selectedEl);
			return false;
		},
		tufiDbleClkRight : function (source,rowIndex,e){
			selectedEl = tufiDsMediaRight.getAt(rowIndex);
			tufiDsMediaLeft.add(selectedEl);
			tufiDsMediaLeft.sort("media","ASC");
			tufiDsMediaRight.remove(selectedEl);
			return false;
		},
		tufiToRight : function (){
			selectionModel = tufiGridLeft.getSelectionModel();
			if (selectionModel.hasSelection()) {
				selections = selectionModel.getSelections();
				for (i=0;i<selections.length;i++) {
				tufiDsMediaRight.add(selections[i]);
					tufiDsMediaLeft.remove(selections[i]);
				}
				tufiDsMediaRight.sort("media","ASC");
			}
		},
		tufiToLeft : function (){
			selectionModel = tufiGridRight.getSelectionModel();
			if (selectionModel.hasSelection()) {
				selections = selectionModel.getSelections();
				for (i=0;i<selections.length;i++) {
					tufiDsMediaLeft.add(selections[i]);
					tufiDsMediaRight.remove(selections[i]);
				}
				tufiDsMediaLeft.sort("media","ASC");
			}
		},
		tufiTransferToLeft : function (record){
			tufiDsMediaLeft.add(record);
		},
		tufiGridRemoveAll : function (){
			tufiDsMediaRight.each(Tufi.tufiTransferToLeft);
			tufiDsMediaLeft.sort("media","ASC");
			tufiDsMediaRight.removeAll();
		},
		showTemperatureDialog : function(e){
			if(!temperatureDlg){ // lazy initialize the dialog and only create it once
				temperatureDlg = new Ext.LayoutDialog("tufiTemperatureDlg", { 
					autoTabs:true,
					width:500,
					title:pointeur.contentStore.getById("menu03").get("name"),
					collapsible:false,
					resizable:false,
					height:190,
					width:280,
					modal:true,
					shadow:true,
					minWidth:300,
					minHeight:250,
					proxyDrag: true,
					center: {}
				});
				document.getElementById("tufiTemperatureContent").innerHTML = pointeur.contentStore.getById("temperature1").get("name")+"<br><br>";
				var temperatureDlgLayout = temperatureDlg.getLayout();
				temperatureDlg.addKeyListener(27, temperatureDlg.hide, temperatureDlg);
				temperatureDlg.addButton(pointeur.contentStore.getById("validate").get("name"), this.updateTemperature, temperatureDlg);
				temperatureDlg.addButton(pointeur.contentStore.getById("cancel").get("name"), temperatureDlg.hide, temperatureDlg);
				temperatureDlgLayout.add('center',
					gpLoginDivCenter=new Ext.ContentPanel("tufiTemperatureDlgCenter",{})
				);
				var temperatureForm = new Ext.form.Form({
			        labelWidth: 100 // label settings here cascade unless overridden
				});
				temperatureForm.column(
					{width:150, hideLabels:false},
					unitF = new Ext.form.Radio({
						fieldLabel: pointeur.contentStore.getById("unit").get("name")+" ",
						name: 'unit',
						boxLabel:"°F",
						value:"F",
						checked:true
					})
				);
				temperatureForm.column(
					{width:40, hideLabels:true},
					unitC = new Ext.form.Radio({
						name: 'unit',
						value:"C",
						boxLabel:"°C"
					})
				);
				temperatureForm.add(
					unitV = new Ext.form.NumberField({
						fieldLabel: pointeur.contentStore.getById("menu03").get("name")+" ",
						decimalPrecision: 0,
						name: 'temperature',
						width:100,
						allowBlank:false
					})
				);
				temperatureForm.render("tufiTemperatureDlgCenter");
			}
            if (temperatureUnit == "F")
                document.getElementById(unitF.getId()).checked=true;
            else
                document.getElementById(unitC.getId()).checked=true;
			temperatureDlg.show(e.getEl());
			document.getElementById(unitV.getId()).value=temperature;
//        	setTimeout(function() {unitV.focus();}, 10);
		},
		updateTemperature : function(e){
            temperature = document.getElementById(unitV.getId()).value;
            if (document.getElementById(unitF.getId()).checked)
                temperatureUnit = "F";
            else
                temperatureUnit = "C";
			temperatureDlg.hide();
//			this.updateResult();
//			alert(mediaPost);
            if (temperature != "") {
                document.getElementById("temperature").innerHTML = pointeur.contentStore.getById("menu03").get("name")+": "+temperature+"°"+temperatureUnit+"<br /><br />";
                document.getElementById("temperatureTrash").innerHTML = "<img style=\"cursor:hand\" onclick=\"pointeur.removeTemperature();\" src=trash2.jpg alt=\""+pointeur.contentStore.getById("trash").get("name")+" "+pointeur.contentStore.getById("menu03").get("name")+"\" />";
            }
            else {
                document.getElementById("temperature").innerHTML = "";
                document.getElementById("temperatureTrash").innerHTML = "";
            }
			pointeur.checkCriteria();
            pointeur.updateResult();
		},
        removeTemperature : function() {
            document.getElementById("temperature").innerHTML = "";
            document.getElementById("temperatureTrash").innerHTML = "";
            temperature = "";
            pointeur.updateResult();
        },
		showDimDialog : function(e){
			if(!dimDlg){ // lazy initialize the dialog and only create it once
				dimDlg = new Ext.LayoutDialog("tufiDimDlg", { 
					autoTabs:true,
					width:500,
					title:pointeur.contentStore.getById("menu04").get("name"),
					collapsible:false,
					resizable:false,
					height:450,
					width:450,
					modal:true,
					shadow:true,
					minWidth:300,
					minHeight:250,
					proxyDrag: true,
					center: {}
				});
				document.getElementById("tufiDimContent").innerHTML = pointeur.contentStore.getById("dimension1").get("name")+"<br><br>";
				document.getElementById("tufiDimCommentVersitec").innerHTML = "<br><br><br><br><br><br><br><br><br><br><br><br><br><br>"+pointeur.contentStore.getById("dimVersitec").get("name");
				var dimDlgLayout = dimDlg.getLayout();
				dimDlg.addKeyListener(27, dimDlg.hide, dimDlg);
				dimDlg.addButton(pointeur.contentStore.getById("validate").get("name"), this.updateDim, dimDlg);
				dimDlg.addButton(pointeur.contentStore.getById("cancel").get("name"), dimDlg.hide, dimDlg);
				dimDlgLayout.add('center',
					gpLoginDivCenter=new Ext.ContentPanel("tufiDimDlgCenter",{})
				);
				var dimForm = new Ext.form.Form({
				});
				dimForm.column(
					{width:150, hideLabels:true},
					unitI = new Ext.form.Radio({
						name: 'unit',
						boxLabel:pointeur.contentStore.getById("inch").get("name"),
						value:"inch",
						checked:true
					})
				);
				dimForm.column(
					{width:150, hideLabels:true},
					unitM = new Ext.form.Radio({
						name: 'unit',
						value:"C",
						boxLabel:pointeur.contentStore.getById("metric").get("name")
					})
				);
				dimForm.render("tufiDimForm");
				dimStore = new Ext.data.Store({
	                proxy: new Ext.data.HttpProxy({url: 'dimList.asp'}),
	                reader: new Ext.data.XmlReader({
		                record: 'dim'
		                }, [
//		                'id','dtInnerMm','dtOuterMm','dtWallMm','dtInnerInch','dtOuterInch','dtWallInch'
		                'id','dtInnerMm','dtOuterMm','dtWallMm','dtInnerInch','dtOuterInch','dtWallInch'
	                ])
				});
    		    tufiColModelDim = new Ext.grid.ColumnModel([
				    {header: pointeur.contentStore.getById("ID").get("name"), width: 70, dataIndex: 'dtInnerMm'},
				    {header: pointeur.contentStore.getById("OD").get("name"), width: 70, dataIndex: 'dtOuterMm'},
				    {header: pointeur.contentStore.getById("WALL").get("name"), width: 70, dataIndex: 'dtWallMm'},
				    {hidden:true,header: pointeur.contentStore.getById("ID").get("name"), width: 70, dataIndex: 'dtInnerInch'},
				    {hidden:true,header: pointeur.contentStore.getById("OD").get("name"), width: 70, dataIndex: 'dtOuterInch'},
				    {hidden:true,header: pointeur.contentStore.getById("WALL").get("name"), width: 70, dataIndex: 'dtWallInch'},
				    {id:'id',hidden:true,header: 'id', dataIndex: 'id'}
			    ]);
				tufiGridDim = new Ext.grid.Grid('tufi-grid-dim', {
					ds: dimStore,
					cm: tufiColModelDim,
    				enableColumnMove: false,
//					autoExpandColumn: 'dim',
					selModel:new Ext.grid.RowSelectionModel({singleSelect:true})
				});
				dimDlgLayout.add('center',
					new Ext.ContentPanel("tufiDimDlgCenter",{})
				);
				Ext.BorderLayout.create({
					center: {
						margins:{left:3,top:3,right:3,bottom:3},
						panels: [new Ext.GridPanel(tufiGridDim)]
					}
				}, 'tufiGridDim');
				tufiGridDim.render();
//                unitI.on('change', this.changeUnitDim);
                document.getElementById(unitI.getId()).onclick = this.changeUnitDimInch;
                document.getElementById(unitM.getId()).onclick = this.changeUnitDimMM;
			}
	        dimStore.load({params:{lang : lang,
	            resultPost : resultPost
	            },
	            callback: function(r, options, success) {
		            if (!success) 
		                Ext.Msg.alert('Cookie Alerte', 'Erreur dim!');
	            }
	        });
            if (dimUnit == "inch") {
                document.getElementById(unitI.getId()).checked=true;
                tufiGridDim.getColumnModel().setHidden(0,true);
                tufiGridDim.getColumnModel().setHidden(1,true);
                tufiGridDim.getColumnModel().setHidden(2,true);
                tufiGridDim.getColumnModel().setHidden(3,false);
                tufiGridDim.getColumnModel().setHidden(4,false);
                tufiGridDim.getColumnModel().setHidden(5,false);
            }
            else {
                document.getElementById(unitM.getId()).checked=true;
                tufiGridDim.getColumnModel().setHidden(0,false);
                tufiGridDim.getColumnModel().setHidden(1,false);
                tufiGridDim.getColumnModel().setHidden(2,false);
                tufiGridDim.getColumnModel().setHidden(3,true);
                tufiGridDim.getColumnModel().setHidden(4,true);
                tufiGridDim.getColumnModel().setHidden(5,true);
            }
			dimDlg.show(e.getEl());
		},
		changeUnitDimInch : function() {
            if (unitI.checked) {
                tufiGridDim.getColumnModel().setHidden(0,true);
                tufiGridDim.getColumnModel().setHidden(1,true);
                tufiGridDim.getColumnModel().setHidden(2,true);
                tufiGridDim.getColumnModel().setHidden(3,false);
                tufiGridDim.getColumnModel().setHidden(4,false);
                tufiGridDim.getColumnModel().setHidden(5,false);
                dimUnit = "inch";
            }
        }, 
		changeUnitDimMM : function() {
            if (unitM.checked) {
                tufiGridDim.getColumnModel().setHidden(0,false);
                tufiGridDim.getColumnModel().setHidden(1,false);
                tufiGridDim.getColumnModel().setHidden(2,false);
                tufiGridDim.getColumnModel().setHidden(3,true);
                tufiGridDim.getColumnModel().setHidden(4,true);
                tufiGridDim.getColumnModel().setHidden(5,true);
            }
        }, 
		updateDim : function(e){
			dimPost = "";
			displayMsg ="";
			selectionModel = tufiGridDim.getSelectionModel();
			if (selectionModel.hasSelection()) {
				selections = selectionModel.getSelections();
				dimPost = selections[0].get("id");
                displayMsg = pointeur.contentStore.getById("menu04").get("name")+": ";
                if (dimUnit == "inch") 
                    displayMsg += selections[0].get("dtInnerInch")+'\" '+selections[0].get("dtOuterInch")+'\" '+selections[0].get("dtWallInch")+'\" '+'<br /><br />';
                else
                    displayMsg += selections[0].get("dtInnerMm")+' mm '+selections[0].get("dtOuterMm")+' mm '+selections[0].get("dtWallMm")+' mm'+'<br /><br />';
                    document.getElementById("dimTrash").innerHTML = "<img style=\"cursor:hand\" onclick=\"pointeur.removeDim();\" src=trash2.jpg alt=\""+pointeur.contentStore.getById("trash").get("name")+" "+pointeur.contentStore.getById("menu04").get("name")+"\" />";
			} else
			{
                pressurePost = "";
                document.getElementById("pressure").innerHTML = "";
                document.getElementById("pressureTrash").innerHTML = "";
                document.getElementById("dimTrash").innerHTML = "";
			}
            document.getElementById("dim").innerHTML = displayMsg;
			dimDlg.hide();
			pointeur.checkCriteria();
            pointeur.updateResult();
		},
        removeDim : function(){
			dimPost = "";
            pressurePost = "";
            document.getElementById("dim").innerHTML = "";
            document.getElementById("pressure").innerHTML = "";
            document.getElementById("pressureTrash").innerHTML = "";
            document.getElementById("dimTrash").innerHTML = "";
            pointeur.updateResult();
        },
		showPressureDialog : function(e){
		    if(dimPost=="") {Ext.Msg.alert(pointeur.contentStore.getById("error").get("name"), pointeur.contentStore.getById("mustSelect").get("name"));return;}
			if(!pressureDlg){ // lazy initialize the dialog and only create it once
				pressureDlg = new Ext.LayoutDialog("tufiPressureDlg", { 
					autoTabs:true,
					width:500,
					title:pointeur.contentStore.getById("menu05").get("name"),
					collapsible:false,
					resizable:false,
					height:250,
					width:280,
					modal:true,
					shadow:true,
					minWidth:300,
					minHeight:250,
					proxyDrag: true,
					center: {}
				});
				document.getElementById("tufiPressureContent").innerHTML = pointeur.contentStore.getById("pressure1").get("name")+"<br><br>";
				document.getElementById("tufiPressureComment").innerHTML = "<br>"+pointeur.contentStore.getById("pressVersitec").get("name")+"<br><br>";
				var pressureDlgLayout = pressureDlg.getLayout();
				pressureDlg.addKeyListener(27, pressureDlg.hide, pressureDlg);
				pressureDlg.addButton(pointeur.contentStore.getById("validate").get("name"), this.updatePressure, pressureDlg);
				pressureDlg.addButton(pointeur.contentStore.getById("cancel").get("name"), pressureDlg.hide, pressureDlg);
				pressureDlgLayout.add('center',
					gpLoginDivCenter=new Ext.ContentPanel("tufiPressureDlgCenter",{})
				);
				var pressureForm = new Ext.form.Form({
			        labelWidth: 100 // label settings here cascade unless overridden
				});
				pressureForm.add(
					pressureField = new Ext.form.NumberField({
						fieldLabel: pointeur.contentStore.getById("menu05").get("name")+"(bar)",
						decimalPrecision: 2,
						name: 'pressure',
						width:100,
						allowBlank:true
					})
				);
				pressureForm.render("tufiPressureForm");
				
			}
			pressureDlg.show(e.getEl());
			document.getElementById(pressureField.getId()).value=pressurePost;
		},
		updatePressure : function(e){
            pressurePost = document.getElementById(pressureField.getId()).value;
			pressureDlg.hide();
            if (pressurePost != "") {
                document.getElementById("pressure").innerHTML = pointeur.contentStore.getById("menu05").get("name")+": "+pressurePost+" bar"+"<br /><br />";
                document.getElementById("pressureTrash").innerHTML = "<img style=\"cursor:hand\" onclick=\"pointeur.removePressure();\" src=trash2.jpg alt=\""+pointeur.contentStore.getById("trash").get("name")+" "+pointeur.contentStore.getById("menu05").get("name")+"\" />";
            }
            else {
                document.getElementById("pressure").innerHTML = "";
                document.getElementById("pressureTrash").innerHTML = "";
            }
			pointeur.checkCriteria();
            pointeur.updateResult();
		},
        removePressure : function(){
            pressurePost = "";
            document.getElementById("pressure").innerHTML = "";
            document.getElementById("pressureTrash").innerHTML = "";
            pointeur.updateResult();
        },
	    showValidationDialog : function(e){
		    if(!validationDlg){ // lazy initialize the dialog and only create it once
			    validationDlg = new Ext.LayoutDialog("tufiValidationDlg", { 
				    autoTabs:true,
				    width:500,
				    title:pointeur.contentStore.getById("menu06").get("name"),
				    collapsible:false,
				    resizable:false,
				    height:300,
				    width:280,
				    modal:true,
				    shadow:true,
				    minWidth:300,
				    minHeight:500,
				    proxyDrag: true,
				    center: {}
			    });
			    document.getElementById("tufiValidationContent").innerHTML = pointeur.contentStore.getById("validation1").get("name")+"<br><br>";
			    var validationDlgLayout = validationDlg.getLayout();
			    validationDlg.addKeyListener(27, validationDlg.hide, validationDlg);
			    validationDlg.addButton(pointeur.contentStore.getById("validate").get("name"), this.updateValidation, validationDlg);
			    validationDlg.addButton(pointeur.contentStore.getById("cancel").get("name"), validationDlg.hide, validationDlg);
			    validationDlgLayout.add('center',
				    gpLoginDivCenter=new Ext.ContentPanel("tufiValidationDlgCenter",{})
			    );
			    var validationForm = new Ext.form.Form({
		            labelWidth: 100 // label settings here cascade unless overridden
			    });
	            validationForm.column(
					{width:200, hideLabels:true},
				    validation1 = new Ext.form.Checkbox({
					    boxLabel: pointeur.contentStore.getById("result23").get("name")+" ",
					    checked:false
	                    }),
				    validation2 = new Ext.form.Checkbox({
					    boxLabel: pointeur.contentStore.getById("result24").get("name")+" ",
					    checked:false
	                    }),
				    validation3 = new Ext.form.Checkbox({
					    boxLabel: pointeur.contentStore.getById("result25").get("name")+" ",
					    checked:false
	                    }),
				    validation4 = new Ext.form.Checkbox({
					    boxLabel: pointeur.contentStore.getById("result26").get("name")+" ",
					    checked:false
	                    }),
				    validation5 = new Ext.form.Checkbox({
					    boxLabel: pointeur.contentStore.getById("result27").get("name")+" ",
					    checked:false
	                    }),
				    validation6 = new Ext.form.Checkbox({
					    boxLabel: pointeur.contentStore.getById("result28").get("name")+" ",
					    checked:false
	                    }),
				    validation7 = new Ext.form.Checkbox({
					    boxLabel: pointeur.contentStore.getById("result32").get("name")+" ",
					    checked:false
	                    })
	            );
			    validationForm.render("tufiValidationDlgCenter");
		    }
            if (validation1Post)
                document.getElementById(validation1.getId()).checked=true;
            else
                document.getElementById(validation1.getId()).checked=false;
            if (validation2Post)
                document.getElementById(validation2.getId()).checked=true;
            else
                document.getElementById(validation2.getId()).checked=false;
            if (validation3Post)
                document.getElementById(validation3.getId()).checked=true;
            else
                document.getElementById(validation3.getId()).checked=false;
            if (validation4Post)
                document.getElementById(validation4.getId()).checked=true;
            else
                document.getElementById(validation4.getId()).checked=false;
            if (validation5Post)
                document.getElementById(validation5.getId()).checked=true;
            else
                document.getElementById(validation5.getId()).checked=false;
            if (validation6Post)
                document.getElementById(validation6.getId()).checked=true;
            else
                document.getElementById(validation6.getId()).checked=false;
            if (validation7Post)
                document.getElementById(validation7.getId()).checked=true;
            else
                document.getElementById(validation7.getId()).checked=false;
		    validationDlg.show(e.getEl());
	    },
	    updateValidation : function(e){
            validation1Post = document.getElementById(validation1.getId()).checked;
            validation2Post = document.getElementById(validation2.getId()).checked;
            validation3Post = document.getElementById(validation3.getId()).checked;
            validation4Post = document.getElementById(validation4.getId()).checked;
            validation5Post = document.getElementById(validation5.getId()).checked;
            validation6Post = document.getElementById(validation6.getId()).checked;
            validation7Post = document.getElementById(validation7.getId()).checked;
            validationMessage = (validation1Post) ? "&nbsp;&nbsp;3A":"";
            validationMessage += (validation2Post) ? "&nbsp;&nbsp;FDA":"";
            validationMessage += (validation3Post) ? "&nbsp;&nbsp;NSF 51":"";
            validationMessage += (validation4Post) ? "&nbsp;&nbsp;NSF 61":"";
            validationMessage += (validation5Post) ? "&nbsp;&nbsp;Food Contact EU":"";
            validationMessage += (validation6Post) ? "&nbsp;&nbsp;EPA":"";
            validationMessage += (validation7Post) ? "&nbsp;&nbsp;Carb":"";
            if (validationMessage.length > 0) {
                validationMessage=pointeur.contentStore.getById("menu06").get("name")+": "+validationMessage+"<br /><br />";
                document.getElementById("validationTrash").innerHTML = "<img style=\"cursor:hand\" onclick=\"pointeur.removeValidation();\" src=trash2.jpg alt=\""+pointeur.contentStore.getById("trash").get("name")+" "+pointeur.contentStore.getById("menu06").get("name")+"\" />";
            }
            else {
                document.getElementById("validationTrash").innerHTML = "";
            }
            document.getElementById("validation").innerHTML = validationMessage;
		    validationDlg.hide();
			pointeur.checkCriteria();
            pointeur.updateResult();
	    },
        removeValidation : function(){
            validation1Post = false;
            validation2Post = false;
            validation3Post = false;
            validation4Post = false;
            validation5Post = false;
            validation6Post = false;
            validation7Post = false;
            document.getElementById("validation").innerHTML = "";
            document.getElementById("validationTrash").innerHTML = "";
            pointeur.updateResult();
        },
	    showSterilDialog : function(e){
		    if(!sterilDlg){ // lazy initialize the dialog and only create it once
			    sterilDlg = new Ext.LayoutDialog("tufiSterilDlg", { 
				    autoTabs:true,
				    width:500,
				    title:pointeur.contentStore.getById("menu07").get("name"),
				    collapsible:false,
				    resizable:false,
				    height:270,
				    width:280,
				    modal:true,
				    shadow:true,
				    minWidth:300,
				    minHeight:500,
				    proxyDrag: true,
				    center: {}
			    });
			    document.getElementById("tufiSterilContent").innerHTML = pointeur.contentStore.getById("sterilisation1").get("name")+"<br><br>";
			    var sterilDlgLayout = sterilDlg.getLayout();
			    sterilDlg.addKeyListener(27, sterilDlg.hide, sterilDlg);
			    sterilDlg.addButton(pointeur.contentStore.getById("validate").get("name"), this.updateSteril, sterilDlg);
			    sterilDlg.addButton(pointeur.contentStore.getById("cancel").get("name"), sterilDlg.hide, sterilDlg);
			    sterilDlgLayout.add('center',
				    gpLoginDivCenter=new Ext.ContentPanel("tufiSterilDlgCenter",{})
			    );
			    var sterilForm = new Ext.form.Form({
		            labelWidth: 100 // label settings here cascade unless overridden
			    });
	            sterilForm.column(
					{width:200, hideLabels:true},
				    steril1 = new Ext.form.Checkbox({
					    boxLabel: pointeur.contentStore.getById("result30").get("name")+" ",
					    checked:false
	                    }),
				    steril2 = new Ext.form.Checkbox({
					    boxLabel: pointeur.contentStore.getById("result29").get("name")+" ",
					    checked:false
	                    }),
				    steril3 = new Ext.form.Checkbox({
					    boxLabel: pointeur.contentStore.getById("result31").get("name")+" ",
					    checked:false
	                    })
	            );
			    sterilForm.render("tufiSterilDlgCenter");
		    }
            if (steril1Post)
                document.getElementById(steril1.getId()).checked=true;
            else
                document.getElementById(steril1.getId()).checked=false;
            if (steril2Post)
                document.getElementById(steril2.getId()).checked=true;
            else
                document.getElementById(steril2.getId()).checked=false;
            if (steril3Post)
                document.getElementById(steril3.getId()).checked=true;
            else
                document.getElementById(steril3.getId()).checked=false;
		    sterilDlg.show(e.getEl());
	    },
	    updateSteril : function(e){
            steril1Post = document.getElementById(steril1.getId()).checked;
            steril2Post = document.getElementById(steril2.getId()).checked;
            steril3Post = document.getElementById(steril3.getId()).checked;
            sterilMessage = (steril1Post) ? "&nbsp;&nbsp;"+pointeur.contentStore.getById("result30").get("name"):"";
            sterilMessage += (steril2Post) ? "&nbsp;&nbsp;"+pointeur.contentStore.getById("result29").get("name"):"";
            sterilMessage += (steril3Post) ? "&nbsp;&nbsp;"+pointeur.contentStore.getById("result31").get("name"):"";
            if (sterilMessage.length > 0) {
                sterilMessage=pointeur.contentStore.getById("menu07").get("name")+": "+sterilMessage+"<br /><br />";
                document.getElementById("sterilTrash").innerHTML = "<img style=\"cursor:hand\" onclick=\"pointeur.removeSteril();\" src=trash2.jpg alt=\""+pointeur.contentStore.getById("trash").get("name")+" "+pointeur.contentStore.getById("menu07").get("name")+"\" />";
            }
            else {
                document.getElementById("sterilTrash").innerHTML = "";
            }
            document.getElementById("steril").innerHTML = sterilMessage;
		    sterilDlg.hide();
			pointeur.checkCriteria();
            pointeur.updateResult();
	    },
        removeSteril : function(){
            steril1Post = false;
            steril2Post = false;
            steril3Post = false;
            document.getElementById("steril").innerHTML = "";
            document.getElementById("sterilTrash").innerHTML = "";
            pointeur.updateResult();
        },
	    showPermeaDialog : function(e){
		    if(!permeaDlg){ // lazy initialize the dialog and only create it once
			    permeaDlg = new Ext.LayoutDialog("tufiPermeaDlg", { 
				    autoTabs:true,
				    width:500,
				    title:pointeur.contentStore.getById("menu07").get("name"),
				    collapsible:false,
				    resizable:false,
				    height:270,
				    width:280,
				    modal:true,
				    shadow:true,
				    minWidth:300,
				    minHeight:500,
				    proxyDrag: true,
				    center: {}
			    });
			    document.getElementById("tufiPermeaContent").innerHTML = pointeur.contentStore.getById("permeability1").get("name")+"<br><br>";
			    var permeaDlgLayout = permeaDlg.getLayout();
			    permeaDlg.addKeyListener(27, permeaDlg.hide, permeaDlg);
			    permeaDlg.addButton(pointeur.contentStore.getById("validate").get("name"), this.updatePermea, permeaDlg);
			    permeaDlg.addButton(pointeur.contentStore.getById("cancel").get("name"), permeaDlg.hide, permeaDlg);
			    permeaDlgLayout.add('center',
				    gpLoginDivCenter=new Ext.ContentPanel("tufiPermeaDlgCenter",{})
			    );
			    var permeaForm = new Ext.form.Form({
		            labelWidth: 100 // label settings here cascade unless overridden
			    });
	            permeaForm.column(
					{width:200, hideLabels:true},
				    permea1 = new Ext.form.Radio({
					    boxLabel: pointeur.contentStore.getById("yes").get("name")+" ",
                        name:"permea",
					    checked:false
	                    }),
				    permea2 = new Ext.form.Radio({
					    boxLabel: pointeur.contentStore.getById("no").get("name")+" ",
                        name:"permea",
					    checked:true
	                    })
	            );
			    permeaForm.render("tufiPermeaDlgCenter");
		    }
            if (permeaPost)
                document.getElementById(permea1.getId()).checked=true;
            else
                document.getElementById(permea2.getId()).checked=true;
		    permeaDlg.show(e.getEl());
	    },
	    updatePermea : function(e){
	        if (document.getElementById(permea1.getId()).checked==true) {
                document.getElementById("permea").innerHTML = sterilMessage=pointeur.contentStore.getById("menu07").get("name")+": "+pointeur.contentStore.getById("yes").get("name")+"<br /><br />";
                permeaPost = true;
                document.getElementById("permeaTrash").innerHTML = "<img style=\"cursor:hand\" onclick=\"pointeur.removePermea();\" src=trash2.jpg alt=\""+pointeur.contentStore.getById("trash").get("name")+" "+pointeur.contentStore.getById("menu07").get("name")+"\" />";
	        }
	        else {
                document.getElementById("permea").innerHTML = "";
                permeaPost = false;
                document.getElementById("permeaTrash").innerHTML = "";
	        }
		    permeaDlg.hide();
			pointeur.checkCriteria();
            pointeur.updateResult();
	    },
        removePermea : function(){
            permeaPost = false;
            document.getElementById("permea").innerHTML = "";
            document.getElementById("permeaTrash").innerHTML = "";
            pointeur.updateResult();
        },
	    showPumpableDialog : function(e){
		    if(!pumpableDlg){ // lazy initialize the dialog and only create it once
			    pumpableDlg = new Ext.LayoutDialog("tufiPumpableDlg", { 
				    autoTabs:true,
				    width:500,
				    title:pointeur.contentStore.getById("menu08").get("name"),
				    collapsible:false,
				    resizable:false,
				    height:270,
				    width:280,
				    modal:true,
				    shadow:true,
				    minWidth:300,
				    minHeight:500,
				    proxyDrag: true,
				    center: {}
			    });
			    document.getElementById("tufiPumpableContent").innerHTML = pointeur.contentStore.getById("pumpable1").get("name")+"<br><br>";
			    var pumpableDlgLayout = pumpableDlg.getLayout();
			    pumpableDlg.addKeyListener(27, pumpableDlg.hide, pumpableDlg);
			    pumpableDlg.addButton(pointeur.contentStore.getById("validate").get("name"), this.updatePumpable, pumpableDlg);
			    pumpableDlg.addButton(pointeur.contentStore.getById("cancel").get("name"), pumpableDlg.hide, pumpableDlg);
			    pumpableDlgLayout.add('center',
				    gpLoginDivCenter=new Ext.ContentPanel("tufiPumpableDlgCenter",{})
			    );
			    var pumpableForm = new Ext.form.Form({
		            labelWidth: 100 // label settings here cascade unless overridden
			    });
	            pumpableForm.column(
					{width:200, hideLabels:true},
				    pumpable1 = new Ext.form.Radio({
					    boxLabel: pointeur.contentStore.getById("yes").get("name")+" ",
                        name:"pumpable",
					    checked:false
	                    }),
				    pumpable2 = new Ext.form.Radio({
					    boxLabel: pointeur.contentStore.getById("no").get("name")+" ",
                        name:"pumpable",
					    checked:true
	                    })
	            );
			    pumpableForm.render("tufiPumpableDlgCenter");
		    }
            if (pumpablePost)
                document.getElementById(pumpable1.getId()).checked=true;
            else
                document.getElementById(pumpable2.getId()).checked=true;
		    pumpableDlg.show(e.getEl());
	    },
	    updatePumpable : function(e){
	        if (document.getElementById(pumpable1.getId()).checked==true) {
                document.getElementById("pumpable").innerHTML = pointeur.contentStore.getById("menu08").get("name")+": "+pointeur.contentStore.getById("yes").get("name")+"<br /><br />";
                pumpablePost = true;
                document.getElementById("pumpableTrash").innerHTML = "<img style=\"cursor:hand\" onclick=\"pointeur.removePumpable();\" src=trash2.jpg alt=\""+pointeur.contentStore.getById("trash").get("name")+" "+pointeur.contentStore.getById("menu08").get("name")+"\" />";
	        }
	        else {
                document.getElementById("pumpable").innerHTML = "";
                pumpablePost = false;
                document.getElementById("pumpableTrash").innerHTML = "";
	        }
		    pumpableDlg.hide();
			pointeur.checkCriteria();
            pointeur.updateResult();
	    },
        removePumpable : function(){
            pumpablePost = false;
            document.getElementById("pumpable").innerHTML = "";
            document.getElementById("pumpableTrash").innerHTML = "";
            pointeur.updateResult();
        },
	    showLifetimeDialog : function(e){
		    if(!lifetimeDlg){ // lazy initialize the dialog and only create it once
			    lifetimeDlg = new Ext.LayoutDialog("tufiLifetimeDlg", { 
				    autoTabs:true,
				    width:500,
				    title:pointeur.contentStore.getById("menu10").get("name"),
				    collapsible:false,
				    resizable:false,
				    height:270,
				    width:280,
				    modal:true,
				    shadow:true,
				    minWidth:300,
				    minHeight:500,
				    proxyDrag: true,
				    center: {}
			    });
			    document.getElementById("tufiLifetimeContent").innerHTML = pointeur.contentStore.getById("livetime1").get("name")+"<br><br>";
			    var lifetimeDlgLayout = lifetimeDlg.getLayout();
			    lifetimeDlg.addKeyListener(27, lifetimeDlg.hide, lifetimeDlg);
			    lifetimeDlg.addButton(pointeur.contentStore.getById("validate").get("name"), this.updateLifetime, lifetimeDlg);
			    lifetimeDlg.addButton(pointeur.contentStore.getById("cancel").get("name"), lifetimeDlg.hide, lifetimeDlg);
			    lifetimeDlgLayout.add('center',
				    gpLoginDivCenter=new Ext.ContentPanel("tufiLifetimeDlgCenter",{})
			    );
			    var lifetimeForm = new Ext.form.Form({
		            labelWidth: 100 // label settings here cascade unless overridden
			    });
	            lifetimeForm.column(
					{width:200, hideLabels:true},
				    lifetime1 = new Ext.form.Radio({
					    boxLabel: pointeur.contentStore.getById("yes").get("name")+" ",
                        name:"lifetime",
					    checked:false
	                    }),
				    lifetime2 = new Ext.form.Radio({
					    boxLabel: pointeur.contentStore.getById("no").get("name")+" ",
                        name:"lifetime",
					    checked:true
	                    })
	            );
			    lifetimeForm.render("tufiLifetimeDlgCenter");
		    }
            if (lifetimePost)
                document.getElementById(lifetime1.getId()).checked=true;
            else
                document.getElementById(lifetime2.getId()).checked=true;
		    lifetimeDlg.show(e.getEl());
	    },
	    updateLifetime : function(e){
	        if (document.getElementById(lifetime1.getId()).checked==true) {
                document.getElementById("lifetime").innerHTML = pointeur.contentStore.getById("menu10").get("name")+": "+pointeur.contentStore.getById("yes").get("name")+"<br /><br />";
                lifetimePost = true;
                document.getElementById("lifetimeTrash").innerHTML = "<img style=\"cursor:hand\" onclick=\"pointeur.removeLifetime();\" src=trash2.jpg alt=\""+pointeur.contentStore.getById("trash").get("name")+" "+pointeur.contentStore.getById("menu10").get("name")+"\" />";
	        }
	        else {
                document.getElementById("lifetime").innerHTML = "";
                lifetimePost = false;
                document.getElementById("lifetimeTrash").innerHTML = "";
	        }
		    lifetimeDlg.hide();
			pointeur.checkCriteria();
            pointeur.updateResult();
	    },
        removeLifetime : function(){
            lifetimePost = false;
            document.getElementById("lifetime").innerHTML = "";
            document.getElementById("lifetimeTrash").innerHTML = "";
            pointeur.updateResult();
        },
		showColourDialog : function(e){
			if(!colourDlg){ // lazy initialize the dialog and only create it once
				colourDlg = new Ext.LayoutDialog("tufiColourDlg", { 
					autoTabs:true,
					width:500,
					title:pointeur.contentStore.getById("menu09").get("name"),
					collapsible:false,
					resizable:false,
					height:420,
					width:300,
					modal:true,
					shadow:true,
					minWidth:300,
					minHeight:250,
					proxyDrag: true,
					center: {}
				});
				document.getElementById("tufiColourContent").innerHTML = pointeur.contentStore.getById("colour1").get("name");
				var colourDlgLayout = colourDlg.getLayout();
				colourDlg.addKeyListener(27, colourDlg.hide, colourDlg);
				colourDlg.addButton(pointeur.contentStore.getById("validate").get("name"), this.updateColourList, colourDlg);
				colourDlg.addButton(pointeur.contentStore.getById("cancel").get("name"), colourDlg.hide, colourDlg);
				colourStore = new Ext.data.Store({
	                proxy: new Ext.data.HttpProxy({url: 'colourList.asp'}),
	                reader: new Ext.data.XmlReader({
		                record: 'colour',
		                id: 'id'
		                }, [
		                'name'
	                ])
				});
    		    tufiColModelColour = new Ext.grid.ColumnModel([
				    {id:'colour',header: pointeur.contentStore.getById("result15").get("name"), width: 160, dataIndex: 'name'}
			    ]);
				tufiGridColour = new Ext.grid.Grid('tufi-grid-colour', {
					ds: colourStore,
    				enableColumnMove: false,
					cm: tufiColModelColour,
					autoExpandColumn: 'colour',
					selModel:new Ext.grid.RowSelectionModel({singleSelect:true})
				});
				colourDlgLayout.add('center',
					new Ext.ContentPanel("tufiColourDlgCenter",{})
				);
				Ext.BorderLayout.create({
					center: {
						margins:{left:3,top:3,right:3,bottom:3},
						panels: [new Ext.GridPanel(tufiGridColour)]
					}
				}, 'tufiGridColour');
				tufiGridColour.render();
			}
	        colourStore.load({params:{lang : lang,
	            resultPost : resultPost
	            },
	            callback: function(r, options, success) {
		            if (!success) 
		                Ext.Msg.alert('Cookie Alerte', 'Erreur colour!');
	            }
	        });
			colourDlg.show(e.getEl());
		},
		updateColourList : function(e){
			colourPost = "";
			selectionModel = tufiGridColour.getSelectionModel();
			if (selectionModel.hasSelection()) {
				selections = selectionModel.getSelections();
				colourPost = selections[0].get("name");
			}
	        if (colourPost != "") {
                document.getElementById("colour").innerHTML = pointeur.contentStore.getById("menu09").get("name")+": "+colourPost+"<br /><br />";
                document.getElementById("colourTrash").innerHTML = "<img style=\"cursor:hand\" onclick=\"pointeur.removeColor();\" src=trash2.jpg alt=\""+pointeur.contentStore.getById("trash").get("name")+" "+pointeur.contentStore.getById("menu09").get("name")+"\" />";
            }
	        else {
                document.getElementById("colour").innerHTML = "";
                document.getElementById("colourTrash").innerHTML = "";
            }
			colourDlg.hide();
			pointeur.checkCriteria();
            pointeur.updateResult();
		},
        removeColor : function(){
			colourPost = "";
            document.getElementById("colour").innerHTML = "";
            document.getElementById("colourTrash").innerHTML = "";
            pointeur.updateResult();
        },
	    updateResult: function () {
			resultStore.load({params:{lang : lang,
			    resultPost : resultPost,
			    mediaPost : mediaPost,
			    validation1Post : validation1Post,
			    validation2Post : validation2Post,
			    validation3Post : validation3Post,
			    validation4Post : validation4Post,
			    validation5Post : validation5Post,
			    validation6Post : validation6Post,
			    validation7Post : validation7Post,
                dimPost : dimPost,
                pressurePost : pressurePost,
			    steril1Post : steril1Post,
			    steril2Post : steril2Post,
			    steril3Post : steril3Post,
                permeaPost : permeaPost,
                pumpablePost : pumpablePost,
                lifetimePost : lifetimePost,
			    temperaturePost: temperature,
			    temperatureUnitPost: temperatureUnit,
			    colourPost: colourPost
			    },
			    callback: function(r, options, success) {
				    if (success) {
                        document.getElementById("number").innerHTML=r.length;
            	        resultPost = "";
//            	        for (x in r[0].data)
//                        {
//                        document.write(x+" "+r[0].data[x] + "<br /><br />");
//                        }
                        for (i=0;i<r.length;i++)
            			    resultPost += r[i].get("id")+"_";
            	    }
				    else Ext.Msg.alert('Cookie Alerte', 'Erreur result!');
			    }
			});
        }
	};
}();

Ext.onReady(Tufi.init, Tufi, true);

