/***************************************************************************************
» Projet :				Portail du Village 3D
» Dernière modif. :			24/07/2007 - 13h45 (fr) par Nicoteo31
» Développeur(s) :			Nicoteo31
» Langages utilisés :		XHTML 1.0 Strict, CSS 2, JavaScript, PHP 5, MySQL, technologie AJAX
» Dossier :				/EspaceCitoyen/
» Fichier :				javascript.js
» Description :			Fichier de scripts JavaScript
***************************************************************************************/

function supprimerContact(numero_contact) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer ce contact de votre liste de contacts ?")==true) {
		document.location.href='?d=citoyens&p=mes-contacts&act=supprimer&numero_contact='+numero_contact;
	}
}

function supprimerTelegramme(id) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer ce télégramme ?")==true) {
		document.location.href='?d=citoyens&p=telegrammes&act=supprimer&id='+id;
	}
}

function supprimerAttaqueAdjoints(id) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer cette attaque ?")==true) {
		document.location.href='?d=adjoints&p=log-des-hackers&act=supprimer&id='+id;
	}
}
function supprimerAttaqueMaire(id) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer cette attaque ?")==true) {
		document.location.href='?d=maire&p=log-des-hackers&act=supprimer&id='+id;
	}
}

function supprimerPrivileges(id) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer les privilèges de ce citoyen de votre liste ?")==true) {
		document.location.href='?d=citoyens&p=mes-privileges&act=supprimer&id='+id;
	}
}

function supprimerEjectionAdjoints(ip) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer cette éjection ?")==true) {
		document.location.href='?d=adjoints&p=ejections&act=supprimer&ip='+ip;
	}
}
function supprimerEjectionMaire(ip) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer cette éjection ?")==true) {
		document.location.href='?d=maire&p=ejections&act=supprimer&ip='+ip;
	}
}

function supprimerProjetAdjoints(id) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer ce projet ?")==true) {
		document.location.href='?d=adjoints&p=projets&act=supprimer&id='+id;
	}
}
function supprimerProjetMaire(id) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer ce projet ?")==true) {
		document.location.href='?d=maire&p=projets&act=supprimer&id='+id;
	}
}

function supprimerEvenementAdjoints(id) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer cet évènement ?")==true) {
		document.location.href='?d=adjoints&p=agenda&act=supprimer&id='+id;
	}
}
function supprimerEvenementMaire(id) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer cet évènement ?")==true) {
		document.location.href='?d=maire&p=agenda&act=supprimer&id='+id;
	}
}

function menuAdjoints() {
	var menu = document.getElementById("menuAdjoints");
	
	if(menu.style.display == "none") {
		menu.style.display = "block";
	}
	else {
		menu.style.display = "none"
	}
}
function menuMaire() {
	var menu = document.getElementById("menuMaire");
	
	if(menu.style.display == "none") {
		menu.style.display = "block";
	}
	else {
		menu.style.display = "none"
	}
}

// AJAX

function compteur(numero_citoyen) {
	var connectesPortail2; 
    try { connectesPortail2 = new XMLHttpRequest(); }                 
    catch(e) 
    {    
      connectesPortail2 = new ActiveXObject("Microsoft.XMLHTTP");
    } 
	
	connectesPortail2.onreadystatechange = function() 
	{
		// Si c'est à l'état "prêt"
		if(connectesPortail2.readyState == 4) 
		{
			// Si aucune erreur n'est retournée de la part du serveur
			if(connectesPortail2.status == 200) 
			{
				document.getElementById("connectesPortail").innerHTML = connectesPortail2.responseText;
			}
			else {
				document.getElementById("connectesPortail").innerHTML = "Erreur " + connectesPortail2.status;
			}
		}
	};
	
	// 1er arg.: méthode GET|POST
	// 2e arg.: fichier de traitement
	// 3e arg.: true pour Asynchrone | false pour Synchrone
	connectesPortail2.open("POST", "config/connectesPortail.php", true);
	connectesPortail2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	connectesPortail2.send("numero="+ numero_citoyen);
}

function afficherCalendrier(champ) {
	window.open("pages/navigation/mini-calendrier.php?champ="+champ,"calendrier","width=400,height=350");
}

function ajouterDate(champ, date) {	
	if(window.opener.document.forms[0].elements[champ]) {
		window.opener.document.forms[0].elements[champ].value=date;
	}
	else {
		window.opener.document.forms[1].elements[champ].value=date;
	}
}

function afficher_masquer(id) {
	if(document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "block";
	}
	else {
		document.getElementById(id).style.display = "none";
	}	
}

function MdPperdu() {
	window.open("motdepasseperdu.php","MdPperdu","width=400,height=250");
}

function detailsTerrain() {
	var type_terrain = document.forms[1].elements["type_terrain"].value;
	var prix = document.getElementById("prix");
	var taille_m = document.getElementById("taille_m");
	var taille_m2 = document.getElementById("taille_m2");
	var monde = document.getElementById("monde");
	
	switch(type_terrain) {
		case "T0":
			prix.innerHTML = "0 € TTC";
			taille_m.innerHTML = "20x20 m";
			taille_m2.innerHTML = "400 m²";
			monde.innerHTML = "Village";
			break;
		case "T1":
			prix.innerHTML = "5 € TTC";
			taille_m.innerHTML = "50x50 m";
			taille_m2.innerHTML = "2500 m²";
			monde.innerHTML = "Azura";
			break;
		case "T2":
			prix.innerHTML = "15 € TTC";
			taille_m.innerHTML = "100x100 m";
			taille_m2.innerHTML = "10000 m²";
			monde.innerHTML = "Azura";
			break;
		case "T3":
			prix.innerHTML = "25 € TTC";
			taille_m.innerHTML = "200x200 m";
			taille_m2.innerHTML = "40000 m²";
			monde.innerHTML = "Azura";
			break;
		case "T01":
			prix.innerHTML = "0 € TTC";
			taille_m.innerHTML = "20x20 m";
			taille_m2.innerHTML = "400 m²";
			monde.innerHTML = "Village (renouvellement => terrain offert)";
			break;
	}
}

