// Streampower ® 2007
if (!window.mainsite) var mainsite='/';
else mainsite=window.mainsite;

function errorbox(msg, url, linenumber) { return true; }
window.onerror=errorbox;

if(!window.skin) {
	var imgpath = mainsite+'images/';
} else {
	var imgpath = mainsite+'images_skin/' + window.skin + '/';
}
if(window.partenaire && window.partenaire!='') var imgpath = window.partenaire + '/';

function popUp(url,largeur,hauteur,scrolling)
{
  window.open(url,'popup','width=' + largeur + ',height=' + hauteur + ',left='+(Math.round((screen.width-largeur)/2))+',top='+(Math.round((screen.height-hauteur)/2))+',scrollbars='+scrolling);
}

function showBloc(name, num, off, on) {
  	var onglet = eval("document.getElementById('"+name+num+"')");
	var bloc = eval("document.getElementById('"+name+"bloc"+num+"')");

	for (var i=1; i<=20; i++) {
		tmp_onglet = eval("document.getElementById('"+name+i+"')");
		tmp_bloc = eval("document.getElementById('"+name+"bloc"+i+"')");
		if (tmp_onglet) tmp_onglet.className = off;
		if (tmp_bloc) tmp_bloc.style.display = 'none';
	}
	if (onglet) onglet.className = on;
	if (bloc) bloc.style.display = 'block';
	loadImgInNode(bloc);
}


function loadImgInNode(bloc)
{
	for( var x = 0; x < bloc.childNodes.length; x++ )
	{
		if( bloc.childNodes[x].nodeName.toLowerCase() == 'img' )
		{
			var tmp=bloc.childNodes[x].getAttribute('src2');
			if (tmp==null || tmp=='') tmp=bloc.childNodes[x].getAttribute('longdesc');
			if (tmp!=null && tmp!='' && tmp!=bloc.childNodes[x].getAttribute('src'))
			{
				bloc.childNodes[x].src= tmp;
			}
		}
		loadImgInNode(bloc.childNodes[x]);
	}
}

function getObj2(name) {
	if (document.getElementById) {
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}
	else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers) {
		if (document.layers[name]) {
			this.obj = document.layers[name];
			this.style = document.layers[name];
		}
	}
}
var Timer;

function moveLayer(Sens) {
	if(document.getElementById)
		Objet = document.getElementById("Contenu");
	else
		Objet = document.all["Contenu"];
	if(parseInt(Objet.style.top) + (3*Sens) > 0)
		Objet.style.top = "0px";
	else
		Objet.style.top = (parseInt(Objet.style.top) + (3*Sens)) + "px";
	Timer = setTimeout("moveLayer(" + Sens + ");", 40);
}

function affEnvoi() {
	if (document.getElementById('envoi').style.display == 'block') {
		document.getElementById('envoi').style.display = 'none';
	  document.getElementById('texte').style.display = 'block';
	}
	else {
		document.getElementById('texte').style.display = 'none';
		document.getElementById('envoi').style.display = 'block';
    document.forms.envoi_ami.url.value = window.location.href;
	}
}

function verifSendami() {
	var verif=true;
	var msg='';

	if (document.forms.envoi_ami['nom'].value == '' || document.forms.envoi_ami['from'].value == '' || document.forms.envoi_ami.dest.value == '' || document.forms.envoi_ami.email.value == '') {
		msg += 'Tu dois remplir tous les champs pour pouvoir envoyer cet article';
		verif = false;
	}
	else
	{
	  if (!document.forms.envoi_ami['from'].value.match(/^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/i)) {
		  msg += 'Ton email n\'est pas valide<br>';
		  verif = false;
	  }
	  if (!document.forms.envoi_ami.email.value.match(/^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/i)) {
		  msg += 'L\'email de ton ami n\'est pas valide';
		  verif = false;
	  }
	}
   if(msg != '') document.getElementById('mailmessage').style.display = 'block';

   document.getElementById('mailmessage').innerHTML = msg;
   return verif;
}

function verifDesinsc(){
	if (!document.forms.profil.email.value.match(/^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/i)) {
		document.getElementById('mailmessage').innerHTML = 'Votre email n\'est pas valide';
		return false;
	}
	return true;
}


function verifContact() {
	var verif=true;
	var msg='';

	if (document.forms.contact.nom.value == '' || document.forms.contact.prenom.value == '' || document.forms.contact.email.value == '' || document.forms.contact.message.value == '') {
		msg += 'Vous devez remplir tous les champs marqués d\'une étoile';
		verif = false;
	}
	else
	{
	  if (!document.forms.contact.email.value.match(/^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/i)) {
		  msg += 'Votre email n\'est pas valide';
		  verif = false;
	  }
	}

  document.getElementById('mailmessage').innerHTML = msg;
  return verif;
}

function verifFormIns(){
	var verif=true;
	var msg='';
	if (document.forms.profil.nom.value == '' || document.forms.profil.prenom.value == '' || document.forms.profil.email.value == ''  || document.forms.profil.pseudo.value == ''   || document.forms.profil.jour.value == '' || document.forms.profil.mois.value == ''  || document.forms.profil.annee.value == '') {
		msg += 'Vous devez remplir tous les champs marqués d\'une étoile.\n';
		verif = false;
	}else{
	  if (document.getElementById('q').value=='createProfil' && (document.forms.profil.pass.value == '' || document.forms.profil.pass2.value == '' )){
		  msg += 'Vous devez saisir un mot de passe et le confirmer.\n';
		  verif = false;
	  }else if(document.getElementById('q').value=='createProfil' && (document.forms.profil.pass.value!=document.forms.profil.pass2.value)){
		  msg += 'Vos deux mots de passe ne sont pas identiques.\n';
		  verif = false;
	  }
	  if (!document.forms.profil.email.value.match(/^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/i)) {
		  msg += 'Votre email n\'est pas valide.\n';
		  verif = false;
	  }
	  if(!document.profil['optin_cgu'][0].checked){
		  msg += 'Vous n\'avez pas pris connaissance de la notice légale et la charte de modération de sportweekfoot.fr.\n';
		  verif = false;
	  }
	  if ( document.forms.profil.pays_iso.value=='FR' && !document.forms.profil.cp.value.match(/^[0-9]{4,5}$/i)) {
		  msg += 'Votre code postal n\'est pas valide.\n';
		  verif = false;
	  }
	  if ( document.forms.profil.code.value=='') {
		  msg += 'Votre n\'avez pas recopié le code.\n';
		  verif = false;
	  }
	}
	if(msg!='') alert(msg);
	return verif;
}

function switchContact() {
	document.forms.contact.destinataire.value = document.getElementById('contact').value;
  document.forms.contact.url.value = window.location.href;
}

function replaceAll(oldStr,findStr,repStr) {
  var srchNdx = 0;
  var newStr = "";
  while (oldStr.indexOf(findStr,srchNdx) != -1)
  {
    newStr += oldStr.substring(srchNdx,oldStr.indexOf(findStr,srchNdx));
    newStr += repStr;
    srchNdx = (oldStr.indexOf(findStr,srchNdx) + findStr.length);
  }
  newStr += oldStr.substring(srchNdx,oldStr.length);
  return newStr;
}

function getCookieVal(offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	var noms = unescape(document.cookie.substring(offset, endstr));
	noms=replaceAll(noms, '+', ' ');
	return noms;
}
function GetCookie(name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function SetCookie(name, value)
{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);

   return output;
}

/* content actions */
function comments() {
	var div = document.getElementById("commenter");
	if (!div)
	{
		alert('Impossible de commenter cet article.');
		return;
	}
	document.getElementById("commenter").style.display = "block";
	document.getElementById("envoi").style.display = "none";
	document.getElementById("bloguer").style.display = "none";
	location.href='#commentform';
}

function displayHeaderBlog(id_content){
	var identifiant=GetCookie('my_identifiant');
	var div = document.getElementById("bloguer");
	if( ((identifiant=='') || (identifiant==null)) /*&& (div.style.display == 'none')*/ ){
		document.getElementById("blog_entete").innerHTML = "Pour publier automatiquement ce contenu, <a href=\"/dynamic/profil.php?q=identif&destination="+encode64(location.href)+"#blogform\" target=\"_top\">vous devez vous identifier</a>";
		if (!div)
		{
			alert('Impossible de publier cet article sur votre blog.');
			return;
		}
	}else{
		loadXMLDocGeneric('/dynamic/web.php?q=blog_ajax&article='+escape(id_content)+'&destination='+encode64(location.href), 'innerHTML', 'text/html', 'blog_entete', '');
		if (!div)
		{
			alert('Impossible de publier cet article sur votre blog.');
			return;
		}
	}
}

