
function commentJouer()
{
    if(!document.programmeForm || !document.programmeForm.hiddenJeu)
    {
        location.href = gContextRoot+"/cmd/commentjouer/cotes";        
    }
    else if(document.programmeForm.hiddenJeu.value == '1')
    {
        location.href = gContextRoot+"/cmd/commentjouer/cotes";
    }
    else if(document.programmeForm.hiddenJeu.value == '2')
    {
        location.href = gContextRoot+"/cmd/commentjouer/ecart";
    }
    else if(document.programmeForm.hiddenJeu.value == '3')
    {
        location.href = gContextRoot+"/cmd/commentjouer/total";
    }
    else
    {
        location.href = gContextRoot+"/cmd/commentjouer/cotes";
    }
}

function reglements()
{
    if(!document.programmeForm || !document.programmeForm.hiddenJeu)
    {
        location.href = gContextRoot+"/cmd/reglements/moj";        
    }
    else if(document.programmeForm.hiddenJeu.value == '1' || document.programmeForm.hiddenJeu.value == '2')
    {
        location.href = gContextRoot+"/cmd/reglements/moj";
    }
    else if(document.programmeForm.hiddenJeu.value == '3')
    {
        location.href = gContextRoot+"/cmd/reglements/total";
    }
    else
    {
        location.href = gContextRoot+"/cmd/reglements/moj";
    }
}

function redirectTotal()
{
    location.href = "/pesweb/cmd/getprogramme?paramsport=" + document.programmeForm.selSport.value + "&paramjeu=3";
}

function sportChanged(context)
{
    location.href = context+"/cmd/getprogramme?paramsport=" + document.programmeForm.selSport.value;
}

function sportChangedResultats(context,date)
{
    location.href = context+"/cmd/getresultats?paramdate="+date+"&paramsport=" + document.programmeForm.selSport.value;
}

function imprimeResultats(context, date, sport, jeu, programme)
{
    var lImprimeWindow = window.open(context+'/cmd/imprimeresultats?paramdate='+date+'&paramsport='+sport+'&paramjeu='+jeu+'&paramprogramme='+programme, 'impressionWindow', 'location=0,titlebar=0,hotkeys=0,toolbar=0,menubar=0,directories=0,scrollbars=1,width=745');
    lImprimeWindow.focus();
}


function imprimeProgramme(context, sport, jeu, programme)
{
    var lImprimeWindow = window.open(context+'/cmd/imprimeprogramme?paramsport='+sport+'&paramjeu='+jeu+'&paramprogramme='+programme, 'impressionWindow', 'location=0,titlebar=0,hotkeys=0,toolbar=0,menubar=0,directories=0,scrollbars=1,width=745');
    lImprimeWindow.focus();
}

function changeDate(context,y,m,d)
{
    if(m.length == 1)
    {
        m = '0' + m;
    }
    if(d.length == 1)
    {
        d = '0' + d;
    }
    
    var lLocation = context+'/cmd/getresultats?paramdate='+y+'-'+m+'-'+d+'&paramsport='+document.programmeForm.hiddenSport.value+'&paramjeu='+document.programmeForm.hiddenJeu.value+'&paramprogramme='+document.programmeForm.hiddenProgramme.value;
    location.href = lLocation;
}

function changeDatePronostik(context,y,m,d)
{
    if(m.length == 1)
    {
        m = '0' + m;
    }
    if(d.length == 1)
    {
        d = '0' + d;
    }
    
    var lLocation = context+'/cmd/getresultatspronostik?paramdate='+y+'-'+m+'-'+d+'&paramgrille='+document.grilleForm.NoGrille.value;
    location.href = lLocation;
}

function changeDateMOJPredictions(context,y,m,d)
{
    if(m.length == 1)
    {
        m = '0' + m;
    }
    if(d.length == 1)
    {
        d = '0' + d;
    }
    
    var lLocation = context+'/cmd/getresultatsmojpredictions?paramdate='+y+'-'+m+'-'+d+'&paramgrille='+document.grilleForm.NoGrille.value;
    location.href = lLocation;
}

function imprimeGrille(context, grille)
{
    var lImprimeWindow = window.open(context+'/cmd/imprimegrille?paramgrille='+grille, 'impressionWindow', 'location=0,titlebar=0,hotkeys=0,toolbar=0,menubar=0,directories=0,scrollbars=1,width=745');
    lImprimeWindow.focus();
}

function imprimeGrilleMOJPredictions(context, grille)
{
    var lImprimeWindow = window.open(context+'/cmd/imprimegrillemojpredictions?paramgrille='+grille, 'impressionWindow', 'location=0,titlebar=0,hotkeys=0,toolbar=0,menubar=0,directories=0,scrollbars=1,width=745');
    lImprimeWindow.focus();
}

function imprimeResultatsPronostik(context, grille, datefinacceptation, heurefinacceptation)
{
    var lImprimeWindow = window.open(context+'/cmd/imprimeresultatspronostik?paramgrille='+grille+'&paramdate='+datefinacceptation+'&paramheure='+heurefinacceptation, 'impressionWindow', 'location=0,titlebar=0,hotkeys=0,toolbar=0,menubar=0,directories=0,scrollbars=1,width=745');
    lImprimeWindow.focus();
}

function imprimeResultatsMOJPredictions(context, grille, datefinacceptation, heurefinacceptation)
{
    var lImprimeWindow = window.open(context+'/cmd/imprimeresultatsmojpredictions?paramgrille='+grille+'&paramdate='+datefinacceptation+'&paramheure='+heurefinacceptation, 'impressionWindow', 'location=0,titlebar=0,hotkeys=0,toolbar=0,menubar=0,directories=0,scrollbars=1,width=745');
    lImprimeWindow.focus();
}

