// © ATELIER 33 / ALL RIGHTS RESERVED / 2008 / http://www.atelier33.com / contact@atelier33.com
// Toute copie complete ou partielle de ce code est interdite ;) -=]U-R[=-
//=============================================================================================\\
//                                          COMMON LIB                                         \\
//=============================================================================================\\
//----------------------
//MISC
//----------------------
function GeneRound(pvValue, pvCoeff)
{ 	
	var pvVal=pvValue.toString().replace(",","."); pvVal=parseFloat(pvVal)*parseInt(pvCoeff); pvVal=pvVal.toString().split(".")[0];	
	var pvInt=pvVal.substring(0, pvVal.length-1); var pvLastFloat=pvVal.charAt(pvVal.length-1); var pvRound=0;
	
	if(parseInt(pvLastFloat)<5)	{pvRound=parseInt(pvInt)*10;} else {pvRound=(parseInt(pvInt)*10)+10;}
	pvRound=parseFloat((pvRound/parseInt(pvCoeff)));	
	//alert(pvValue+" | "+pvVal+" | "+pvInt+" | "+pvLastFloat+" | "+pvRound);	
	return(pvRound);	
}
//-----------------------------
function GeneStrClear01(pvValue)
{
	var sTemp=""; var i=0; var j=0; 
	var sToClean="update;delete;insert;des;de;les;le;la;en;dans;en;et;avec;a;à;";
	var Accents='à;â;ä;é;è;ê;ë;î;ï;ö;ô;û;ü;ù;ç';
	var NoAccents='a;a;a;e;e;e;e;i;i;o;o;u;u;u;ç';
	
	if(pvValue==""){pvValue="0"}
	else
		{	
			//BAD WORDS	
			var ArTemp=pvValue.toLowerCase().split(" ");
			var ArToClean=sToClean.split(";");
			for(i=0; i<ArTemp.length; i++)						
				{
					for(j=0; j<ArToClean.length; j++){if(ArToClean[j]==ArTemp[i]){ArTemp[i]=""; break;}}
					if(ArTemp[i].length>0){sTemp+=ArTemp[i]+" "};
				}				
			pvValue=sTemp.substring(0, sTemp.length-1); 			
			//alert("#1 : "+pvValue);
			
			//LETTER
			var ArAccents=Accents.split(";");
			var ArNoAccents=NoAccents.split(";");
			i=0;
			while(ArAccents[i]){ var Reg=new RegExp(ArAccents[i],'gi'); pvValue=pvValue.replace(Reg,ArNoAccents[i]); i++; }
			//alert("#2 : "+pvValue);
						
			pvValue=pvValue.replace(/["'"]/gi," ");			
			pvValue=pvValue.replace(/[\.]/gi," ");	
			pvValue=pvValue.replace(/[\\]/gi," ");
			pvValue=pvValue.replace(/[\/]/gi," ");
			pvValue=pvValue.replace(/[\[\]]/gi," ");
			pvValue=pvValue.replace(/[-,;?!:&=+#<>]/gi," ");
			pvValue=pvValue.replace(/[*°\(\)%]/gi," ");
			pvValue=pvValue.replace(/[_]/gi," ");			
			pvValue=pvValue.replace(/[ ]/gi,"+");			
			while(pvValue.indexOf("++")>=0){pvValue=pvValue.replace("++","+");}
			//alert("#3 : "+pvValue);
		}
	//OUTPUT
	if(pvValue==""){pvValue="0"}
	return escape(pvValue);
}
//----------------------
function FullScreen(){var winWi=screen.availWidth-10; var winHei=screen.availHeight-20; self.resizeTo(winWi, winHei); self.moveTo(3, 3);}
//----------------------
//CHECK
//----------------------
function CountChar(pvTxtLen, pvCounterBox)
{	
	var pvBox=pvCounterBox.replace("CW.value", ".value");
	var pvTxt=unescape(encodeURIComponent(eval(pvBox)));
	var pvTxtLen=pvTxt.length+2;
	var pvAct=eval(pvCounterBox+"="+pvTxtLen);
}
//----------------------
function check_empty(text){return (text.length > 0);} 
//----------------------
function check_list(box){	if(box.options.length==0){return false;} else {return true;}}
//----------------------
function check_email(adresse)
{
 if ((adresse == "") || (adresse.indexOf ('@') == -1) || (adresse.indexOf ('.') == -1))
      return false;
    return true;
}
//----------------------
function check_per(DaBox, IsPositif, IsZero)
{
	var DaAction=eval("DaVal=DaBox.value"); 
	var DaVal=DaVal.replace(" ",""); DaVal=DaVal.replace(",",".");
	var AllowNum="0123456789."; var bInt=true; var iChar=0; var sChar="";
	
	if(!check_empty(DaVal)){return false;}

	for(iChar=0; iChar<DaVal.length; iChar++)
		{
		sChar=DaVal.charAt(iChar); 
		bInt=(AllowNum.indexOf(sChar, 0)>=0)
		if(!bInt){return false; break;}
		}

	if(parseFloat(DaVal)>100){return false;}
	if(IsPositif && DaVal<0){return false;}
	if(!IsZero && DaVal==0){return false;}
	if(IsZero && DaVal==0){DaVal=0}	
	if(isNaN(DaVal)){return false;} else {DaAction=eval("DaBox.value=DaVal"); return true;}
}
//----------------------
function check_int(DaBox, IsPositif, IsZero)
{
	var DaAction=eval("DaVal=DaBox.value"); 
	var DaVal=DaVal.replace(" ","");
	var AllowNum="0123456789"; var bInt=true; var iChar=0; var sChar="";
	
	if(!check_empty(DaVal)){return false;}	

	for(iChar=0; iChar<DaVal.length; iChar++)
		{
		sChar=DaVal.charAt(iChar); 
		bInt=(AllowNum.indexOf(sChar, 0)>=0)
		if(!bInt){return false; break;}
		}
	
	if(IsPositif && DaVal<0){return false;}
	if(!IsZero && DaVal==0){return false;}
	if(IsZero && DaVal==0){DaVal=0}	
	if(isNaN(DaVal)){return false;} else {DaAction=eval("DaBox.value=DaVal"); return true;}
}
//----------------------
function check_float(DaBox, IsPositif, IsZero)
{
	var DaAction=eval("DaVal=DaBox.value"); 
	var DaVal=DaVal.replace(" ",""); DaVal=DaVal.replace(",",".");
	var AllowNum="0123456789."; var bInt=true; var iChar=0; var sChar="";

	
	if(!check_empty(DaVal)){return false;}

	for(iChar=0; iChar<DaVal.length; iChar++)
		{
		sChar=DaVal.charAt(iChar); 
		bInt=(AllowNum.indexOf(sChar, 0)>=0)
		if(!bInt){return false; break;}
		}
	
	if(IsPositif && DaVal<0){return false;}
	if(!IsZero && DaVal==0){return false;}
	if(IsZero && DaVal==0){DaVal=0}	
	if(isNaN(DaVal)){return false;} else {DaAction=eval("DaBox.value=DaVal"); return true;}
}
//----------------------
function check_len(pvName, pvForm)
{
	//var pvTxtLen=eval(pvForm+"."+pvName+".value.length");	
	var pvBox=eval(pvForm+"."+pvName);
	var pvTxt=unescape(encodeURIComponent(pvBox.value));
	var pvTxtLen=pvTxt.length+2;
	var pvTxtLenMax=eval(pvForm+"."+pvName+"LM.value");
	var pvAct=eval(pvForm+"."+pvName+"CW.value="+pvTxtLen);
	if (parseInt(pvTxtLen)>parseInt(pvTxtLenMax)){return false;} else {return true;}
}
//----------------------
function check_url(DaUrl,DaType)
{
	var e; 
	switch (DaType)
	{
		case "VALIDE"	:			 
			 e=new RegExp("^(http://|https://){0,1}[A-Za-z0-9][A-Za-z0-9\-\.]+[A-Za-z0-9]\.[A-Za-z]{2,}[\43-\176]*$");
			 //alert(DaUrl); alert(e.test(DaUrl));
			 if (!e.test(DaUrl)){return false;} else {return true;}
			break;
   	default				: 
			if(DaUrl!=""){winUrl=window.open(DaUrl,'URL','menubar=yes,scrollbars=yes,resizable=yes,status=yes,width=500,height=500');}
			break;       
	}	
}
//----------------------
function check_tel(DaBox, IsOblg)
{
	//VARS
	var sMsg=""; var temp=""; var DaAct=""; var bCheck=false;	var reg=/^\d+$/
	//TO LOWER CASE
	temp=eval("DaBox.value.toLowerCase()"); 
	if(IsOblg){bCheck=true;}	else {if(temp!=""){bCheck=true;}}	
	if(bCheck)
		{
		temp=temp.replace(/[abcdefghijklmnopqrstuvwxyz]/gi,"");
		temp=temp.replace(/[ ]/gi,"");
		temp=temp.replace(/[\.]/gi,"");	
		temp=temp.replace(/[\\]/gi,"");
		temp=temp.replace(/[\/]/gi,"");	
		temp=temp.replace(/[\[\]]/gi,"");
		temp=temp.replace(/[-,;?!:&=+#<>]/gi,"");
		temp=temp.replace(/[*°\(\)%]/gi,"");
		DaAct=eval("DaBox.value=temp");
		//REG EXP CHECK	+ OUTPUT		
		if((reg.exec(temp)==null) || (temp.length<10)){return false;}
		else 																					{return true;}
		}
	else
		{return true}
}
//----------------------
function check_date(d) 
{	
	var e; var j=0; var m=0; var a=0;
	//jj/mm/aa ou jj/mm/aaaa
	//EMPTY ?
	if (d==""){return false;}
	
	//10 ALPHA ?
	if (d.length!=10){return false;}
		
	//REG EXP ?
	e=new RegExp("^[0-9]{1,2}\/[0-9]{1,2}\/([0-9]{2}|[0-9]{4})$");
	if (!e.test(d))	{	return false;}
	else
			{
				//GRAB jj mm aaaa || aa
				j=parseInt(d.split("/")[0], 10); m=parseInt(d.split("/")[1], 10); a=parseInt(d.split("/")[2], 10);
				//COMPLETE aa
				if (a<1000){if (a < 89){a+=2000;} else {a+=1900;}}
				//ANNEE BISEXTILE
				if (a%4==0 && a%100!=0 || a%400==0){fev=29;} else {fev=28;}
				//NB JOURS
				nbJours=new Array(31,fev,31,30,31,30,31,31,30,31,30,31);
				//CHECK jj mm aaaa
				return (m>=1 && m<=12 && j>=1 && j<=nbJours[m-1]);
		 }
}
//----------------------
/*
function check_url(DaUrl,DaType)
{
	var e; 
	switch (DaType)
	{
		case "VALIDE"	:			 
			 e=new RegExp("^(http://|https://){0,1}[A-Za-z0-9][A-Za-z0-9\-\.]+[A-Za-z0-9]\.[A-Za-z]{2,}[\43-\176]*$");
			 //alert(DaUrl); alert(e.test(DaUrl));
			 if (!e.test(DaUrl)){return false;} else {return true;}
			break;
   	default				: 
			if(DaUrl!=""){winUrl=window.open(DaUrl,'URL','menubar=yes,scrollbars=yes,resizable=yes,status=yes,width=500,height=500');}
			break;       
	}	
}
*/
//----------------------
function check_FldrName(DaFld, DaForm)
{
	//VARS
	var Dis=eval(DaForm); var sMsg=""; var temp="";

	//TO LOWER CASE
	init=eval("Dis."+DaFld+".value.toLowerCase()");
	temp=init;

	//REPLACE	
	temp=temp.replace(/[\\']/gi,"");
	temp=temp.replace(/[\\"]/gi,"");
	temp=temp.replace(/[’]/gi,"");
	temp=temp.replace(/[`]/gi,"");
	temp=temp.replace(/[àâä@]/gi,"a");
	temp=temp.replace(/[éèêë]/gi,"e");
	temp=temp.replace(/[îï]/gi,"i");
	temp=temp.replace(/[ôö]/gi,"o");
	temp=temp.replace(/[ùûü]/gi,"u");
	temp=temp.replace(/[ç]/gi,"c");		
	temp=temp.replace(/[ ]/gi,"-");
	temp=temp.replace(/[\.]/gi,"-");	
	temp=temp.replace(/[\\]/gi,"");
	temp=temp.replace(/[\/]/gi,"");	
	temp=temp.replace(/[\[\]]/gi,"");
	temp=temp.replace(/[,;?!:&=+#<>]/gi,"");
	temp=temp.replace(/[*°\(\)%]/gi,"");
	temp=temp.toLowerCase();
		
	//MSG
	sMsg ="Des corrections ont été apportées au nom du fichier / raccourci :\n\n";
	sMsg+=init+"\n\n"+"DEVIENT\n\n"+temp.toLowerCase();		
	
	//OUTPUT
	if (temp!=init){alert(sMsg); DaAct=eval("Dis."+DaFld+".value=temp");}	
}
//----------------------
//OTHER STUFF
//----------------------
function ReloadOpener(){opener.location.reload(true)}
//----------------------
function ReloadPage(){self.location.reload(true)}
//----------------------
function ReloadParent(){parent.location.reload(true)}
//----------------------
function SelfMoveTo(DaX, DaY){self.moveTo(DaX, DaY)}
//----------------------
function SelfResizeTo(DaX, DaY){self.resizeTo(DaX, DaY);}
//----------------------
//DHTML 
//----------------------
function GetDivTxt(DaTxt,which,DaAct)
{
	oWhich=GetDaID(which); window.focus(); 
	switch (DaAct)
	{
		case "APPEND"	: oWhich.innerHTML+=DaTxt; break;
		default			: oWhich.innerHTML=DaTxt; break;       
	}	
}
//----------------------------
function SwitchClass01(pvDiv, pvClass){ oWhich=GetDaID(pvDiv); oWhich.className=pvClass;}	
//----------------------
function GetDaID(which)
{
	if (!document.getElementById|document.all){return}
	else
		{
		if (document.getElementById){oWhich = eval ("document.getElementById('" + which + "')")}
		else						{oWhich = eval ("document.all." + which)}
		}
	//window.focus(); 
	return oWhich;
}
//----------------------------
function GetParentDiv(which)
{
	//window.parent.document.getElementById
	if (!window.parent.document.getElementById|window.parent.document.all){return}
	else
		{
		if (window.parent.document.getElementById){oWhich=eval("window.parent.document.getElementById('" + which + "')")}
		else						{oWhich=eval ("window.parent.document.all." + which);}
		}
	//window.focus(); 
	return oWhich;
}
//----------------------------
function HideDiv(which){var oWhich=GetDaID(which); window.focus(); oWhich.style.display="none";}
//----------------------------
function ShowDiv(which){var oWhich=GetDaID(which); window.focus(); oWhich.style.display="";}
//----------------------
function ShowHideDiv(pvID, pvVis)
{
	if(pvID!="")
	{	
		oWhich=GetDaID(pvID); //window.focus(); 
		if(pvVis!=""){oWhich.style.display=pvVis;}
		else {if (oWhich.style.display=="none"){oWhich.style.display="";} else {oWhich.style.display="none";}}		
	}
}
//----------------------
function GeneShowHide(pvWin, pvID, pvVis)
{
	if(pvID!="")
	{	
		//var objWin=eval(pvWin);
		
		if (!pvWin.getElementById|pvWin.all){alert("Err#1");}
		else
		{
		if (pvWin.getElementById){oWhich=eval("pvWin.getElementById('"+pvID+"')")}
		else {oWhich=eval("pvWin.all."+pvID)}
		
		if(pvVis!=""){oWhich.style.display=pvVis;}
		else {if (oWhich.style.display=="none"){oWhich.style.display="";} else {oWhich.style.display="none";}}	
		}	
	}
}
//----------------------
/*
function GetVis(which, DaVis)
{
	if(which!="")
	{	
		oWhich=GetDaID(which); //window.focus(); 
		if(DaVis!="")	{oWhich.style.display=DaVis;}
		else					{if (oWhich.style.display=="none"){oWhich.style.display="";} else {oWhich.style.display="none";}}		
	}
}
*/
//----------------------------
function GetPosX(which)
{
	if (which.offsetParent)	{return (which.offsetLeft + GetPosX(which.offsetParent));}
	else										{return (which.offsetLeft);}
} 
//----------------------------	
function GetPosY(which)
{
	if (which.offsetParent)	{return (which.offsetTop + GetPosY(which.offsetParent));}
	else										{return (which.offsetTop);}
}
//----------------------------
//POP UP
//----------------------------
function Pop(pvPage, pvWName)
{
 if (pvPage!="" && pvWName!="") {winView=window.open (pvPage, pvWName,'menubar=yes,scrollbars=yes,resizable=yes,status=yes,width=330,height=200');}
 else							{alert(ExpNoParam)}
}
//----------------------
function PopImg(pvType, pvImg, pvTitre)
{
	var xOffSet=30; var yOffSet=60;

	w=open("",'image','width=400,height=580,toolbar=no,scrollbars=yes,resizable=yes');   
	w.document.write("<HTML><HEAD><TITLE>"+pvTitre+"</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+"+xOffSet+",580); window.focus();} else { setTimeout('checksize()',50) } }</"+"SCRIPT>");
	//w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+"+xOffSet+",document.images[0].height+"+yOffSet+"); window.focus();} else { setTimeout('checksize()',50) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+pvImg+"' border=0>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
}
//----------------------------
function ImgZoom(pvName, pvImg, pvWi, pvHei, pvAnchID, isPopDiv, pvClose)
{	
	if(isPopDiv)
		{	
			if (!pvWi>0){pvWi=320;}
			if (!pvHei>0){pvHei=250;}
			//SCREEN
			var winWi=document.body.offsetWidth; var winHei=document.body.offsetHeight;
			var popWi=pvWi+20; var popHei=pvHei+20;		
			var popLeft=GetPosX(GetDaID(pvAnchID))+20; if (popLeft<0 || popLeft>(winWi-popWi) || popLeft>(parseInt((winWi/2)-(pvWi/2))) ){popLeft=parseInt((winWi/2)-(pvWi/2))};
			var popTop=GetPosY(GetDaID(pvAnchID))-parseInt(popHei/2); if (popTop<0){popTop=parseInt(winHei/3)};
			
			//if(popLeft>(parseInt((winWi/2)))){popLeft=popLeft-200;} 
			//else {popLeft=popLeft+100;}	
		
			//CONTENT
			var pvContent='<img src="'+pvImg+'" vspace="0" hspace="0" border="0" align="absmiddle" style="border:1px solid #B71EB9;">';

			//ACTION	
			oWhich=GetDaID(pvName); //alert(oWhich.style.display);	
			if(oWhich.style.display=="none")
			{				
				oWhich.style.width=popWi+"px"; oWhich.style.height=popHei+"px";
				oWhich.style.left=popLeft+"px"; oWhich.style.top=popTop+"px";
				oWhich.innerHTML=pvContent;	ShowDiv(pvName);
			}			
		}
	else
		{
		DaWidth=parseInt(pvWi)+30; pvHei=parseInt(DaHeight)+30;
		winView=window.open (pvImg, pvAnchID,'menubar=yes,scrollbars=yes,resizable=yes,status=yes,width='+pvWi+',height='+pvHei+'');
		}
}
//----------------------------
function ImgSwitch(which, pvImg, pvStyle)
{	
	oWhich=GetDaID(which);	//alert(oWhich);
	oWhich.src=pvImg;
}
//----------------------
function ClosePopUp(which){oWhich=GetDaID(which); oWhich.innerHTML=""; HideDiv(which);}
//----------------------------
function GetPopUp(which, DaUrl, DaWidth, DaHeight, DaAnchID, DaPopDiv)
{	
	//alert(DaPopDiv);
	if(DaPopDiv)
		{	
		//CHECK	
		if (!DaWidth>0){DaWidth=320;}
		if (!DaHeight>0){DaHeight=250;}
		//SCREEN
		var winWi=document.body.offsetWidth; var winHei=document.body.offsetHeight;
		var popWi=DaWidth+20; var popHei=DaHeight+20;
		/*
		var popLeft=GetPosX(GetDaID(DaAnchID))+20; if (popLeft<0 || popLeft>(winWi-popWi)){popLeft=parseInt(winWi/2)};
		var popTop=GetPosY(GetDaID(DaAnchID))-parseInt(popHei/2); if (popTop<0){popTop=parseInt(winHei/3)};
		*/
		var popLeft=GetPosX(GetDaID(DaAnchID))+20; 
		if (popLeft<0 || popLeft>(winWi-popWi) || popLeft>(parseInt((winWi/2)-(DaWidth/2))) ){popLeft=parseInt((winWi/2)-(DaWidth/2))};
		
		var popTop=GetPosY(GetDaID(DaAnchID))-parseInt(popHei/2); 
		if (popTop<0){popTop=parseInt(winHei/3)};
		
		if(DaAnchID=="SUPPMAIL"){popTop=20; popLeft=100;}
		
		//POPCONTENT
		DaContent ="<div align='left'>";
		DaContent+="<img src='/app_pix/adm_mep/b_popmove.gif' vspace='0' hspace='0' border='0' align='absmiddle' alt='Deplacer'></a>&nbsp;";
		//DaContent+="<a href='javascript:HideDiv(\"DivPop\");'><img src='/app_pix/adm_mep/b_popclose.gif' vspace='0' hspace='0' border='0' align='absmiddle' alt='Fermer'></a>";
		DaContent+="<a href='javascript:ClosePopUp(\"DivPop\");'><img src='/app_pix/adm_mep/b_popclose.gif' vspace='0' hspace='0' border='0' align='absmiddle' alt='Fermer'></a>";		
		DaContent+="</div>";	
		DaContent+="<iframe id='divpopcontent' name='divpopcontent' src='"+DaUrl+"' width='100%' height='100%' scrolling='auto' frameborder='0' marginwidth='0' marginheight='0'></iframe>";
		//ACTION	
		oWhich=GetDaID(which);	
		oWhich.style.width=popWi; oWhich.style.height=popHei;
		oWhich.style.left=popLeft; oWhich.style.top=popTop;
		
		//oWhich.style.background="#FFFFFF";		
		//oWhich.style.width="100%"; oWhich.style.height="100%";
		//oWhich.style.left=0; oWhich.style.top=0;
		//oWhich.style.padding-top="30px"; oWhich.style.padding-bottom="30px"; 
		//oWhich.style.padding-left="25%"; oWhich.style.padding-right="25%";
		
		oWhich.innerHTML=DaContent;	
		ShowDiv(which);	
		}
	else
		{
		DaWidth=parseInt(DaWidth)+30; DaHeight=parseInt(DaHeight)+30;
		winView=window.open (DaUrl, DaAnchID,'menubar=yes,scrollbars=yes,resizable=yes,status=yes,width='+DaWidth+',height='+DaHeight+'');
		}
}
//----------------------
//CHECKBOXES
//----------------------
function ManageCheckBox01(DaBox, DaNum, DaCheck){ for(i=1; i<=DaNum; i++){eval(DaBox+i+'.checked='+DaCheck);} }
//----------------------
//LISTBOXES
//----------------------
function Gene2BoxAdd1(pvBox, pvVal1, pvVal2) 
{	
	var bFlag=true;
	
	//alert(pvBox+" | "+pvVal1+" | "+pvVal2);
			
	try {eval("var BoxTo1=parent."+pvBox); eval("var BoxTo2=parent."+pvBox+"Descr");}
	catch (e) {if(e!=""){bFlag=false;}}
	
	if(!bFlag)
	{
		bFlag=true;
		try {eval("var BoxTo1=opener."+pvBox); eval("var BoxTo2=opener."+pvBox+"Descr");}
		catch (e) {if(e!==""){bFlag=false;}}
	}	
	
	if(!bFlag){alert("Windows conversation error : "+e.description)}
	else {BoxTo1.value=pvVal1;	BoxTo2.value=pvVal2;}
}
//----------------------
function GeneListDel(pvBox)  {
   for(var i=0; i<pvBox.options.length; i++)  
   	{ if(pvBox.options[i].selected && pvBox.options[i].value!=""){pvBox.options[i]=null; i--;} }
}
//----------------------
function GeneListAdd1(pvBox, pvValue,pvTxt) 
{	
	var bFlag=true;
	var no=new Option(); no.value=pvValue; no.text=pvTxt;
		
	try {eval("var BoxTo=parent.document."+pvBox);}
	catch (e) {if(e!=""){bFlag=false;}}
	
	if(!bFlag)
	{
		bFlag=true;
		try {eval("var BoxTo=opener.document."+pvBox);}
		catch (e) {if(e!==""){bFlag=false;}}
	}	
	if(!bFlag){alert("Windows conversation error : "+e.description)}
	else {BoxTo.options[BoxTo.options.length]=no;}
}
//----------------------
function GeneListAddX(pvFBox, pvTBox) 
 {
   for(var i=0; i<pvFBox.options.length; i++)
   	{
     if(pvFBox.options[i].selected && pvFBox.options[i].value!="")
	 	{
        var NewOpt=new Option(); NewOpt.value=pvFBox.options[i].value; NewOpt.text=pvFBox.options[i].text;
        pvTBox.options[pvTBox.options.length]=NewOpt;
     	}
	}
}
//----------------------
function GeneListFocus(pvBox){for(var i=0; i<pvBox.options.length; i++){pvBox.options[i].selected=true;}}
//----------------------
function GeneListMove(pvFrom, pvTo) 
 {
   for(var i=0; i<pvFrom.options.length; i++)  
   	{
     if(pvFrom.options[i].selected && pvFrom.options[i].value!="")
	 	{
        var NewOpt=new Option(); 
		NewOpt.value=pvFrom.options[i].value; NewOpt.text=pvFrom.options[i].text; 
		pvTo.options[pvTo.options.length]=NewOpt;
     	}
	}
}
//----------------------
function GeneUtf8Encode (string) 
{
	string = string.replace(/\r\n/g,"\n");
	var utftext = "";
	for (var n = 0; n < string.length; n++) 
	{
		var c = string.charCodeAt(n);
		if (c < 128) {
                utftext += String.fromCharCode(c);
            }
        else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
        else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }
        }
        return utftext;
    }
//----------------------