
// Array des messages i18n
var t = {};
if (lang == "en") {
	t["confirmDeletePlayer"] = "Do you wish to delete this player?";
	t["confirmDeleteEvent"] = "Do you wish to delete this event?";
} else {
	t["confirmDeletePlayer"] = "Voulez-vous supprimer ce joueur?";
	t["confirmDeleteEvent"] = "Voulez-vous supprimer cette activitée?";
}


/* ****************************************
// Exemple d'utilisation de l'engine ajax ...
function getStatesForCountry(ddown, contextPath){
document.getElementById("statesDdown").innerHTML = "<input type=\"hidden\" name=\"state\" value=\"\"/>";
document.getElementById("metroDdown").innerHTML = "<input type=\"hidden\" name=\"metroArea\" value=\"\"/>";
document.getElementById("cityDdown").innerHTML = "<input type=\"hidden\" name=\"city\" value=\"\"/>";
var index = ddown.selectedIndex;
var id = ddown[index].value;
http('GET', contextPath + '/getStatesForCountry.tsb?countryId=' + id, fillStatesDropDown);
}

function fillStatesDropDown(obj){
document.getElementById("statesDdown").innerHTML = obj;
}
******************************************** */

var photoInterval = 5000;
var rotatingImages = new Array();
currentIndex = 0;

setInterval(updateRotatingImage, photoInterval);

function updateRotatingImage() {
	try {
		if (rotatingImages.length == 0)
			return;
		var imgElement = document.getElementById("rotationImgElement");
		imgElement.src = rotatingImages[currentIndex];
		currentIndex++;
		if(currentIndex >= rotatingImages.length){
			currentIndex = 0;
		}
	} catch(err) {};
}

function displayTeamImfos(ddl) {
	var id = ddl[ddl['selectedIndex']].value;
	if(id != "-1"){
		var teamid = "teamInfos-" + id;
		document.getElementById("teaminfos").innerHTML = document.getElementById(teamid).innerHTML
	}
}

function popMessage(msg) {
	if(msg != '')
		alert(msg);
}

// Example (very) simple animation
function animateBall(i) {
	if (i == null) i = 0;
	var el = document.getElementById('ballon');
	if (! el) return;
	el.style.display = (i % 2 == 0) ? 'block' : 'none';
	if (i < 2)
		setTimeout("animateBall(" + (i + 1) + ")", 75);
}


function gotoTeamSite(o) {
	var value = o.options[o.selectedIndex].value;
	if (value != null && value != "")
		document.location = context + "/" + lang + "/" + value;
}

function changeLang(newLang) {
	var oldLang = newLang == "fr" ? "en" : "fr";
	document.location = document.location.href.replace(oldLang, newLang);
	return false;
}

function confirmDelete(textId) {
	return confirm(t[textId]);
}

function e(id) {
	if (id == null) return null;
	return document.getElementById(id);
}

function hide(id) {
	var el = e(id);
	if (el != null) el.style.display = 'none';
}

function show(id) {
	var el = e(id);
	if (el != null) el.style.display = '';
}
