function twitVid(lid, ti, tiu)
{
nbal = nbal+nbal;
var xhr_sp = httpReq();
var filenamesp= hostajax+"ajax/createSujetVid.php?ok=ok&id="+lid+"&al="+nbal;
xhr_sp.open("GET", filenamesp, true);
xhr_sp.onreadystatechange = function() {
if(xhr_sp.readyState == 4) {
openThis("http://twitter.com/home?status="+ti+" http://forom.com/"+tiu+"."+ xhr_sp.responseText+".html", '_blank');
}
}
xhr_sp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr_sp.send("");
}

function showVideo(lid)
{
nbal = nbal+nbal;
var xhr_sp = httpReq();

var filenamesp= hostajax+"ajax/createSujetVid2.php?ok=ok&id="+lid+"&c="+code+"&al="+nbal;
xhr_sp.open("GET", filenamesp, true);
xhr_sp.onreadystatechange = function() {
if(xhr_sp.readyState == 4) {
tmpstr = xhr_sp.responseText;
lindex = tmpstr.indexOf("|", 0); 
window.location.href=tmpstr.substr(0, lindex);

}
}
xhr_sp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr_sp.send("");

/*
nbal = nbal+nbal;
var xhr_sp = httpReq();
var filenamesp= hostajax+"ajax/getVid.inc.php?ok=ok&id="+lid+"&c="+code+"&al="+nbal;

xhr_sp.open("GET", filenamesp, true);
xhr_sp.onreadystatechange = function() {
if(xhr_sp.readyState == 4) {
tmpstr = xhr_sp.responseText;

gt('showvideo').style.display='block';
lindex = tmpstr.indexOf("|", 0); 
gt('showvideo').innerHTML=tmpstr.substr(0, lindex);
gt('contentVid').innerHTML= tmpstr.substr(lindex+1);
gt('contentVid').style.display='block';
gt('backvideo').style.display='block';
window.location.href='#top';
}
}
xhr_sp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr_sp.send("");
*/
}

function commentVideo(lid)
{
nbal = nbal+nbal;
var xhr_sp = httpReq();

var filenamesp= hostajax+"ajax/createSujetVid.php?ok=ok&id="+lid+"&c="+code+"&al="+nbal;
xhr_sp.open("GET", filenamesp, true);
xhr_sp.onreadystatechange = function() {
if(xhr_sp.readyState == 4) {
tmpstr = xhr_sp.responseText;
lindex = tmpstr.indexOf("|", 0); 

if (gt('repondre')) {bigrep('1000000000000000000', tmpstr.substr(0, lindex), tmpstr.substr(0, lindex), 0);}
else {showrep(tmpstr.substr(lindex+1));}

}
}
xhr_sp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr_sp.send("");

}
function closeRep(){document.getElementById('repondre').style.display='none';}

function showrep(rep)
{
gt('addrep').innerHTML= rep;
gt('addrep').style.display='block';
gt('affimg').style.display='none';
gt('affsml').style.display='none';
gt('repondre').style.display='block';
gt('repondre').style.width='455px';
gt('repsimple').style.width='620px';
gt('repsimple').style.border='0';
gt('repondre').style.padding='0';
gt('repondre').style.position='relative';
gt('repondreb').style.padding='0 0 0 100px';
gt('repondreb').style.border='0';
gt('repondreb').style.height='300px';
gt('fosr').target="sauvmsg";
gt('repfb').style.display='none';
}

function closeVideo()
{
gt('contentVid').innerHTML='';
if(gt('repvid')) {gt('repvid').style.display='none';}
gt('contentVid').style.display='none';
gt('showvideo').style.display='none';
gt('backvideo').style.display='none';
}

function savePos(ch)
{
nbal = nbal+nbal;
var xhr_sp = httpReq();
var data="";
var filenamesp= hostajax+"ajax/savePos.inc.php?ok=ok&ch="+ch+"&c="+code+"&al="+nbal;

xhr_sp.open("GET", filenamesp, true);
xhr_sp.onreadystatechange = function() {
if(xhr_sp.readyState == 4) {;}
}
xhr_sp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr_sp.send(data);
}


function affComm(nb, twrid)
{
 nbal = nbal+nbal;
 var xhr_affc = httpReq();
 var filenameaffc = hostajax+"ajax/affcomm.php?twid="+twrid+"&c="+code+"&modc="+modc+"&al="+nbal;
 gt("affcomm"+nb).innerHTML = '<img src="images/loading.gif" class="imgloading" alt="Loading..." />';
 xhr_affc.open("GET", filenameaffc, true);
 xhr_affc.onreadystatechange = function() {
 if(xhr_affc.readyState == 4) {
  var tmp = xhr_affc.responseText.split("@@");
  gt("affcomm"+nb).innerHTML = "";
  gt("affcomm"+nb).innerHTML = tmp[0];
 }
 }
 xhr_affc.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 xhr_affc.send("");
}

function repTwit(nb, relog, twid)
{
if (gt('repondre')) {bigrep('1000000000000000000', '498127', '498127', 0);gt("addtwit").value ="@"+relog;gt("twid").value =twid;}
else {
	nbal = nbal+nbal;
	var xhr_sp = httpReq();

	var filenamesp= hostajax+"ajax/getblocrep.php?ok=ok&id=498127&c="+code+"&al="+nbal;
	xhr_sp.open("GET", filenamesp, true);
	xhr_sp.onreadystatechange = function() {
	if(xhr_sp.readyState == 4) {
		tmpstr = xhr_sp.responseText;
		showrep(tmpstr.substr(1));
		gt("addtwit").value ="@"+relog;
		gt("twid").value =twid;
	}
	}
	xhr_sp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr_sp.send("");
}
}

