/*********************************************************/
// Function "AJAX" pour lire un fichier sans rafraichissement
function file(fichier)
	{
		if(window.XMLHttpRequest) // FIREFOX
			xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // IE
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else
			return(false);
			xhr_object.open("GET", fichier, false);
			xhr_object.send(null);
		if(xhr_object.readyState == 4) 
			return(xhr_object.responseText);
		else return(false);
	}
	
/*********************************************************/

// Fonction pour afficher et effacer une "layer"
function Aff_layer (id) {
  if (document.layers)
	document[id].visibility = 'show';
  else if (document.getElementById)
	document.getElementById(id).style.visibility = 'visible';
	else if (document.all)
	document.all[id].style.visibility = 'visible';
}

function Cache_layer (id) {
  if (document.layers)
	document[id].visibility = 'hide';
	else if (document.getElementById)
	document.getElementById(id).style.visibility = 'hidden';
  else if (document.all)
	document.all[id].style.visibility = 'hidden';
}

/*********************************************************/

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*********************************************************/

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("javascript:void(0)")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow2(theURL,winName,features) { //v2.0
  window.open(theURL, winName, "scrollbars=yes, resizable=no, width=380, height=400");
}

var navigateur = navigator.appName;
var version = navigator.appVersion;
IE = false;
NN = false;
if (navigateur=="Microsoft Internet Explorer" && version.indexOf("MSIE") != -1)
{
	IE = true;
}
else {
	NN = true;
}

/*********************************************************/

// ******* EMPECHER CLICK DROIT
function verif_click(){
	//settimes();
	if (IE)
	{
		if (window.event.button==2){
			alert('interdit!')
		}
	}
	else {
		function processClicks(e) {
			
			if (e.button == 2)
			{
				alert('interdit!')
			}
		}
		window.captureEvents(Event.CLICK); // click is an event
		window.onclick = processClicks; // onclick is an event handler
	}
}
//document.onmousedown = verif_click;

// ******* FIN EMPECHER CLICK DROIT

/*********************************************************/

// ****** TESTER DECONNEXION
function suppression_chat(id_chat) {
	/*if(window.event.clientX < -1000)
	{*/
		fene = window.open('../chat/suppression_chat.php?id_chat='+id_chat, 'fen', "width=0, height=0, top=1000, left=1000,alwaysLowered=yes"); 
		setTimeout('fene.close()','5000');
		//fen.close();
	//}
}


function quitter(path_relatif) {
	var navigateur = navigator.appName;
	var version = navigator.appVersion;
	IE = false;
	NN = false;
	if (navigateur=="Microsoft Internet Explorer" && version.indexOf("MSIE") != -1)
	{
		//alert(window.event.clientX);
		if(window.event.clientX < -1000)
		{
			//alert("Au revoir !");
			fen = window.open(path_relatif+'deconnexion.php', 'fen', "width=0, height=0, top=1000, left=1000,alwaysLowered=yes"); 
			setTimeout('fen.close()','5000');
			//fen.close();
		}
	}
	else {
			
		//alert("bye");
	}
}

//document.onmousemove = settimes;
//document.onmousedown = settimes();
//document.onclick = settimes();
//document.onkeypress = settimes();

function display(){
	rtime=etime-ctime;
	if (rtime>60)
		m=parseInt(rtime/60);
	else{
		m=0;
	}
	s=parseInt(rtime-m*60);
	if(s<10)
		s="0"+s
	window.status="Time Remaining :  "+m+":"+s
	window.setTimeout("checktime()",1000)
}

function settimes(){

	var time= new Date();
	hours= time.getHours();
	mins= time.getMinutes();
	secs= time.getSeconds();
	etime=hours*3600+mins*60+secs;
	etime+= 30;//1200;  
	//You can change the value of 1200 according to how much time you wish to set the timer. 
	//Where 1200 is time in secs (1200 = 20 mins * 60 secs/min). 
	//Max time is 60 mins (3600secs)
	checktime();
}

function checktime(){
	var time= new Date();
	hours= time.getHours();
	mins= time.getMinutes();
	secs= time.getSeconds();
	ctime=hours*3600+mins*60+secs

	if(ctime>=etime){
		temps_expire();
	}
	else
		display();
}

function temps_expire(){
	//alert("Time expired");
	location.href="../logout.php";  //Put here the next page
}


/*if (NN)
{
	//function test_souris(evt) {

		function getmouse(e) 
		{
			alert(e.pageX);
			if (e.pageXOffset < 0)
			{
				alert("bye");
			}
			
		}
		
		window.captureEvents(Event.MOUSEDOWN); // click is an event
		window.onmousedown = getmouse;
	//}

	//window.onunload = test_souris;
}*/
// ****** FIN TESTER DECONNEXION

// ****** TEST ANTI-POPUP
function test_popup() {
	
	if (window.location.href.indexOf("accueil") != -1)
	{
		fen = window.open('', 'fen', "width=0, height=0, top=1000, left=1000,alwaysLowered=yes"); 
		if (!fen)
		{
			alert("Pour un meilleur fonctionnement du site Web Romantique, \r\nnous vous demandons de réactiver l'ouverture des pop-up.\r\n Aucune publicité n'apparaitra par ce biais.\r\nSi vous ne savez comment effectuer cette manipulation,\r\n une aide vous est proposée dans le lien SOS présent en bas de chaque page.\r\n \r\n Merci de votre compréhension.");
		}
		else {
			fen.close();
		}
	}
}

// ****** FIN TEST ANTI-POPUP

// ******* ACCEPTE CHAT
function accepte_chat(pseudo_expe, id_expe, id_chat, id, path_relatif) {
	//if (confirm('Souhaitez-vous chatter avec '+pseudo_expe+' ?')){
		
		window.open(path_relatif+'chat/popup_chat.php?accepte_chat=1&id='+id+'&id_chat='+id_chat+'&id_expe='+id_expe,'popchat_'+id_chat+'_'+id_expe,'scrollbars=yes,width=400,height=400');
	/*}
	else {
		fen = window.open(path_relatif+'chat/non_accepte_chat.php?id_chat='+id_chat, 'fen', "width=0, height=0, top=1000, left=1000"); 
		setTimeout('fen.close()','5000');
		
	}*/
}

function confirmation_chat(pseudo_expe, id_expe, id_chat, id, path_relatif) {
	//if (confirm('Souhaitez-vous chatter avec '+pseudo_expe+' ?')){
		
		window.open(path_relatif+'chat/confirmation_chat.php?&id='+id+'&id_chat='+id_chat+'&id_expe='+id_expe,'popchat_'+id_chat+'_'+id_expe,'scrollbars=yes,width=400,height=400');
	/*}
	else {
		fen = window.open(path_relatif+'chat/non_accepte_chat.php?id_chat='+id_chat, 'fen', "width=0, height=0, top=1000, left=1000"); 
		setTimeout('fen.close()','5000');
		
	}*/
}

function non_accepte_chat(id_chat, path_relatif) {
	
	fen = window.open(path_relatif+'chat/non_accepte_chat.php?id_chat='+id_chat, 'fen', "width=0, height=0, top=1000, left=1000"); 
	setTimeout('fen.close()','5000');
	
}
// ***** FIN ACCEPTE CHAT

// ***** CALQUES CHAT ET MSG

function cacher_chat() {
	if(document.getElementById)
	{
		document.getElementById("calque_chat").style.visibility="hidden";
		
	}
	else if(document.all) {
		document.all["calque_chat"].style.visibility="hidden";
	}
}

// ***** FIN CALQUES CHAT ET MSG