function popAide(context)
{
    var lAideWindow = window.open(context+'/cmd/aide', 'aideWindow', 'location=0,titlebar=0,hotkeys=0,toolbar=0,menubar=0,directories=0,scrollbars=1,width=710,height=480');
    lAideWindow.focus();
}

function popAideResultats(context)
{
    var lAideResultatsWindow = window.open(context+'/cmd/aideresultats', 'aideResultatsWindow', 'location=0,titlebar=0,hotkeys=0,toolbar=0,menubar=0,directories=0,scrollbars=1,width=710,height=350');
    lAideResultatsWindow.focus();
}

function visualiserParis(context, sport, jeu, programme)
{
    if(gSelectedTotal.length < 3)
    {
        alert(document.programmeForm['messageVisualiser'].value);
        return;
    }
    
    var lStringEvenements = "&evenementsparies=";
    var lPremier = true;
    for(i = 0; i < gSelectedTotal.length; ++i)
    {
        if(lPremier)
        {
            lPremier = false;
        }
        else
        {
            lStringEvenements = lStringEvenements + '|';
        }
        lStringEvenements = lStringEvenements + gSelectedTotal[i] + '$' + document.programmeForm[gSelectedTotal[i]].value + '$' + document.programmeForm[gSelectedTotal[i]+'Sport'].value;
    }    
    
    var lStringMise = document.programmeForm.selMise.value;
    if(document.programmeForm[gSelectedTotal[0]].value.charAt(0)=='t')
    {
        lStringMise = lStringMise + '|' + document.programmeForm['structureGain'+gSelectedTotal.length].value;
    }
    
    var lVisualisationWindow = window.open(context+'/cmd/visualiserprogramme?paramsport='+sport+'&paramjeu='+jeu+'&paramprogramme='+programme+'&parammise='+lStringMise+lStringEvenements, 'visualisationWindow', 'location=0,titlebar=0,hotkeys=0,toolbar=0,menubar=0,directories=0,scrollbars=1,width=745');
    lVisualisationWindow.focus();
}

function visualiserGrille(context, grille)
{
    if(gSelectedTotal.length != parseInt(document.grilleForm['nombreQuestions'].value))
    {
        alert(document.grilleForm['messageVisualiserGrille'].value);
        return;
    }
    
    var lStringChoix = "";
    var lPremier = true;
    for(i = 0; i < gSelectedTotal.length; ++i)
    {
        if(lPremier)
        {
            lPremier = false;
        }
        else
        {
            lStringChoix = lStringChoix + '|';
        }
        lStringChoix = lStringChoix + gSelectedTotal[i] + '$' + document.grilleForm[gSelectedTotal[i]].value;
    }    
    
    var lVisualisationWindow = window.open(context+'/cmd/visualisergrille?paramgrille='+grille+'&paramchoix='+lStringChoix, 'visualisationWindow', 'location=0,titlebar=0,hotkeys=0,toolbar=0,menubar=0,directories=0,scrollbars=1,width=745');
    lVisualisationWindow.focus();
}

function visualiserGrilleMOJPredictions(context, grille)
{
    if(gSelectedTotal.length != parseInt(document.grilleForm['nombreQuestions'].value))
    {
        alert(document.grilleForm['messageVisualiserGrille'].value);
        return;
    }
    
    var lStringChoix = "";
    var lPremier = true;
    for(i = 0; i < gSelectedTotal.length; ++i)
    {
        if(lPremier)
        {
            lPremier = false;
        }
        else
        {
            lStringChoix = lStringChoix + '|';
        }
        lStringChoix = lStringChoix + gSelectedTotal[i] + '$' + document.grilleForm[gSelectedTotal[i]].value;
    }    
    
    var lVisualisationWindow = window.open(context+'/cmd/visualisergrillemojpredictions?paramgrille='+grille+'&paramchoix='+lStringChoix, 'visualisationWindow', 'location=0,titlebar=0,hotkeys=0,toolbar=0,menubar=0,directories=0,scrollbars=1,width=745');
    lVisualisationWindow.focus();
}


function getSeparatorString(pString, pSeparator)
{
    var lStringFormate = "";
    while(pString.length > 3)
    {
        lStringFormate = pSeparator + pString.substr(pString.length-3) + lStringFormate;
        pString = pString.substring(0, pString.length-3);
    }
    
    return pString + lStringFormate;
}

function getCurrencyString(pString)
{
    var lLocale = getLQLocale();
    if(lLocale == null || lLocale == FRANCAIS)
    {
        return getSeparatorString(pString.substring(0, pString.length-2), '&nbsp;') + ',' + pString.substring(pString.length-2) + '&nbsp;$';
    }
    else if(lLocale == ANGLAIS)
    {
        return '$' + getSeparatorString(pString.substring(0, pString.length-2), ',') + '.' + pString.substring(pString.length-2);
    }        
}

function getNumberString(pString)
{
    var lLocale = getLQLocale();
    var lIndex = pString.indexOf('.');    
    if(lLocale == null || lLocale == FRANCAIS)
    {

        return getSeparatorString(pString.substring(0, lIndex), '&nbsp;') + ',' + pString.substring(lIndex+1);
    }
    else if(lLocale == ANGLAIS)
    {
        return getSeparatorString(pString.substring(0, lIndex), ',') + '.' + pString.substring(lIndex+1);
    }        
}