function popfirefoot() {
	window.open('/images/firefoot.jpg', '', 'width=630, height=450');
}
function formcomment() {
document.write('<textarea name="comment" cols="10" rows="3" wrap="physical" id="comment" style="width:95%;height:100px;"></textarea><br /><input type="submit" name="Submit" value="Ajouter le commentaire" style="cursor:pointer" onclick="ajaxcomment();" />');
}
function croning() {
document.write('<iframe src="/crontop.php" width="0" height="0" frameborder="0"></iframe>');
}

function ScanCookie(variable)
     {
     cook = document.cookie;
     variable += "=";
     place = cook.indexOf(variable,0);
     if (place <= -1)
         return("0");
     else
         {
         end = cook.indexOf(";",place)
         if (end <= -1)
             return(unescape(cook.substring(place+variable.length,cook.length)));
         else
             return(unescape(cook.substring(place+variable.length,end)));
         }
     }
  

function CreationCookie(nom,valeur,permanent)
     {
     if(permanent)
         {
         dateExp = new Date(2010,06,01);
         dateExp = dateExp.toGMTString();
         ifpermanent = '; expires=' + dateExp + ';';
         }
     else {
	 	var d = new Date()
		var dateExp = d.getTime() + (60 * 60 * 1);		
        ifpermanent = '; expires=' + dateExp + ';';
		 }
		 
     document.cookie = nom + '=' + escape(valeur) + ifpermanent + 'domain=www.footballistique.com';
     }	
function index() {
	window.location.href='/';
}


function smiley_add(smile)
{
	this.document.getElementById('comment').value += ' ' + smile + ' ';
}


function createRequestObject() 
{
	var ro = null;	
	
     if(window.XMLHttpRequest) ro = new XMLHttpRequest();
     else
     if (window.ActiveXObject) ro = new ActiveXObject("Microsoft.XMLHTTP");

	return ro;
}

var http = createRequestObject();

function ajaxcomment() {

	var comment = document.getElementById('comment').value;
	var parentid = document.getElementById('parentid').value;
	var story_id = document.getElementById('story_id').value;
	var cmd = 'comments';
	var url = '/ajax.php';
	var data = 'id=' + story_id + '&parentid=' + parentid + '&comment=' + comment;
	
	//alert(url);
	var xhr_object = null;
    var position = 'reload_comm';

        document.getElementById('bouton').innerHTML = '<br /><br /><br /><img src="/js/ajax-loader.gif" height="19" width="220" alt="" style="margin-top: 30px;" />';
	
	
     if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
     else
     if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
 
    xhr_object.open("POST", url, true);
    xhr_object.onreadystatechange = function(){
    if ( xhr_object.readyState == 4 )
    {
        document.getElementById(position).innerHTML = xhr_object.responseText;
    document.getElementById('bouton').innerHTML = '<textarea name="comment" id="comment" style="width:95%;height:100px;"></textarea><br /><input type="submit" name="Submit" value="Ajouter un commentaire" style="cursor:pointer" onclick="ajaxcomment();" /><input type="hidden" name="parentid" id="parentid" value="0" /><input type="hidden" name="story_id" id="story_id" value="' + story_id + '" />';
    }
    }
	
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr_object.send(data);

}

function forumfoot() {
	
	all_ajax();
	
	if (window.ActiveXObject) { 
			document.getElementById('forum-foot').style.display = 'block';
		} else {
			document.getElementById('forum-foot').style.display = 'table';
		};
	
	document.getElementById('footballistique').style.display = 'none';
	document.getElementById('bouton').innerHTML = '<a href="javascript://" onclick="footballistique();">Actualité Football</a>';
	
	
	CreationCookie('why_foot','1',1);
}

function footballistique() {
	
	if (location.href != 'http://www.footballistique.com/') {
		index();
	CreationCookie('why_foot','0',1);
	}
	document.getElementById('footballistique').style.display = 'block';
	document.getElementById('forum-foot').style.display = 'none';
	document.getElementById('bouton').innerHTML = '<a href="javascript://" onclick="forumfoot();">Forum Foot</a>';
	
	
	CreationCookie('why_foot','0',1);
}

function css_it(type) {
		document.write('<style type="text/css"> #footballistique { display:none; } #forum-foot { display:table; } </style>');
	if (window.ActiveXObject) {
		document.write('<style type="text/css"> #footballistique { display:none; } #forum-foot { display:block; } </style>');			 
		 }
}


function menu_it() {
if (ScanCookie('why_foot') == 1) {
	document.getElementById('bouton').innerHTML = '<a href="javascript://" onclick="footballistique();">Actualité Football</a>';
} else {
	document.getElementById('bouton').innerHTML = '<a href="javascript://" onclick="forumfoot();">Forum Foot</a>';
}
 if (location.href == 'http://www.footballistique.com/forum-foot/')
 	{
	document.getElementById('bouton').innerHTML = '<a href="javascript://" onclick="footballistique();">Actualité Football</a>';
	}
	document.getElementById('aa').style.display = 'none';
	document.getElementById('bb').style.display = 'none';
}


function digResponse() 
{
	if(http.readyState == 4)
	{
        var response = http.responseText;
		
		var returned = response.split('|');

		if(response.indexOf('|' != -1)) 
		{
			var id=returned[1];
			var numdigs=returned[2];
			var status=returned[0];
			//alert(status + '|' + id + '|' + numdigs);
			
			if(status == '1')
			{
				document.getElementById('digbut'+id).innerHTML = 'voté';
				document.getElementById('numdigs'+id).innerHTML = numdigs;
  			}
			else if(status == '2')
			{
				document.getElementById('digbut'+id).innerHTML = 'voté';
			}
			else if(status == '0')
			{
				document.getElementById('digbut'+id).innerHTML = '<a href="/login.php">login</a>';
			}
		}
    }
}

