var allume = 'idf'; // peut importe mais que la variable ait une valeur pour le premier appel de S
var carte='reg';

function GetItem(id)
{
	var itm = null;
	if(document.getElementById)
		itm = document.getElementById(id);
	else if(document.all)
		itm = document.all[id];
	else if(document.layers)
		itm = document.layers[id];
	
	return itm;
}

var switch_carte= function(){
	if(carte=='reg'){
		GetItem('france_dep').style.display='inline';
		GetItem('france_reg').style.display='none';
		GetItem('bouton').innerHTML='<a href="javascript:switch_carte()">Affichage par Région</a>';
		carte='dep';
	}
	else{
		GetItem('france_reg').style.display='inline';
		GetItem('france_dep').style.display='none';
		GetItem('bouton').innerHTML='<a href="javascript:switch_carte()">Affichage par Département</a>';
		carte='reg';
	}
};

function S(id)
{
	GetItem(allume).style.display='none';
	GetItem(id).style.display='block';
	allume=id;
}
function S2(id)
{
	GetItem(id).style.display='none';
}

function goselect(select)
{
	select.form.action = select.value;
	select.value = '-1';
	select.form.submit();
}

function verif_cp(input)
{
	YAHOO.util.Dom.removeClass(input, 'wronginput');
	var cp = input.value;
	if(cp=='' || (cp != '' && cp.length != 5 && cp.length!=2) || (cp != '' && isNaN(cp)))
	{
		alert('Le code postal est invalide');
		YAHOO.util.Dom.addClass(input, 'wronginput');
		input.focus();
		return false;
	}
	return true;
}

function v_rechercheav(f)
{
	if(verif_cp(f.cp))
	{
		var destination = 'permis-points-jour-' + f.jour.value + '-' + f.cp.value + '.html'; // stages Jour+CP -> Tri dates asc
		f.jour.value = destination;
		goselect(f.jour);
		return true;
	}
	return false;
}

function init_m()
{
	document.rechercheav.cp.focus();
}

var afficher_departement = function(el){
	document.location.replace(el.value);
};