function blogme(id){
	var div = document.getElementById("bloguer");

	if(div.style.display == 'none') div.style.display = "block";
	else div.style.display = "none";
	document.getElementById("envoi").style.display = "none";
	document.getElementById("commenter").style.display = "none";
	location.href='#blogform';
	displayHeaderBlog(id);
}

function blogAuto(id_content, id_blog){
	if (id_content)
	{
		document.getElementById('blog_entete').innerHTML = "Veuillez patienter...";
		loadXMLDocGeneric('/dynamic/web.php?q=blog_auto&article='+escape(id_content)+'&id_blog='+escape(id_blog), 'innerHTML', 'text/html', 'blog_entete', '');
	}
}

function sendbymail() {
	var div = document.getElementById("envoi");
	if(div.style.display == 'none') div.style.display = "block";
	else div.style.display = "none";
	document.getElementById("bloguer").style.display = "none";
	location.href='#sendfriendform';
}

function rating(id_content, val) {
	if(GetCookie('my_vote')!=null){
		var tableau = GetCookie('my_vote').split(';');
		var trouve=false;
		for(var i=0;(!trouve)&&(i<tableau.length);i++){
			if(tableau[i]==id_content)	trouve=true;
		}
		if(trouve)	document.getElementById('content_rating').innerHTML='d&eacute;j&agrave; not&eacute;';
		else loadXMLDocGeneric('/dynamic/web.php?q=rating&id_contenu='+escape(id_content)+'&type=1&rank='+escape(val), 'Rating', 'text/html', 'content_rating', 'content_avg_rating');
	}
	else loadXMLDocGeneric('/dynamic/web.php?q=rating&id_contenu='+escape(id_content)+'&type=1&rank='+escape(val), 'Rating', 'text/html', 'content_rating', 'content_avg_rating');
}

function digit(id_content) {
	if(GetCookie('my_vote')!=null){
		var tableau = GetCookie('my_vote').split(';');
		var trouve=false;
		for(var i=0;(!trouve)&&(i<tableau.length);i++){
			if(tableau[i]==id_content)	trouve=true;
		}
		if(trouve)	document.getElementById('buzz_rating'+id_content).innerHTML='<span style="font-size:9px;line-height:8px;">déjà voté</span>';
		else loadXMLDocGeneric('/dynamic/web.php?q=rating&id_contenu='+escape(id_content)+'&type=2', 'innerHTML', 'text/html', 'buzz_rating'+id_content, '');
	}
	else loadXMLDocGeneric('/dynamic/web.php?q=rating&id_contenu='+escape(id_content)+'&type=2', 'innerHTML', 'text/html', 'buzz_rating'+id_content, '');
}

function digJeuPhoto(id) {
	//var identifiant=GetCookie('my_identifiant');
	//if( (identifiant=='') || (identifiant==null) ){
	//	location.href='/dynamic/profil.php?q=identif&destination='+encode64(location.href);
	//}else{
		var myjeuphoto=GetCookie('my_jeuphoto');
		if(GetCookie('my_jeuphoto')!=null){
			var tableau = GetCookie('my_jeuphoto').split(';');
			var trouve=false;
			for(var i=0;(!trouve)&&(i<tableau.length);i++){
				if(tableau[i]==id)	trouve=true;
			}
			if(trouve)	document.getElementById('jeu_photo'+id).innerHTML='<span style="font-size:9px;">déjà voté</span>';
			else loadXMLDocGeneric('/dynamic/web.php?q=jeuphotoDig&id_participation='+escape(id), 'innerHTML', 'text/html', 'jeu_photo'+id, '');
		}
		else loadXMLDocGeneric('/dynamic/web.php?q=jeuphotoDig&id_participation='+escape(id), 'innerHTML', 'text/html', 'jeu_photo'+id, '');
	//}
}

function commenter(id_content, anonyme){
	var commentaire=document.getElementById('commentaire').value;
	loadXMLDocGeneric('/dynamic/web.php?q=commentaire_ins_ajax&article='+escape(id_content)+'&commentaire='+escape(commentaire), 'CommentsIns', 'text/html', 'comment_results', 'comment_form');
	//if(anonyme==0){
		//loadXMLDocGeneric('/dynamic/web.php?q=commentaire_ins_ajax&article='+escape(id_content)+'&commentaire='+escape(commentaire)+'&anonyme=0', 'CommentsIns', 'text/html', 'comment_results', 'comment_form');
	/*
	}
	else{
		var comm_code=document.getElementById('comm_code').value;
		loadXMLDocGeneric('/dynamic/web.php?q=commentaire_ins_ajax&article='+escape(id_content)+'&commentaire='+escape(commentaire)+'&code='+escape(comm_code)+'&anonyme='+escape(anonyme), 'CommentsIns', 'text/html', 'comment_results', 'comment_form');
	}
	*/
}

function repondreSondage(id_sondage,options){
	var trouve=false;
	var reponse='';
	for(var i=0;(!trouve)&&(i<options.length);i++){
		if(trouve=options[i].checked)
		reponse=options[i].value;
	}
	if (trouve==false){
		alert('il faut choisir une réponse');
		return false;
	}
	loadXMLDocGeneric('/dynamic/web.php?q=answer_poll&id_sondage='+escape(id_sondage)+'&reponse='+escape(reponse), 'innerHTML', 'text/html', 'sondage_'+id_sondage,'');
}

function repondreSondage2(id_sondage,options,url){
	var trouve=false;
	var reponse='';
	for(var i=0;(!trouve)&&(i<options.length);i++){
		if(trouve=options[i].checked)
		reponse=options[i].value;
	}
	if (trouve==false){
		alert('il faut choisir une réponse');
		return false;
	}
	loadXMLDocGeneric('/dynamic/web.php?q=answer_poll&id_sondage='+escape(id_sondage)+'&reponse='+escape(reponse), 'Javascript', 'text/html', 'location.href="'+url+'"','');
}

function loadSondage(id_sondage){
	if(GetCookie('my_poll')!=null){
		var tableau = GetCookie('my_poll').split(';');
		var trouve=false;
		for(var i=0;(!trouve)&&(i<tableau.length);i++){
			if(tableau[i]==id_sondage)	trouve=true;
		}
		if (trouve){
			document.getElementById('sondage_'+id_sondage).style.display='none';
			document.getElementById('resultat_'+id_sondage).style.display='block';
		}else{
			document.getElementById('sondage_'+id_sondage).style.display='block';
			document.getElementById('resultat_'+id_sondage).style.display='none';
		}
	}
}

function printpage(url) {
	url=url.split('#');
	var w=window.open(url[0].replace('.html', 'p.html'), '_blank');
}

function sendFriend(){
	var id_article = document.getElementById('sendfriend_id_article').value;
	var url = document.getElementById('sendfriend_url').value;
	var nom = document.getElementById('sendfriend_nom').value;
	var from = document.getElementById('sendfriend_from').value;
	var dest = document.getElementById('sendfriend_dest').value;
	var email = document.getElementById('sendfriend_email').value;
	var message = document.getElementById('sendfriend_message').value;
	if ((nom=='')||(nom==null)||(nom==undefined) || (from=='')||(from==null)||(from==undefined)|| (dest=='')||(dest==null)||(dest==undefined)|| (email=='')||(email==null)||(email==undefined)|| (message=='')||(message==null)||(message==undefined))
	{
		alert('Veuillez remplir tous les champs');
		return false;
	}
	else
	{
		loadXMLDocGeneric('/dynamic/web.php?q=sendfriend&id_article='+escape(id_article)+'&url='+escape(url)+'&nom='+escape(nom)+'&from='+escape(from)+'&dest='+escape(dest)+'&email='+escape(email)+'&message='+escape(message), 'SendFriend', 'text/html', 'sendfriends_results', 'envoi');
		return true;
	}
}

function contact(){
	var civ = document.getElementById('civ').value;
	var nom = document.getElementById('nom').value;
	var prenom = document.getElementById('prenom').value;
	var age = document.getElementById('age').value;
	var cp = document.getElementById('cp').value;
	var ville = document.getElementById('ville').value;
	var email = document.getElementById('email').value;
	var message = document.getElementById('message').value;
	var sujet = document.getElementById('sujet').value;

	loadXMLDocGeneric('/dynamic/web.php?q=contact&civ='+escape(civ)+'&sujet='+escape(sujet)+'&nom='+escape(nom)
		+'&prenom='+escape(prenom)+'&age='+escape(age)+'&cp='+escape(cp)+'&ville='+escape(ville)
		+'&email='+escape(email)+'&message='+escape(message), 'Contact', 'text/html', 'contact_results', '');
}

