// JavaScript Document



function change_mouse(valeur,clip)
{	
	clip.style.cursor=valeur;
}

function agrandi() {
window.moveTo(0,0);
window.resizeTo(screen.availWidth, screen.availHeight);
}

agrandi();
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function ouvre_fiche(fichier, type) 
{
	var large=screen.width/2;
	var haute=screen.height/2;
	var test=haute-(haute/2);
	//if(popW){ large = popW; }
	//if(popH){ haute = popH; }
	
	if(type == 'byId'){
		fichier = document.getElementById(fichier).src;
		var newImg = new Image();
		newImg.src = fichier;
		haute = newImg.height;
		large = newImg.width;
	}
	window.open(fichier,"popup2","width="+large+",height="+haute+",top="+test+",left="+(screen.width/2-screen.width/4)+",scrollbars=no,resizable=yes,menubar=no,status=no");
}


function etend_div(clip)
{
    if(document.getElementById(clip).style.display=="none")
    {
        document.getElementById(clip).style.display="block";
    }
    else
    {
        document.getElementById(clip).style.display="none";
    }
}


/*******************************************************************************************/
/*******************************************************************************************/
/*******************************************************************************************/
function envoi_form(id_form)
{
	var iteme = document.getElementById(id_form);
//	alert(iteme);
	iteme.submit();	

}
function envoi_form_modele(id_form)
{
	if(document.getElementById('isOk').value == 'true'){
		var iteme = document.getElementById(id_form);
			
		iteme.submit();	
	} else {
		alert('Il y a des identifiants doublon');
	}
}

function reset_form(id_form)
{
	var item = document.getElementById(id_form);
	item.reset();	
}


function envoi_form_val(id_form,ids_champs,valeurs, envoi, type)
{
	var tab_champs = ids_champs.split('|');
	var tab_values = valeurs.split('|');
	if(type == 'src'){
		if(tab_champs.length!=0)
		{
			for(i = 0; i < tab_champs.length; i++)
			{
				document.getElementById(tab_champs[i]).src = tab_values[i];
			}
		}
	}
	else
	{
		if(tab_champs.length!=0)
		{
			for(i = 0; i < tab_champs.length; i++)
			{
				document.getElementById(tab_champs[i]).value = tab_values[i];
			}
		}
	}
	if(envoi != 'false'){
		envoi_form(id_form);
	}
}

function trim (myString)
{
	return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
} 
	

//disabled des objets ou pas
function disable_item(items_list, value)
{
	var tab_items = items_list.split('|');
	if(tab_items.length!=0)
	{
		for(i = 0; i < items_list.length; i++)
		{
			document.getElementById(tab_items[i]).disabled = value;
		}
	}
}

//modifie UNE propriété pour PLUSIEURS élement
function change_items_prop(items_list, property, value){

	var tab_items = items_list.split('|');
	if(tab_items.length!=0)
	{
		for(i = 0; i < tab_items.length; i++)
		{
			itm = document.getElementById(tab_items[i]);
			itm.style[property] = value;
		}
	}
}
//modifie PLUSIEURS propriétés pour UN élement
function change_props(itm, property_list, values_list){

	var tab_props = property_list.split('|');
	var tab_values = values_list.split('|');
		
/*	ze_item = document.getElementById(itm);
	
	alert(ze_itm);*/
	
	if(tab_props.length!=0)
	{
		for(z = 0; z < tab_props.length; z++)
		{
			document.getElementById(itm).style[tab_props[z]] = tab_values[z];
		}

	}
}

function checkSelectInput(mySelectId, myInputId, myDivId, sens)
{
	if(sens != false){ sens = true; }
	var mySelect = document.getElementById(mySelectId);
	var myInput = document.getElementById(myInputId);
	if (mySelect.value != "")
	{
		myInput.disabled = true;
		if(myInput.value == '') { myInput.value = "déjà sélectionné"; }
	}
	else
	{
		myInput.disabled = false;
		if(myInput.value == "déjà sélectionné") { myInput.value = ''; }
	}
	
	if (myDivId)
	{
		var dispA = 'none';
		var dispB = 'table-row';
		if(sens == false){
			dispA = 'table-row';
			dispB = 'none';
		}
		var myDiv = document.getElementById(myDivId);
		if(mySelect.value == ''){ myDiv.style.display = dispA; } else { myDiv.style.display = dispB; }
	}
}
function toggleDisplay(myItem, type){
	dispType = 'block';
	if(type == 'table'){ dispType = 'table-row'; }
	var elem = document.getElementById(myItem);
	var disp = elem.style.display;
	if(disp == 'none'){ elem.style.display = dispType; } else { elem.style.display = 'none'; }
}
/*******************************************************************************************/
/*******************************************************************************************/
/*******************************************************************************************/
