/* Concu par Yanonix pour War-Evolution */

// Reboot de la page
function Reboot(Demande){
	if(Demande==1)
	{
		if(confirm('L\'administrateur demande le rafrachissement de la page (F5) pour mettre à jour le jeu, voulez-vous le faire maintenant ?'))				
			window.location.reload()
	}
	else
		window.location.reload()
}

// Inscription
function Inscription(){
	Page('Inscription',Form(document.Inscription_Form))
}

// Validation
function Validation_Redemander(){
	Page('Validation_Redemander',Form(document.Validation_Redemander_Form))
}

// MDP_Perdu
function MDP_Perdu(Etape){
	Page('MDP_Perdu',Form(document['MDP_Perdu_'+Etape+'_Form']))
}

// Déconnexion
function Deconnexion(){	
	if(confirm('Êtes-vous sûr de vouloir vous déconnecter ?'))
		Page('Deconnexion');
}

// Lieux
function Lieu_Ile_Ami(){
	Ajax("Recherche de l'ile","Actions.php?Act=Lieu_Ile_Ami_Afficher","POST",Form(document.Lieu_Ile_Ami_Form),document.getElementById('Lieu_Ile_Ami_RepAjax'))
}
function Lieu_Modifier(){
	Ajax("Emenagement sur le lieu","Actions.php?Act=Lieu_Modifier","POST",Form(document.Lieu_Modifier_Form),document.getElementById('RepAjax'))
}


// Ressources
function Ressources_Actualiser(){
	if(Ressources_Calcul_Auto>0)	Ajax('Ressources',"Actions.php?Act=Ressources_Actualiser","GET","","","Ressources_Reset(); Boucle('Ressources_Calcul()',Ressources_Calcul_Auto,1);")
	else							Ajax('Ressources',"Actions.php?Act=Ressources_Actualiser","GET","","","Ressources_Reset(); Ressources_Calcul();")
}

// Production_Taux
function Production_Taux_Modifier(){
	Ajax("Taux des ressources","Actions.php?Act=Production_Taux_Modifier","POST",Form(document.Production_Taux_Modifier_Form),document.getElementById("RepAjax"),"Ressources_Actualiser();")
}
function Production_Taux_Actualiser(){
	for(i=0;i<Production_Taux_Ressources_Nombre;i++)
	{
		Nombre=document.getElementById('Production_Taux_Input_'+Production_Taux_Ressources[i]).value*Production_Taux_Unites_Nombre*60/100*Production_Taux_Ressources_Taux[i]
		document.getElementById('Production_Taux_'+Production_Taux_Ressources[i]).innerHTML="<strong>"+FormatNumber(Nombre)+"</strong>/min<br /><strong>"+FormatNumber(Nombre*60)+"</strong>/heures<br /><strong>"+FormatNumber(Nombre*1440)+"</strong>/jours"
	}
}

// Menu
function Menu_Alertes_Afficher(){
	Ajax('Menu',"Actions.php?Act=Menu_Alertes_Afficher","GET","","")
}

// ListeJoueurs
function Liste_Joueurs(Formulaire,Limite,Alliance){
	Ouvrir('Liste_Joueurs&Liste='+Formulaire+'&Limite='+Limite+'&Alliance='+Alliance,300,200)
}

// Infos Joueur Rechercher
function Infos_Joueur_Rechercher(){
	Page('Infos_Joueur'+Form(document.Infos_Joueur_Rechercher_Form))
}

// Bâtiments
function Batiments_Acheter(ID){
	if(document.getElementById('Batiments_'+ID+'_Construire').value>0)
	{
		if(window.confirm('Voulez-vous acheter '+document.getElementById('Batiments_'+ID+'_Construire').value+' bâtiments ?'))
			Ajax("Acheter bâtiments","Actions.php?Act=Acheter","POST","Quantite="+document.getElementById('Batiments_'+ID+'_Construire').value+"&Produit="+ID+"&Type=1",document.getElementById("RepAjax"))
	}
}
function Batiments_Reparer(ID,Ressource){
	if(window.confirm(Ressource+'\n\Voulez-vous réparer ce bâtiment ?'))
		Ajax("Réparer","Actions.php?Act=Acheter","POST","Quantite=-1&Type=1&Produit="+ID,document.getElementById("RepAjax"))
}