/* Live scores pour foot par défaut */
var scores_page='cla';
var scores_item='FRAL1';
var scores_onglet1='scores_page2';
var scores_onglet2='scores_item1';
function loadlivescore1(page, obj){
	window.scores_page=page;

	document.getElementById('live_corps').innerHTML='Chargement en cours...';
	loadXMLDocGeneric('/dynamic/web.php?q=all_livescores_foot&page='+escape(window.scores_page)+'&item='+escape(window.scores_item), 'livebloc', 'text/html', 'live_corps', '');

	for(var n=1; document.getElementById('scores_page'+n); n++)
	{
		if ('scores_page'+n==obj)
		{
			document.getElementById('scores_page'+n+'b').className="btn_gch";
			document.getElementById('scores_page'+n).className="btn_dte";
		}
		else
		{
			document.getElementById('scores_page'+n+'b').className="btn_gch_off";
			document.getElementById('scores_page'+n).className="btn_dte_off";
		}
	}
}
function loadlivescore2(item, obj){
	if (!item)
	{
		item=window.scores_item;
		obj=window.scores_onglet2;


		document.getElementById(window.scores_onglet1+'b').className="btn_gch";
		document.getElementById(window.scores_onglet1).className="btn_dte";
	}
	window.scores_item=item;

	document.getElementById('live_corps').innerHTML='Chargement en cours...';
	loadXMLDocGeneric('/dynamic/web.php?q=all_livescores_foot&page='+escape(window.scores_page)+'&item='+escape(window.scores_item), 'livebloc', 'text/html', 'live_corps', '');
	for(var n=1; document.getElementById('scores_item'+n); n++)
	{
		if ('scores_item'+n==obj) document.getElementById('scores_item'+n).className="btn_on";
		else document.getElementById('scores_item'+n).className="btn";
	}


}
/* fin live scores */

/*begin fonctions scores BHV*/
var bhvscores_page='live';
var bhvscores_item='BASK';
var bhvscores_onglet1='bhvscores_page1';
var bhvscores_onglet2='bhvscores_item1';
function bhvloadlivescore1(page, obj){
	window.bhvscores_page=page;
	document.getElementById('bhvlive_corps').innerHTML='Chargement en cours...';
	loadXMLDocGeneric('/dynamic/web.php?q=all_livescores_bhv&page='+escape(window.bhvscores_page)+'&item='+escape(window.bhvscores_item), 'innerHTML', 'text/html', 'bhvlive_corps', '');
	for(var n=1; document.getElementById('bhvscores_page'+n); n++)
	{
		if ('bhvscores_page'+n==obj) document.getElementById('bhvscores_page'+n).className="btn_on";
		else document.getElementById('bhvscores_page'+n).className="btn";
	}
}

function bhvloadlivescore2(item, obj){
	if (!item)
	{
		item=window.bhvscores_item;
		obj=window.bhvscores_onglet2;

		document.getElementById(window.bhvscores_onglet1).className="btn_on";
	}
	window.bhvscores_item=item;
	document.getElementById('bhvlive_corps').innerHTML='Chargement en cours...';
	loadXMLDocGeneric('/dynamic/web.php?q=all_livescores_bhv&page='+escape(window.bhvscores_page)+'&item='+escape(window.bhvscores_item), 'innerHTML', 'text/html', 'bhvlive_corps', '');
	for(var n=1; document.getElementById('bhvscores_item'+n); n++)
	{
		if ('bhvscores_item'+n==obj)
		{
			document.getElementById('bhvscores_item'+n+'b').className="btn_gch";
			document.getElementById('bhvscores_item'+n).className="btn_dte";
		}
		else
		{
			document.getElementById('bhvscores_item'+n+'b').className="btn_gch_off";
			document.getElementById('bhvscores_item'+n).className="btn_dte_off";
		}

	}
}
/*end fonctions scores BHV*/


function noaccent(str) {
	str = str.replace(/[àâä]/gi,"a");
	str = str.replace(/[éèêë]/gi,"e");
	str = str.replace(/[îï]/gi,"i");
	str = str.replace(/[ôö]/gi,"o");
	str = str.replace(/[ùûü]/gi,"u");
	return str;
}

function freesearch()
{
	var tag=document.getElementById('freesearch').value;
	tag=replaceAll(tag, ' ', '-');
	if (tag!='') location.href=mainsite+'recherche/'+escape(tag);
	return;
}

/* AJAX GENERIC */
var req = false;
function loadXMLDocGeneric(url, typeaction, mimetype, cible1, cible2)
{
	if (window.req!=false)
	{
		if (window.req.abort) window.req.abort();
		window.req=null;
		window.req=false;
	}

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		window.req = new XMLHttpRequest();
		if (window.req.overrideMimeType) {
			window.req.overrideMimeType(mimetype);
		}
	} else if (window.ActiveXObject) { // IE
		try {
			window.req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				window.req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!window.req) {
		alert('Abandon :( Impossible de créer une instance XMLHTTP');
		return false;
	}

	window.req.onreadystatechange = function() { processReqChangeGeneric(typeaction,cible1,cible2); };
	window.req.open('GET', url, true);
	window.req.send(null);
}

function processReqChangeGeneric(typeaction, cible1, cible2) {
	if (window.req.readyState == 4)
	{
		if (window.req.status == 200)
		{
			if (typeaction=='innerHTML' && document.getElementById(cible1))
			{
				document.getElementById(cible1).innerHTML = req.responseText;
			}
			else if (typeaction=='CommentsIns')
			{
				var tableau = new Array();
				if (document.getElementById(cible1))
				{
					tableau = req.responseText.split(';');
					if (tableau[0]==1){
						document.getElementById(cible2).style.display='none';
					}
					document.getElementById(cible1).innerHTML = tableau[1];
					document.getElementById('commentaire').value = '';
				}
			}
			else if (typeaction=='SendFriend')
			{
				var tableau = new Array();
				if (document.getElementById(cible1))
				{
					tableau = req.responseText.split(';');
					if (tableau[0]==1){
						document.getElementById(cible2).style.display='none';
					}
					document.getElementById(cible1).innerHTML = tableau[1];
				}
			}
			else if (typeaction=='Rating')
			{
				var tableau = new Array();
				if (document.getElementById(cible1) && document.getElementById(cible2))
				{
					tableau = req.responseText.split('|');
					if (tableau[0]=='1'){
						document.getElementById(cible1).innerHTML = tableau[1];
						document.getElementById(cible2).innerHTML = tableau[2];
					}
					else document.getElementById(cible1).innerHTML = tableau[1];
				}
			}
			else if (typeaction=='Contact')
			{
				var tableau = new Array();
				if (document.getElementById(cible1))
				{
					tableau = req.responseText.split(';');
					document.getElementById(cible1).innerHTML = tableau[1];
					document.getElementById('nom').value = '';
					document.getElementById('prenom').value = '';
					document.getElementById('age').value = '';
					document.getElementById('civ').value = '';
					document.getElementById('cp').value = '';
					document.getElementById('ville').value = '';
					document.getElementById('email').value = '';
					document.getElementById('message').value = '';
				}
			}
			else if (typeaction=='Alert')
			{
				alert(window.req.responseText);
			}
			else if (typeaction=='Javascript')
			{
				eval(cible1);
			}
			else if (typeaction=='livebloc')
			{
				document.getElementById(cible1).innerHTML = req.responseText;

				// Onglet live si besoin
				var showbloc=false;
				if(window.scores_item=='FRAL1' && req.responseText.indexOf('en cours')!=-1)
				{
					showbloc=true;
				}
				if(location.href.indexOf('liveon')>0)
				{
					showbloc=true;
				}
				if (showbloc)
				{
					var trnode=document.getElementById('tabhoriz').getElementsByTagName('tr').item(0);
					var pos=trnode.getElementsByTagName('td').item(trnode.getElementsByTagName('td').length-2);

					if (pos.getAttribute('id')!='catlive')
					{
						var tdnode= document.createElement('td');
						tdnode.setAttribute('class','top_categories');
						tdnode.setAttribute('align','center');
						tdnode.setAttribute('id','catlive');
						var anode= document.createElement('a');
						anode.setAttribute('href','javascript:popUp(\'http://livefootball.myfreesport.fr/?im=1\', 800, 620, \'no\');');
						tdnode.appendChild(anode);
						var imgnode= document.createElement('img');
						imgnode.setAttribute('src','/images_skin/default/live_anime.gif');
						imgnode.setAttribute('alt','LIVE');
						imgnode.setAttribute('border','0');
						anode.appendChild(imgnode);
						trnode.insertBefore(tdnode,pos.nextSibling);
					}
				}
			}
			else if(typeaction=='login'){
				var tableau = new Array();
				if (document.getElementById(cible1))
				{
					tableau = req.responseText.split(';');
					if (tableau[0]==0)	document.getElementById(cible1).innerHTML = tableau[1];
					else if (tableau[0]==1)	{
						window.document.location.reload();
					}
				}
			}
			else if(typeaction=='addTag'){
				var tableau = new Array();
				tableau = req.responseText.split(';');
				if (tableau[0]==1) {
					document.getElementById(cible1).innerHTML = tableau[1];
					var tableau1 = new Array();
					tableau1 = tableau[2].split('|');
					if(document.getElementById('alerte_tag_ids').value!=""){
						var tableau2 = new Array();
						tableau2 = document.getElementById('alerte_tag_ids').value.split(';');
						var trouve=false;
						for(var i=0;i<tableau2.length && trouve==false;i++){
							if(tableau2[i]==tableau1[0]) trouve=true;
						}
						if(trouve==false){
							var taille=document.getElementById('alerte_tag_labels').options.length;
							var option0 = new Option(tableau1[1], tableau1[0]);
							document.getElementById('alerte_tag_labels')[taille]=option0;
							document.getElementById('alerte_tag_ids').value+=";"+tableau1[0];
						}
					}
					else{
						var taille=document.getElementById('alerte_tag_labels').options.length;
						var option0 = new Option(tableau1[1], tableau1[0]);
						document.getElementById('alerte_tag_labels')[taille]=option0;
						document.getElementById('alerte_tag_ids').value=tableau1[0];
					}
				}else{
					document.getElementById(cible1).innerHTML = tableau[1];
				}
			}
		}
		else
		{

		}
		window.req.abort();
		window.req=null;
		window.req=false;
	}
}
/* */

