<!--
// ---------------------------
// 4DBK javascript librairies
// CONVERT DATA TOOLS
// (c) 4D SA - 2000-2002
// A.L - version 1.01
// ---------------------------

// ------------------------------------------------------------------------------
// convert a field to lowercase without accent
// var str=ToLowerCase("AOzÀÉ"); --> aozae
// ------------------------------------------------------------------------------
function ToLowerCase(str)
{	var	res="",thechar,thecode,done;
	str=str.toLowerCase();
	for (var i=0;i<str.length;i++)
	{	thechar=str.substring(i,i+1);
		thecode=str.charCodeAt(i);
		done=0;
		
		if((thecode>=192) && (thecode<=198)) {res=res+"a"; done=1;}
		if((thecode>=224) && (thecode<=230)) {res=res+"a"; done=1;}
		if(thecode==199) 					 {res=res+"c"; done=1;}
		if(thecode==231) 					 {res=res+"c"; done=1;}
		if((thecode>=200) && (thecode<=203)) {res=res+"e"; done=1;}
		if((thecode>=232) && (thecode<=235)) {res=res+"e"; done=1;}
		if((thecode>=204) && (thecode<=207)) {res=res+"i"; done=1;}
		if((thecode>=236) && (thecode<=239)) {res=res+"i"; done=1;}
		if(thecode==209) 					 {res=res+"n"; done=1;}
		if(thecode==241) 					 {res=res+"n"; done=1;}
		if((thecode>=210) && (thecode<=216)) {res=res+"o"; done=1;}
		if((thecode>=242) && (thecode<=246)) {res=res+"o"; done=1;}
		if((thecode>=217) && (thecode<=220)) {res=res+"u"; done=1;}
		if((thecode>=249) && (thecode<=252)) {res=res+"u"; done=1;}
		if(thecode==223) 					 {res=res+"b"; done=1;}
		if(thecode==255) 					 {res=res+"y"; done=1;}
		if(thecode==376) 					 {res=res+"y"; done=1;}
		if(done==0) res=res+thechar;
	}
	return res;
}

// ------------------------------------------------------------------------------
// convert a field to uppercase without accent
// var str=ToUpperCase("aéioZ"); --> AEIOZ
// ------------------------------------------------------------------------------
function ToUpperCase(str)
{	var	res="",thechar,thecode,done;
	str=str.toUpperCase();
	for (var i=0;i<str.length;i++)
	{	thechar=str.substring(i,i+1);
		thecode=str.charCodeAt(i);
		done=0;
		
		if((thecode>=192) && (thecode<=198)) {res=res+"A"; done=1;}
		if((thecode>=224) && (thecode<=230)) {res=res+"A"; done=1;}
		if(thecode==199) 					 {res=res+"C"; done=1;}
		if(thecode==231) 					 {res=res+"C"; done=1;}
		if((thecode>=200) && (thecode<=203)) {res=res+"E"; done=1;}
		if((thecode>=232) && (thecode<=235)) {res=res+"E"; done=1;}
		if((thecode>=204) && (thecode<=207)) {res=res+"I"; done=1;}
		if((thecode>=236) && (thecode<=239)) {res=res+"I"; done=1;}
		if(thecode==209) 					 {res=res+"N"; done=1;}
		if(thecode==241) 					 {res=res+"N"; done=1;}
		if((thecode>=210) && (thecode<=216)) {res=res+"O"; done=1;}
		if((thecode>=242) && (thecode<=246)) {res=res+"O"; done=1;}
		if((thecode>=217) && (thecode<=220)) {res=res+"U"; done=1;}
		if((thecode>=249) && (thecode<=252)) {res=res+"U"; done=1;}
		if(thecode==223) 					 {res=res+"B"; done=1;}
		if(thecode==255) 					 {res=res+"Y"; done=1;}
		if(thecode==376) 					 {res=res+"Y"; done=1;}
		if(done==0) res=res+thechar;
	}
	return res;
}

// ------------------------------------------------------------------------------
// convert a the first letter of a field to uppercase without accent
// var str=ToCaps("ouvea"); --> Ouvea
// ------------------------------------------------------------------------------
function ToCaps(str)
{	return ToUpperCase(str.substring(0,1))+str.substring(1,str.length);
}

// ------------------------------------------------------------------------------
// encore extended characters into decimal codes
// var str=ToISOCodes("aéioZ"); --> a&#97;ioZ
// ------------------------------------------------------------------------------
function ToISOCodes(str)
{	var	res="",thechar,thecode,done;
	var hexa="0123456789ABCDEF";
	var start,end;
	for (var i=0;i<str.length;i++)
	{	thechar=str.substring(i,i+1);
		thecode=str.charCodeAt(i);
		done=0;
		
		if((thecode>=126) && (thecode<=255))
		{	res=res+"%";
			start=Math.floor(thecode/16);
			end=start+1;
			res=res+hexa.substring(start,end);
			start=thecode-(Math.floor(thecode/16)*16);
			end=start+1;
			res=res+hexa.substring(start,end);
			done=1;
		}
		if(done==0) res=res+thechar;
	}
	return res;
}
        
// ------------------------------------------------------------------------------
// convert spaces into plus (for Netscape URL)
// var str=EncodeURL("ABC DEé"); --> ABC+DE&#201;
// ------------------------------------------------------------------------------
function EncodeURL(str)
{	str=str.replace(/ /gi,"+");
	str=str.replace(/\r\n/gi,"^r");
	str=str.replace(/\r/gi,"^r");
	str=str.replace(/\n/gi,"^r");
	
	return ToISOCodes(str);
}

function EncodeURL2(str)
{	str=str.replace(/ /gi,"+");
	str=str.replace(/\r/gi,"<br>");
	str=str.replace(/\n/gi,"");
	
	return str;
}

// ------------------------------------------------------------------------------
// remove empty words
// var str=RemoveEmptyWords("ABC  DEF "); --> ABC DEF
// ------------------------------------------------------------------------------
function RemoveEmptyWords(str)
{	str=str.replace(/\s\s/gi," ");
	str=str.replace(/^\s/gi,"");
	str=str.replace(/\s$/gi,"");
	return str;
}

// ------------------------------------------------------------------------------
// remove semicolon
// var str=RemoveSemiColon("ABC;DEF "); --> ABCDEF
// ------------------------------------------------------------------------------
function RemoveSemiColon(str)
{	if(str.length>0) str=str.replace(/\x3B/gi,"");
	return str;
}
// -->
