// Gestion des catégories (affichage ou non)
function showDiv(divID, setting)
{
	var objDiv = document.getElementById(divID);
	if(setting == 1) objDiv.style.display='block';
	else if(setting == 0) objDiv.style.display='none';
	else
	{
		if(objDiv.style.display == 'none') objDiv.style.display='block';
		else objDiv.style.display='none';
	}
}

// Fonction de gestion pour la suppression de plusieurs photos en même temps
function delThisImage(id)
{
	if(document.getElementById(id).checked)
	{
		document.getElementById('listSupprPhoto').value += id + '+';
	}
	else
	{
		listeId = document.getElementById('listSupprPhoto').value;
		document.getElementById('listSupprPhoto').value = '';
		listeIdArray = listeId.split('+');

		for(index = 0; index < listeIdArray.length; index ++)
	{
			if(id != listeIdArray[index] && listeIdArray[index] != '')
			{
				document.getElementById('listSupprPhoto').value += listeIdArray[index] + '+';
			}
		}
	}
}

// Remplace toutes les occurences d'une chaine
function replaceAll(str, search, repl)
{
	while (str.indexOf(search) != -1)
	str = str.replace(search, repl);
	return str;
}

// Remplace les caractères accentués (+ espace)
function htmlToAccent(str)
{
	var spec = new Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "e", "e", "e", "e", "e", "e", "e", "e", "a", "a", "a", "a", "u", "u", "u", "u", "c", "c", "-");
	var norm = new Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "é", "É", "è", "È", "ê", "Ê", "ë", "Ë", "à", "ä", "Ä", "À", "ù", "Ù", "ü", "Ü", "ç", "Ç", " ");
	for (var i = 0; i < spec.length; i++)
	str = replaceAll(str, norm[i], spec[i]);
	return str;
}

// Fonction de contrôle du formulaire de contact
function checkForm(nomForm)
{
	var champ = document.getElementById("robots").value;
	if(champ == "") document.getElementById(nomForm).submit();
}

// Fonction de calcule du prix pour commande de flyers
function calculerPrix()
{
	var form = document.getElementById('form_flyers');
	for(i = 0; i < 2; i++)
	{
		if(form.conception[i].checked) var conception = form.conception[i].value;
	}
	for(i = 0; i < 2; i++)
	{
		if(form.UCanimation[i].checked) var animation = form.UCanimation[i].value;
	}
	for(i = 0; i < 2; i++)
	{
		if(form.impression[i].checked) var impression = form.impression[i].value;
	}
	
	var prix = 0;
	if(impression == 'recto-verso') prix = prix + 200;
	else if(impression == 'recto-pub') prix = prix + 150;
	if(conception == 'Oui') prix = prix + 120;
	if(animation == 'Oui') prix = prix - 30;
	
	if(prix != 0) document.getElementById('prix').innerHTML = prix + '.-';
	else document.getElementById('prix').innerHTML = 'Veuillez indiqu&eacute; toutes les informations ci-dessus pour le calcule du prix.';
}
