function show(div_id) {
	element	= document.getElementById(div_id);
	element.style.display =	"block";
}

function hide(div_id) 	{
	element	= document.getElementById(div_id);
	element.style.display =	"none";
}


function show_hide(div_id1, div_id2) {		
	element	= document.getElementById(div_id1); 
	if (element.style.display == "none") {
		show(div_id1);
		hide(div_id2);
	} else {
		hide(div_id1);
		show(div_id2);
	}
}

function show_hide(div_id) {		
	element	= document.getElementById(div_id); 
	if (element.style.display == "none") {
		element.style.display =	"block";
	} else {
		element.style.display =	"none";
	}
}

function switch_bg(aId1, aId2) {
	element1 = document.getElementById(aId1);
	element2 = document.getElementById(aId2);
	if (element2.style.display == "none")
	{
		element1.style.backgroundImage = "url('../images/show.png')";
	}
	else
	{
		element1.style.backgroundImage = "url('../images/hide.png')";
	}
}



function disable_departement(aSelect1, aSelect2) {		
	list1 = document.getElementById(aSelect1);
	list2 = document.getElementById(aSelect2);
	label = document.getElementById('label_'+aSelect2);
	
	if (list1.value != '1')
	{
		label.style.visibility = 'hidden';
		list2.style.visibility = 'hidden';
		list2.value = '0';
	}
	else
	{
		label.style.visibility = 'visible';
		list2.style.visibility = 'visible';
		list2.value = '0';
	}
}


function trim(aString) 
{
	var regExpBeginning = /^\s+/;
	var regExpEnd       = /\s+$/;
    return aString.replace(regExpBeginning, "").replace(regExpEnd, "");
}

function verif_date(date)
{
	var e = new RegExp("^[0-9]{1,2}\/[0-9]{1,2}\/([0-9]{2}|[0-9]{4})$");			
	if (!e.test(date)) // On teste l'expression régulière pour valider la forme de la date
	{
		return false;
	}	
	return true;
}

function affiche_div(nom_el)
{
	monElement = document.getElementById(nom_el);
	if (monElement.style.display == 'none')
		monElement.style.display = 'block';
	else
		monElement.style.display = 'none';
}

function affiche_div_membre(id, nb_membre)
{
	nom		=	navigator.appName;
	version	=	navigator.appVersion;
	ie4 = (nom == 'Microsoft Internet Explorer' && version.substr(0, 1) >= 4 ) ? 1:0
	if (!ie4)
	{
		document.getElementById("div_fiche").style.height	=	"0px";
		document.getElementById("div_lien_ville").style.top	=	"248px";
	}
	
	for(var i=0; i < nb_membre; i++)
	{
		j	=	i+1;
		/*myVerticalSlide.toggle();
		$('myVerticalSlide_'+i).toggle();*/
		monElement = document.getElementById('fiche_'+i);
		if(i == id && id != -1)
		{
			if (monElement.style.display == 'none')
			{
				monElement.style.display = 'block';
				MM_swapImage('img_'+i,'','images/membre_on_'+j+'.jpg',1);
			}
			else
			{
				monElement.style.display = 'none';
				MM_swapImage('img_'+i,'','images/membre_off_'+j+'.jpg',1);
			}
		}
		else
		{
			
			monElement.style.display = 'none';	
			MM_swapImage('img_'+i,'','images/membre_off_'+j+'.jpg',1);
		}
	}
}

function affiche_cache_div(nom_el, aEtat)
{
	monElement = document.getElementById(nom_el);
	if(aEtat == 1)
	{
		monElement.style.display = 'block';
	}
	else
	{
		monElement.style.display = 'none';
	}
}

function formcheck_date(el){
    if (!verif_date(el.value)) {
	//	alert("dqsdqsd");
        el.errors.push("La date n'est pas au format JJ/MM/AAAA");
        return false;
    } else {
        return true;
    }
}

function formcheck_password(el)
{
	if($('confirm_password').value != '' && $('confirm_password').value != $('password').value)
	{
		el.errors.push("La confirmation ne correspond pas au mot de passe.");
		return false;
	}
	else
	{
		return true;
	}
}

function telecharger(aChemin, aFichier, aDestFileName)
{
	if (aDestFileName == undefined)
		aDestFileName	=	aFichier;
	window.location.href	=	"includes/telecharger.php?chemin=" + aChemin + "&fichier=" + aFichier + "&nom=" + aDestFileName;
}

function telecharger_admin(aChemin, aFichier, aDestFileName)
{
	if (aDestFileName == undefined)
		aDestFileName	=	aFichier;
	window.location.href	=	"../includes/telecharger.php?chemin=" + aChemin + "&fichier=" + aFichier + "&nom=" + aDestFileName;
}


function telecharger_sauvegarde(aChemin, aFichier, aCandidat_id, aFichier_id, aDestFileName)
{
	if (aDestFileName == undefined)
		aDestFileName	=	aFichier;
	//alert(aCandidat_id+' '+aFichier_id)
	window.location.href	=	"includes/telecharger_sauvegarde.php?chemin=" + aChemin + "&fichier=" + aFichier + "&nom=" + aDestFileName+ "&candidat_id=" + aCandidat_id + "&fichier_id=" + aFichier_id;
}

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=document.getElementById(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function chargement(num)
{
	//Affiche un image de chargement
	MM_findObj('img_chargement'+num).style.display='inline';	
}

function stop_chargement(num)
{
	//Stoppe l\'image de chargement
	MM_findObj('img_chargement'+num).style.display='none';		
}

function init_loading()
{
	$('img_transparent').style.display		=	'block';
}

function stop_loading()
{
	$('img_transparent').style.display		=	'none';
}

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_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;
}

*/



