/* ************************************************************************************************
												From Example
 **************************************************************************************************/

rialto.example1Demo=function(objPar){
	
	this.filename="example1.js";
	
	if(!objPar){
		var objPar={title : "Form example" ,
					parent : document.body ,
					icone:'images/imgFenSimple/picto-gr_default.gif'
					}
	}
    this.simpleWindow=new rialto.widget.SimpleWindow(objPar);
	var oThis=this;
	
								    	
	var help = new rialto.widget.Image('../rialtoEngine/imagesDemo/idea.png','10','10',this.simpleWindow,"",'../rialtoEngine/imagesDemo/ktip.png');									    	
	var labHelp= new rialto.widget.Label("",15,30,this.simpleWindow,"Notice the required field","libelleTip");
	labHelp.setVisible(false);
	help.onmouseover=function(){labHelp.setVisible(true);}
	help.onmouseout=function(){labHelp.setVisible(false);}

	var CADREC = new rialto.widget.Frame({name:'CADREC',top:'45',left:'10',width:'100',height:'335',title:'Search criteria',
										  open:true,dynamic:true,
									      position:'relative',draggable:false,
									      parent:this.simpleWindow,autoResizableW:true});
			
    var CADRE1 = new rialto.widget.Frame({name:'CADRE1',top:'10',left:'0',width:'395',height:'265',title:'Patient id',
    									  open:true,dynamic:false,position:'absolute',
    									  draggable:false,parent:CADREC});
	var lib = new rialto.widget.Label('lib',15,10,CADRE1,"Folder from",'libelle1');
    var DOSA = new rialto.widget.Text('DOSA',10,80,80,'A',CADRE1,{autoUp:false,isRequired:false,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});
	lib = new rialto.widget.Label('lib',15,168,CADRE1,"to",'libelle1');
	var DOSB = new rialto.widget.Text('DOSB',10,180,80,'A',CADRE1,{autoUp:false,isRequired:false,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});
	lib = new rialto.widget.Label('lib',45,10,CADRE1,"Name",'libelle1');
	var NOM = new rialto.widget.Text('NOM',40,80,200,'A',CADRE1,{autoUp:false,isRequired:true,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});	
    var PHON = new rialto.widget.Checkbox('PHON',40,280,CADRE1,'Phonetics',false,'libelle1');				
    lib = new rialto.widget.Label('lib',75,10,CADRE1,"First name",'libelle1');
    var PRENOM = new rialto.widget.Text('PRENOM',70,80,200,'A',CADRE1,{autoUp:false,isRequired:false,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});
    lib = new rialto.widget.Label('lib',75,290,CADRE1,"Sex",'libelle1');
    var SEXE = new rialto.widget.Combo('','SEXE',70,320,40,CADRE1,{suggest:true,enable:true,heightItem:0});
    SEXE.addItem("M","M");
    SEXE.addItem("F","F");
    SEXE.addItem(" ","?");
    lib = new rialto.widget.Label('lib',105,10,CADRE1,"Maiden name",'libelle1');
    var NOMJF = new rialto.widget.Text('NOMJF',100,80,200,'A',CADRE1,{autoUp:false,isRequired:false,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});                   
    lib = new rialto.widget.Label('lib',135,10,CADRE1,"Born on",'libelle1');
    var DATNAI = new rialto.widget.Text('DATNAI',130,80,200,'D',CADRE1,{autoUp:false,isRequired:false,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});				      
    lib = new rialto.widget.Label('lib',135,195,CADRE1,"Age",'libelle1');
    var AGEIN = new rialto.widget.Text('AGEIN',130,240,50,'N',CADRE1,{autoUp:false,isRequired:false,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});				
    lib = new rialto.widget.Label('lib',135,293,CADRE1,"to",'libelle1');
    var AGEOUT = new rialto.widget.Text('AGEOUT',130,305,50,'N',CADRE1,{autoUp:false,isRequired:false,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});				
    lib = new rialto.widget.Label('lib',165,10,CADRE1,"Committee",'libelle1');
    var CCOM = new rialto.widget.codeLabel('CCOM',160,80,250,CADRE1,{withLabel:true,submitOnload:true,alwaysRefresh:true,codeWidth:0,url:'../RechCodeLibelle'});                        
    var CADRE5 = new rialto.widget.Frame({name:'CADRE5',top:'205',left:'8',width:'345',height:'40',title:'Medical inscription',open:true,dynamic:false,position:'absolute',draggable:false,parent:CADRE1});	
    var T =  new rialto.widget.Radio('T',7,10,CADRE5,'INSC','All',true,'libNormal');
    var P =  new rialto.widget.Radio('P',7,85,CADRE5,'INSC','Provisional',false,'libNormal');
    var D =  new rialto.widget.Radio('D',7,177,CADRE5,'INSC','Final',false,'libNormal');
    var A =  new rialto.widget.Radio('A',7,260,CADRE5,'INSC','Opinion',false,'libNormal');                               	
    //CRITTERS DE RDV
    var CADRE2 = new rialto.widget.Frame({name:'CADRE2',top:'10',left:'400',width:'325',height:'75',
    									  title:'Appointment',open:true,dynamic:false,
    									  position:'absolute',draggable:false,parent:CADREC});
	lib = new rialto.widget.Label('lib',15,10,CADRE2,"date of",'libelle1');
    var DATRVI = new rialto.widget.Text('DATRVI',10,70,200,'D',CADRE2,{autoUp:false,isRequired:false,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});							
    lib = new rialto.widget.Label('lib',15,180,CADRE2,"to",'libelle1');
    var DATRVO = new rialto.widget.Text('DATRVO',10,190,200,'D',CADRE2,{autoUp:false,isRequired:false,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});                        
    lib = new rialto.widget.Label('lib',45,10,CADRE2,"Act",'libelle1');				
    var LIBACT = new rialto.widget.codeLabel('LIBACT',40,70,225,CADRE2,{withLabel:true,submitOnload:true,alwaysRefresh:true,codeWidth:0,url:'../RechCodeLibelle'});                	
    //CRITTERS D'HOSPI
    var CADRE3 = new rialto.widget.Frame({name:'CADRE3',top:'95',left:'400',width:'325',height:'105',
    									  title:'Hospitalization',open:true,dynamic:false,
	    								  position:'absolute',draggable:false,parent:CADREC});
    var HOSPCEJOUR = new rialto.widget.Checkbox('HOSPCEJOUR',5,7,CADRE3,'In-patients to date',false,'libelle1');				
    var LIBH1 = new rialto.widget.Label('LIBH1',35,10,CADRE3,"date of",'libelle1');
    var DATHOSI = new rialto.widget.Text('DATHOSI',30,70,200,'D',CADRE3,{autoUp:false,isRequired:false,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});							
    var LIBH2 = new rialto.widget.Label('LIBH2',35,180,CADRE3,"to",'libelle1');
    var DATHOSO = new rialto.widget.Text('DATHOSO',30,190,200,'D',CADRE3,{autoUp:false,isRequired:false,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});
    lib = new rialto.widget.Label('lib',65,10,CADRE3,"Committee",'libelle1');
    var CSEHO = new rialto.widget.codeLabel('CSEHO',60,70,230,CADRE3,{withLabel:true,submitOnload:true,alwaysRefresh:true,codeWidth:0,url:'../RechCodeLibelle'});                	
    //CRITTERS et
    var CADRE4 = new rialto.widget.Frame({name:'CADRE4',top:'210',left:'400',width:'325',height:'65',
    									  title:'Therapeutic tests',open:true,dynamic:false,
    									  position:'absolute',draggable:false,parent:CADREC});
    var INCLUSETUDE = new rialto.widget.Checkbox('INCLUSETUDE',5,7,CADRE4,'Patients currently included in a test',false,'libelle1');								
    lib = new rialto.widget.Label('lib',35,10,CADRE4,"N? CET",'libelle1');
    var NOCET = new rialto.widget.codeLabel('NOCET',30,70,230,CADRE4,{withLabel:true,submitOnload:true,alwaysRefresh:true,codeWidth:0,url:'../RechCodeLibelle'});                                
    lib = new rialto.widget.Label('lib',290,10,CADREC,"Numbers maximum posted patients",'libelle2');
    var NBENR = new rialto.widget.Text('NBENR',285,230,40,'N',CADREC,{autoUp:false,isRequired:false,disable:false,rows:5,accessKey:'',tabIndex:'',initValue:""});                
    var BRES = new rialto.widget.Button(290,290,"Reset","Effacer toute la saisie",CADREC,{enable:true,adaptToText:true,width:88,widthMin:88});
    var BRECH = new rialto.widget.Button(290,380,"Find","Lancer la recherche",CADREC,{enable:true,adaptToText:true,width:88,widthMin:88});
               
    // Initialisation du champs NBENR ? 100
    NBENR.setValue("100");
    BRES.onclick=function () {            
        FORM1.resetForm();
        NBENR.champs.value="100";
	    T.setCheck(true);
        //on simule le clik des checkbox (pour le coding applicatif)
        INCLUSETUDE.onclick();
        HOSPCEJOUR.onclick();
        oGrid.deleteLines();
	};

    //Bouton rechercher                                                        
	BRECH.onclick=function () {           		            
        if (NOM.getValue()==""){
        	info = new rialto.widget.Alert("Champ(s) obligatoire(s)");     
			NOM.showAsRequired();
			return true;
		}
		var nom=NOM.getValue()+" "+PRENOM.getValue();	
		var datN=DATNAI.getValue();					
						
        var tab = new Array;
        for (var i =0;i<50;i++){
			if(datN==""){datN="01/12/"+(1975+i);}
			tab.push([i,nom,datN,'010']); 
		}        			     
		oGrid.fillGrid(tab);
	};
		
	
	var CADRER = new rialto.widget.Frame({name:'CADRER',top:'45',left:'10',width:'98%',height:'160',
										  title:'Results of research',open:true,dynamic:true,
										  position:'relative',draggable:false,
										  parent:this.simpleWindow,autoResizableW:true,autoResizableH:true});
	var oGrid = new rialto.widget.Grid({top:0,left:5,height:130,
	 								   arrHeader:[{title:"Folder",type:"string",width:80},
												  {title:"Surname-First  name",type:"string",width:200},
												  {title:"Date of birth",type:"date",width:100},
												  {title:"Committee",type:"date",width:60}],
									   name:'oGrid',parent:CADRER,bNavig:false,rang:5,
									   cellActive:false,
									   asynchLoad:true,
									   sortable:true,multiSelect:false,lineHeight:16,boolPrint:true,switchable:true,
									   clickable:true,autoResizableW:true,autoResizableH:true,
									   writable:true});
}
