var curent_menu;
var repImg = '/v2/';
function selectMenu(idMenu){
	// on désactive l'initialisation
	//if(idSousMenu != '' && $(idSousMenu)){ $(idSousMenu).removeClassName('selected');}
	
	// on désaffiche le menu visible
	var menu;
	if (curent_menu) menu= curent_menu.substring(1,curent_menu.length);
	
	if($(curent_menu)){
		$(curent_menu).style.display = 'none';
		$(menu).src = $(menu).src.replace('ON','OFF');
	}
	// on affiche le menu
	curent_menu = 's'+idMenu;
	if($(curent_menu)) {
		$(idMenu).src = $(idMenu).src.replace('OFF','ON');
		$(curent_menu).style.display = 'block';
	}
}

function initialiseNav(idSousMenu){
	
	switch(idSousMenu){
		case 'societe'  :
			selectMenu('societe');
			break;
		case 'solution' :
		case 'jeux' 	:
		case 'envoi' 	: 
		case 'micro' 	: 
		case 'dedicace' : 
		case 'contenu' 	:
		case 'votes' 	:
		case 'commande' :
		case 'autre' :{
			selectMenu('solution');
			if(idSousMenu != 'solution' && $(idSousMenu)) {
				if($(idSousMenu).addClassName){$(idSousMenu).addClassName('selected');}
				else{$(idSousMenu).addClass('selected');}
			}
			break;
		}
		
		case 'applications' :
		case 'horoscope' 	:
		case 'tarologie' 	:
		case 'astro' 		:
		case 'prenoms' 		:
		case 'myDog' 		:
		case 'myCatch' 		:{
			selectMenu('applications');
			if(idSousMenu != 'applications' && $(idSousMenu)) {
				if($(idSousMenu).addClassName){$(idSousMenu).addClassName('selected');}
				else{$(idSousMenu).addClass('selected');}
				switch(idSousMenu){
					case 'horoscope' :{
						goToAncre('horoscopesms')
						break;
					}
					case 'tarologie' :{
						goToAncre('tarosms')
						break;
					}
					case 'astro' :{
						goToAncre('compatibilitastro')
						break;
					}
					case 'prenoms' :{
						goToAncre('prenom')
						break;
					}
					case 'myDog' :{
						goToAncre('mydog')
						break;
					}
					case 'myCatch' :{
						goToAncre('mycatch')
						break;
					}
				}
			}
			break;
		}
		
		case 'references' 		:{
			selectMenu('references');
			break;
		}
		
		case 'objectifs' 	:
		case 'buzz' 		:
		case 'marque' 		:
		case 'trafic' 		:
		case 'communaute' 	:
		case 'crm' 			:
		case 'affect' 		:
		case '1pas' 		:
		case 'rentabiliser' :
		case 'optin' 		:
		case 'autres' 		:{
			selectMenu('objectifs');
			if(idSousMenu != 'objectifs' && $(idSousMenu)) {
				if($(idSousMenu).addClassName){$(idSousMenu).addClassName('selected');}
				else{$(idSousMenu).addClass('selected');}
			}
			break;
		}
		case 'contact' 		:{
			selectMenu('contact');
			break;
		}
		case 'espaceClient' 		:{
			selectMenu('espaceClient');
			break;
		}
	}
	idSousMenu = '';
}

function goToAncre(idAncre){
	window.document.location.href = "#"+idAncre;
}

function EspaceClient(){
	 return false;
}

function redirectUS(){
	window.location.href='/en/';
}
/***********	Gestion du slide exemple	**************/