function allcomments(myid)
{
	loadXMLDocGeneric('/dynamic/web.php?q=all_comments&id_article='+escape(myid), 'innerHTML', 'text/html', 'commentslist', '');
	if (document.getElementById('btallcomments')) document.getElementById('btallcomments').innerHTML='';
}

function openCommentForm()
{
	if(location.href.search(/#commentform/)!=-1){
		var div = document.getElementById("commenter");
		if(div && div.style.display == 'none') div.style.display = "block";
	}
}
function openBlogForm(id_content)
{
	if(location.href.search(/#blogform/)!=-1){
		var div = document.getElementById("bloguer");
		if(div && div.style.display == 'none') div.style.display = "block";
		displayHeaderBlog(id_content);
	}
}

var t="";
var id_courant="";
var mActif="";
var mActif2="";
function showsubmenu(id_arbo,topWidth,obj) {
  if(document.getElementById("subsubmenu"+id_arbo)) {
    if(id_courant==id_arbo) clearTimeout(t);
    else if(id_courant!="" && document.getElementById("subsubmenu"+id_arbo)) {
      if (document.getElementById("subsubmenu"+id_courant)) document.getElementById("subsubmenu"+id_courant).style.display="none";
      if(obj != mActif) {
        if (mActif.className.substr((mActif.className.length-6), 6) == '_actif') mActif.className = mActif.className.substr(0, (mActif.className.length-6));
      }
    }
    id_courant=id_arbo;
      if(obj) {
        if (obj.className.substr((obj.className.length-6), 6) != '_actif') obj.className=obj.className+"_actif";
        mActif=obj;
      }
      if(topWidth) document.getElementById("subsubmenu"+id_arbo).style.marginTop=topWidth+"px";
      document.getElementById("subsubmenu"+id_arbo).style.display="block";
      if (!z) z=20;
      document.getElementById("subsubmenu"+id_arbo).style.zIndex=z+1;
  }
	else{
		if(obj) {
			hidesubmenu(id_courant);
			if (obj.className.substr((obj.className.length-6), 6) != '_actif') obj.className=obj.className+"_actif";
			mActif2=obj;
     }
	}
}
function onmouseoutmenu(){
	if (mActif2.className.substr((mActif2.className.length-6), 6) == '_actif') mActif2.className = mActif2.className.substr(0, (mActif2.className.length-6));
}
function hidesubmenu(id_arbo) {
  if(document.getElementById("subsubmenu"+id_arbo)) {
    document.getElementById("subsubmenu"+id_arbo).style.display="none";
    if (mActif.className.substr((mActif.className.length-6), 6) == '_actif') mActif.className = mActif.className.substr(0, (mActif.className.length-6));
  }
}
function hidesubmenu2(id_arbo) {
  clearTimeout(t);
  window.t=setTimeout('hidesubmenu('+id_arbo+')',500);
}


var t="";
var id_courantSub="";
var mSubActif="";
function showsubmenuV2(id_arbo,idSub) {
	if(document.getElementById("subsubmenu"+id_arbo) && idSub==null ) {
		var obj = document.getElementById("subsubmenu"+id_arbo);
		if(mSubActif!="") {
			if (mSubActif.className.substr((mSubActif.className.length-6), 6) == '_actif') mSubActif.className = mSubActif.className.substr(0, (mSubActif.className.length-6));
			mSubActif="";
		}
		if(id_courant==id_arbo) clearTimeout(t);
		else if(id_courant!="" && document.getElementById("subsubmenu"+id_arbo)) {
			if(obj != mActif) {
				if (mActif.className.substr((mActif.className.length-6), 6) == '_actif') mActif.className = mActif.className.substr(0, (mActif.className.length-6));
			}
		}
		id_courant=id_arbo;
		if(obj) {
			if (obj.className.substr((obj.className.length-6), 6) != '_actif') obj.className=obj.className+"_actif";
			mActif=obj;
		}
	}
	else if(document.getElementById("subsubmenu"+id_arbo) && idSub!=null ) {
		var obj = document.getElementById("subsubmenu"+idSub);
		if(id_courantSub==idSub) clearTimeout(t);
		else if(id_courantSub!="" && document.getElementById("subsubmenu"+idSub)) {
			if(obj != mSubActif && mSubActif!="") {
				if (mSubActif.className.substr((mSubActif.className.length-6), 6) == '_actif') mSubActif.className = mSubActif.className.substr(0, (mSubActif.className.length-6));
			}
		}
		id_courantSub=idSub;
		if(obj) {
			if (obj.className.substr((obj.className.length-6), 6) != '_actif') obj.className=obj.className+"_actif";
			mSubActif=obj;
		}
	} else { alert("else"); }
	/*else{
		if(obj) {
			if(idSub) hidesubmenu(id_courant,idSub);
			else hidesubmenu(id_courant,null);
			if (obj.className.substr((obj.className.length-6), 6) != '_actif') obj.className=obj.className+"_actif";
			mActif2=obj;
		}
	}*/
}
function hidesubmenuV2(id_arbo,idSub) {
	if(document.getElementById("subsubmenu"+id_arbo)) {
		if (mActif.className.substr((mActif.className.length-6), 6) == '_actif') mActif.className = mActif.className.substr(0, (mActif.className.length-6));
	}
	if(idSub && document.getElementById("subsubmenu"+idSub)) {
		if (mSubActif.className.substr((mSubActif.className.length-6), 6) == '_actif') mSubActif.className = mSubActif.className.substr(0, (mSubActif.className.length-6));
	}
}
function hidesubmenu2V2(id_arbo,idSub) {
	clearTimeout(t);
	window.t=setTimeout('hidesubmenuV2('+id_arbo+','+idSub+')',500);
}


function FullScreen(arg){
	if(document.getElementById("video_fullscreen").style.display=="none"){
		document.getElementById("video_fullscreen").innerHTML = document.getElementById("videoplayer").innerHTML;
		if(window.innerWidth) document.getElementById("video_fullscreen").style.width = window.innerWidth+"px";
		else document.getElementById("video_fullscreen").style.width = (screen.width-22)+"px";
		if (window.innerHeight && window.innerHeight!='undefined') document.getElementById("video_fullscreen").style.height = window.innerHeight+"px";
		else document.getElementById("video_fullscreen").style.height = (screen.height-160)+"px";
		document.getElementsByTagName("table")[0].style.display = "none";
		document.getElementById("video_fullscreen").style.display = "block";
	}
	else{
		document.getElementById("video_fullscreen").innerHTML = "";
		document.getElementById("video_fullscreen").style.display = "none";
		document.getElementsByTagName("table")[0].style.display = "block";
	}
}

var image_curr='';

function hasloaded(image,wintop,largeur,hauteur){
  if(hauteur-image.height>0){
    var posh=wintop+(hauteur-image.height)/2;
  }else{
    var posh=wintop+10;
  }
  if(largeur-image.width>0){
    var posl=(largeur-image.width)/2;
  }
  else{
    var posl=10;
  }
  var img1 = '<img src="/images/shadow.png" border="0" width="10" height="'+image.height+'" class="png" alt="" />';
  var img2 = '<img src="/images/shadow_bottom.png" border="0" width="'+image.width+'" height="10" class="png" alt="" />';
  var img3 = '<img src="/images/shadow_corner.png" border="0" width="10" height="10" class="png" alt="" />';
	if((image_curr!='') && (image_curr!=image.src) && (document.getElementById("fullimage").style.display=="block"))
  {
    document.getElementById("fullimage").innerHTML = "";
    document.getElementById("fullimage").style.display = "none";
    document.getElementById("fullimage").style.top = posh+"px";
    document.getElementById("fullimage").style.left = posl+"px";
    document.getElementById("fullimage").innerHTML = "<div class=\"dropshadow2\"><div class=\"dropshadow2\"><a href=\"javascript:FullImage('"+image.src+"')\"><img title=\"Fermer\" alt=\"Fermer\" src=\""+image.src+"\" width="+image.width+" height="+image.height+" border=\"0\" /></a>"+img1+"</div>"+img2+""+img3+"</div>";
    document.getElementById("fullimage").style.display = "block";
    document.getElementById("fullimage").style.zIndex = 101000;

  }else if(document.getElementById("fullimage").style.display=="none"){
    document.getElementById("fullimage").style.top = posh+"px";
    document.getElementById("fullimage").style.left = posl+"px";
    document.getElementById("fullimage").innerHTML = "<div class=\"dropshadow2\"><div class=\"dropshadow2\"><a href=\"javascript:FullImage('"+image.src+"')\"><img title=\"Fermer\" alt=\"Fermer\" src=\""+image.src+"\" width="+image.width+" height="+image.height+" border=\"0\" /></a>"+img1+"</div>"+img2+""+img3+"</div>";
    document.getElementById("fullimage").style.display = "block";
    document.getElementById("fullimage").style.zIndex = 500000;
  }else{
    document.getElementById("fullimage").innerHTML = "";
    document.getElementById("fullimage").style.display = "none";
  }
  image_curr=image.src;
}

function FullImage(arg){
	var wintop=10;
	if (navigator.appName=='Opera') { //IE5
		var wintop=parseInt(document.body.scrollTop);
		var hauteur=document.body.clientHeight;
		var largeur=document.body.clientWidth;
	}
	else if ((document.getElementById) && (!document.all)) { //NS6
		var wintop=parseInt(window.pageYOffset);
		var hauteur=window.innerHeight;
		var largeur=window.innerWidth;
	}
	else if ((document.getElementById) && (document.all)) { //IE6
		var wintop=parseInt(document.documentElement.scrollTop);
		var hauteur=document.documentElement.clientHeight;
		var largeur=document.documentElement.clientWidth;
	}
	else if (document.getElementById) { //IE5
		var wintop=parseInt(document.body.scrollTop);
		var hauteur=document.body.clientHeight;
		var largeur=document.body.clientWidth;
	}
	var image=new Image;
	image.src=arg;
	if(!image.complete)		image.onload = function(){hasloaded(this,wintop,largeur,hauteur)};
	else hasloaded(image,wintop,largeur,hauteur);
}

function diapoMove(num){
	debut='<p class="spArtImgLegend spCenter">';
	milieu=num+1+"/"+photos_diapo.length;
	fin = "";
	fin2 = "";
	if(num!=0)	fin += '<a href="javascript:diapoMove('+(num-1)+')"><img src="/images/btn_precedent.gif" border="0" alt="précédente" /></a>';
	if(num!=(photos_diapo.length-1))	fin2 = '<a href="javascript:diapoMove('+(num+1)+')"><img src="/images/btn_suivant.gif" border="0" alt="suivante" /></a>';
	if (photos_diapo[num][2]==''){
		document.getElementById("diaporama").innerHTML = '<img src="/commun/n260x195/'+photos_diapo[num][0]+'" border="0" alt="" class="contour2" />'+debut+'<span class="spArtImgBtnR">'+fin2+'</span><span class="spArtImgBtnL">'+fin+'</span>'+milieu+'<br/></p><p class="spArtImgLegend">'+photos_diapo[num][1]+'</p>';
	}else{
		document.getElementById("diaporama").innerHTML = '<a href="'+photos_diapo[num][2]+'" ><img src="/commun/n260x/'+photos_diapo[num][0]+'" border="0" alt="" title="cliquer pour agrandir la photo" class="contour2" /></a>'+debut+'<span class="spArtImgBtnR">'+fin2+'</span><span class="spArtImgBtnL">'+fin+'</span>'+milieu+'<br/></p><p class="spArtImgLegend">'+photos_diapo[num][1]+'</p>';
	}
}

function switchResult(num, mode) {
  var listes=new Array();
  listes[0] = new Array("articles", "videos","flash_news");
  listes[1] = new Array("block", "none", "none");
  listes[2] = new Array("none", "block", "none");
  listes[3] = new Array("none", "none", "block");

  if (mode!=true && num==3 && location.href.indexOf('/page')!=-1)
  {
  	location.href='.?1';
  	return;
  }
  if (mode!=true && num==2 && location.href.indexOf('/page')!=-1)
  {
  	location.href='.?4';
  	return;
  }

  for(var i=0; i<listes[0].length; i++) {
    liste = eval('document.getElementById("liste_'+listes[0][i]+'")');
    onglet = eval('document.getElementById("onglet_'+listes[0][i]+'")');
    liste.style.display = listes[num][i];
    var etat_onglet = "";
    if (listes[num][i]=="none") etat_onglet = "_off";
		onglet.className = (listes[num][i]=="none")?"lien3":"style1";
		onglet.parentNode.className = 'onglet_gch'+etat_onglet;
	  onglet.parentNode.parentNode.className = 'onglet_dte'+etat_onglet;
  }
}


function switchCategorie(num, nbmax, mode){

  if (mode==true && location.href.indexOf('/page')!=-1){
	location.href='.?'+num;
	return;
  }

  for(var i=1; i<=nbmax; i++) {
    liste = eval('document.getElementById("liste_categorie_'+i+'")');
    onglet = eval('document.getElementById("onglet_categorie_'+i+'")');
		if(i==num) liste.style.display = "block";
		else liste.style.display = "none";
	    var etat_onglet = "";

	    if(i!=num) etat_onglet = "_off";
		onglet.className = 'jeu_photo_onglet'+etat_onglet;
  }

}

	var startSize = "";
	function textSize(valeur) {
		if (startSize=="") {
			startSize = parseInt(document.getElementById('articleMain').style.fontSize);
			if(isNaN(startSize) == true) {
				startSize = 12;
				document.getElementById('articleMain').style.fontSize = "12px";
			}
		}
		var size = parseInt(document.getElementById('articleMain').style.fontSize.substr(0, 2));
		if (valeur<0 && size > startSize)
			document.getElementById('articleMain').style.fontSize = parseInt(document.getElementById('articleMain').style.fontSize.substr(0, 2)) + valeur + "px";
		else if (valeur>0 && size <= 24)
			document.getElementById('articleMain').style.fontSize = parseInt(document.getElementById('articleMain').style.fontSize.substr(0, 2)) + valeur + "px";
	}

function createFlash(largeur, hauteur, haut, gauche, mode, fond, couleur, duree)
{
  window.intermode=mode;
	if (mode == 2) {
		if(window.innerWidth) {
			var hauteur = Math.round(hauteur*(window.innerWidth/largeur));
			var largeur = window.innerWidth;
		}	else {
			var hauteur = Math.round(hauteur*(document.body.clientWidth/largeur));
			var largeur = document.body.clientWidth;
		}
	}

	document.write('<div id="intersticiel" style="z-index:99;position:absolute;display:block;top:' + haut + 'px;left:' + gauche + 'px;padding:0;margin:0; background-color:' + couleur + '"><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&amp;promoid=BIOW" target="_blank"><img src="/images/flash_player.png" alt="Installer flash player !" border="0" /></a></div>');
  var so1 = new SWFObject("/swf/fh.swf", "flashhomeint", largeur, hauteur, "8", couleur, true);
    so1.addParam("quality", "High");
    so1.addParam("menu", "false");
    so1.addParam("bgcolor", couleur);
    so1.addParam("WMODE", fond);
		so1.addVariable('n', 1);
		so1.addVariable('path_xml', 'xml/fh.xml');
		so1.addVariable('nav', 1);
		so1.addVariable('mode', 'inter');
		so1.addVariable('swf_wid', largeur);
		so1.addVariable('swf_hei', hauteur);
    so1.setAttribute('xiRedirectUrl', location.href);
    so1.addVariable('feedXmlUrl', '/dynamic/rss_mea.php?id_arbo={ARBO_ID_ARBO}');
 	  so1.write("intersticiel");

	if (window.intermode == 3) {
		document.getElementById('intersticiel').style.top = '50%';
		document.getElementById('intersticiel').style.left = '50%';

		if(document.getElementById('embInterst') && document.getElementById('embInterst').height) {
			document.getElementById('intersticiel').style.marginTop = "-" + hauteur/2 + "px";
			document.getElementById('intersticiel').style.marginLeft = "-" + largeur/2 + "px";
		} else {
			document.getElementById('intersticiel').style.marginTop = "-" + hauteur/2 + "px";
			document.getElementById('intersticiel').style.marginLeft = "-" + largeur/2 + "px";
		}
	}
	setTimeout(removeFlash, duree);
}
function removeFlash()
{
	document.getElementById('intersticiel').innerHTML = "";
}

var id_themes='';

function updateThemes(){
	id_themes='';
	var themes=document.getElementsByName("themes");
	for(var i=0;i<themes.length;i++){
		if(themes[i].checked == true){
			if (id_themes=='') id_themes+=themes[i].value;
			else id_themes+=';'+themes[i].value;
		}
	}
	getProgramme();
}

function checkAll(field,state){
	var fields=document.getElementsByName(field);
	for (i = 0; i < fields.length; i++) {
		fields[i].checked = state;
	}
}

function getProgramme(){
	var id_articles='';
	if(document.getElementById('candidats_1').value!='') id_articles+=document.getElementById('candidats_1').value;
	if(document.getElementById('candidats_2').value!=''){
		if(id_articles=='')	id_articles += document.getElementById('candidats_2').value;
		else id_articles += ';'+document.getElementById('candidats_2').value;
	}
	loadXMLDocGeneric('/dynamic/rtl_test.php?q=programme_ajax&id_article='+escape(id_articles)+'&id_theme='+escape(id_themes), 'innerHTML', 'text/html','programmes', '');
}

function AddBook(url, label) {
  if (url=='' || !url) url=location.href;
  if (label=='' || !label) label=document.title;

  if ( navigator.appName != 'Microsoft Internet Explorer' ){
   window.sidebar.addPanel(label,url,"");
  }
  else{
    window.external.AddFavorite(url,label);
  }
}

function AddStartPage(url) {
  if (url=='' || !url) url=location.href;

  if ( navigator.appName != 'Microsoft Internet Explorer' ){
    alert('Pour définir cette page en page de démarrage, glissez l\'icône du site sur le logo "Maison" de votre navigateur.');
  }
  else{
   document.body.style.behavior='url(#default#homepage)';
   document.body.setHomePage(url);
  }
}

function rchTag(type) {
	window.open("/dynamic/web.php?q=popupTag&type="+type, "popup", "toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=500,height=600,dependent=yes,screenX=200,screenY=100,left=200,top=100");
}

function show_alerte(id_alerte,id_text){
	if(document.getElementById(id_alerte).style.display=="none"){
		document.getElementById(id_alerte).style.display="block";
		document.getElementById(id_text).value="";
	}
	else{
		document.getElementById(id_alerte).style.display="none";
		document.getElementById(id_alerte).value="";
	}
}
function alerte_confirm(url,id_alerte,id_text){
	if(document.getElementById(id_text).value.length < 5 || document.getElementById(id_text).value.length ==" "){
		alert('Votre message est vide');
	}
	else if(confirm("Etes-vous sur de vouloir alerter l'équipe de modération ?" )){
		loadXMLDocGeneric(url,'Alert', '', '', '');
	}
	show_alerte(id_alerte,id_text);
	windows.close();
}

function connexion(){
	var identifiant=document.getElementById('identifiant').value;
	var password=document.getElementById('password').value;
	var autoconnect=document.getElementById('autoconnect').value;
	loadXMLDocGeneric('/dynamic/profil.php?q=loginAjax&identifiant='+identifiant+'&password='+password+'&autoconnect='+autoconnect, 'login', 'text/html', 'login_msg', '');
}

function addAlert(tag, type){
	if(type==0){
		loadXMLDocGeneric('/dynamic/profil.php?q=addAlert&tag='+tag+'&type=0', 'Alert', 'text/html', '', '');
	}
	else if(type==1){
		loadXMLDocGeneric('/dynamic/profil.php?q=addAlert&tag='+tag+'&type=1', 'addTag', 'text/html', 'msg_add_alert', '');
	}
	document.getElementById("o5").checked=true;
	document.getElementById("sp_fmode").style.display='block';
}

function removeAlert(){
	if(document.forms.profil.alerte_tag_labels.selectedIndex>=0) {
		var tag=document.forms.profil.alerte_tag_labels.options[document.forms.profil.alerte_tag_labels.selectedIndex].value;
		while(document.forms.profil.alerte_tag_labels.selectedIndex>=0) {
			// Delete from hidden list
			tag_array = document.forms.profil.alerte_tag_ids.value.split(";");
			tag_array.splice(document.forms.profil.alerte_tag_labels.selectedIndex,1);
			document.forms.profil.alerte_tag_ids.value = tag_array.join(";");
			// Delete from select field
			document.forms.profil.alerte_tag_labels.options[document.forms.profil.alerte_tag_labels.selectedIndex]=null;
		}
		loadXMLDocGeneric('/dynamic/profil.php?q=removeAlert&tag='+tag, 'innerHTML', 'text/html', 'msg_remove_alert', '');
	}
	else alert("Veuillez sélectionner un emplacement\nà supprimer.");
}

function loadflashnews(div, numero){
	for(var n=1; document.getElementById('flashnews'+n); n++)
	{
		if (n==numero)
		{
			document.getElementById('flashnews'+n+'b').className="btn_gch";
			document.getElementById('flashnews'+n).className="btn_dte";
		}
		else
		{
			document.getElementById('flashnews'+n+'b').className="btn_gch_off";
			document.getElementById('flashnews'+n).className="btn_dte_off";
		}
	}
	if(div!='flashnews'){
		var content=document.getElementById(div).innerHTML;
		document.getElementById('result').innerHTML=content;
		document.getElementById('result').style.display="block";
		document.getElementById('flashnews').style.display="none";
	}
	else {
		document.getElementById('result').style.display="none";
		document.getElementById('flashnews').style.display="block";
		document.getElementById('result').innerHTML='';
	}
}


function zoomwikio(id, evt){
	var xfenetre,yfenetre,xpage,ypage;
	var offset= 15;

	if (document.layers) {
		xpage = evt.pageX; ypage  = evt.pageY;
	} else if (document.all) {
		xfenetre = evt.x; yfenetre = evt.y;
		xpage=xfenetre; ypage=yfenetre;
		if (document.body.scrollLeft) xpage = xfenetre + document.body.scrollLeft;
		if (document.body.scrollTop) ypage = yfenetre + document.body.scrollTop;
		if (document.documentElement.scrollTop) ypage = yfenetre + document.documentElement.scrollTop;
		if (document.documentElement.scrollLeft) ypage = xfenetre + document.documentElement.scrollLeft;
	} else if (document.getElementById) {
		xfenetre = evt.clientX; yfenetre = evt.clientY;
		xpage=xfenetre; ypage=yfenetre;
		if(evt.pageX) xpage = evt.pageX;
		if(evt.pageY) ypage  = evt.pageY;
	}
	xpage = xpage+offset;
	ypage = ypage+2*offset;
	if(document.getElementById('zoom_wikio_'+id).innerHTML!=''){
		document.getElementById('zoom_wikio').innerHTML=document.getElementById('zoom_wikio_'+id).innerHTML;
		document.getElementById('zoom_wikio').style.top = ypage+"px";
	    document.getElementById('zoom_wikio').style.left = xpage+"px";
		document.getElementById('zoom_wikio').style.display="block";
	}
}

function unzoomwikio(){
	document.getElementById('zoom_wikio').innerHTML='';
	document.getElementById('zoom_wikio').style.display="none";
}

var gal_opened = false;
var tv_opened = false;
var frame;

function openGal(idArt) {
	var galSRC = "/diaporama.php?id="+idArt;
	window.open (galSRC,"galerie","width=757,height=680,left=0,top=0,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
}

function closeGal() {
	window.close();
}
var nextPhoto;
var gal_action='play';
function galMove(num,action){
	window.gal_action=action;
	if(action=='pause') clearTimeout(window.nextPhoto);
	if(num>=photos_diapo.length){
			num=0;
	}
		//var fin = '<div class="gal_diaponav">&nbsp;</div>';
		//var fin2 = '';
		var txt = photos_diapo[num][1];
		var copy = photos_diapo[num][2];
		var num_page= (num+1)+'/'+photos_diapo.length;
		//if(num!=0)	fin = '<div class="gal_diaponav"><a href="javascript:galMove('+(num-1)+')"><img src="/images/gal_btnleft.gif" width="18" height="71" border="0" alt="précédente" title="photo précédente" /></a></div>';
		//if(num!=(photos_diapo.length-1))	fin2 = '<div class="gal_diaponav"><a href="javascript:galMove('+(num+1)+')"><img src="/images/gal_btnrgt.gif" width="18" height="71" border="0" alt="suivante" title="photo suivante" /></a></div>';

		document.getElementById("diaporama").innerHTML = '<div onmouseover="javascript:showBtnAction()" onmouseout="javascript:hideBtnAction()"><img src="/commun/n545x409/'+photos_diapo[num][0]+'" width="545" height="409" border="0" alt="'+photos_diapo[num][1]+'"  align="left" /></div>';
		document.getElementById("copy").innerHTML = copy;
		document.getElementById("num_page").innerHTML = num_page;
		document.getElementById("txt").innerHTML = txt;

		if(window.frames['galPub']) window.frames['galPub'].location.href='/frm/pub_galerie.html?'+Math.random();
		if(document.getElementById("sendfriends_results")) document.getElementById("sendfriends_results").innerHTML='';
		if(document.getElementById("envoi").style.display=='block') document.getElementById("envoi").style.display='none';

		currentPhoto = num;

		document.getElementById("diapo_hl").style.top = num*100 + "px";

		if(window.gal_action=='play'){
			hl_y = parseInt(document.getElementById("diapo_hl").style.top);
			nav_height	= parseInt(document.getElementById("gal_navig").style.height);
			zone_y = Math.abs(parseInt(document.getElementById("zonescroll").style.top));

			if((hl_y+75) >= (zone_y+nav_height) || hl_y <= zone_y){
				//document.getElementById("zonescroll").style.top = -num*100 + 'px';
				var scroll_rm = new Tween(document.getElementById("zonescroll").style,'top',Tween.regularEaseOut,parseInt(document.getElementById("zonescroll").style.top),-num*100,0.7,'px');
				scroll_rm.start();
			}
			else if(num==0){
				//document.getElementById("zonescroll").style.top = 0 + 'px';
				var scroll_rm2 = new Tween(document.getElementById("zonescroll").style,'top',Tween.regularEaseOut,parseInt(document.getElementById("zonescroll").style.top),0,0.7,'px');
				scroll_rm2.start();
			}
			num++;
			window.nextPhoto = setTimeout("galMove("+num+",'play')",5000);
		}
}

var move_sens;
var u_last;
var d_last;
function scrolldown(obj,zone){
	window.gal_action='pause';
	clearTimeout(window.nextPhoto);
	window.move_sens = 'up';
	window.u_last = new Tween(document.getElementById(obj).style,'top',Tween.regularEaseOut,parseInt(document.getElementById(obj).style.top),-(photos_diapo.length*100-parseInt(document.getElementById(zone).style.height)),((photos_diapo.length*100)+parseInt(document.getElementById(obj).style.top)+parseInt(document.getElementById(zone).style.height))/150,'px');
	window.u_last.start();
}
function scrollup(obj,zone){
	window.gal_action='pause';
	clearTimeout(window.nextPhoto);
	window.move_sens = 'down';
	window.d_last = new Tween(document.getElementById(obj).style,'top',Tween.regularEaseOut,parseInt(document.getElementById(obj).style.top),0,(-parseInt(document.getElementById(obj).style.top))/150,'px');
	window.d_last.start();
}
function scrollstop(){
	if(window.move_sens == 'up'){
		window.u_last.stop();
	}
	if(window.move_sens == 'down'){
		window.d_last.stop();
	}
}

function findYPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop;
		}
	}
	return curtop;
}
function findXPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetLeft;
		while (obj = obj.offsetParent) {
			curtop += obj.offsetLeft;
		}
	}
	return curtop;
}
function affDiapoNavig() {
  str = '';
  for ( i=0; i<photos_diapo.length; i++) {
    document.write('<div id="diapo_'+i+'"  class="gal_navimg" ><a href="javascript:galMove('+i+',\'pause\');stopScroll()" ><img src="/commun/n120x90/'+photos_diapo[i][0]+'" border="0" width="120" alt="'+photos_diapo[i][1]+'" title="'+photos_diapo[i][1]+'"/></a></div>');
  }
}