function afficherTerrains(numero_citoyen) {
	if(document.getElementById(numero_citoyen).style.display == "none") {
		document.getElementById(numero_citoyen).style.display = "block";
	}
	else {
		document.getElementById(numero_citoyen).style.display = "none";
	}
}

function modifierTerrainMaire(id) {
	document.location.href="?d=maire&p=terrains&act=modifier-terrain&id="+id;
}
function modifierTerrainAdjoints(id) {
	document.location.href="?d=adjoints&p=terrains&act=modifier-terrain&id="+id;
}

function supprimerTerrain(id) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer ce terrain ?")==true) {
		document.location.href="?d=maire&p=terrains&act=supprimer-terrain&id="+id;
	}
}

function terrainMouseOver(id) {
	document.getElementById(id).style.border = "1px #0000FF solid";
	document.getElementById(id).style.cursor = "pointer";
}
function terrainMouseOut(id) {
	document.getElementById(id).style.border = "1px #CCCCCC solid";
	document.getElementById(id).style.cursor = "auto";
}



function forumGras(champ) {
	document.forms[0].elements[champ].value += "[g]#Tapez le texte à mettre en gras ici#[/g]";
}
function forumItalique(champ) {
	document.forms[0].elements[champ].value += "[i]#Tapez le texte à mettre en italique ici#[/i]";
}
function forumSouligne(champ) {
	document.forms[0].elements[champ].value += "[s]#Tapez le texte à souligner ici#[/s]";
}
function forumLien(champ) {
	document.forms[0].elements[champ].value += "[l=#Tapez l'url du lien ici#]#Tapez l'intitulé du lien ici#[/l]";
}


function afficherInformation() {
	var information = document.getElementById("information");
	if(information.style.display == "none") {
		information.style.display = "block";
	}
	else {
		information.style.display = "none";
	}
}



function citoyens() {
	window.open("pages/adjoints/citoyens2.php","citoyens","height=480,width=640,scrollbars=yes");
}
function ajouterNumCito(numcito) {
	window.opener.document.forms[1].elements["numero_citoyen"].value = numcito;
}

function clignoter(id) {
	var cible = document.getElementById(id);
	if(cible) {
		/*if(cible.style.backgroundColor == "lightgoldenrodyellow" || !cible.style.backgroundColor) {
			cible.style.backgroundColor = "gold";
		}
		else {
			cible.style.backgroundColor = "lightgoldenrodyellow";
		}*/
		if(cible.style.backgroundImage == 'url(images/fiche.jpg)' || !cible.style.backgroundImage) {
			cible.style.backgroundImage = 'url(images/fiche3.jpg)';
		}
		else {
			cible.style.backgroundImage = 'url(images/fiche.jpg)';
		}
	}
	//cible.style.backgroundImage = 'url(images/fiche3.jpg)';	
}


function supprimerTerrainMaire(id) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer ce terrain ?\nAttention, cette opération est irréversible!") == true) {
		document.location.href = "?d=maire&p=terrains&act=supprimer-terrain&id="+id;
	}
}
function supprimerTerrainAdjoints(id) {
	if(confirm("Êtes-vous sûr(e) de vouloir supprimer ce terrain ?\nAttention, cette opération est irréversible!") == true) {
		document.location.href = "?d=adjoints&p=terrains&act=supprimer-terrain&id="+id;
	}
}

function emoticone(emo) {
	if(document.forms[0].elements["message"]) 
	{
		document.forms[0].elements["message"].value += " " + emo;
	}
	else 
	{
		document.forms[0].elements["reponse"].value += " " + emo;
	}
}

function descriptif(id)
{
	var obj = document.getElementById(id);
	if(obj.style.display == "none")
	{
		obj.style.display = "block";
	}
	else
	{
		obj.style.display = "none";
	}

}

function terrainsNonAttribues()
{
	var terrainsNonAttribuesON = document.getElementById("terrains-non-attribues-on");
	var terrainsNonAttribuesOFF = document.getElementById("terrains-non-attribues-off");
	if(terrainsNonAttribuesOFF.style.display == "block" || !terrainsNonAttribuesOFF.style.display)
	{
		terrainsNonAttribuesON.style.display = "block";
		terrainsNonAttribuesOFF.style.display = "none";
	}
	else
	{
		terrainsNonAttribuesON.style.display = "none";
		terrainsNonAttribuesOFF.style.display = "block";
	}
}

function noteTerrains()
{
	var noteTerrainsON = document.getElementById("note-terrains-on");
	var noteTerrainsOFF = document.getElementById("note-terrains-off");
	if(noteTerrainsOFF.style.display == "block" || !noteTerrainsOFF.style.display)
	{
		noteTerrainsON.style.display = "block";
		noteTerrainsOFF.style.display = "none";
	}
	else
	{
		noteTerrainsON.style.display = "none";
		noteTerrainsOFF.style.display = "block";
	}
}

function etatTerrainExp(id)
{
	var terrainExp = document.getElementById(id);
	if(terrainExp.style.display == "block")
	{
		terrainExp.style.display = "none";
	}
	else
	{
		terrainExp.style.display = "block";
	}
}

function detailsEjection(id)
{
	var ejection = document.getElementById(id);
	if(ejection.style.display == "block")
	{
		ejection.style.display = "none";
	}
	else
	{
		ejection.style.display = "block";
	}
}