var ind_img_logo = 0
var tabImgLogos = new Array (81);
tabImgLogos[0] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/ab_group.jpg';
tabImgLogos[1] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/air_fr.jpg';
tabImgLogos[2] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/bacardi.jpg';
tabImgLogos[3] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/biquette.jpg';
tabImgLogos[4] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/bnpi.jpg';
tabImgLogos[5] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/bordeaux7.jpg';
tabImgLogos[6] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/bouyg.jpg';
tabImgLogos[7] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/budget.jpg';
tabImgLogos[8] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/bulgari.jpg';
tabImgLogos[9] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/b_interactif.jpg';
tabImgLogos[10] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/cashTv.jpg';
tabImgLogos[11] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/centrepresse.jpg';
tabImgLogos[12] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/CentrePresseAveyron.jpg';
tabImgLogos[13] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/century21.jpg';
tabImgLogos[14] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/champion.jpg';
tabImgLogos[15] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/citadum.jpg';
tabImgLogos[16] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/citroen.jpg';
tabImgLogos[17] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/cochonlande.jpg';
tabImgLogos[18] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/companile.jpg';
tabImgLogos[19] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/danone.jpg';
tabImgLogos[20] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/decathlon.jpg';
tabImgLogos[21] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/dh.jpg';
tabImgLogos[22] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/ea.jpg';
tabImgLogos[23] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/ford.jpg';
tabImgLogos[24] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/france_mutuelle.jpg';
tabImgLogos[25] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/frolic.jpg';
tabImgLogos[26] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/GoSport.jpg';
tabImgLogos[27] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/hachette.jpg';
tabImgLogos[28] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/hasbro.jpg';
tabImgLogos[29] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/hermes.jpg';
tabImgLogos[30] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/hi_media.jpg';
tabImgLogos[31] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/kdmobile.jpg';
tabImgLogos[32] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/kelkoo.jpg';
tabImgLogos[33] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/larepublique.jpg';
tabImgLogos[34] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/latribune.jpg';
tabImgLogos[35] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/lebienpublic.jpg';
tabImgLogos[36] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/leroysmerlin.jpg';
tabImgLogos[37] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/lesiuer.jpg';
tabImgLogos[38] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/letelegramme.jpg';
tabImgLogos[39] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/libertytv.jpg';
tabImgLogos[40] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/universal.jpg';
tabImgLogos[41] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/loreal.jpg';
tabImgLogos[42] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/madeinsport.jpg';
tabImgLogos[43] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/midilibre.jpg';
tabImgLogos[44] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/mobistar.jpg';
tabImgLogos[45] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/mrf.jpg';
tabImgLogos[46] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/mrmpartners.jpg';
tabImgLogos[47] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/mtv.jpg';
tabImgLogos[48] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/nba.jpg';
tabImgLogos[49] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/noumba.jpg';
tabImgLogos[50] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/nrj.jpg';
tabImgLogos[51] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/ogilvy.jpg';
tabImgLogos[52] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/orange.jpg';
tabImgLogos[53] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/passionata.jpg';
tabImgLogos[54] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/passoa.jpg';
tabImgLogos[55] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/perrier.jpg';
tabImgLogos[56] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/prizee.jpg';
tabImgLogos[57] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/proximus.jpg';
tabImgLogos[58] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/quicksilver.jpg';
tabImgLogos[59] = 'http://www.mobiletrend.fr'+repImg+'/IMG/LOGOS/reebok.jpg';
tabImgLogos[60] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/rtl.jpg';
tabImgLogos[61] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/rtl9.jpg';
tabImgLogos[62] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/sagem.jpg';
tabImgLogos[63] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/samantha.jpg';
tabImgLogos[64] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/selpro.jpg';
tabImgLogos[65] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/sfr.jpg';
tabImgLogos[66] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/sidaction.jpg';
tabImgLogos[67] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/sony.jpg';
tabImgLogos[68] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/southwing.jpg';
tabImgLogos[69] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/sppedy.jpg';
tabImgLogos[70] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/spqr.jpg';
tabImgLogos[71] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/sudouest.jpg';
tabImgLogos[72] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/supergazol.jpg';
tabImgLogos[73] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/taatu.jpg';
tabImgLogos[74] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/tmc.jpg';
tabImgLogos[75] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/trace_tv.jpg';
tabImgLogos[76] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/trbf.jpg';
tabImgLogos[77] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/tv7.jpg';
tabImgLogos[78] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/ufb.jpg';
tabImgLogos[79] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/unerencontre.jpg';
tabImgLogos[80] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/vittel.jpg';
tabImgLogos[81] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/vodafonelife.jpg';
tabImgLogos[82] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/AB.jpg';
tabImgLogos[83] = 'http://www.mobiletrend.fr'+repImg+'IMG/LOGOS/nt1.jpg';

function Logos_Fade(){
	var effet = new Fx.Morph('img_mod', {duration: 1000,onComplete: Logos_Appear}).start({'opacity':[1,0]});
}

function Logos_Appear(){
	if(ind_img_logo==tabImgLogos.length-1){ind_img_logo = 0;}
	else{ind_img_logo++;}
	source = tabImgLogos[ind_img_logo]
	$('img_mod').src = source;
	new Fx.Morph('img_mod', {duration: 1000}).start({'opacity':[0,1]});
}

function gereMarquee(id,direction,a){
	new Effect.Appear(a, {duration:0.7, fps:10, from:0.0, to:1.0});
	$(id).direction = direction;
	$(id).start();
}

function stopMarquee(id,a){
	new Effect.Appear(a, {duration:0.7, fps:10, from:1.0, to:0.0});
	$(id).stop();
}