function galPrintpage(url) {
	var url=url.split('#');
	url = url[0].replace('.html', 'p.html');
	if(currentPhoto == "") currentPhoto = '0';
	newUrl = url+"?"+currentPhoto;
	var w=window.open(newUrl, '_blank');
}

function galSendbymail() {
	window.gal_action='pause';
	clearTimeout(window.nextPhoto);
	var div = document.getElementById("envoi");
	if(div.style.display == 'none') div.style.display = "block";
	else div.style.display = "none";
}

function clickAction(action){
	if(action=='play'){
		window.gal_action='play';
		galMove(currentPhoto+1,'play');
	}
	else if(action=='pause'){
		window.gal_action='pause';
		clearTimeout(window.nextPhoto);
		galMove(currentPhoto,'pause');
	}
	showBtnAction();
}

var mouseOnBtnAction;
function BtnActionStatusOn(){
	mouseOnBtnAction=true;
}
function BtnActionStatusOut(){
	mouseOnBtnAction=false;
}

function hideBtnAction(){
	setTimeout("timeOutHideBtn()",10);
}

function timeOutHideBtn(){
	if(!mouseOnBtnAction){
		document.getElementById("gal_play").style.display="none";
		document.getElementById("gal_pause").style.display="none";
	}
}

function showBtnAction(){
	if(window.gal_action=='pause'){
		document.getElementById("gal_play").style.display="block";
		document.getElementById("gal_pause").style.display="none";
	}
	else{
		document.getElementById("gal_pause").style.display="block";
		document.getElementById("gal_play").style.display="none";
	}
}



