function show(divId)
{
if (document.layers) document.layers[divId].visibility = 'show';
else if (document.all[divId]) 
{
  document.all[divId].style.visibility = 'visible';
  document.all[divId].style.display = 'block';
}
else if (document.getElementById) 
{
  document.getElementById(divId).style.visibility = 'visible';  
  document.getElementById(divId).style.display = 'block';
}
}


function hide(divId)
{
if (document.layers) 
{
  document.layers[divId].visibility = 'hide';
}
else if (document.all[divId]) 
{
  document.all[divId].style.visibility = 'hidden';
  document.all[divId].style.display = 'none';
}
else if (document.getElementById) 
{
  document.getElementById(divId).style.visibility = 'hidden';  
  document.getElementById(divId).style.display = 'none';
}
}

//directement sur l'element
//directement sur l'element
function showElt(elt)
{

  elt.style.visibility = 'visible';  
  
 
 /*if(navigator.appName == "Microsoft Internet Explorer")
	elt.style.display = "inline";
        else 
            elt.style.display = "table-row";*/
  //elt.style.width = '100%';
elt.style.display = 'block';
}

function hideElt(elt)
{
  elt.style.visibility = 'hidden'; 
  elt.style.display = 'none';
  
}




function getElt(div)
{
if (document.getElementById) return document.getElementById(div);
else if (document.all) return document.all[div];
return null;    
}

function trim(string)
{
	return string.replace(/(^\s*)|(\s*$)/g,'');
} 

function selectListContains(selectList,testvalue){

	var i=0;
	for(i;i<selectList.options.length;i++){
		if(selectList.options[i].value==testvalue)
		return 1;
	}
	return 0;
}

function checkMail(theFormInput)
{
	var x = theFormInput.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return (true);
	else return (false);
}

function openpop(url, name,widthf,heightf) {
	newwindow=window.open(url,name,'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1 ,resizable=1 ,WIDTH='+widthf+' ,HEIGHT='+heightf+'');
	if (window.focus) {newwindow.focus()}
	return false;
}

function setSelected(select,defaultvalue)
{
 var object=getElt(select);
 if(object!=null)
 {
  for(var i=0; i<object.length;i++)
  {
  if(object.options[i].value==defaultvalue)
  {
  object.options[i].selected=true;
  }	
  }  
  }
}

function findPosTop(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop
		}
	}
	return curtop;
}
function findPosLeft(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
		}
	}
	return curleft;
}

function checkSupportedCharacters(sText)
{	
	var mChar;
	var alreadyFlagged = "";
	var asci = 0;
	var table = new Array(); 
	var j = 0;
	for (i = 0; i < sText.length; i++)
	{
		mChar = sText.charAt(i);
		asci = sText.charCodeAt(i);

		if (asci == 34 || asci == 38 
		|| asci == 39 || asci == 60 
		|| asci == 62 || asci > 126 
		|| asci < 32)
		{
			if (alreadyFlagged.indexOf(mChar) == -1)
			{
				table[j++]=mChar;	
				alreadyFlagged+=mChar;
			}
					
		}
	 }
	 
	 return table;
	 
}

function controleString(str)
{
	b = false;
	for(var i=0; i<str.length; i++)
	{
		var alphaa = str.charAt(i);
		//var hh = alphaa.charCodeAt(0);
		if((alphaa=="&") || (alphaa=="<") || (alphaa==">") || (alphaa=="\'") || (alphaa=="\""))
		{
			b = true;
		}
	}
	return b;
}

function controleStringDesc(str)
{
	b = false;
	for(var i=0; i<str.length; i++)
	{
		var alphaa = str.charAt(i);
		//var hh = alphaa.charCodeAt(0);
		if((alphaa=="&") || (alphaa=="<") || (alphaa==">"))
		{
			b = true;
		}
	}
	return b;
}

function controleStringDefCombo(str)
{
	b = false;
	for(var i=0; i<str.length; i++)
	{
		var alphaa = str.charAt(i);
		//var hh = alphaa.charCodeAt(0);
		if((alphaa=="&") || (alphaa=="<") || (alphaa==">") || (alphaa=="\'") || (alphaa=="\""))
		{
			b = true;
		}

	}
	return b;
}
function getcontroleStringerrormessageDefCombo(){
	return '( & < > \" \' ) ';
}
function getcontroleStringDescerrormessage(){
	return '( & < > ) ';
}
function getcontroleStringerrormessage(){
	return '( & < > \" \' ) ';
}

