function isNumber(arg){
	var digit, pos;
	var bool = true;
	var base = "0123456789";

	for(i=0;i < arg.length;i++){
		digit = arg.substr(i, 1);
		pos = base.indexOf(digit);
		if(pos == -1){bool = false;}
	}
	return bool;
}

function ucfirst( str ) {
	str += '';
    var f = str.charAt(0).toUpperCase();
    return f + str.substr(1);
}

// Variable recuperant le nom du champs de recherche pour la dynamissite
var inputName;

function getAutoId(text, li) {
	if (li.id.substr(0,1) == 'v') {
		$('ville_id').value			= li.id.substr(2);
	} else if (li.id.substr(0,1) == 'd') {
		$('departement_id').value	= li.id.substr(2);
	} else if (li.id.substr(0,1) == 'r') {
		$('region_id').value		= li.id.substr(2);
	} else if (li.id.substr(0,1) == 'e') {
		$('email_id').value			= li.id.substr(2);
	} else {
		return false;
	}

	$(inputName+'_form').submit();
}

function autosuggest_recherche (champs, input)
{
	inputName = input;
	$('auto'+ucfirst(champs)).setStyle({display: 'block'});

	new Ajax.Autocompleter(input, 'auto'+ucfirst(champs), '/index.php?op=autosuggest', {
		paramName: 	'value',
		frequency: 	0.3,
		minChars: 	2,
		parameters: 	'field='+champs,
		afterUpdateElement: getAutoId
	});
}

// Vide le value du champs de recherche au clic
function emptySearchPAP(inputName, value){
	if(document.getElementById(inputName).value == value){
		document.getElementById(inputName).value = '';
	}
}

// Remplit le champs de recherche s'il est vide
function completeSearchPAP(inputName, value){
	if(document.getElementById(inputName).value == ''){
		document.getElementById(inputName).value = value;
	}
}

function civilit(civ){
	switch (civ) {
		case '0':
		case 0:
		default:
			$('photopermis').src 	= "./templates/frontoffice/telepoints/images/hommepermis.jpg";
			$('nomjf').hide();
		break;
		
		case '1':
		case 1:
			$('photopermis').src 	= "./templates/frontoffice/telepoints/images/madamepermis.jpg";
			$('nomjf').show();
		break;
		
		case '2':
		case 2:
			$('photopermis').src 	= "./templates/frontoffice/telepoints/images/madamepermis.jpg";
			$('nomjf').hide();
		break;
	}
}
