/* MAINLIB :: Fonction globale de l'application  */
function initApp () {
	trace("initApp");
	//this.isLoaded = false;
	//CallSWF
	displayFlashApp();
	//hidePopin("inviteFriendsPopin");
}
function openPopup(type) {
	filePath = (type=="credits")?'/credits.html':'/reglement.html';
	var height = (type=="credits")?'180':'500';
	var width = (type=="credits")?'500':'600';
    window.open(filePath, type, "width="+width+", height="+height+", scrollbars=yes");
}
function openRules() {
	openPopup("reglement");
}
function displayFlashApp() {
	trace("displayFlashApp");
	var params = {
		bgcolor : "#FFFFFF",
		scale : "noScale",
		salign : "t",
		menu : "false",
		allowfullscreen : "false",
		allowScriptAccess:"sameDomain",
		quality : "high",
		salign : '',
		menu : 'true',
		codebase: 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'
	} 
	var flashvars = {
		
	}
	var attributes = {
		id:"module",
		allowScriptAccess:"always"
	};
	swfobject.embedSWF("loader.swf", "module", "100%", "643", "9.0.115", "expressInstall.swf",flashvars,params,attributes);
}

/*function hidePopin(id){
	trace("showPopin");
	document.getElementById(id).className = "hidden";
}

function showPopin(id){
	trace("showPopin");
	document.getElementById(id).className = "show";
}

function inviteFriends(){
	//document.getElementById('inviteFriendsPopin').innerHTML = "<iframe src='invite.html' frameborder='no' width='770' height='600' scrolling='no' />";
	//showPopin("inviteFriendsPopin");
}*/

//Lecture du cookie de l'application
/*function readCookie(name) {
	trace("readCookie");
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function storeSession() {
	trace("storeSession");
	if(!this.isLoaded){
		var cookie = readCookie('51cbbed1c36bd1efa9372f1b27c52bba_user');
		trace("cookie",cookie);
		document.getElementById('module').setSession(cookie);
	}else{
		this.isLoaded = true;
	}
}
*/
function initCheckInvite(ids){
	trace('ids',ids);
	window.opener.hasInvitedSomeFriends(ids.length);
	window.close();
}

function hasInvitedSomeFriends(nbFriends){
	(nbFriends>0)?document.getElementById('module').hasInvitedSomeFriends():'';
}

function trace (label, value){
	return;
	value = (value != undefined)?value:"";
	console.info(label,value);
}