﻿
var prono_ax;

function desactiv_prono(id_prono)
{
    prono_ax = id_prono;
    SoapMethod = "POST";
	ajax.Start(AxSupProno);
}

var AxSupProno = {
	delay: 200,
	prepare: function() 
	{ 
	    InputVar = new Array(prono_ax);
	    
	},
	call: proxies.AjaxFunc.SuppProno,
	finish: function (p) 
	{ 
	    document.getElementById("ligne_"+prono_ax).style.display = "none";
	},
	onException: ajax.alertException
}

var idUsagerProno;

function Enregistre_rep_prono()
{
    idUsagerProno = readCookie("USAGER");
    //alert(idUsagerProno);
    
    if(document.getElementById("uc_sondage2_rep_pronoAB").value == "" || document.getElementById("uc_sondage2_rep_pronoAdv").value == "")
    {
        alert("Vous devez saisir un pronostic pour les deux equipes");
    }
    else
    {
        if(isNaN(document.getElementById("uc_sondage2_rep_pronoAB").value) || isNaN(document.getElementById("uc_sondage2_rep_pronoAdv").value))
        {
            alert("Vous ne pouvez saisir uniquement que des chiffres");
        }
        else
        {
            SoapMethod = "POST";
            ajax.Start(AxEnregistre_rep_prono);            
        }
    }
}


var AxEnregistre_rep_prono = {
	delay: 200,
	prepare: function() { 
		
		var id_Prono = idProno;
	    var reponseAviron = document.getElementById("uc_sondage2_rep_pronoAB").value;
	    var reponseAdversaire = document.getElementById("uc_sondage2_rep_pronoAdv").value;
	    
	    /*
	    alert(idAdv);
	    alert(reponseAviron);
	    alert(reponseAdversaire);
		*/
	    InputVar = new Array(id_Prono, reponseAviron, reponseAdversaire, idUsagerProno);
			    
	},
	call: proxies.AjaxFunc.GetPronostics,
	finish: function (p) 
	{ 
        SetCookie("PRONO", "1", 2);
        document.location.href = "/";
	},
	onException: ajax.alertException
}

function WhoWin()
{
    if(document.getElementById("score_aviron").value == "" || document.getElementById("score_adversaire").value == "")
    {
        alert("Vous devez saisir les deux scores, de l'Aviron et de l'Adversaire");
    }
    else
    {
        SoapMethod = "POST";
        ajax.Start(AxWhoWin);
    }
}

var AxWhoWin = {
	delay: 200,
	prepare: function() { 
		
		var id_Prono = document.getElementById("MatchGamed").value;
	    var sAviron = document.getElementById("score_aviron").value;
	    var sAdversaire = document.getElementById("score_adversaire").value;
	    
	    InputVar = new Array(id_Prono, sAviron, sAdversaire);
			    
	},
	call: proxies.AjaxFunc.GetGagnant,
	finish: function (p) 
	{ 
	    document.getElementById("AffichGagnant").style.display = "";
        document.getElementById("GagnantSpan").innerHTML = p;
	},
	onException: ajax.alertException
}


function affichAdv()
{
    document.getElementById("ScoreAviron").style.display = "";
    document.getElementById("ScoreAdversaire").style.display = "";
    document.getElementById("ValidationGagnant").style.display = "";
    document.getElementById("score_aviron").value = "";
    document.getElementById("score_adversaire").value = ""; 
    document.getElementById("AffichGagnant").style.display = "none";
}
