// blink ie
/*if ( document.all )
{
	function blink_show()
	{
		blink_tags  = document.all.tags('blink');
		blink_count = blink_tags.length;
		for ( i = 0; i < blink_count; i++ )
		{
			blink_tags[i].style.visibility = 'visible';
		}
		
		window.setTimeout( 'blink_hide()', 700 );
	}
	
	function blink_hide()
	{
		blink_tags  = document.all.tags('blink');
		blink_count = blink_tags.length;
		for ( i = 0; i < blink_count; i++ )
		{
			blink_tags[i].style.visibility = 'hidden';
		}
		
		window.setTimeout( 'blink_show()', 250 );
	}
	
	window.onload = blink_show;
}*/



// JavaScript Document
function getXMLHTTP(){
	var xhr=null;
	  if(window.XMLHttpRequest) // Firefox et autres
	  xhr = new XMLHttpRequest();
	  else if(window.ActiveXObject){ // Internet Explorer
		try {
		  xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		  try {
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (e1) {
			xhr = null;
		  }
		}
	  }
	  else { // XMLHttpRequest non supporté par le navigateur
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	  }
	  return xhr;
};

// POP UP //////////
var popup;

function popup_open(adresse,width,height){
	popup_close();
	popup=window.open(adresse,'popup','width='+width+',height='+height+',directories=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no')
};

function popup_close(){
	 if (popup != null){
		if(!popup.closed){
			popup.close();
		};
	};
};

function popup_affiche(){
	window.focus();
	var le = window.screen.availWidth;
	var he = window.screen.availHeight;;
	var xf = le/2 - 300;
	var yf = he/2 - 300;
	window.moveTo(xf, yf);
};
///////////////////

function deconnexion(){
	a=confirm('Etes-vous sûr de vouloir quitter Magic Country ?');
	if(a){
		window.document.location.replace('index.php?action=disconnect');
	};
};

/********* SAC ***********/
sac_etat=0;
sac_en_cours=0;
function ouvrir_fermer_sac(){
	if(sac_etat==0){
		document.getElementById('sac_img').alt='Fermer mon sac';
		document.getElementById('sac_img').title='Fermer mon sac';
		document.getElementById('sac_text').innerHTML='<a href="#NULL" onClick="sac_delai();Effect.toggle(\'monsac\',\'BLIND\'); return false;">Fermer mon sac</a>';
		sac_etat=1;
	}else{
		document.getElementById('sac_img').alt='Ouvrir mon sac';
		document.getElementById('sac_img').title='Ouvrir mon sac';
		document.getElementById('sac_text').innerHTML='<a href="#NULL" onClick="sac_delai();Effect.toggle(\'monsac\',\'BLIND\'); return false;">Ouvrir mon sac</a>';
		sac_etat=0;
	};
	sac_en_cours=0;
};

function sac_delai(){
	if(sac_en_cours==0){
		sac_en_cours=1;
		setTimeout(ouvrir_fermer_sac,1300);
	};
};

function sac_refresh(url,rayon){
	_xmlhttp=getXMLHTTP();
	chaine="includes/sac-refresh.php?url="+url+"&rayon="+rayon;
	_xmlhttp.open("GET",chaine,true);
	_xmlhttp.onreadystatechange=function(){
		if (_xmlhttp.readyState == 4){
			var tmp = _xmlhttp.responseText;
			document.getElementById('contenu_sac').innerHTML = tmp;
		};
	};
	_xmlhttp.send(null);
};
/*************************/
/******** ONGLET *********/
function onglet_afficher(id){
	if(onglet_en_cours==0){
		if(tab_onglets[id]==0){
			// En cours
			onglet_en_cours=1;
			id_en_cours=id;
			
			// On cache tous
			for(i=0;i<tab_onglets_key.length;i++){
				if(tab_onglets_key[i]!=id){
					if(tab_onglets[tab_onglets_key[i]]==1){
						Effect.toggle(tab_onglets_key[i],'BLIND');
						tab_onglets[tab_onglets_key[i]]=0;
						// Liens
						lien_id='onglet-lien-'+tab_onglets_key[i];
						if(tab_onglets_liens[tab_onglets_key[i]]==0){
							document.getElementById(lien_id).className='onglet';
						}else{
							document.getElementById(lien_id).className='onglet_recherche';
						};
					};
				};
			};
			
			// On affiche le bon
			Effect.toggle(id,'BLIND');
			
			// Liens a
			lien_id='onglet-lien-'+id;
			if(tab_onglets_liens[id]==0){
				document.getElementById(lien_id).className='onglet_hover';
			}else{
				document.getElementById(lien_id).className='onglet_recherche_hover';
			};
			setTimeout(onglet_valider,1300);
		};
	};
};

function onglet_valider(){
	if(tab_onglets[id_en_cours]==0){
		tab_onglets[id_en_cours]=1;
		onglet_en_cours=0;
	};
};
/*************************/
//*****affichage heure

function tS(){
    x=new Date(heure_serveur);
	oT=x.getHours()+':'+lZ(x.getMinutes())+':'+lZ(x.getSeconds());
	document.getElementById("tP").innerHTML = oT;
	heure_serveur+=1000;
};

function lZ(x){
    return (x>9)?x:'0'+x;
};

function dT(tps){
    heure_serveur=tps*1000;
    setInterval(tS,1000);
};
/*************************/
/******** COMBATS *********/
function list_init(){
	document.getElementById('liste').innerHTML='<div style="border:2px #2686C2 solid;padding:0 10 10 10;"><h2 class="rechercher" style="text-decoration:blink;">Chargement...</h2><br /></div>';
	list();
};

function list(){
	cont=document.getElementById('liste');
	
	_xmlhttp=getXMLHTTP();
	url="arene-de-combat-maj.php?mode="+list_mode+"&theme="+list_theme;
	chaine=url;
	_xmlhttp.open("GET",chaine,true);
	_xmlhttp.onreadystatechange=function(){
		if (_xmlhttp.readyState == 4){ /* 4 : état "complete" */
			recup=_xmlhttp.responseText;
			
			if(recup!=''){
				cont.innerHTML=recup;
			}else{
				html='<div style="background-color:#D6FF00;border:2px #CC0000 solid;padding:0 10 10 10;"><h2 class="rechercher" style="text-decoration:blink;">Chargement...</h2><br /></div>';
				cont.innerHTML=html;
			};
		};
	};
	_xmlhttp.send(null);
	
	
	
};
/*************************/