// JavaScript Document

nouveau = new Image;
nouveau.src = "/forum/images/theme/btn/nouveau.gif";
nouveauover = new Image;
nouveauover.src = "/forum/images/theme/btn/nouveauover.gif";
nouveaupress = new Image;
nouveaupress.src = "/forum/images/theme/btn/nouveaupress.gif";
sondage = new Image;
sondage.src = "/forum/images/theme/btn/sondage.gif";
sondageover = new Image;
sondageover.src = "/forum/images/theme/btn/sondageover.gif";
sondagepress = new Image;
sondagepress.src = "/forum/images/theme/btn/sondagepress.gif";
repondre = new Image;
repondre.src = "/forum/images/theme/btn/repondre.gif";
repondreover = new Image;
repondreover.src = "/forum/images/theme/btn/repondreover.gif";
repondrepress = new Image;
repondrepress.src = "/forum/images/theme/btn/repondrepress.gif";
fgauche = new Image;
fgauche.src = "/forum/images/theme/fleches/gauche.gif";
fdroite = new Image;
fdroite.src = "/forum/images/theme/fleches/droite.gif";
fgaucheo = new Image;
fgaucheo.src = "/forum/images/theme/fleches/gaucheO.gif";
fdroiteo = new Image;
fdroiteo.src = "/forum/images/theme/fleches/droiteO.gif";

icnalbumo = new Image;
icnalbumo.src = "/images/v3/forum/icn_wikipedi_o.jpg";
icnfranceo = new Image;
icnfranceo.src = "/images/v3/forum/icn_france_o.jpg";
icnwikipedio = new Image;
icnwikipedio.src = "/images/v3/forum/icn_wikipedi_o.jpg";

icn_lunonlu1= new Image;
icn_lunonlu1.src= "/forum/images/theme/icn/lunonlu1.gif";
icn_lunonlu2= new Image;
icn_lunonlu2.src= "/forum/images/theme/icn/lunonlu2.gif";
icn_lunonlu3= new Image;
icn_lunonlu3.src= "/forum/images/theme/icn/lunonlu3.gif";
icn_lunonlu4= new Image;
icn_lunonlu4.src= "/forum/images/theme/icn/lunonlu4.gif";

dateexpirescookies=new Date;
dateexpirescookies.setMonth(dateexpirescookies.getMonth()+1);

function ajtMultiQuote(norep) {
	document.getElementById('mqn'+norep).style.display='none';
	document.getElementById('mqy'+norep).style.display='inline';
	document.getElementById('postopic').repquote.value+='-'+norep;
	var cookmulti=document.getElementById('postopic').repquote.value;
	document.cookie = 'multiquote='+cookmulti +'; expires='+ dateexpirescookies.toGMTString() + '; path=/';

}
function supprimeMultiQuote(norep) {
	document.getElementById('mqn'+norep).style.display='inline';
	document.getElementById('mqy'+norep).style.display='none';
	document.getElementById('postopic').repquote.value=document.getElementById('postopic').repquote.value.replace('-'+norep, '')
	document.cookie = 'multiquote='+cookmulti +'; expires='+ expires.toGMTString() + '; path=/';
}

function recup_rep_rapide(idtopic,anclu) {
	document.getElementById('postopic').action='reptopic.php?idtopic='+idtopic+'&anclu='+anclu;
	document.getElementById('postopic').submit();
}


/* Posting */

function ajoutURL() {
	ADRESSEURL = prompt('Indiquez l\'adresse a ajouter : ',"http://");
	NOMURL = prompt('Indiquez un nom pour ce lien (exemple "Cliquez-ici!") : ',"")
}

function clic_url() {
	ajoutURL();
	if (ADRESSEURL != null && ADRESSEURL != 'http://' && ADRESSEURL != '' && NOMURL != '')	{
		varURL1 = ' [url='+ADRESSEURL+']'+NOMURL+'[/url] ';
		document.forms['postopic'].textetopic.value=parent.document.forms['postopic'].textetopic.value+varURL1;
	}
}

function clic_flash() {
	ajoutFLASH();
	if (ADRESSEFLASH != null && ADRESSEFLASH != 'http://' && ADRESSEFLASH != '' && LARGFLASH != '' && HAUTFLASH != '')	{
		varFLASH = ' [fla width='+LARGFLASH+' height='+HAUTFLASH+']'+ADRESSEFLASH+'[/fla]';
		document.forms['postopic'].textetopic.value=parent.document.forms['postopic'].textetopic.value+varFLASH;
	}
}

