function popitup(url) {
	newwindow=window.open(url,'name','height=150,width=200');
	if (window.focus) {newwindow.focus()}
	return false;
}


	function fadeIn(objId,opacity) {  if (document.getElementById) {    obj = document.getElementById(objId);    if (opacity <= 100) {      setOpacity(obj, opacity);      opacity += 10;      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);    }  }}
	//HDATE
	function aff_heure()
	{
		
		var url = './ajax.php?act=aff_heure';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				onComplete: gestionReponse162
			});
		function gestionReponse162(xhr)
		{
			if (xhr.status == 200)
			{
				$('heure_site').innerHTML = xhr.responseText;
			}
			else
			{
				$('heure_site').innerHTML = xhr.status;
			}
		}
	}

     function refresh_tps()//script javascript qui va appeler le fonction afficher toutes les 5 secondes
     {
                        aff_tpsreel();
                        setTimeout(refresh_tps, 10000);
      }
      
     function refresh_s()//script javascript qui va appeler le fonction afficher toutes les 5 secondes
     {
				  		shout_affich();
                        setTimeout(refresh_s, 2000);
      }      
	function SendForm()	{
		var url = './ajax.php?act=ad_shoutbox';
  		var myAjax = new Ajax.Request( 		url,            {    		 	method:       'post',     			asynchronous: true,      			contentType:  'application/x-www-form-urlencoded', 				encoding: 'ISO-8859-1', 				
 				parameters: { message_shoutbox : $F('message')},
                onComplete: gestionReponse            });
	
	function gestionReponse(xhr)	{
		if (xhr.status == 200)		{			$('messages_shoutbox').innerHTML = xhr.responseText;
		}  	   else  	   { 	       $('messages_shoutbox').innerHTML = xhr.status; 	   }
			$('message').value = '';
	}
	}
	function shout_affich()	{
		var url = './ajax.php?act=af_shoutbox';
  		var myAjax = new Ajax.Request( 		url,            {    		 	method:       'post',     			asynchronous: true,      			contentType:  'application/x-www-form-urlencoded', 				encoding: 'ISO-8859-1', 				
                onComplete: gestionReponse            });
	
	function gestionReponse(xhr)	{
		if (xhr.status == 200)		{			$('messages_shoutbox').innerHTML = xhr.responseText;
		}  	   else  	   { 	       $('messages_shoutbox').innerHTML = xhr.status; 	   }
	}
	}
      


	//TPS REEL
	function aff_tpsreel()
	{
		aff_heure();
		var url = './ajax.php?act=aff_tpsreel';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				onComplete: gestionReponse88
			});
		function gestionReponse88(xhr)
		{
			if (xhr.status == 200)
			{
				$('tps_reel').innerHTML = xhr.responseText;
			}
			else
			{
				$('tps_reel').innerHTML = xhr.status;
			}
		}
	}
	
	function setOpacity(obj, opacity) {  opacity = (opacity == 100)?99.999:opacity;  obj.style.filter = "alpha(opacity:"+opacity+")";  obj.style.KHTMLOpacity = opacity/100;  obj.style.MozOpacity = opacity/100;  obj.style.opacity = opacity/100;}


	//Suppression mail parrainage
	function del_mail_imp(id_bloc)
	{
		$('mail_'+id_bloc).innerHTML = '';
	}	
	//Switch non connecte
	function switch_p(type)
	{
		var url = './ajax.php?act=switch';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: 'type='+type,
				onComplete: gestionReponse
			});
		function gestionReponse(xhr)
		{
			if (xhr.status == 200)
			{
				fadeIn('type_paiement', 20);
				$('type_paiement').innerHTML = xhr.responseText;
			}
			else
			{
				fadeIn('type_paiement', 20);
				$('type_paiement').innerHTML = xhr.status;
			}
		}
	}	
	
	
	//Multijeu
	function s_nb_cred(nb, id_lot, id_player)
	{
		if(isFinite(nb))
		{		
			nb_def = nb;	
		}
		else
		{
			nb_def = 0;
		}
		
		
		if(nb > 0)
		{
			$('but_jouez').innerHTML = '<div class="but_jouer" style="margin:0px;"><a href="#" onClick="jouez(\''+id_lot+'\', \''+id_player+'\', \''+nb+'\');">JOUER ('+nb+')</a></div>';
		}
		else
		{
			$('but_jouez').innerHTML = '<div class="but_crediter" style="margin:0px;"><a href="crediter.php">CREDITER</a></div>';			
		}
	}	
	
	//Multimise
	function s_nb_mise(nb, id_player)
	{
		if(isFinite(nb))
		{		
			nb_def = nb;	
		}
		else
		{
			nb_def = 0;
		}
		
		
		if(nb > 0)
		{
			$('but_misez').innerHTML = '<div class="but_jouer" style="margin:0px;"><a href="#" onClick="qod( \''+id_player+'\', \''+nb+'\');">JOUER ('+nb+')</a></div>';
		}
		else
		{
			$('but_jouez').innerHTML = '<div class="but_crediter" style="margin:0px;"><a href="crediter.php">CREDITER</a></div>';			
		}
	}		
	
	//Suppression catégorie
	function del_cat(id_cat)
	{
		$('trcat_'+id_cat).innerHTML = '<td colspan="3"><img src="themes/1/img/bar-loader.gif"/></td>';
		var url = './ajax.php?act=del_cat';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: 'id_cat='+id_cat,
				onComplete: gestionReponse
			});
		function gestionReponse(xhr)
		{
			if (xhr.status == 200)
			{
				$('trcat_'+id_cat).innerHTML = xhr.responseText;
			}
			else
			{
				$('trcat_'+id_cat).innerHTML = xhr.status;
			}
		}
	}
	//Suppression lot
	function del_lot(id_lot)
	{
		$('trlot_'+id_lot).innerHTML = '<td colspan="5"><img src="themes/1/img/bar-loader.gif"/></td>';
		var url = './ajax.php?act=del_lot';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: 'id_lot='+id_lot,
				onComplete: gestionReponse1
			});
		function gestionReponse1(xhr)
		{
			if (xhr.status == 200)
			{
				$('trlot_'+id_lot).innerHTML = xhr.responseText;
			}
			else
			{
				$('trlot_'+id_lot).innerHTML = xhr.status;
			}
		}
	}
	
	//Quitte ou double
	function qod(id_player, nb)
	{
		$('but_misez').innerHTML = '<div class="but_jouer" style="margin:0px;">PATIENTEZ...</div>';
		var url = './ajax.php?act=qod';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: '&nb='+nb,
				onComplete: gestionReponse55
			});
		function gestionReponse55(xhr)
		{
			if (xhr.status == 200)
			{
				fadeIn('result_ajax', 20);
				$('result_ajax').innerHTML = xhr.responseText;
				verif_mise();
				refresh_credit();
				refresh_lnb_qod();
			}
			else
			{
				fadeIn('result_ajax', 20);
				$('result_ajax').innerHTML = xhr.status;
				verif_mise();
				refresh_credit();
				refresh_lnb_qod();

			}
		}
	}	
	
	//Actualisation du crédit
	function refresh_lnb_qod()
	{
		var url = './ajax.php?act=refresh_lnb-qod';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: 'id_lot=1',
				onComplete: gestionReponse44
			});
		function gestionReponse44(xhr)
		{
			if (xhr.status == 200)
			{
				$('lnb').innerHTML = xhr.responseText;
			}
			else
			{
				$('lnb').innerHTML = xhr.status;
			}
		}
	}
			
	//Vérification du crédit
	function verif_mise()
	{
		var url = './ajax.php?act=verif_mise';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: 'id_lot=1',
				onComplete: gestionReponse3
			});
		function gestionReponse3(xhr)
		{
			if (xhr.status == 200)
			{
				$('but_misez').innerHTML = xhr.responseText;
			}
			else
			{
				$('but_misez').innerHTML = xhr.status;;
			}
		}
	}	
	
	//Suppression lot
	function jouez(id_lot,id_player, nb)
	{
		$('but_jouez').innerHTML = '<div class="but_jouer" style="margin:0px;">PATIENTEZ...</div>';
		var url = './ajax.php?act=jouez';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: 'id_lot='+id_lot+'&nb='+nb,
				onComplete: gestionReponse2
			});
		function gestionReponse2(xhr)
		{
			if (xhr.status == 200)
			{
				fadeIn('result_ajax', 20);
				$('result_ajax').innerHTML = xhr.responseText;
				verif_credit(id_lot);
				refresh_credit();
				refresh_lnb(id_lot);
			}
			else
			{
				fadeIn('result_ajax', 20);
				$('result_ajax').innerHTML = xhr.status;
				verif_credit(id_lot);
				refresh_credit();
				refresh_lnb(id_lot);

			}
		}
	}
	
	
	
	//Vérification du crédit
	function verif_credit(id_lot)
	{
		var url = './ajax.php?act=verif_credit';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: 'id_lot='+id_lot,
				onComplete: gestionReponse3
			});
		function gestionReponse3(xhr)
		{
			if (xhr.status == 200)
			{
				$('but_jouez').innerHTML = xhr.responseText;
			}
			else
			{
				$('but_jouez').innerHTML = xhr.status;
			}
		}
	}
	//Actualisation du crédit
	function refresh_lnb(id_lot)
	{
		var url = './ajax.php?act=refresh_lnb';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: 'id_lot='+id_lot,
				onComplete: gestionReponse40
			});
		function gestionReponse40(xhr)
		{
			if (xhr.status == 200)
			{
				$('lnb').innerHTML = xhr.responseText;
			}
			else
			{
				$('lnb').innerHTML = xhr.status;
			}
		}
	}
	
	//Actualisation du crédit
	function refresh_credit()
	{
		var url = './ajax.php?act=refresh_credit';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				onComplete: gestionReponse4
			});
		function gestionReponse4(xhr)
		{
			if (xhr.status == 200)
			{
				$('refresh_credit').innerHTML = xhr.responseText;
				$('cred_bar').innerHTML = xhr.responseText;
			}
			else
			{
				$('refresh_credit').innerHTML = xhr.status;
				$('cred_bar').innerHTML = xhr.status;
			}
		}
	}
	//Affichage des lots
	function show_lots(cat, tri)
	{
		var url = './ajax.php?act=show_lots';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: 'cat='+cat+'&tri='+tri,
				onComplete: gestionReponse5
			});
		function gestionReponse5(xhr)
		{
			if (xhr.status == 200)
			{
				$('p_lots').innerHTML = xhr.responseText;
			}
			else
			{
				$('p_lots').innerHTML = xhr.status;
			}
		}
	}
	//Envoi notif adresse incorrect
	function ad_inco(mail, id_gain)
	{
		var url = './ajax.php?act=ad_inco';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: 'mail='+mail,
				onComplete: gestionReponse6
			});
		function gestionReponse6(xhr)
		{
			if (xhr.status == 200)
			{
				$('ad_inco_'+id_gain).innerHTML = xhr.responseText;
			}
			else
			{
				$('ad_inco_'+id_gain).innerHTML = xhr.status;
			}
		}
	}
	//Envoi notif adresse incorrect
	function expe1(mail, id_gain)
	{
		$('expe_'+id_gain).innerHTML = '<form method="POST" onsubmit="expe2( \''+mail+'\',\''+id_gain+'\')"><p> Num. : <input type="text" name="num" id="num" size="8" /> <input type="button" value="OK" class="ok-acc" onclick="expe2( \''+mail+'\',\''+id_gain+'\')"></p></form>';
	}
	
	//Expedition d'un lot
	function expe2(mail, id_gain)
	{
		var num = $F("num");
		var url = './ajax.php?act=expe_lot';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: 'mail='+mail+'&id_gain='+id_gain+'&num='+num,
				onComplete: gestionReponse7
			});
		function gestionReponse7(xhr)
		{
			if (xhr.status == 200)
			{
				$('expe_'+id_gain).innerHTML = xhr.responseText;
			}
			else
			{
				$('expe_'+id_gain).innerHTML = xhr.status;
			}
		}
	}
	
	//Accusé de réception
	function acc(mail, id_gain)
	{
		var url = './ajax.php?act=acc_lot';
		var myAjax = new Ajax.Request(
		url,
			{
				method: 'POST',
				parameters: 'mail='+mail+'&id_gain='+id_gain,
				onComplete: gestionReponse8
			});
		function gestionReponse8(xhr)
		{
			if (xhr.status == 200)
			{
				$('acc_'+id_gain).innerHTML = xhr.responseText;
			}
			else
			{
				$('acc_'+id_gain).innerHTML = xhr.status;
			}
		}
	}	
	
	//Ajouter un commentaire sur un jeu
	function ad_com(id_jeu)
	{
		var comment = $F("comment");
		var url = './ajax.php?act=ad_com';
  		var myAjax = new Ajax.Request(
 		url,
            {
    		 	method:       'post',
     			asynchronous: true,
      			contentType:  'application/x-www-form-urlencoded',
 				encoding: 'ISO-8859-1', 				
       			parameters: 'id_jeu='+id_jeu+'&comment='+comment,
                onComplete: gestionReponse9
            });
	
	function gestionReponse9(xhr)
	{
		if (xhr.status == 200)
		{
			$('res_com').innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('res_com').innerHTML = xhr.status;
 	   }
 	   	$("comment").value='';
 	    aff_com(id_jeu);	
	}
	}
	//Ajouter un commentaire sur un jeu
	function ad_com_blog(id_art)
	{
		var comment = $F("comment");
		var url = './ajax.php?act=ad_com_b';
  		var myAjax = new Ajax.Request(
 		url,
            {
    		 	method:       'post',
     			asynchronous: true,
      			contentType:  'application/x-www-form-urlencoded',
 				encoding: 'ISO-8859-1', 				
       			parameters: 'id_art='+id_art+'&comment='+comment,
                onComplete: gestionReponse99
            });
	
	function gestionReponse99(xhr)
	{
		if (xhr.status == 200)
		{
			$('res_com').innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('res_com').innerHTML = xhr.status;
 	   }
 	   	$("comment").value='';
 	    aff_com_b(id_art);	
	}
	}
	//afficher les commentaires d'un jeu
	function aff_com_b(id_art)
	{
		
		var url = './ajax.php?act=aff_com_b';
  		var myAjax = new Ajax.Request(
 		url,
            {
    		 	method:       'post',
     			asynchronous: true,
      			contentType:  'application/x-www-form-urlencoded',
 				encoding: 'ISO-8859-1', 				
       			parameters: 'id_art='+id_art,
                onComplete: gestionReponse100
            });
	
	function gestionReponse100(xhr)
	{
		if (xhr.status == 200)
		{
			$('list_comment').innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('list_comment').innerHTML = xhr.status;
 	   }
	}
	}		
	
	//afficher les commentaires d'un jeu
	function aff_com(id_jeu)
	{
		
		var url = './ajax.php?act=aff_com';
  		var myAjax = new Ajax.Request(
 		url,
            {
    		 	method:       'post',
     			asynchronous: true,
      			contentType:  'application/x-www-form-urlencoded',
 				encoding: 'ISO-8859-1', 				
       			parameters: 'id_jeu='+id_jeu,
                onComplete: gestionReponse10
            });
	
	function gestionReponse10(xhr)
	{
		if (xhr.status == 200)
		{
			$('list_comment').innerHTML = xhr.responseText;
		}
  	   else
  	   {
 	       $('list_comment').innerHTML = xhr.status;
 	   }
	}
	}
	
	//Textarea limité
	var Ecrire = function Ecrire(id, message)
	{
  	  if (document.getElementById) document.getElementById(id).innerHTML = message;
	}

	var TextareaLong = function TextareaLong(Objet,TailleMax,IdAffichage)
	{
 	   TailleObj = Objet.value.length
 	   if (TailleObj > TailleMax )
 	   {
    	    Objet.value = Objet.value.substring(0,TailleMax);
    	    TailleObj = TailleMax;
  	  }
  		  Ecrire(IdAffichage, TailleMax-TailleObj);
	}