function autotab(src,dest){
	if (src.getAttribute && src.value.length == src.getAttribute("maxlength")) dest.focus();
}
/* -------------------------------------------------------------------------------------------------*/
function isObject(obj) {
	if (document.layers) {if (typeof obj == "string") {return document.layers[obj]} else {return obj}}
	if (document.all) {if (typeof obj == "string") {return document.all(obj)} else {return obj}	}
	if (document.getElementById) {if (typeof obj == "string") {return document.getElementById(obj)} else {return obj}}
	return null
}
/* -------------------------------------------------------------------------------------------------*/
function focusonfirst()
{
	if (document.forms.length <= 0) return;
	var field = document.getElementsByTagName("form")[0];
	for (i = 0; i < field.length; i++) 
 	   {
	    if (field.elements[i].readOnly ) continue ;
		if ((field.elements[i].type == "text") || 
		    (field.elements[i].type == "textarea") || 
		    (field.elements[i].type.toString().charAt(0) == "s")) 
		    {
			document.forms[0].elements[i].focus();
	        break;
		    }
	    }
}
/* -------------------------------------------------------------------------------------------------*/
function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1) return "";
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE=="") return "";
	return TRIM_VALUE;
} 
/* -------------------------------------------------------------------------------------------------*/
function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0) return "";
	var iTemp = v_length -1;
	while(iTemp > -1)
		{
		if(VALUE.charAt(iTemp) != w_space) {strTemp = VALUE.substring(0,iTemp +1);break;}
		iTemp = iTemp-1;
		} 
	return strTemp;
} 
/* -------------------------------------------------------------------------------------------------*/
function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if (v_length < 1) return "";
	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;
	while(iTemp < v_length)
		{
		if(VALUE.charAt(iTemp) != w_space){strTemp = VALUE.substring(iTemp,v_length);break;}
		iTemp = iTemp + 1;
		} 
	return strTemp;
} 
/* -------------------------------------------------------------------------------------------------*/
function isnum(wstr)
{
	var cpt;
	cpt = 0;
	wstr=wstr.replace(/[ ]+/g,"") ; 
	while (cpt < wstr.length) 
	   {  
	   if ( wstr.substr(cpt,1) == "," ) cpt++;
	   else
	   if ( wstr.substr(cpt,1) < "0" || wstr.substr(cpt,1) > "9" ) return(false); 
       else cpt++ ; 
       }
	return(true);
}
/* --------------------------------------------------------------------------------------------------*/
function Zoom(chemin)
{
image = new Image();
//image.onerror= function () { popupImage.close() ; return false; }; 
image.src = chemin;
html = '<HTML><HEAD><TITLE>Image</TITLE></HEAD><BODY style="margin:0px 0 0 0;padding:0px"><IMG SRC="'+chemin+'" NAME="zoom" onLoad="lmax=screen.width;hmax=screen.height;i=document.zoom;l=i.width;h=i.height+50;if(l>=lmax){h=(lmax/l)*h;l=lmax};if(h>=hmax)h=hmax;window.resizeTo(l,h);moveTo((lmax-l)/2,(hmax-h)/2)"></BODY></HTML>';

//popupImage = window.open('','',"top=" + screen.height/2 + ",left=" + screen.width/2 + ",scrollbars=1,toolbar=0,resizable");
//popupImage = window.open('','',"top=" + screen.height/2 + ",left=" + screen.width/2 + ",width=10px,height=10px,toolbar=0,resizable");

popupImage = window.open('','',"top=" + screen.height/3 + ",left=" + screen.width/3 + ",width=" + screen.width/2 + ",height=" + screen.height/2 + ",toolbar=0,resizable");

popupImage.focus();

if (popupImage && popupImage.top) {
// popup has opened
popupImage.document.open();
popupImage.document.write(html);
popupImage.document.close();
} else {
alert("Pour voir l'image, autorisez l'ouverture des fenêtres"); 
// popup has been blocked
}
} 
/* --------------------------------------------------------------------------------------------------*/
function imprime_zone(titre, obj) 
{
var zi = document.getElementById(obj).innerHTML;
var f = window.open("", "ZoneImpr", "height=500, width=600,toolbar=0, menubar=0, scrollbars=1, resizable=1,status=0, location=0, left=10, top=10");

   f.document.body.style.color = '#000000';
   f.document.body.style.backgroundColor = '#FFFFFF';
   f.document.body.style.padding = "10px";
   f.document.title = titre;
   f.document.body.innerHTML += "" + zi + "";
   f.window.print();
   f.window.close();

return true;
}