// Pages - couleurs
var pages = new Array();
var colors = new Array();

function doSubmit(){
	document.globalForm.submit();
}

function submitTo(action_){
	document.globalForm.action = action_;
	doSubmit();
}

function postTo(action_){
	document.globalForm.action = action_;
	document.globalForm.method = 'POST';
	doSubmit();
}

// Retourne page courante
function selectLang(languageId_){
	var searchStr = location.search.replace(/lg=.{2}/,"lg="+languageId_);
	location.search = searchStr;
	window.reload(true);
}

// Change lang
function refreshPage(){
	location.reload(true);
}

// Set page
function setPage(pageIndex) {
	// Set main frame page
	setMainFrame(pageIndex);
	// Set title
	setTitle(pageIndex);
}

// Add to title
function addToTitle(titleElement_) {
	setTitle(titleElement_  + " @ " +  document.title);
}

// Set title
function setTitle(title_) {
	document.title = title_;
}

// Goto url
function goToURL(url){
	window.location = url;
}


// Set main frame content
function setMainFrame(pageIndex) {
	var suffixe = "php";
	if (pageIndex<6) {
		suffixe = "html";
	}
	top.mainFrame.location = pages[pageIndex] + "." + suffixe;
}

// Scrolling text
// To find more free cut and paste scripts online please visit http://www.x-lab.info/javascripts.html
// Remove these comments and feel the wrath on the day of reckoning.

// Begin -->
// THESE VARIABLES CAN BE CHANGED 
var theMessage="  Visite du Pasteur Russ Moyer de Eagle Worldwide Ministries... Visitez la section 'Calendrier' pour plus de détails...   ";
var speed=150; // SET THIS BETWEEN 1 - 1000
var scrollingRegion=theMessage.length; // THIS VALUE MUST MATCH TOTAL NUMBER OF CHARACTERS IN theMessage INCLUDING SPACES
// END CHANGEABLE VARIABLES 
var startPosition=0;

function scrollText() {
	var mainMessage=theMessage;
	var tempLoc=(scrollingRegion*3/mainMessage.length)+1;
	if (tempLoc<1) {tempLoc=1}
	var counter;
	for(counter=0;counter<=tempLoc;counter++)
	mainMessage+=mainMessage;
	document.globalForm.TextScroller.value=mainMessage.substring(startPosition,startPosition+scrollingRegion);
	startPosition++;
	if(startPosition>scrollingRegion) startPosition=0;
	window.setInterval("scrollText()",speed); 
}
//  End -->


function openPopup(url, windowWidth, windowHeight) {
	var win = window.open(url,"popup","width="+windowWidth+",height="+windowHeight+",titlebar=0,scrollbars=0,resizable=0");
	win.focus();
}
var agt = navigator.userAgent.toLowerCase();

function detectBrowser() {
	if ( agt.indexOf('msie') != -1 ) {
		return "IE";
	} else {
		return "NS";
	}
}

var truncatePosition;
var textLength;

function truncate(text, maxLength) {
	maxPosition = parseInt(maxLength);
	textLength = text.length;
	if (textLength > maxPosition) {
		text = text.substr(0, maxPosition);
		truncatePosition = maxPosition;
		while(truncatePosition>maxPosition-1) {
			truncatePosition = text.lastIndexOf(" ",textLength-1);
			textLength = truncatePosition;
		}
		text = text.substr(0, truncatePosition) + "[...]";
	}
	return text;

}

function parseForSql(text) {
	var textStr;
	var outputText;
	textStr = new String(text);
	outputText = textStr.replace(/[\']+/g, " ");
	outputText = outputText.replace(/[\"]+/g, " ");
	return outputText;
}

function formatTime(time) {
	var timeStr;
	timeStr = new String(time);
	if (timeStr.length<2) {
		timeStr = "0"+new String(time);
	}
	return timeStr;
}

function getTheDate() {
	var today;
	var monthStr;
	today = new Date();
	monthStr = new String(parseInt(today.getMonth()) + 1);
	return formatTime(today.getDate())+"."+formatTime(monthStr)+"."+formatTime(today.getFullYear());
}

function getTheTime() {
	var today;
	var code;
	today = new Date();
	return formatTime(today.getHours())+":"+formatTime(today.getMinutes())+":"+formatTime(today.getSeconds());
}

function displayDate() {
	document.all['dateTime'].innerText=getTheDate();
}

function displayTime() {
	window.setInterval("document.globalForm.time.value=getTheTime()",1000);
}

function displayDateAndTime(){
	displayDate();
	displayTime();
}

function JSW_OpenNWin(url) {
	remote = window.open(url,"jsw","width=300,height=500,resizable=0,menubar=0,status=0,scrollbars=auto,top=15,left=150");
	remote.opener.name = "JScriptWiz";
}

function JSW_OpenNWin2(url) {
	remote = window.open(url,"jsw2","width=420,height=400,resizable=0,menubar=0,status=0,scrollbars=auto,top=15,left=150");
	remote.opener.name = "JScriptWiz";
}


/*****************************************
* Open links in new window Script- By spk100 (spk100@yahoo.com)
* Script featured on/available at Dynamic Drive- http://www.dynamicdrive.com/
* Modified by DD. This notice must stay intact for use
*****************************************/

//Enter "_blank" for new window (each time), "window2" for a set secondary window
var newwindow="_blank"

function hyperlinks(target){
   if (target) where = newwindow;
   else where = "_self";
   for (var i=0; i<=(document.links.length-1); i++){
	 var linkobj=document.links[i].href
   if ( linkobj.indexOf("javascript:") ==-1 && linkobj.indexOf("#") ==-1){
   	if (target && where!="_blank") //DynamicDrive.com added routine- open window in set secondary window
      	document.links[i].onclick=function(){
			if (window.window2 && !window2.closed)
			window2.location=this.href
			else
        	window2=window.open(this.href)
			window2.focus()
      		return false
      			}
   	else{
      	if (newwindow=="window2") document.links[i].onclick = "";    
      	document.links[i].target = where;
       	}
   	}
	}
}

function inithyperlinks(){    //DynamicDrive.com added routine
//	if (document.forms[0].targetnew.checked)
	hyperlinks(true);
}


/**********************
* AJAX RSS reader - from w3school.org
***********************/
var	xmlHttp

function showRSS(str)
 { 
 
 xmlHttp=GetXmlHttpObject();
 
 if	(xmlHttp==null)
  {
  alert	("Browser does not support HTTP	Request")
  return
  }
 
 var url="getrss.php";
 url=url+"?q="+str;
 url=url+"&sid="+Math.random();
 xmlHttp.onreadystatechange=stateChanged ;
 xmlHttp.open("GET",url,true);
 xmlHttp.send(null);
 
 }

function stateChanged()	
 { 
 if	(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  {	
  document.getElementById("rssOutput").innerHTML=xmlHttp.responseText ;
  }	
 }

function GetXmlHttpObject()
{
var	xmlHttp=null;
try
 {
 //	Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //	Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}