function checkgals()
{
	if(typeof(eval(Timer)) != 'undefined') clearTimeout(Timer);

	/* aff mail galerie */
	if (location.href.indexOf('?gal-')>0)
	{
	 /* var gparam = location.href.split('?',2);
	  var galid = gparam[1].slice(4);
	  if (galid.indexOf('#')!=-1) galid = galid.substring(0,galid.indexOf('#'));
	  if(isNaN(galid) == false) Timer=window.setTimeout("openGal("+galid+")", 3000);*/
		var gparam = location.href.split('?',2);
	  var galid = gparam[1].slice(4);
		galid = galid.toString();
	  if (galid.indexOf('#')!=-1){
			galid = galid.split('#',2);
			if (galid[0].indexOf('&')!=-1){
				galid = galid[0].split('&',2);
			}
			if(isNaN(galid[0]) == false) Timer=window.setTimeout("openGal("+galid[0]+")", 3000);
		}
	  else if(galid.indexOf('&')!=-1){
			galid = galid.split('&',2);
			if(isNaN(galid[0]) == false) Timer=window.setTimeout("openGal("+galid[0]+")", 3000);
		}
		else{
			if(isNaN(galid) == false) Timer=window.setTimeout("openGal("+galid+")", 3000);
		}
	}
	if (location.href.indexOf('?tv-')>0)
	{
	  var tvparam = location.href.split('?',2);
	  var tvid = tvparam[1].slice(3);
		tvid = tvid.toString();
	  if (tvid.indexOf('#')!=-1){
			tvid = tvid.split('#',2);
			if (tvid[0].indexOf('&')!=-1){
				tvid = tvid[0].split('&',2);
			}
			if(isNaN(tvid[0]) == false) Timer=window.setTimeout("openTv("+tvid[0]+")", 3000);
		}
	  else if(tvid.indexOf('&')!=-1){
			tvid = tvid.split('&',2);
			if(isNaN(tvid[0]) == false) Timer=window.setTimeout("openTv("+tvid[0]+")", 3000);
		}
		else{
			if(isNaN(tvid) == false) Timer=window.setTimeout("openTv("+tvid+")", 3000);
		}

	}

}