function ajoutFLASH() {
	ADRESSEFLASH = prompt('Indiquez l\'adresse a de l\'animation a ajouter : ',"http://");
	if (ADRESSEFLASH != null) {
		LARGFLASH = prompt('Indiquez la largeur de l\'animation : ',"400");
		if (LARGFLASH != null) {
			HAUTFLASH = prompt('Indiquez la hauteur de l\'animation : ',"300")
		}
	}
}


function ajoutIMAGE() {ADRESSEIMAGE = prompt('Indiquez l\'adresse de l\'image a ajouter  (ex : http://www.site.com/image.jpg) : ',"http://")};

function clic_image()	{
	ajoutIMAGE();
	if (ADRESSEIMAGE != 'http://' && ADRESSEIMAGE != null && ADRESSEIMAGE != '')
	{
	varIMAGE1 = '[img]'+ADRESSEIMAGE+'[/img]';
	document.forms['postopic'].textetopic.value=document.forms['postopic'].textetopic.value+varIMAGE1;
	document.forms['postopic'].textetopic.focus();
	}
}

function ajoutBOLD() {ADRESSEBOLD = prompt('Indiquez le texte a ecrire en gras : ',"")};
function clic_bold()
{
ajoutBOLD();
if (ADRESSEBOLD != null)
{
varBOLD1 = ' [b]'+ADRESSEBOLD+'[/b]';
document.forms['postopic'].textetopic.value=document.forms['postopic'].textetopic.value+varBOLD1;
document.forms['postopic'].textetopic.focus();
}
}

function ajoutITAL() {ADRESSEITAL = prompt('Indiquez le texte a ecrire en italique : ',"")};
function clic_italique()
{
ajoutITAL();
if (ADRESSEITAL != null)
{
varITAL1 = ' [i]'+ADRESSEITAL+'[/i]';
document.forms['postopic'].textetopic.value=document.forms['postopic'].textetopic.value+varITAL1;
document.forms['postopic'].textetopic.focus();
}
}

function countInstances(open,closed) 
  { 
     var opening = document.contenu.value.split(open); 
     var closing = document.contenu.value.split(closed); 
     return opening.length + closing.length ; 
  } 

  function ATTinsert(text1,text2) 
  { 
     var ta = document.getElementById('textetopic'); 
       
     if (document.selection) { 
        var str = document.selection.createRange().text; 
        ta.focus(); 
        var sel = document.selection.createRange(); 
        if (text2!="") 
        { 
           if (str=="") 
           { 
              var instances = countInstances(text1,text2); 
              if (instances%2 != 0){ sel.text = sel.text + text2;} 
              else{ sel.text = sel.text + text1;} 
           } 
           else 
           { 
              sel.text = text1 + sel.text + text2; 
           } 
        } 
        else 
        { 
           sel.text = sel.text + text1; 
        } 
        
     } 
     else if (ta.selectionStart | ta.selectionStart == 0) 
     { 
        if (ta.selectionEnd > ta.value.length) { ta.selectionEnd = ta.value.length; } 
       
        var firstPos = ta.selectionStart; 
        var secondPos = ta.selectionEnd+text1.length; 
       
        ta.value=ta.value.slice(0,firstPos)+text1+ta.value.slice(firstPos); 
        ta.value=ta.value.slice(0,secondPos)+text2+ta.value.slice(secondPos); 
         
        ta.selectionStart = firstPos+text1.length; 
        ta.selectionEnd = secondPos; 
        ta.focus(); 
     } 
     else 
     { // Opera 
        var sel = document.hop.textetopic; 
       
        var instances = countInstances(text1,text2); 
        if (instances%2 != 0 && text2 != ""){ sel.value = sel.value + text2; } 
        else{ sel.value = sel.value + text1; } 
     }  
  } 
  
  
 /* Carte de france */

