ï»¿var sauvFens = new Array();

var memSuj = new Array();
var cptSuj = 0;
var memMode = 1;
var timeout3 ="";
var decnb=15;
var dref="";
var imgload = '<img src="images/loading.gif" class="imgloading" alt="" />';
var newmsgnb=0;


function openExt (lurl, lafen){ewWindow=window.open(lurl, lafen);}

function openThis (lurl, lafen)
{
 var thehost = "";
  var lidfiche = lurl.substr(lurl.indexOf("'")+3);
  lidfiche = lidfiche.substr(lidfiche.indexOf(".")+1);
  lidfiche = lidfiche.substr(0, lidfiche.indexOf("."));
 ewWindow=window.open(thehost+lurl, lafen); 
}

function newToLu (nb){gt('seen'+nb).innerHTML= '<img src="images/lu.gif" class="imglu" alt="Lu" />';}

function selectFor(val)
{
hideFor();
var oksel=0;
for (i=0; i < gt("chforum").length; i++)
{
if (gt("chforum").options[i].value == val){gt('chforum').selectedIndex = i; i = gt("chforum").length; oksel=1;}
}
if (oksel == 1) {goNavig();}
}

function showSkins(nb)
{
	if (nb == 1){gt('skinsdiv').style.display="block";}
	else{gt('skinsdiv').style.display="none";}
}


function affFor()
{
	gt("safffor").innerHTML = "<a href=\"javascript:hideFor();\"><img src=\"images/loupe2.gif\" class=\"imglu\" alt=\"-\" /></a>";
	nbal = nbal+nbal;
	var xhr_sp = httpReq();
	var filenamesp= hostajax+"affforums.inc.php?home=1&ok=ok&al="+nbal;

	xhr_sp.open("GET", filenamesp, true);
	xhr_sp.onreadystatechange = function() {
	if(xhr_sp.readyState == 4) {gt('showfo').innerHTML=xhr_sp.responseText;(function($) {$("#showfo").slideDown("normal");})(jQuery);}
	}
	xhr_sp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr_sp.send("");
}

function hideFor(){ gt("safffor").innerHTML = "<a href=\"javascript:affFor();\"><img src=\"images/loupe.gif\" class=\"imglu\" alt=\"+\" /></a>"; (function($) {$("#showfo").slideUp("normal");})(jQuery);}

function resetForum()
{
 for (i=1; i <= 25; i++)
 {
  if (gt("forum"+i)) {gt("forum"+i).innerHTML='';}
  if (gt("titre"+i)) {gt("titre"+i).innerHTML='';}
  if (gt("time"+i)) {gt("time"+i).innerHTML='';}
  if (gt("login"+i)) {gt("login"+i).innerHTML='';}
  if (gt("llogin"+i)) {gt("llogin"+i).innerHTML='';}
  if (gt("nb"+i)) {gt("nb"+i).innerHTML='';}
  if (gt("seen"+i)) {gt("seen"+i).innerHTML='';}
 }
}

