function makearray(n) {
this.length = n;
for(var i = 1; i <= n; i++)
this[i] = 0;
return this;
}
hexa = new makearray(16);
for(var i = 0; i < 10; i++)
hexa[i] = i;
hexa[10]="A"; hexa[11]="B"; hexa[12]="C"; 
hexa[13]="D"; hexa[14]="E"; hexa[15]="F"; 
function hex(i) {
if (i < 0)
return "00";
else if (i > 255)
return "ff";
else return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}
// Patch pour firefox
function ffbgColor(ffstring) {
 var re=/([0-9]{2,3}), *([0-9]{2,3}), *([0-9]{2,3})/;
 tab=re.exec(ffstring);
 return "#"+hex(tab[1])+hex(tab[2])+hex(tab[3]);
 
return ffstring;
}
function setPointer(theCell, theIndex, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
	obj=theCell;
	while(obj.tagName!="TR") {
		obj=obj.parentNode;
	}

	actualCol=obj.style.backgroundColor.toUpperCase();
	brow=navigator.appName+navigator.appVersion
	if (brow.indexOf("Netscape")>-1 && brow.indexOf("Safari")==-1) {
		if (actualCol!=""){
			actualCol=ffbgColor(actualCol);
		}
	}
	theDefaultColor=theDefaultColor.toUpperCase();
	theMarkColor=theMarkColor.toUpperCase();
	thePointerColor=thePointerColor.toUpperCase();
 	if(theAction=='click'){
 		if(actualCol==theMarkColor){
	obj.style.backgroundColor=theDefaultColor;
 		} else {
	obj.style.backgroundColor=theMarkColor;
 		}
 	}
 	if(actualCol!=theMarkColor){
	 	if(theAction=='out'){
	obj.style.backgroundColor=theDefaultColor;
 		}
 		if(theAction=='over'){
	obj.style.backgroundColor=thePointerColor;
 		}
 	}
 }

 function appendToField(theField,theValue){
 	var v=eval(theField+'.value');

 	var varray=v.split(";");
 	var deleted=0;
	if(varray.length>0){
 	for(i=0;i<varray.length;i++){
 		if (varray[i]==theValue){
 			varray[i]='';
 			deleted=1;
 		}
 	}
 	}
	
 	if(deleted==0){
 		varray[varray.length]=theValue;
 	}
 	v=varray.join(";");
	eval(theField+'.value=v');
 }
 function invertChecked(theField){
if(theField.checked){
 		theField.checked=false;
 	} else {
 		theField.checked=true;
 	}
 }
function montrewait() {
	document.getElementById('waitbar').style.visibility='visible';
}
function cachewait() {
	document.getElementById('waitbar').style.visibility='hidden';
}
function fermealerte() {
	document.getElementById('errorPanel').style.visibility='hidden';
}
function montrealerte() {
	document.getElementById('errorPanel').style.visibility='visible';
}
var clic=0;
function avoidDblClk(){
	if(clic==1){
		alert('Formulaire en cours de traitement. Veuillez patienter SVP');
		return false;
	} else {
		clic=1;
		return true;
	}
}