var mousex=0;
var mousey=0;

	function affrance(dep) {
		if (document.getElementById('membfr'+dep)) {
			document.getElementById('membfr'+dep).style.display='block';
			document.getElementById('membfr'+dep).style.left = mousex + 5+'px';
			document.getElementById('membfr'+dep).style.top = mousey + 5+'px';
			document.getElementById('membfr'+dep).style.zindex= 200;
			if (document.getElementById('xx')) {
				document.getElementById("xx").value = mousex;
			}
			if (document.getElementById('yy')) {
				document.getElementById("yy").value = mousey;
			}
		}
	}
	function hidefr(dep) {
		if (document.getElementById('membfr'+dep)) {
		fixediv=document.getElementById('membfr'+dep);
		fixediv.style.display='none';
		}
		deppos=dep;
	}
	
	var isIE = (navigator.userAgent.indexOf("MSIE")>-1)

	function traceMouse(e) {
		if(isIE){
			e.pageX = e.clientX+document.body.scrollLeft;
			e.pageY = e.clientY+document.body.scrollTop;
		}
		var posX = e.pageX;
		var posY = e.pageY;
		mousex=posX;
		mousey=posY;
	}
	
	
	
	function doIthjk(posx, posy) {
		mousex=posx;
		mousey=posy;
	}

	function affichehelp(filename) {
		window.open('http://quakelike.online.fr/flv/wps-helpvideo.php?fichier='+filename+'','VideoHelp','width=770, height=580, toolbar=0, location=0, status=0, resize=1');	
	}

function cachespoiler(idbox) {
		if (idbox.style.visibility=='hidden') {
			idbox.style.visibility='visible';
		}
}

function gopage(url) {
	var retour= prompt('Aller à la page :','');
	if (retour != '') {
		window.location= url+'&nopage='+retour;
	}
}

function gopage_cut(url1,url2) {
	var retour= prompt('Aller à la page :','');
	if (retour != '') {
		window.location= url1+retour+url2;
	}
}

function trim(string) {
	return string.replace(/(^\s*)|(\s*$)/g,'');
} 