function actu()
{
var xhr_object = httpReq();

var filename = hostajax+"newmsg.php?cat="+catj+"&up="+lup+"&ltup="+ltup+"&al="+nbal+"&c="+code+"&sujourep="+sujourep+"&sp="+spoilless+"&page="+page+"&modc="+modc+"&fpri="+fpri+"&multif="+multif;
nbal = nbal + nbal2;
var decal = 0;
var i = 0;
var tabids = new Array();
var newids = "@@";
var tmpstr = "";

var newvals = new Array();
var newvalsb = new Array();
var newvalsc = new Array();
var newvalsd = new Array();
var newvalse = new Array();
var newvalsf = new Array();
var newvalsg = new Array();
xhr_object.open("GET", filename, true);
anclup =lup;
xhr_object.onreadystatechange = function() {
   if(xhr_object.readyState < 4) 
	 {
	 tmpstr = imgload;
	 gt("loading").innerHTML= tmpstr;
	}
  else if(xhr_object.readyState == 4) {
	gt("loading").innerHTML= '';

    var tmp = xhr_object.responseText.split("@@");
	decal = tmp[0];

	if (decal > 0)
	{
		lup=tmp[1]; newids="@";

		// recup des nouvelles id dans une chaine
		for (i=1; i <= decal; i++)
		{newids = newids + "@"+ tmp[2+((i-1)*8)] + "@";}

		// recup des anciennes id
		for (i=1; i <= 25; i++)
		{
			tmpstr = gt("titre"+i).innerHTML;
			lindex = tmpstr.indexOf("href=", 0)+6;
			tmpstr = tmpstr.substr(lindex, 150);
			tabids[i] = tmpstr.substr(0, tmpstr.indexOf('"', 0));
//			alert(tabids[i]);
		}

		decalb=1;
		for (i=1+1*decal; i <= 25; i++)
		{
			if (gt("seen"+decalb))
			{
			while (newids.indexOf("@"+tabids[decalb]+"@", 0) > 0){  decalb++;}
			newvals[i] = gt("forum"+decalb).innerHTML;
			newvalsb[i] = gt("titre"+decalb).innerHTML;
			tmptime = gt("time"+decalb).innerHTML;
			if (tmptime.indexOf("!--") > 0){newvalsc[i] = tmptime.substring (tmptime.indexOf("<!"+"--")+4,tmptime.indexOf("--"+">"));}
			else {newvalsc[i] = tmptime;}
			newvalsd[i] = gt("login"+decalb).innerHTML;
			newvalse[i] = gt("llogin"+decalb).innerHTML;
			newvalsf[i] = gt("nb"+decalb).innerHTML;
			newvalsg[i] = gt("seen"+decalb).innerHTML;
			decalb = 1*decalb+1;
			}
		}
			
		//DÃ©calage des anciens
		for (i=1+1*decal; i <= 25; i++)
		{
		if (gt("seen"+i))
		{
		gt("forum"+i).innerHTML = newvals[i];

		var stra = newvalsb[i]; 
		var motif = stra.substring(stra.indexOf('lien')); motif = motif.substring(0, motif.indexOf('a')+1);
	
		stra = newvalsb[i]; 
		stra = stra.replace(motif, 'lien'+i+'a');
		newvalsb[i] = stra;
			 
		gt("titre"+i).innerHTML = newvalsb[i];
		gt("time"+i).innerHTML = newvalsc[i];
		gt("login"+i).innerHTML = newvalsd[i];

		stra = newvalse[i]; 
		motif = stra.substring(stra.indexOf('lien')); motif = motif.substring(0, motif.indexOf('b')+1);

		stra = newvalse[i]; 
		stra = stra.replace(motif, 'lien'+i+'b');
		newvalse[i] = stra;
			 
		gt("llogin"+i).innerHTML = newvalse[i];
		if (gt("nb"+i))
		{
			gt("nb"+i).innerHTML = newvalsf[i];
			if ((newvalsf[i]*1) > 0) {gt("nbcont"+i).style.display='block';} else {gt("nbcont"+i).style.display='none';}
		}
		gt("seen"+i).innerHTML = newvalsg[i];
		}
		}
			
		//Assignation nouveaux
		for (i=1; i <= decal; i++)
		{gt("forum"+i).innerHTML =tmp[3+((i-1)*8)];
			gt("titre"+i).innerHTML =tmp[4+((i-1)*8)];
			gt("time"+i).innerHTML =tmp[5+((i-1)*8)];
			gt("login"+i).innerHTML =tmp[6+((i-1)*8)];
			gt("llogin"+i).innerHTML =tmp[7+((i-1)*8)];
			gt("nb"+i).innerHTML =tmp[8+((i-1)*8)];
			if (tmp[8+((i-1)*8)] > 0) {gt("nbcont"+i).style.display='block';} else {gt("nbcont"+i).style.display='none';}
			gt("seen"+i).innerHTML =tmp[9+((i-1)*8)];
		}
	}
   }
}
xhr_object.send("");
}

function nextPage(pag)
{
lup = 0;
initSeen();
page=pag;
gt('affpage').innerHTML=''+page;
actu();
window.location.href="#amain3";
}


function chgImg(lurl) {gt('imgnews').src=''+lurl;}


function addFav(ida)
{
var xhr_fav = httpReq();
var filenamesuj =hostajax+"ajax/addFav.php?code="+code+"&id="+ida+"&nb="+nbal;
var tmpstr = "";

xhr_fav.open("GET", filenamesuj, true);
xhr_fav.onreadystatechange = function()
{
if(xhr_fav.readyState == 4){tmpstr  = xhr_fav.responseText;alert(''+tmpstr);}
}
xhr_fav.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr_fav.send("");
}