//utils for option list
function selectAllMultipleList(mySelect) {
	var aSelect = mySelect;
	var i = 0;
	
	while (i < aSelect.options.length)
	{
		aSelect.options[i].selected = true;
		i++;
	}
}
function unselectAllMultipleList(mySelect) {
	var aSelect = mySelect;
	var i = 0;
	
	while (i < aSelect.options.length)
	{
		aSelect.options[i].selected = false;
		i++;
	}
}
function listContainsValue(optionlist,valuetest){
	var icv=0;
	for(icv;icv<optionlist.options.length;icv++){
		if(optionlist.options[icv].value==valuetest){
			return true;
		}
	}
	return false;
}
function addValueInList(inputtextvalue,aSelect){
	if(trim(inputtextvalue)!=''&&!listContainsValue(aSelect,inputtextvalue)){
		aSelect.options[aSelect.options.length]=new Option(inputtextvalue,inputtextvalue);
		inputtextvalue='';
	}
}
function addInputValueInList(inputtext,aSelect){
	if(trim(inputtext.value)!=''&&!listContainsValue(aSelect,inputtext.value)){
		aSelect.options[aSelect.options.length]=new Option(inputtext.value,inputtext.value);
		inputtext.value='';
	}
}
function addSelectionInList(aSelectAdder,aSelect){
	var ias=0;
	for(ias;ias<aSelectAdder.options.length;ias++){
		if(aSelectAdder.options[ias].selected){
			addValueInList(aSelectAdder.options[ias].value,aSelect)
		}
	}
}
function removeElementFromList(optionlist){
	var selected=optionlist.selectedIndex;
	if(selected!=-1){
		optionlist.options[selected]=null;
	}
}
function removeMultipleElementFromList(optionlist){
	var irm=0;
	irm=optionlist.options.length-1;
	for(irm;irm>=0;irm--){
		if(optionlist.options[irm].selected){
			optionlist.options[irm]=null;
		}
	}
}
function showDeleteOption(optionlist,messageSelect,messageUnselect,elementId){
	var selected=optionlist.selectedIndex;
	if(selected!=-1)
	document.getElementById(elementId).innerHTML=messageSelect;
	else if(optionlist.options.length>0)document.getElementById(elementId).innerHTML=messageUnselect;
	else if(optionlist.options.length==0)document.getElementById(elementId).innerHTML='';
	
}

function selectAllMultipleBox(eltBox){
	for(i=0;i<eltBox.length;i++){
		eltBox[i].checked=true;
	}
}

function unselectAllMultipleBox(eltBox){
	for(i=0;i<eltBox.length;i++){
		eltBox[i].checked=false;
	}
}

function isAllSelectedMultipleBox(eltBox){
	for(i=0;i<eltBox.length;i++){
		if(!eltBox[i].checked)return false;
	}
	return true;
}
function sortIgnoreCase(a,b)
{
	try{
	a = a.toLowerCase(); 
	b = b.toLowerCase();
	if (a>b) return 1;
	if (a<b) return -1;
	return 0;}catch(err){return 0;}
}
function addValueInSortedList(aSelect,aValue){
	var tab=new Array();
	for(var i=0;i<aSelect.options.length;i++){
		tab.push(aSelect.options[i].value);
	}
	tab.push(aValue);
	tab.sort(sortIgnoreCase);
	
	for(var y=0;y<tab.length;y++){
		var opt=new Option(tab[y],tab[y]);
		aSelect.options[y]=opt;
	}
}
function addMultipleValueInSortedList(aSelect,aSelectSource){
	var tab=new Array();
	for(var i=0;i<aSelect.options.length;i++){
		tab.push(aSelect.options[i].value);
	}
	
	var irm=0;
	irm=aSelectSource.options.length-1;
	for(irm;irm>=0;irm--){
		if(aSelectSource.options[irm].selected){
			tab.push(aSelectSource.options[irm].value);
		}
	}
	tab.sort(sortIgnoreCase);
	
	for(var y=0;y<tab.length;y++){
		var opt=new Option(tab[y],tab[y]);
		aSelect.options[y]=opt;
	}
}

function enableDocumentSelection(){
	if(window.sidebar){
		document.onmousedown=null;
		document.onclick=null;
	}
	else{
		document.onselectstart=null;
	}
}
function disableDocumentSelection(){
	if(window.sidebar){
		document.onmousedown=new Function("return false");
		document.onclick=new Function("return false");
	}
	else{
		document.onselectstart=new Function("return false");
	}
}

