MenuAnalysesWatcher = Class.create();
MenuAnalysesWatcher.prototype={
	initialize:function(gestEvt,pA){
		gestEvt.ajouteEcouteur('ANALYSEMENUADDED',this.addAnalyse,this);
		this.gE=gestEvt;
		this.a1=false;
		this.pA=pA;
		this.a2=false;
	},
	supA:function(t){
		if(t==1){
	    if(this.a1.LAYERID!='18'){
			   this.gE.lanceEvenement('SETNEWSTATEANALYSE',[''+this.a1.ANALYSEID+'',0]);
			}else{
          this.gE.lanceEvenement('SETNEWSTATEANALYSE',[''+this.a1.ANALYSEID+'-18',0]);
      }
			this.a1Old=this.a1;
			this.a1=false;
			Element.hide('interfaceA1');

		}else{
			this.gE.lanceEvenement('SETNEWSTATEANALYSE',[this.a2.ANALYSEID+'-'+this.a2.LAYERID,0]);
			this.a2Old=this.a2;
			this.a2=false;
				Element.hide('interfaceA2');
		}
	},
	addAnalyse:function(analyse){

		if(analyse.TYPEANALYSE==1){

			if(this.a1!=false){
				this.supA(1);
			}
			Element.show('dispA1');
			Element.hide('hideA1');
			this.a1=analyse;
			this.a1Old=this.a1;
			this.addLegende(1,analyse);
			Element.show('interfaceA1');
			this.gE.lanceEvenement('SETNEWSTATEANALYSE',[this.a1.ANALYSEID+'-'+this.a1.LAYERID,1]);
		}else{
			if(this.a2!=false){
				this.supA(2);
			}
			Element.show('dispA2');
			Element.hide('hideA2');
			this.a2=analyse;
			this.a2Old=this.a2;
			this.addLegende(2,analyse);
			Element.show('interfaceA2');
			this.gE.lanceEvenement('SETNEWSTATEANALYSE',[this.a2.ANALYSEID+'-'+this.a2.LAYERID,1]);
		}
	},
	addLegende:function(niv,ana){
		Element.hide('noneT'+niv);
		var imgS='/dynmap/getLegend.php?A='+ana.ANALYSEID;

		imgS+='&path_application=/'+this.pA+'/&B=FFFFFF&title=no&typelegende=PNG&wImg='+widthLegend;
		$('imgT'+niv).innerHTML='<img src="'+imgS+'" />';
		var linkExport='/dynmap/class/modules/mvccarte.php?cont=ANALYSERECHERCHE&event=doExport&type=excel';
		linkExport+='&path_application='+path_application+'&idA='+ana.ANALYSEID;
		$('titreT'+niv).innerHTML=ana.TITLE;
		if(ana.S_TITLE!=''){
      	$('stitreT'+niv).innerHTML=ana.S_TITLE;
      	$('stitreT'+niv).style.display='';
    }else{
        $('stitreT'+niv).style.display='none';
    }

		if(ana.TYPE!='4'){
	
			$('exportExcelA'+niv).innerHTML='<a href="javascript:;"  onClick="window.open(\''+linkExport+'\',\'export_excel\',\'width=500, height=200\');" title="exporter en excel"><img src="/dynmap/images/excel.gif" border="0"></a>';
		}else{
			$('exportExcelA'+niv).innerHTML='';
		}
		Element.show('selectT'+niv);
	},
	closeA:function(t){
		//Element.hide('selectT'+t);
		//Element.show('noneT'+t);
		if(t==1){
			this.supA(1);
		}else{
			this.supA(2);
		}
	},
	viewA:function(t){
		if(t==1){
			this.addAnalyse(this.a1Old);
		}else{
			this.addAnalyse(this.a2Old);
		}
	}


}



