
var isMac = (navigator.platform.indexOf('Mac') > -1);
var nava = (document.layers);
var iex = (document.all);
//var skn = (nava) ? document.topdeck : topdeck.style;
//if (nava) document.captureEvents(Event.MOUSEMOVE);		
//document.onmousemove = get_mouse;


//=================================

function saisieTxtLongInit(leChamp){
	 if (nava){  // document.layers['longtexte'].document.write(content);
 	}else if (iex){
		document.fST.zeField.value=leChamp;
		eval ('document.fST.mytxt.value=document.fML.' + document.fST.zeField.value + '.value;');
		document.all['longtexte'].style.visibility='visible';
}}

function saisieTxtLongFin(valide){
	 if (nava){	
 	}else if (iex){
		if (valide){
			eval ('document.fML.' + document.fST.zeField.value + '.value=document.fST.mytxt.value;');
			}
		document.all['longtexte'].style.visibility='hidden';
}}

function testFenSaisieTexteDejaOuv(){
if (document.fML.champTexte.value != '')
	if (window.winSaisieTexteLong) 
		if (!window.winSaisieTexteLong.closed)
			if(window.winSaisieTexteLong.document.fST.mytxt.value != '')
				window.winSaisieTexteLong.setTimeout("StockeTexte()",10);
}

function testOnLoad(){
	if(parseInt(document.fML['MLNbSubm'].value)>0){
		//alert(document.fML['MLNbSubm'].value);
		//alert(document.fML['MLHF_MLRQAnc'].value);
		if(document.fML['MLHF_MLRQAnc'].value == 'qn'){
			//alert('reset/reload');
			document.fML.reset();
			//location.reload();
			//history.go(0);
		}	
	}
}
function onLoad2Reload(){
	if (typeof(document.fML['MLNboL'])!='undefined'){
		if(parseInt(document.fML['MLNboL'].value)>0){
			location.reload();
		}else{
			document.fML['MLNboL'].value='1';
		}
	}
	window.focus();
}
function locationEnvoi(){
	document.fML['MLHO'].value = location.host;
	if (document.fML['MLHF_Nav'])
		document.fML['MLHF_Nav'].value=navigator.userAgent;
}
function testSubmit(){
	document.fML.submit();
}
function MLActOpenWin(zeReq,zeURL,zeTitre){
	//if(zeReq != ''){
		//MLAction(zeReq,'');
	//}
	zeURL = zeURL + '?MLfcour=' + escape(document.fML['MLHF_MLFCour'].value);
	zeURL = zeURL + '&mlFormTitre=' + escape(document.fML['mlFormTitre'].value);
	zeURL = zeURL + '&mlFormEntete=' + escape(document.fML['mlFormEntete'].value);
	zeURL = zeURL + '&MLHO=' + escape(location.host);
	window.open(zeURL,'form_ext','location=0,directories=0,menubar=1,toolbar=0,statusbar=1,scrollbars=1,resizable=1,width=550');
}