function cdigResponse() 
{
	if(http.readyState == 4)
	{
        var response = http.responseText;
		
		returned = response.split('|');

		if(response.indexOf('|' != -1)) 
		{
			var id=returned[1];
			var numdigs=returned[2];
			var status=returned[0];
			
			if(status == '1')
			{
				document.getElementById('comd'+id).innerHTML = numdigs;
  			}
			else if(status == '2')
			{
				document.getElementById('comd'+id).innerHTML = numdigs;
			}
			else if(status == '0')
			{
				document.getElementById('comd'+id).innerHTML = '<a href="/login.php">#</a>';
			}
		}
    }
}

function buryResponse() 
{
	if(http.readyState == 4)
	{
        var response = http.responseText;
		
		returned = response.split('|');

		if(response.indexOf('|' != -1)) 
		{
			var id=returned[1];
			var status=returned[0];
			
			if(status == '0')
			{
				document.getElementById('digbut'+id).innerHTML = '<a href="/login.php">login</a>';
			}
			else
			{
				document.getElementById('storyb'+id).className = "entry_disable";
				document.getElementById('storyb'+id).style.opacity = ".2";
				document.getElementById('storyb'+id).disabled = true;
			}
		}
	}
}

function dig(id)
{
	document.getElementById('digbut'+id).innerHTML = 'sending';
	http.open('get', '/dig.php?i='+id);
    http.onreadystatechange = digResponse;
    http.send(null);
}

function digcom(comment_id,dir,story_id)
{
	http.open('get', '/dig.php?type=comm&i='+comment_id+'&story='+story_id+'&dir='+dir);
	document.getElementById('comd'+comment_id).innerHTML = '---';
    http.onreadystatechange = cdigResponse;
    http.send(null);

	if(1 == 0)
	{
		return;
	}

	if(dir == 0)
	{
		dispcomment(comment_id,false,0);
	}
}

function cacher(id)
{
	http.open('get', '/bury.php?i='+id);
    http.onreadystatechange = buryResponse;
    http.send(null);
}


function dispcomment(id,show,ctype)
{	
	if(ctype == 0)
	{
		if(show)
		{
			document.getElementById('commdesc'+id).style.display = '';
			document.getElementById('commbut'+id).innerHTML = 'commentaire ignoré [<a href="javascript://" onclick="dispcomment('+id+',false,0);">cacher</a>]';
		}
		else
		{
			document.getElementById('commdesc'+id).style.display = 'none';
			document.getElementById('commbut'+id).innerHTML = 'commentaire ignoré [<a href="javascript://" onclick="dispcomment('+id+',true,0);">voir</a>]';
		}
	}
	else if(ctype == 1)
	{
		if(show)
		{
			document.getElementById('commdesc'+id).style.display = '';
			document.getElementById('commbut'+id).innerHTML = 'Below Threshold [<a href="javascript://" onclick="dispcomment('+id+',false,1);">cacher le commentaire</a>]';
		}
		else
		{
			document.getElementById('commdesc'+id).style.display = 'none';
			document.getElementById('commbut'+id).innerHTML = 'Below Threshold [<a href="javascript://" onclick="dispcomment('+id+',true,1);">voir le commentaire</a>]';
		}
	}
}

function forum_back() {
	var ancrs = location.href.split('#forumfoot');
	//alert(ancrs[1]);
	if (ancrs[1] == '' ) { 
		ongletforumfoot(); 
	} 
	else
	{
		if (ScanCookie('position_index') == '1')
		{
			ongletforumfoot();
		}
		
	}

}


function run() {
	setInterval("time()",60000);
	if (ScanCookie('why_foot') == 1) {
		if (location.href != 'http://www.footballistique.com/forum-foot/') {
			forumfoot();
		}
	}
}
function preloadimage() {
	document.write('<img src="/css/idforum.png" alt="" width="0" height="0" /><img src="/images/menu-unhover.png" alt="" width="0" height="0" /><img src="/images/menu.png" alt="" width="0" height="0" /><img src="/forum-foot/ajax/ajax-loader.gif" alt="" width="0" height="0" />');
}
function proposes()
{
	
	if (location.href == 'http://www.footballistique.com/') {
		footballistique();
	}
    var position = 'main';

        document.getElementById(position).innerHTML = '<div style="width: 100%; text-align: center; padding-top: 30px; height:200px;"><img src="/forum-foot/ajax/ajax-loader.gif" height="19" width="220"></div>';
 //load
    var xhr_object = null;
    var position = 'main';
     if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
     else
     if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
 
    xhr_object.open("GET", '/proposes.php', true);
    xhr_object.onreadystatechange = function(){
    if ( xhr_object.readyState == 4 )
    {
        document.getElementById(position).innerHTML = xhr_object.responseText;
		resort();
    }
    }
    xhr_object.send(null);
	return false;
 
}
function cote()
{

    var position = 'cote';
    var xhr_object = null;
	
     if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
     else
     if (window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
 
    xhr_object.open("GET", '/forum-foot/ajax/cotehome.php', true);
    xhr_object.onreadystatechange = function(){
    if ( xhr_object.readyState == 4 )
    {
        document.getElementById(position).innerHTML = xhr_object.responseText;
		resort();
    }
    }
    xhr_object.send(null);
	return false;
 
}

sfHover = function() {
	if (window.attachEvent) {
	var sfEls = document.getElementById("catie").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className="";
		}
	}
	}
}