function detecteConfig()
{
 var tmpstr="";
 var tabCases = "";
 for (i=1; i<=nbCases; i++)
 {
  tmpstr  = gt("case"+i).innerHTML;
  if (tmpstr.indexOf('Navigation') > 0) {tabCases = tabCases+"a";}
  else if (tmpstr.indexOf('Rubriques') > 0) {tabCases = tabCases+"b";}
  else if (tmpstr.indexOf('Zapette') > 0) {tabCases = tabCases+"c";}
  else if (tmpstr.indexOf('ocuments') > 0) {tabCases = tabCases+"d";}
  else if (tmpstr.indexOf('privé') > 0) {tabCases = tabCases+"e";}
  else if (tmpstr.indexOf('Twitter') > 0) {tabCases = tabCases+"f";}
 }
 return tabCases;
}

function retAccueil(){;}

function goForum(lacat)
{
resetForum();
sujourep=0;

catj = lacat;
lup = 0;
initSeen();
catbj="";
page=1;

actu();
}

function goNavig()
{
newAct="0";
selObj = gt('chforum');
selFor = selObj.selectedIndex;
newFor = selObj.options[selFor].value;
if (newFor.substr(0, 2) == "--"){alert("Merci de choisir un forum ou une série !");}
else
{

 if (newAct == "0")
 {
 sujourep = 0;
  if (newFor*1 < 1000)
	{
	 resetForum();
	 catj=newFor;
	 lup = 0;
	 initSeen();
	 catbj="";
	 page=1;
 	 actu();
	}
	else
	{
	resetForum();
	catj=newFor;
	catbj=newFor-(catj*1000);
	initSeen();
	lup = 0;
	page=1;
	actu();
	}
	
 }
 else if (newAct == "1")
 {openThis('episodes/index.php?goserie='+selObj.options[selFor].text+'&c=&modc='+modc, 'episodes');}
 else if (newAct == "2")
 {openThis('gaudi.php?goserie='+selObj.options[selFor].text+'&debat=0&cat=0&c='+code, "_blank");}
 else if (newAct == "3")
 {openFPLF('goto='+selObj.options[selFor].text+'&');}
}
}


var oldFens = new Array();

function zap(arg)
{
var titreZap = arg.substr(arg.indexOf(':')+1);
tmp = arg.substr(0, arg.indexOf(':'));
var tmptab = tmp.split(";");

if (tmptab[0] == "1")
{	catj=tmptab[1];
	sujourep = 0;
	lup = 0;
	initSeen();
	catbj="";
	actu();
}
else if (tmptab[0] == "2")
{	catj=tmptab[1];
	catbj=tmptab[2];
	sujourep = 0;
	lup = 0;
	initSeen();
	actu();
}
else if (tmptab[0] == "3")
{
	if (tmptab[1] == "configzap.php") {openThis(tmptab[1]+"?"+tmptab[2]+"&c="+code, "bbb");} else {openThis(tmptab[1]+"?"+tmptab[2]+"&c="+code, "bbb");}
}
else if (tmptab[0] == "4"){openThis ("http://"+tmptab[1]+"?"+tmptab[2]+"&c="+code, "aaa");}
else if (tmptab[0] == "5"){newPost();}
else if (tmptab[0] == "6"){openExt ("http://"+tmptab[1], "_blank");}
else if (tmptab[0] == "7"){window.location.href="#ubertop";}
else if (tmptab[0]== "8"){actu();}
}


function cocher(chk)
{ 
if(gt(chk).checked){gt(chk).checked=false;}
else{gt(chk).checked=true;}
}

function reglages (nb)
{
if (nb == 2) {var obj = gt('multif');}
else if (nb == 3) {var obj = gt('spoilless');}

if ((""+obj.checked) == "true") {var nchecked = 1; if (nb == 2) {multif=1; clearInterval(timeout); gt('sujet').innerHTML=''; gt('sujTitres').innerHTML='';} else if (nb == 3) {spoilless=1;}}
else {var nchecked = 0; if (nb == 2) {multif=0;} else if (nb == 3) {spoilless=0;}}

if (inscrit == 1)
{
 var xhr_regl = httpReq();
 var filename = "ajax/chgmode.php?champ="+nb+"&val="+nchecked+"&c="+code+"&nal="+(nbal+nbal2);

 xhr_regl.open("GET", filename, true);
 xhr_regl.onreadystatechange = function()
 {
  if(xhr_regl.readyState < 4){tmpstr = '<img src="images/loading.gif" class="imgloading" alt="Loading..." />';}
  else if(xhr_regl.readyState == 4){tmpstr = '&nbsp;';if (nb == 2) {window.location.reload(true);}}
 }
 xhr_regl.send("");
}
}

function vosmes(nb)
{
sujourep = nb;
catj=16;
lup = 0;
catbj="";
actu();
}

function affzap(arg)
{
 if (arg == 0) {gt('daffzap').innerHTML='<a href="configzap?c='+code+'">Configurer</a>';}
 else {var titreZap = arg.substr(arg.indexOf(':')+1); gt('daffzap').innerHTML=titreZap;}
}

var sauvForDates="";
function showAddTxtFor()
{
shortcut(0);
sauvForDates=gt('fordates').innerHTML;
gt('fordates').innerHTML='<textarea id="showAddTxtFor" style="width: 90%; height: 115px"></textarea><br /><a class="review" style="cursor: pointer" onclick="javascript:addTxtFor();">Valider</a><span style="padding-left: 20px" id="fordatesload"></span>';
}