function swapLang(elt,lang,urlRewrite){
	var tmpLang = elt.value;
	if (tmpLang == "") tmpLang = 0;
	if(tmpLang != 2){
		var lurl =window.location;
		if(lurl.pathname.toUpperCase().indexOf('/'+getLang(lang).toUpperCase()+'/') < 0 ){
			lurl = lurl.href.replace(lurl.hostname,lurl.hostname+'/'+getLang(tmpLang).toUpperCase());
		}
		else{
			lurl = urlRewrite.toUpperCase().replace('/'+getLang(lang).toUpperCase()+'/','/'+getLang(tmpLang).toUpperCase()+'/');
		}
		window.location.href = lurl.toLowerCase();
	}
	else{
		Slimbox.open('http://www.mobiletrend.fr/v2/enConstruction.asp', '',{defaultIframeWidth :'750',defaultIframeHeight:'200'});	
	}
	/*
	
	
	
	if(urlRewrite != '/nl/'){
		var lurl =window.location;
		if(lurl.pathname.toUpperCase().indexOf('/'+getLang(lang).toUpperCase()+'/') < 0 ){
			lurl = lurl.href.replace(lurl.hostname,lurl.hostname+'/'+getLang(tmpLang).toUpperCase());
			window.location.href = lurl.toLowerCase();
		}
		else{
			lurl = urlRewrite.toUpperCase().replace('/'+getLang(lang).toUpperCase()+'/','/'+getLang(tmpLang).toUpperCase()+'/');
			window.location.href = lurl.toLowerCase();
		}
	}
	else{
		Slimbox.open('http://www.mobiletrend.fr/v2/enConstruction.asp', '',{defaultIframeWidth :'200',defaultIframeHeight:'200'});	
	}
	*/
}

function getLang(lg){
	switch(lg){
		case '2' :{
			return 'NL'
			break;
		}
		case '1' :{
			return 'EN'
			break;
		}
		default :{
			return 'FR'
			break;
		}
	}	
}

var timer;
// fonctions de gestion du chrono
function changeComposante(composante){
	var img_composante1 = document.getElementById(composante+'1');
	var img_composante2 = document.getElementById(composante+'2');
	if(img_composante1 && img_composante2){
		img_composante1.src = repImg +'img/IMG_EXEMPLES_CLIENTS/speedLottery/'+(Math.floor((eval(composante)/10)))+'.gif';
		img_composante2.src = repImg +'img/IMG_EXEMPLES_CLIENTS/speedLottery/'+((eval(composante)%10))+'.gif';
	}
}

function affChrono(){
	changeComposante('minutes');
	changeComposante('secondes');
	
	if (secondes>0){
		secondes--;
	}
	else{
		if(minutes != 0){
			secondes = 59;
			minutes --;
		}
		else{
			newTirage();
			minutes = 9;
			secondes = 59;
		}
	}
}

function newTirage(){
	var tirage = '';
	var boulle = Math.floor(Math.random()*48)+1;
	for(indBoulle = 0;indBoulle<6;indBoulle++){
		while(tirage.indexOf('#'+boulle+'#') >= 0) boulle = Math.floor(Math.random()*48)+1;
		tirage +='#'+boulle+'#';
		document.getElementById('b'+indBoulle).innerHTML = boulle;
	}
}

function startChrono(){
	timer = setInterval("affChrono()",1000);
}

function afficheRecherche(){
	//
	$('module_recherche_auto_complete').set('html',this.xhr.responseText);
	$('module_recherche_auto_complete').setStyle('display', 'block');
}

function mootoolsRecherche(){
	var mot = document.formRecherche.mot.value;
	if( mot ){ 
		var myRequest = new Request({method: 'post', url: '/v2/recherche.asp',onSuccess : afficheRecherche});
		myRequest.send('mot='+mot+'&lang='+lang);	
	}
	else{
		$('module_recherche_auto_complete').style.display = 'none';
	}
}

function affecteRecherche(recherche,url){
	if ( url && document.formRecherche ){
		document.formRecherche.url.value = url;	
		document.formRecherche.mot.value = recherche;
	}
	//$('module_recherche_auto_complete').setStyle('display', 'none');
	$('module_recherche_auto_complete').style.display = 'none';
}

function checkRecherche(lg){
	var url = '';
	if ( document.formRecherche.url.value != '' ){
		url = '/'+getLang(lg)+'/'+document.formRecherche.url.value;
	}
	else{
		if ( document.formRecherche.recherche.value != '' ){
		url = '/'+getLang(lg)+'/'+document.formRecherche.recherche.value;
		}
	}
	if(url != ''){
		window.location.href = url;	
	}
}

function autoLog(laPage){
	var form = window.document.log;
	if(form[0].type != 'hidden'){form = form[0]}
	if( form ){
		form.identi.value = '268';
		form.pass.value = 'mobiletrend';
		form.laPage.value = laPage;
		form.memo.checked = false;
		valideFormLog(form);
	}
}