/* TV player */
function openTv(idArt2)
{
	if(idArt2==0) var tvSRC = "/sporttv-player.php";
	else var tvSRC = "/sporttv-player.php?id="+idArt2;
	window.open (tvSRC,"galerie","width=980,height=700,left=0,top=0,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no");
}

function closeTv()
{
	window.close();
}


var fcontent;
var doc;
function sporttv_play(id_content)
{
	if(id_content=='' || id_content=='undefined' || id_content==null ){
	fcontent = document.getElementById("tvItem");
	fcontent.src='/dynamic/templates/spor_TPL_generic_videotv_empty.html';
	}
	else{
	fcontent = document.getElementById("tvItem");
	fcontent.src='/sport-tv/glamour/4/video-'+id_content+'.html';
	}

}

function sporttv_vote(id_content, rating)
{
  if(fcontent.contentDocument) doc = fcontent.contentDocument;
  else doc = document.frames[0].document;

	if(GetCookie('my_vote')!=null){
		var tableau = GetCookie('my_vote').split(';');
		var trouve=false;
		for(var i=0;(!trouve)&&(i<tableau.length);i++){
			if(tableau[i]==id_content)	trouve=true;
		}
		if(trouve)	doc.getElementById('content_rating').innerHTML='d&eacute;j&agrave; not&eacute;';
		else loadXMLDocGeneric('/dynamic/web.php?q=rating&id_contenu='+escape(id_content)+'&type=1&rank='+escape(rating), 'Rating', 'text/html', 'content_rating', 'content_avg_rating');
	}
	else loadXMLDocGeneric('/dynamic/web.php?q=rating&id_contenu='+escape(id_content)+'&type=1&rank='+escape(rating), 'Rating', 'text/html', 'content_rating', 'content_avg_rating');
}