// Unités
function Unites_Acheter(ID){
	if(document.getElementById('Unites_'+ID+'_Construire').value>0)
	{
		if(window.confirm('Voulez-vous former '+document.getElementById('Unites_'+ID+'_Construire').value+' unités ?'))
			Ajax("Acheter unités","Actions.php?Act=Acheter","POST","Quantite="+document.getElementById('Unites_'+ID+'_Construire').value+"&Produit="+ID+"&Type=0",document.getElementById("RepAjax"))
	}
}
function Unites_Soigner(ID,Ressource){
	if(window.confirm(Ressource+'\n\Voulez-vous soigner cette unité ?'))
		Ajax("Soigner","Actions.php?Act=Acheter","POST","Type=0&Quantite=-1&Produit="+ID,document.getElementById("RepAjax"))
}
function Unites_Organiser_Generales(Act){
	Ajax("Organisation","Actions.php?Act=Unites_Organiser_Generales","POST","Position="+Act,document.getElementById('RepAjax'),"Ressources_Actualiser();")
}
function Unites_Organiser_Perso(Type){
	Ajax("Organisation","Actions.php?Act=Unites_Organiser","POST","Type="+Type+Form(document['Unites_'+Type+'_Organiser_Perso_Form']),document.getElementById("RepAjax"),"Ressources_Actualiser();")
}
function Unites_Organiser_Type(Type,Act){
	Ajax("Organisation","Actions.php?Act=Unites_Organiser_Type","POST","Type="+Type+"&Position="+Act,document.getElementById("RepAjax"),"Ressources_Actualiser();")
}

// Améliorations
function Ameliorations_Invention_Acheter(Produit,Info){
	if(window.confirm(Info+'\n\nVoulez-vous développer cette invention ?'))
		Ajax('Invention',"Actions.php?Act=Acheter","POST","Produit="+Produit+"&Quantite=1&Type=2",document.getElementById('RepAjax'))
}


// Messages
function Messages_Actions(Type){	
	if(!((Type==1 && confirm('Êtes-vous sûr de vouloir marquer ces messages comme "lu" ?')) ||
	(Type==2 && confirm('Êtes-vous sûr de vouloir marquer ces messages comme "non lu" ?')) ||
	(Type==3 && confirm('Êtes-vous sûr de vouloir supprimer ces messages ?'))))
		return
	
	Ajax("Message","Actions.php?Act=Messages_Actions","POST",Form(document.Messages_Form)+"&Type="+Type,document.getElementById("RepAjax"))
}
function Messages_Lire_Supprimer(ID){	
	if(confirm('Êtes-vous sûr de vouloir supprimer ce message ?'))
		Ajax("Message","Actions.php?Act=Messages_Actions","POST","Message_Select[]="+ID+"&Type=3",document.getElementById("RepAjax"))
}
function Messages_Ecrire_Envoyer(){
	document.getElementById("Messages_Ecrire_Submit").disabled="disabled";
	Ajax("Message","Actions.php?Act=Messages_Envoyer","POST",Form(document.Messages_Ecrire_Form),document.getElementById("RepAjax"))
}

function Messages_Rapport_Envoyer(){
	document.getElementById("SubmitMP").disabled="disabled";
	Ajax("Message","Actions.php?Act=MPRapporter","POST",Form(document.Messages_Rapport_Envoyer_Form),document.getElementById("RepAjax"))
}
function Liste_Noire_Ajouter(Joueur){
	if(confirm('Êtes-vous sûr de vouloir rajouter '+Joueur+' dans votre liste noire ?'))
		Ajax('Liste Noire',"Actions.php?Act=Liste_Noire_Ajouter","POST","Joueur="+Joueur,document.getElementById('RepAjax'))
}
function Liste_Noire_Supprimer(Id){
	if(confirm('Êtes-vous sûr de vouloir le supprimer de votre liste noire ?'))
		Ajax('Liste Noire',"Actions.php?Act=Liste_Noire_Supprimer","POST","Id="+Id,document.getElementById('RepAjax'))
}

//WECode_Apercu
function WECode_Apercu(ID){	
	Ajax("Apercu","Actions.php?Act=WECode_Apercu","POST","Texte="+Esc(document.getElementById(ID).value),document.getElementById("Apercu_WECode_Div"))
}

// Compte
function Compte_Modifier(){
	Ajax('Adherer',"Actions.php?Act=Compte_Modifier","POST",Form(document.Compte_Modifier_Form),document.getElementById('RepAjax'))
}
function Vacance_Activer(){
	if(confirm('Êtes-vous sûr de vouloir suspendre votre compte (pendant un minimum de 3 jours) ?'))
		Ajax('Vacances',"Actions.php?Act=Vacance_Activer","GET",'',document.getElementById('RepAjaxVacance'))
}