function MLAction (requete, depart){
	b=true;
	zeURL='';
	zeLang='';
	if(document.fML['MLHF_MLLang'])
		zeLang=document.fML['MLHF_MLLang'].value;
	
	if (document.fML['MLEIaff'])
		if (document.fML['MLEI']) document.fML['MLEI'].value=document.fML['MLEIaff'].value;
	if(requete=='ftp'){
		b=false;
		zeURL='ftp://';
		if (document.fML['MLUS'].value != '') zeURL+=document.fML['MLUS'].value;
			else zeURL+= 'id';
		if (document.fML['MLEI'].value != '') zeURL+= ':' +document.fML['MLEI'].value;
		zeURL+= '@' + location.host;
		location.href=zeURL;
	}else if(requete=='file'){
		document.fML['MLQD'].value=depart;

	}else if(requete=='rapp'){
		b=false;
		zeparms=depart.split(';');
		if(zeparms.length>=2){
			zeenq=zeparms[2];
			if ((zeparms[0] == 'plan' ) || (zeparms[0] == 'vue')){
				zeURL='/mleqf' + zeenq + '?MLRapp=' + escape(depart);	

			}else if (zeparms[0] == 't1' ){
				zequest='';
				if(document.fML['qs']){
				for(i=0;i<document.fML['qs'].length;i++){
					if(document.fML.qs[i].checked){
						zequest=document.fML.qs[i].value;						
						i=document.fML.length;
					}
				}
				}
				if(zequest=='')
					zeURL='/mleqf' + zeenq + '?MLRapp=' + escape(depart);
				else{
					zequest =depart+';;;;;;'+zequest;
					zeURL='/mleqf' + zeenq + '?MLRapp=' + escape(zequest);
				}
					
                        }else if(zeparms[0] == 'bn'){
				zeURL='/mleqf' + zeenq + '?MLRapp=' + escape(depart);

			}else if (zeparms[0]=='tc'){
				bsp=false;
				if(zeparms.length>=7){
					if (zeparms[5]=='sp') bsp=true;
				}
				if(bsp){
					zeURL='/mleqf' + zeenq + '?MLRapp=' + escape(depart);
				}else{
					zequest='';
					if(zeparms.length>=3){
						if ((!isNaN(zeparms[3])) && (parseInt(zeparms[3])>-1)){	
							zequest=depart+';'+zeparms[3];
							zeURL='/mleqf' + zeenq + '?MLRapp=' + escape(zequest);
						}
					}
					if(zequest==''){
						for(i=0;i<document.fML['qs'].length;i++){
							if(document.fML.qs[i].checked){
								zequest=depart+';'+document.fML.qs[i].value;
								zeURL='/mleqf' + zeenq + '?MLRapp=' + escape(zequest);
								i=document.fML.length;
							}
						}
					}
					
						//for(i=0;i<document.fML.length;i++){
							//if(document.fML.elements[i].type=='checkbox'){
								//if(document.fML.elements[i].checked){
									//zequest=depart+';'+document.fML.elements[i].name;
									//zeURL='/mleqf' + zeenq + '?MLRapp=' + escape(zequest);
									//i=document.fML.length;
								//}
							//}
						//}
					
					if(zequest==''){
						zeURL='';
						if(zeLang=='lang_en') alert('Please, select a question.');
						else alert('Cochez une question dans la liste');
					}
				}
			}
		}
		if(zeURL != ''){
			zeURL=zeURL + '&MLEID=' + document.fML['MLEID'].value;
			f16=false;
			for(i=0;i<document.fML.length;i++){
				if(document.fML.elements[i].name=='MLPT1Enr'){
					zeURL=zeURL + document.fML['MLPT1Enr'].value;  //deja encode
				}
				if (zeparms[0] == 'plan' ){
				if(document.fML.elements[i].name=='f16'){
					if ((!isNaN(document.fML.elements[i].value)) && (parseInt(document.fML.elements[i].value)>-1)){	
						zeURL+='&pl='+document.fML.elements[i].value;
					}else{
						alert('Please, select a plan'); zeURL='';
					}
					f16=true;
					//i=document.fML.length-1;
				}
				}
				if(zeURL != ''){
				if(document.fML.elements[i].name=='f12'){
					
					if ((!isNaN(document.fML.elements[i].value)) && (parseInt(document.fML.elements[i].value)>-1)){	
						zeURL+='&grpv='+document.fML.elements[i].value;
					}
				}
				if(document.fML.elements[i].name=='f13'){
					
					if ((!isNaN(document.fML.elements[i].value)) && (parseInt(document.fML.elements[i].value)>-1)){	
						zeURL+='&sp='+document.fML.elements[i].value;
					}
				}	
				}
				
			}
		}
			
		if(zeURL != '')				window.open(zeURL,'Rapp_ext','location=0,directories=0,menubar=1, toolbar=1,statusbar=1,scrollbars=1,resizable=1,width=650');
		
	}else if(requete == 'fn'){
		window.open('Javascript:testSubmit()','ext','menubar=0');
		b=false;
	}else if(requete=='ec'){
		//if(document.fML['MLRQ'].value=='ec') b=false;
		//else 
		document.fML['MLQD'].value=depart;
	}else if(requete=='dsuppr'){
		if (!(confirm('Etes-vous certain ?')))
			b=false;
	}else if(requete=='d1rep'){
		b=false;
		if (typeof(document.fML['MLQrId'])!='undefined')
			document.fML['MLQrId'].value='';
		if(depart=='m'){ //modif
			document.fML['MLQN'].value= -parseInt(document.fML['MLNo'].value) ;
			b=true;
		}else if(depart=='s'){
			document.fML['MLQN'].value=parseInt(document.fML['MLNo'].value) +1;
			b=true;
		}else if(depart=='p'){
			document.fML['MLQN'].value=parseInt(document.fML['MLNo'].value) -1;
			b=true;
		}else if(depart=='i'){
			var leNumero = window.prompt('Identifiant de la reponse : ','');
			if(leNumero!=null){
      				document.fML['MLQrId'].value = leNumero;
				b=true;
			}
		}else{
			
			if(document.fML['MLEI'].value.indexOf('demo')==0){
				b=true;
			}else{
				b=true;//1/2/07

				/*
				if(zeLang=='lang_en') var leMP = window.prompt('Password : ','');
				else var leMP = window.prompt('Mot de passe : ','');
				if(leMP!=null){
				if(leMP.length==3){
					if (document.fML['MLEI'].value.indexOf(leMP)==0)
						b=true;
				}}
				if(!b)	
					if(zeLang=='lang_en') alert('Please , enter a valid password.');
					else alert('Mot de passe incorrect');
				*/
			}
			if(b){
				b=false;
				/*
				if(zeLang=='lang_en') var leNumero = window.prompt('Number of the answer : ','1');
				else var leNumero = window.prompt('Numéro du questionnaire : ','1');
				if ((!isNaN(leNumero)) && (parseInt(leNumero)>0)){	
      					document.fML['MLQN'].value = leNumero;
					b=true;
				}
				*/
				document.fML['MLQN'].value = "1";
				b=true;
				
				/*
				//===mofif du 2/2/07
				var leNumero = window.prompt('Identifiant du questionnaire : ','');
				if(leNumero!=null){
      					document.fML['MLQrId'].value = leNumero;
					b=true;
				}
				///===
				*/
				
			}
		}
		if(b){
			document.fML['MLRQ'].value = requete;
			locationEnvoi();
			document.fML.submit();
			b=false;
		}
	}
	if(b){
		//window.location.replace('a');
		//window.location.assign('a');
		document.fML['MLNbSubm'].value = parseInt(document.fML['MLNbSubm'].value) + 1;
		if(parseInt(document.fML['MLNbSubm'].value)>1){
			if(document.fML['MLHF_MLRQAnc'].value == 'qn'){
				document.fML.reset();
			}
		}
		if (b){
			//document.fML['MLPD'].value = depart;
			document.fML['MLRQ'].value = requete;
			locationEnvoi();
			if(depart.indexOf('demo')==0)
				document.fML['MLEI'].value = depart;
			document.fML.submit();
		}
	}
}

function qDepl ( NoVar, idEnrVar){
	if(zeLang=='lang_en') var leNumero = window.prompt('Please , enter the new number of the question : ',NoVar); 
	else var leNumero = window.prompt('Entrez le nouveau numero de la question : ',NoVar);
	if ((!isNaN(leNumero)) && (parseInt(leNumero)>0)){	
		if (leNumero != NoVar) {
			document.fML['MLRQ'].value = 'qd';
			document.fML['MLQN'].value = idEnrVar;
      			document.fML['MLQD'].value = leNumero;
			locationEnvoi();
			document.fML.submit();
		}
	}
}
function qMod(IdEnrVar){
	document.fML['MLRQ'].value = 'qm';
	document.fML['MLQN'].value =IdEnrVar;
	locationEnvoi();
	document.fML.submit();
}



