/*$(document).ready(function(){
    $("#menu_haut .dpl").each(function(){
       $(this).mouseover(function(){
             $(this).children("ul").slideDown("fast");
                 if($.browser.msie) { var hauteur = $(this).width(); $(this).children("ul").css({marginLeft:"-"+hauteur+"px"});   }
                 $(this).prev().children("ul").fadeOut("fast");
             $(this).siblings().children("ul").fadeOut("fast");
       });
    });
    $("body").click(function(){
            $("#menu_haut div ul").fadeOut("fast");
    });
});*/

function uncheckChoice(div)
{
	var radioType = document.getElementsByName(div);
	if(div == "abo_3")
	{
		$('abo_3_5').checked= false;
	}
	else
	{
		for (var cpt = 0 ; (cpt < radioType.length) ; cpt++) {
			radioType[cpt].checked= false;
		}
	}
}

function display_box()
{

    
    if($('type_1').checked== true)
    {
        $('CB').style.display = "block";
        $('ALLOPASS').style.display = "none";
    }

    if($('type_2').checked== true)
    {
        $('CB').style.display = "none";
        $('ALLOPASS').style.display = "block";
    }
    
}


function go_paiement()
{
    // On vérifie que les cgv sont acceptées
    if($('require_1').checked)
    {
        if($('type_2') && $('type_2').checked== true) $('paiement').action="http://payment.allopass.com/acte/access.apu";
        $('paiement').submit();
    }
    else
    {
        alert("Vous devez accepter les CGV");
    }
}


function showPopup(cmd)
{
	box.show();

	new Request({
		url: '/ajax.php',
		method: 'get',
		data: {
			cmd: cmd
		},
		onSuccess: function(msg) {
			box.update(msg);
		}
	}).send();
}

function showPopupDefi(cmd,idGame)
{
	new Request({
		url: '/ajax.php',
		method: 'get',
		data: {
			cmd: cmd,
			idGame: idGame
		},
		onSuccess: function(msg) {
			$('alertBox').style.display = 'block';
			$('alertBox').innerHTML = msg;
		}
	}).send();
}

function showGraph(cmd)
{
	box.show();

	new Request({
		url: '/graph.php',
		method: 'get',
		data: {
			cmd: cmd
		},
		onSuccess: function(msg) {
			box.update(msg);
		}
	}).send();
}

var timeout;
function setOnline(stop)
{
    if(stop == true) stop = 0;
    else if(!stop)  stop = 1;

    clearTimeout(timeout);
	new Request({
		url: '/includes/online.inc.php',
		method: 'get',
		data: { stop: stop },
		onSuccess: function(response) {			
			$('log').innerHTML = response;

                        // Si on a une invit
                        if(response != '' &&  stop != 2 ){
                            showPopupDefi('defi',response);
                        }else
                        {
                            if(stop == 0 || stop == 2)
                                timeout = setTimeout("setOnline('"+stop+"')", 3000);
                        }

		}
	}).send();
}


function disallow()
{
    clearTimeout(timeout);
    new Request({
            url: '/includes/online.inc.php',
            method: 'get',
            data: { disallow: 1 },
            onSuccess: function() {
                $('alertBox').style.display='none';
                timeout = setTimeout("setOnline('0')", 3000);
            }
    }).send();
}