function sporttv_comment()
{
	if(fcontent.contentDocument) doc = fcontent.contentDocument;
	else doc = document.frames[0].document;

	var identifiant=GetCookie('my_identifiant');
	if( (identifiant=='') || (identifiant==null) ){
		top.scrollTo(0,500);
		doc.getElementById("envoi").style.display = "none";
		doc.getElementById("bloguer").style.display = "none";
		doc.getElementById("rss").style.display = "none";
		location.href='#commentform';
	}else{
		var div = doc.getElementById("commenter");
		if (!div)
		{
			alert('Impossible de commenter cet article.');
			return;
		}
		if(div.style.display == 'none') { div.style.display = "block"; top.scrollTo(0,500); }
		else top.scrollTo(0,500);

		doc.getElementById("envoi").style.display = "none";
		doc.getElementById("bloguer").style.display = "none";
		doc.getElementById("rss").style.display = "none";
		location.href='#commentform';
	}
}

function sporttv_sendfriend()
{
	if(fcontent.contentDocument) doc = fcontent.contentDocument;
	else doc = document.frames[0].document;
  
	var div = doc.getElementById("envoi");
	if(div.style.display == 'none') { div.style.display = "block"; top.scrollTo(0,500); }
	else top.scrollTo(0,500);
	doc.getElementById("bloguer").style.display = "none";
	doc.getElementById("commenter_off").style.display = "none";
	doc.getElementById("commenter").style.display = "none";
	doc.getElementById("rss").style.display = "none";
}

function sporttv_close()
{
	closeTv();
}

function sporttv_blog()
{
	if(fcontent.contentDocument) doc = fcontent.contentDocument;
	else doc = document.frames[0].document;

	var div = doc.getElementById("bloguer");

	if(div.style.display == 'none') { div.style.display = "block"; top.scrollTo(0,500); }
	else top.scrollTo(0,500);
	doc.getElementById("envoi").style.display = "none";
	doc.getElementById("commenter").style.display = "none";
	doc.getElementById("commenter_off").style.display = "none";
	doc.displayHeaderBlog(idArticle);
}

function sporttv_rss()
{
	if(fcontent.contentDocument) doc = fcontent.contentDocument;
	else doc = document.frames[0].document;

	var div = doc.getElementById("rss");
	if(div.style.display == 'none') { div.style.display = "block"; top.scrollTo(0,500); }
	else top.scrollTo(0,500);
	doc.getElementById("envoi").style.display = "none";
	doc.getElementById("bloguer").style.display = "none";
	doc.getElementById("commenter").style.display = "none";
	doc.getElementById("commenter_off").style.display = "none";
}

function sporttv_openloginform(){
	var div = document.getElementById("login_form");
	if (div.style.display=="block"){
		div.style.display="none";
	}
	else{
		div.style.display="block";
	}
}

function jeuphotoHit(id_participation){
	loadXMLDocGeneric('/dynamic/web.php?q=jeuphotoHit&id_participation='+escape(id_participation), '', 'text/html', '', '');
}

function switchOrder(value){
	tmp=location.href.split('?');
	if(tmp[1]!='' && tmp[1]!=undefined ){
		location.href='/jeu-photo/participations/'+value+'?'+tmp[1];
	}
	else{
		location.href='/jeu-photo/participations/'+value;
	}
}

function loadwikio(num){
	for(var n=0; document.getElementById('wikio_item'+n); n++)
	{
		if (n==num)
		{
			document.getElementById('wikio_item'+n).className="btn_on";
			document.getElementById('wikio_'+n).style.display="block";
		}
		else
		{
			document.getElementById('wikio_item'+n).className="btn";
			document.getElementById('wikio_'+n).style.display="none";
		}
	}
}
function hideselectbtn(){
	if(document.getElementById("select").style.display == 'block')
		document.getElementById("select").style.display = 'none';
}
function showselectbtn(){
	if(document.getElementById("select").style.display == 'none')
		document.getElementById("select").style.display = 'block';
}
var refrech;

function loginComment(id_article){
	loadXMLDocGeneric('/dynamic/web.php?q=loginComment&id_article='+escape(id_article), 'innerHTML', 'text/html', 'commenter', '');
}

function loginToComment(identifiant, password){
	loadXMLDocGeneric('/dynamic/profil.php?q=loginAjax&identifiant='+escape(identifiant)+'&password='+escape(password), 'login', 'text/html', 'login_result', '');
}

function gotoSSO(url){
	if(GetCookie('my_sid')!=null){
	 document.location.href=url+"?my_sid="+GetCookie('my_sid');
	}
	else{
	 document.location.href=url;
	}
}

function gotoSSO2(id){
	if(document.getElementById("menusite"+id) && GetCookie('my_sid')!=null){
		document.getElementById("menusite"+id).href=document.getElementById("menusite"+id).href+"?my_sid="+GetCookie('my_sid');
	}
}

/* bloc sport tv player */

var old_player='';
var s1='';
function afficherVideo(flv,num) {
	s1 = new SWFObject("/swf/player_flv.swf", "playervideo"+num, 166, 141, "8", "#000000",true);
	s1.addParam("quality", "High");
	s1.addParam("menu", "false");
	s1.addParam("WMODE",'transparent');
	s1.addParam("Flashvars", "flv="+flv+"&amp;width=166&amp;height=141&amp;playercolor=CCCCCC&amp;bgcolor1=CCCCCC&amp;bgcolor2=CCCCCC&amp;buttoncolor=000000&amp;buttonovercolor=000000&amp;slidercolor1=000000&amp;slidercolor2=000000&amp;sliderovercolor=000000&amp;loadingcolor=000000&amp;showstop=1&amp;showvolume=1&amp;showtime=1&amp;srt=0&amp;autoplay=1"); //&lightcolor=0x02a9e0&backcolor=0x555555&frontcolor=0xFFFFFF");

	$("#playervideo"+num+"a").hide();
	$("#playervideo"+num+"b").show();
	s1.write("playervideo"+num+"b");
	old_player=num;
}
function stop() {
	document.object.SetVariable("player:jsStop", "");
}
function play() {
	document.object.SetVariable("player:jsPlay", "");
}