/********************************************/
/**************      INIT      **************/
/********************************************/
meetingIsOpen=false;
function openMeeting()
{
	meetingIsOpen=true;
}


/********************************************/
/**************      CHAT      **************/
/********************************************/
function loadChat()
{
    $("#chatiframe").attr('src', "/chatlocation.php");
}
/*********************************************/
/**************  WORLDVISITORS  **************/
/*********************************************/
function cronWorldvisitors()
{
	refreshWorldvisitors();
	// toutes les 5min car la purge est toutes les 15 min
	window.setTimeout("cronWorldvisitors();",5*60*1000);
}
function refreshWorldvisitors()
{
	// on met à jour worldvisitor
	document.getElementById("worldvisitorscounter").src="worldvisitorslocation.php?r="+(Math.floor(32760*(Math.random()))+1);
}
/********************************************/
/**************  FIN DU CULTE  **************/
/********************************************/
function end_of_connection()
{
	trombi_run=false;
	loadChat();
}
function ilove_redirect()
{
	window.location="j_aime_moneglise.net.php";
}
/********************************************/
/************* ACTIVEBOX COMMON *************/
/********************************************/
function clearActiveBox1()
{
	textActiveBox1("");
}
function clearActiveBox2()
{
	textActiveBox2("");
}
function textActiveBox1(newhtml)
{
	document.getElementById("activebox1_content").innerHTML=newhtml;
    update_fancybox("#activebox1_content a.fancybox");
}
function textActiveBox2(newhtml)
{
	document.getElementById("activebox2_content").innerHTML=newhtml;
    update_fancybox("#activebox2_content a.fancybox");
}

/********************************************/
/**************   ACTIVE BOX   **************/
/********************************************/
function next_connection(servertime,connectiontime,text)
{
	var serverTime = new Date();
	serverTime.setTime(servertime*1000);

	var currentTime = new Date();
	decalage=currentTime.getTime()-serverTime.getTime();

	var connectionTime = new Date();
	connectionTime.setTime((connectiontime*1000)+decalage);

	var month = format2(connectionTime.getMonth() + 1);
	var day = format2(connectionTime.getDate());
	var year = ""+format2(connectionTime.getFullYear());
	//year=year.substr(2,2);
	var hour = format2(connectionTime.getHours());
	var minutes = format2(connectionTime.getMinutes());
	var seconds = format2(connectionTime.getSeconds());

	timeoffset_connectiontime= day + "/" + month + "/" + year + " " + hour + "h" + minutes;
	
	textActiveBox2(text.replace("%time%",timeoffset_connectiontime));
}

function promo_topboutique(target,image,author,text)
{
	textActiveBox1("<h2>"+author+"</h2><br/><a target='_blank' href='"+target+"'><img src='"+image+"'><br/>"+text+"</a>");
}
function biographie(image,bioname,text)
{
	tmp_imageblock='';
	if (image!='')
	{
		tmp_imageblock="<br/><img src='"+image+"'>";
	}

	textActiveBox1("<h2>"+bioname+"</h2>"+tmp_imageblock+"<br/>"+text);
}

function do_a_calling(link,accept)
{
		global_calling_accept_text=accept;
		textActiveBox2("<a href='javascript:accept_a_calling();' id='callingbtn'>"+link+"</a><span id='calling_text'>"+link+"</span><br/><span id='calling_countdecisions'>0<span> réponses");
		refresh_calling_decisions(true);
		// -> penser à remettre le fichier à 0 à la fin du culte
}
function refresh_calling_decisions()
{
		// si l'element existe, on le rempli, sinon on stop le refresh
		if (document.getElementById("calling_countdecisions"))
		{
			// fait un update du nombre de main et génère le fichier fixe pour le refresh
			tmp_random=Math.floor(100000*(Math.random()))+1;
			include("cache/cache_calling.txt?r="+tmp_random);

			// et on recommence dans 5 secondes
			window.setTimeout("refresh_calling_decisions();",5000);
		}	
}

function accept_a_calling()
{
		// fait un update du nombre de main et génère le fichier fixe pour le refresh
		tmp_random=Math.floor(100000*(Math.random()))+1;
		include("accept_calling.js.php?sid="+sid+"&r="+tmp_random);

		tmp_current_decisions=document.getElementById('calling_countdecisions').innerHTML;
		if (isNaN(tmp_current_decisions))
		{
			tmp_current_decisions=0;
		}
		tmp_current_decisions++;
		document.getElementById("calling_text").innerHTML=global_calling_accept_text;
		document.getElementById("calling_countdecisions").innerHTML=tmp_current_decisions;
		document.getElementById("callingbtn").href="#";
}
function open_conseillers()
{
    var chat_width = 450 ;
    var chat_height = 360 ;
    var url = escape( location.toString() ) ;
    var request_url_4270149 = "http://conseillers.topchretien.com/request.php?l=topc&x=1&deptid=2&moneglise=1&pagex="+url ;
    var newwin_chat = window.open( request_url_4270149, "_blank", 'scrollbars=no,menubar=no,resizable=0,location=no,screenX=50,screenY=100,width='+chat_width+',height='+chat_height+'' ) ;
}
/********************************************/
/**************     SPLASH     **************/
/********************************************/
/* ---->  I LOVE  */
function open_ilove()
{
    $.address.value('/?/jaime');
}


/* ---->  DONATION */
function make_a_donation()
{
    $.address.value('/?/don');
}
/* ---->  IDENTIFICATION */
function make_an_identification()
{
	// on met la bonne taille
	document.getElementById("popupContent").className="makeanidentification";
	// on reprends la bonne iframe, on cache les autres
	loadIframe("topc_connect_iframe");
	// on centre
	centerPopup();
	// on affiche
	loadPopup(true);
}

/* ---->  SCHEDULE  */
function schedule_display()
{
    $.address.value('/?/schedule');
}

/* ---->  WHOSONLINE  */
function open_whosonline()
{
    $.address.value('/?/online');
}

/* ---->  WHOSONLINE  */
function open_whosonjesusnet()
{
    $.address.value('/?/map');
}

/* ---->  KNOWINGJESUS  */
function open_knowingjesus()
{
    $.address.value('/?/connaitre-jesus');
}

/* ---->  SHARING  */
function open_sharing()
{
    $.address.value('/?/pray');
}

/* ---->  ABOUT  */
function open_about()
{
    $.address.value('/?/about');
}

/* ---->  Feedback  */
function open_feedback()
{
    $.address.value('/?/feedback');
}

/* ---->  ABOUT  */
function open_tellafriend()
{
    $.address.value('/?/tell-a-friend');
}

/* ---->  Video From connaitredieu  */
function open_videocd()
{
	document.getElementById("popup_videocd").src="about:blank";
	tmp_random=Math.floor(100000*(Math.random()))+1;
	document.getElementById("popup_videocd").src="videocd.php";
	// on met la bonne taille
	document.getElementById("popupContent").className="videocd";
	// on reprends la bonne iframe, on cache les autres
	loadIframe("popup_videocd");
	// on centre
	centerPopup();
	// on affiche
	loadPopup(true);
}

/********************************************/
/**************      TODO      **************/
/********************************************/
function todo()
{
		alert("Points en attente:\r\n* Megaphone/top: j'aime mon eglise: prévu splashscreen, demande actuelle page: lequel et si page avec quel graphisme ?");
}
