/**
 * Compteur pour zone TEXTAREA
 */
// Intervalle du compteur
var interval_compteur ;

// Début du compteur
function initCompteur(id_textarea, id_compteur, maxlength)
{
	updateCompteur(id_textarea, id_compteur, maxlength) ;
	document.getElementById(id_textarea).onfocus = function() {
		interval_compteur = setInterval("updateCompteur('"+id_textarea+"', '"+id_compteur+"', "+maxlength+");", 100) ;
	}
	document.getElementById(id_textarea).onblur = function() {
		clearInterval(interval_compteur) ;
	}
}

// Exécution du compteur
function updateCompteur(id_textarea, id_compteur, maxlength)
{
	var actuallength = document.getElementById(id_textarea).value.length ;
	document.getElementById(id_compteur).innerHTML = 'Reste : ' + (maxlength - actuallength) + ' caractères (' + actuallength + ' / ' + maxlength + ')' ;
	document.getElementById(id_compteur).style.color = (actuallength > maxlength) ? '#c00' : '#0a0' ;
}

/**
 * Photos
 */

function change_photo(photo, id, largeur, hauteur) {
	document.getElementById(id).src = photo ;
	document.getElementById(id).width = largeur ;
	document.getElementById(id).height = hauteur ;
}

/**
 * Espace annonceur
 */

function internet_localisation_afficher(afficher)
{
	if(el = document.getElementById('internet_localisation_table'))
		el.style.display = afficher ? 'block' : 'none' ;
}

function carte_afficher()
{
	if(localisation.checked)
	{
		if(c_ville.value == '') c_ville.value = ville.value  ;
		if(c_cp.value    == '') c_cp.value    = cp.value  ;
		carte_chercher() ;
		carte.style.display = 'block' ;
	}
	else
	{
		carte.style.display = 'none' ;
	}
}