posFoc=0; posFocb="b";
function moveFoc(dir)
{
 if (dir == "right")
 {
  if (posFoc < 25)
	{
	if (posFoc > 0) {gt('foc'+posFoc+'a').style.visibility="hidden";}
	posFoc++; 
	}
 }
 else if (dir == "left")
 {
  if (posFoc > 1)
	{
	if (posFoc > 0) {gt('foc'+posFoc+'a').style.visibility="hidden";}
	posFoc--;
	}
 }
 gt('foc'+posFoc+posFocb).style.visibility="visible";
}

function clickFoc(){window.location.href = gt('lien'+posFoc+'a').href;}

function ejs_code_clavier(keyStroke)
{
if (shortcutok == 1)
{
	ejs_code_eventChooser = (!document.all) ? keyStroke.which : event.keyCode;
	shiftok = (!document.all) ? keyStroke.shiftKey : event.shiftKey;
	
	if (ejs_code_eventChooser == 37) {moveFoc('left');}
	else if (ejs_code_eventChooser == 39) {moveFoc('right');}
	else if (ejs_code_eventChooser == 13) {clickFoc();}
	ejs_code_which = String.fromCharCode(ejs_code_eventChooser).toLowerCase();
	 
	if (ejs_code_eventChooser > 96) { for (i=1; i<10; i++) {if (ejs_code_eventChooser == (96+i)) {zap(zb[i]);}} }
	else if (ejs_code_eventChooser < 58) { for (i=1; i<10; i++) {if (ejs_code_eventChooser == (48+i)) {zap(zb[i]);}} }
	else
	{
	  if (ejs_code_which == "a") {zap(zb[10]);}
	  else if (ejs_code_which == "b") {zap(zb[11]);}
	  else if (ejs_code_which == "c") {zap(zb[12]);}
	  else if (ejs_code_which == "d") {zap(zb[13]);}
	  else if (ejs_code_which == "e") {zap(zb[14]);}
	  else if (ejs_code_which == "f") {zap(zb[15]);}
	  else if (ejs_code_which == "g") {zap(zb[16]);}
	  else if (ejs_code_which == "t") {goForum('16');}
	  else if (ejs_code_which == "x") {goForum('9');}
	  else if (ejs_code_which == "z") {goForum('124');}
	  else if (ejs_code_which == "u") {window.location.href = "#ubertop";}
	  else if (ejs_code_which == "s") {window.location.href = "#asujet";}
	  else if (ejs_code_which == "n") {newPost();}
	}
}
}

function initSeen (){for (i=1; i < 26; i++){
if (gt('seen'+i)) {gt('seen'+i).innerHTML="";}
}}

function newPost(){openThis("post?debat=0&cat="+catj+"&theshowid=&vopt=0&c="+code+"&modc="+modc+"&al="+(536+nbal), '_blank');}

var sauvtimer="";
function affTyp(nb, letyp)
{
if (letyp != "") {sauvtimer = gt('time'+nb).innerHTML; gt('time'+nb).innerHTML="&nbsp;&nbsp;&nbsp;"+letyp;}
else{gt('time'+nb).innerHTML=sauvtimer;}
}


function getDates(da, mo, ye, lej)
{
var xhr_dates = httpReq();
nbal=nbal+1;

var filename = hostajax+"wp-content/themes/Avenue/fo/getDates_wp.php?day="+da+"&month="+mo+"&year="+ye+"&al="+nbal+"&aj=1";
lenbact=0;

xhr_dates.open("GET", filename, true);
xhr_dates.onreadystatechange = function()
{
  if(xhr_dates.readyState < 4){;}
  else if(xhr_dates.readyState == 4)
	{
		gt('lesdates').innerHTML = xhr_dates.responseText;
	}
}
xhr_dates.send("");
}


function rendInv(ladiv){gt(""+ladiv).style.visibility="hidden";}