function Remplace(expr,a,b) {
  var i=0
  while (i!=-1) {
	 i=expr.indexOf(a,i);
	 if (i>=0) {
		expr=expr.substring(0,i)+b+expr.substring(i+a.length);
		i+=b.length;
	 }
  }
  return expr
}
function converticar(texte) {
	//texte=Remplace(texte,'+','<<<SigneAdditionPlus>>>');
	return texte;
}
function validemodif(nocel) {
	var req = null; 

	if (window.XMLHttpRequest)	{
		req = new XMLHttpRequest();
	}	else if (window.ActiveXObject) 	{
		try {	req = new ActiveXObject("Msxml2.XMLHTTP");	} 
		catch (e)	{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	message=converticar(document.getElementById('input'+nocel).value);

	req.onreadystatechange = function()
	{ 
		if(req.readyState == 4)
		{
			if(req.status == 200)	{
				document.getElementById('tabavatar'+nocel).style.display='block';
				retour=req.responseText.split('[![separe]!]');
				document.getElementById('tab'+nocel).innerHTML = retour[0];
				document.getElementById('tabdateedit'+nocel).innerHTML = retour[1];
				document.getElementById('smil'+nocel).innerHTML='';
				document.getElementById('smil'+nocel).style.display='none';
			}	else	{
				alert('erreur edition en direct');
			}	
		} 
	}; 
	req.open("POST", 'topicaffaj-recoit.php', true ); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  //text/html; charset=UTF-8
	//req.setRequestHeader("Content-Type", "text/html; charset=UTF-8");  //text/html; charset=UTF-8
	req.send('norep='+nocel+'&message='+encodeURIComponent(message)); 

}

function hide_options_album_fct() {
	if (hide_options_album == 1) {
		hide_options_album= 0;
		document.getElementById('optionsalbum').style.display= 'block';
		document.getElementById('iconereplioptions').src= fermeoptions.src;
	} else {
		hide_options_album= 1;
		document.getElementById('optionsalbum').style.display= 'none';
		document.getElementById('iconereplioptions').src= ouvreoptions.src;
	}
	expires = new Date();    // date et heure courante en format texte
    expires.setTime(expires.getTime() + (24*60*60*1000000));
	document.cookie = "hide_options_album="+hide_options_album+ 
	((expires==null) ? "" : ("; expires="+expires.toGMTString()))+"; path=/";
	//location.reload();
	return false;
}

function changetriphoto() {
	var triphotourl= document.getElementById('triphoto').value;	
	var albumpubliqueurl= document.getElementById('albumpublique').value;
	var nbphotoparpage= document.getElementById('nbphotoparpage').value;	
	//var fortitle= document.getElementById('fortitle').value;	
	window.location= 'alb-view.php?triphoto='+triphotourl+'&albumpublique='+albumpubliqueurl+'&nbphotoparpage='+nbphotoparpage;
}

function changecolalbum() {
	var triphotourl= document.getElementById('colalbumnb').value;	
	window.location= 'alb-view.php?colalbumnb='+triphotourl;
}
function changetriphotobbcode() {
	var triphotourl= document.getElementById('triphotobbcode').value;	
	var fortitle= document.getElementById('fortitle').value;	
	window.location= 'alb-bbcode.php?triphotobbcode='+triphotourl+'&fortitle='+fortitle;
}

function fl_upload_auto() {
	window.open('','Photos','status=yes,scrollbars=yes,width=250,height=580');
	document.getElementById('formalbumauto').target= 'Photos';
	document.getElementById('formalbumauto').submit();
	return false;
}

function fl_size(url) {
	window.open(url);
}

function fl_cursor_pointer() {
	document.body.style.cursor='pointer';
}
function fl_cursor_hand() {
	document.body.style.cursor='auto';
}

function fl_verif_size(obj,message,resize,resizevalue,idrepencours) {
	var largeur= obj.width;
	
	if (resize == 1) {
		if (largeur>resizevalue) {
			obj.width= resizevalue;
			obj.setAttribute("alt",message);
			obj.setAttribute("title",message);
			obj.setAttribute("onclick","fl_size("+obj.src+")");
			obj.onclick= function() {fl_size(obj.src);};
			obj.setAttribute("onmouseover","fl_cursor_pointer()");
			obj.setAttribute("onmouseout","fl_cursor_hand()");
			obj.onmouseover= function() {fl_cursor_pointer();};
			obj.onmouseout= function() {fl_cursor_hand();};
			if (idrepencours != 0) {
				fl_flag_resize(idrepencours);
			}
		}
	} else if (resize == 2) {
		var largeurlibre = 0, hauteur = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
		  largeurlibre = window.innerWidth;
		  hauteurlibre = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		  largeurlibre = document.documentElement.clientWidth;
		  hauteurlibre = document.documentElement.clientHeight;
		  }
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		  largeurlibre = document.body.clientWidth;
		  hauteurlibre = document.body.clientHeight;
		}
		if (largeurlibre == 0) {
			return;
		}
		largeurpossible= largeurlibre-resizevalue;
		//alert('largeur=> '+largeurlibre+'=>'+largeurpossible);
		if (largeur>largeurpossible) {
			obj.width= largeurpossible;
			obj.setAttribute("alt",message);
			obj.setAttribute("title",message);
			obj.setAttribute("onclick","md_size("+obj.src+")");
			obj.onclick= function() {fl_size(obj.src);};
			obj.setAttribute("onmouseover","fl_cursor_pointer()");
			obj.setAttribute("onmouseout","fl_cursor_hand()");
			obj.onmouseover= function() {fl_cursor_pointer();};
			obj.onmouseout= function() {fl_cursor_hand();};
		}
	}
}

function fl_flag_resize(idrepencours) {
	
	if (idrepencours == 0) {
		return;	
	}
	var req = null; 

	if (window.XMLHttpRequest)	{
		req = new XMLHttpRequest();
	}	else if (window.ActiveXObject) 	{
		try {	req = new ActiveXObject("Msxml2.XMLHTTP");	} 
		catch (e)	{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	req.onreadystatechange = function()
	{ 
		if(req.readyState == 4)
		{
			if(req.status == 200)	{
				//alert(req.responseText);
			}	else	{
				//alert('erreur edition en direct');
			}	
		} 
	}; 
	req.open("POST", 'imageresize.php', true ); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	req.send('idrep='+idrepencours); 
}

function req_ajax_forum() {
	var reqajax = null; 
	if (window.XMLHttpRequest)	{
		reqajax = new XMLHttpRequest();
	}	else if (window.ActiveXObject) 	{
		try {	reqajax = new ActiveXObject("Msxml2.XMLHTTP");	} 
		catch (e)	{
			try {
				reqreqajax= new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	return reqajax;
}