/*-----------------------------------------------------------------------------------------------*/
//
// Copyright (c) 2008 Agence Clark (http://www.agence-clark.com)
//
/*-----------------------------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------------------------*/
// Init Page
/*-----------------------------------------------------------------------------------------------*/
Event.observe(window, 'load', InitPage, false);
function InitPage(){
	//-- Rollover Input Image --//
	RollOverImage();
	if ($('actualite_droite')) var defilActuDroite = new SwitchBloc('conteneur_actu_droite','liste_actu_droite','actu_droite','bt_prec','bt_suiv',{SwiDirection:'vertical'});
	
	
	if($('acces_region') && !$('niveau_etude')) 
	{ // S'il existe
	//alert('toto');
		Event.observe('acces_region', 'change', function()
		{
			//$('frm_filtrer').submit();
			
			
			tmp = document.location.href.split("?");
			
			if(document.location.href.indexOf("RID=") != -1){
				
				var url = tmp[0] + "?RID=" + ParamUrl("RID") + "&"; // index.php?RDI=97&
			
			} else {
				var url = tmp[0]+"?"; // recrutement_97.php?
			}
			
			
			if ($F('type') == 1)
			document.location.href = url + 'type=' + $F('type') + '&acces_region=' + $F('acces_region');	
			else
			document.location.href =  url + 'type=' + $F('type') + '&acces_region=' + $F('acces_region');	
			
			
			
		});
	}
	
	if($('acces_region') && $('niveau_etude')) 
	{ // S'il existe
	//alert('toto');
		Event.observe('niveau_etude', 'change', function()
		{
			//$('frm_filtrer').submit();
			
			
			tmp = document.location.href.split("?");
			
			if(document.location.href.indexOf("RID=") != -1){
				
				var url = tmp[0] + "?RID=" + ParamUrl("RID") + "&"; // index.php?RDI=97&
			
			} else {
				var url = tmp[0]+"?"; // recrutement_97.php?
			}
			
			
			if ($F('type') == 1)
			document.location.href = url + 'type=' + $F('type') + '&niveau_poste=' + $F('niveau_poste') + '&acces_region=' + $F('acces_region');	
			else
			document.location.href =  url + 'type=' + $F('type') + '&niveau_etude=' + $F('niveau_etude') + '&acces_region=' + $F('acces_region');	
			
			
			
		});
		
		
		//ert('toto');
		Event.observe('acces_region', 'change', function()
		{
			//$('frm_filtrer').submit();
			
			
			tmp = document.location.href.split("?");
			
			if(document.location.href.indexOf("RID=") != -1){
				
				var url = tmp[0] + "?RID=" + ParamUrl("RID") + "&"; // index.php?RDI=97&
			
			} else {
				var url = tmp[0]+"?"; // recrutement_97.php?
			}
			
			
			if ($F('type') == 1)
			document.location.href = url + 'type=' + $F('type') + '&acces_region=' + $F('acces_region');	
			else
			document.location.href =  url + 'type=' + $F('type') + '&acces_region=' + $F('acces_region');	
			
			
			
		});
	}
	
	
	
	function ParamUrl(param)
	{
		var contenu = '';
	
		var chaine=window.location.search;
		chaine=chaine.substring(1);
		var dz=chaine.indexOf("#",0);
		
		if(dz!=-1) chaine=chaine.substring(0,dz);
		chaine=chaine+"&";
		if(chaine.indexOf(param,0)!=-1)
		{
			var pos=chaine.indexOf(param,0);
			var pos2=chaine.indexOf("=",pos);
			var pos3=chaine.indexOf("&",pos);
			contenu=chaine.substring(pos2+1,pos3);
		}
		return contenu;
	}
}




/*-----------------------------------------------------------------------------------------------*/
// Fonctions
/*-----------------------------------------------------------------------------------------------*/