function goToLast(ref)
{
// if (ref == "lastrep" || ref == "atitres"){gt("sujet").innerHTML='<img src="images/loading.gif" class="imgloading" alt="Loading..." />'; gt("sujTitres").innerHTML='<img src="images/loading.gif" class="imgloading" alt="Loading..." />'; dref = ref; loadSujet(code, sujActuel, Math.floor(nbmActuel/25), nbmActuel*1);}
 rendInv("divBasDroite");
 newmsgnb=0;
 if (ref != 'none' && ref != "") {window.location.href="#"+ref;}
}

function addMsgBD(typ, last)
{
if (typ == "sujet")
{
 if (newmsgnb == 1) {gt("addMsg").innerHTML = '<span class="review">Nouvelle r&eacute;ponse dans le sujet ouvert !</span><br /><a href="javascript:goToLast(\''+last+'\');" class="review"><b>La voir</b></a>&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;<a href="javascript:goToLast(\'atitres\');" class="review"><b>Voir tous les titres</b></a>';}
 else {gt("addMsg").innerHTML = '<span class="review">'+ newmsgnb + ' r&eacute;ponses dans le sujet ouvert </span>!<br /><a href="javascript:goToLast(\''+last+'\');" class="review"><b>Voir la dernière</b></a>&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;<a href="javascript:goToLast(\'atitres\');" class="review"><b>Voir tous les titres</b></a>';}
}
else if (typ == "asujet")
{
 gt("addMsg").innerHTML = '<a href="javascript:goToLast(\''+typ+'\');" class="review">Consultez le dernier sujet que vous avez lu.</a>';
 timeout3 = setInterval("decompte()", 1000);
}
gt("divBasDroite").style.visibility="visible";
}

function subNewsl()
{
nbal = nbal+nbal2;
var xhr_newsl = httpReq();

var filenameNewsl = hostajax+"ajax/subscribe_newsl.php?newslmail=" + gt("newslmail").value + "&code="+code + "&al=" + nbal;

xhr_newsl.open("GET", filenameNewsl, true);
xhr_newsl.onreadystatechange = function() {
 if(xhr_newsl.readyState == 4)
 {
  shortcut(1);
  alert("Inscription Ã  la newsletter rÃ©ussie.");
 }
}
xhr_newsl.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr_newsl.send("");
}

var justposted=0;
function actuSujet()
{
actusuj=1;
if (actusuj == 1)
{
	var tmpstr = "";
	nbal = nbal+nbal2;
	var xhr_actuS = httpReq();
	var filenameactuS = hostajax+"ajax/modtalk5.php?idsuj=" + sujActuel + "&nbsuj="+nbmActuel + "&al=" + nbal+ "&c="+code;

	xhr_actuS.open("GET", filenameactuS, true);
	xhr_actuS.onreadystatechange = function() {
	if(xhr_actuS.readyState < 4) {;} else if(xhr_actuS.readyState == 4) {
	 tmpstr  = xhr_actuS.responseText;
	 var tmpok = tmpstr.substr(tmpstr.indexOf('=')+1);
	 tmpok = tmpok.substr(0,tmpok.indexOf('&'));

	 if (tmpok == "1")
	 {
	 tmpstr = tmpstr.substr(tmpstr.indexOf('newnbm=')+7);
	 var nbrep = tmpstr.substr(0, tmpstr.indexOf('&talk'));
	 tmpstr = tmpstr.substr(tmpstr.indexOf('nid=')+4);
	 var nid = tmpstr.substr(0, tmpstr.indexOf('&'));
	 tmpstr = tmpstr.substr(tmpstr.indexOf('&&')+2);
	 if (justposted != nid)
	 { 
		var lp = gt('lastposts').innerHTML;
		gt('lastposts').innerHTML = lp + tmpstr;
		noDiese=1;
		newmsgnb = newmsgnb+ ((nbrep*1)-nbmActuel);
		addMsgBD("sujet", "message"+nbrep);
	 }
	 nbmActuel = nbrep*1;
	 }
	 actusuj=0;
	}
	}
	xhr_actuS.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr_actuS.send("");
}
}

function horloge () {
var maintenant = new Date();
var heures = maintenant.getHours();
var minutes = maintenant.getMinutes();
var resultat = "" + heures + ((minutes < 10)?":0":":") + minutes;
return resultat;
}


function quelleHeure() {
var heure=horloge();
gt('affHorloge').innerHTML=heure;
setTimeout('quelleHeure()',60000);
}
