// Sous IE ?
var IE = document.all;

function noRight(){
 var tmp = $('right').style.display;
 var middle = ($('middle_new'))?$('middle_new'):$('middle_old');
  
  
 if (tmp=="" || tmp=="block"){
  $('right').style.display="none";
  //new Effect.Shrink('right',1);
  if(middle)
  	middle.style.marginRight="0px";
 }
 else {
  $('right').style.display="block";
  //new Effect.Grow('right',1);
  if(middle)
  	middle.style.marginRight=$('right').clientWidth+"px"; 
 }
}

function noLeft(){
 var tmp = $('left').style.display;
 var middle = ($('middle_new'))?$('middle_new'):$('middle_old');
  
  
 if (tmp=="" || tmp=="block"){
  $('left').style.display="none";
  //new Effect.Shrink('right',1);
  if(middle)
  	middle.style.marginLeft="0px";
 }
 else {
  $('left').style.display="block";
  //new Effect.Grow('right',1);
  if(middle)
  	middle.style.marginLeft=$('left').clientWidth+"px"; 
 }
}

function writeCurrentDate(){
 var navvers = navigator.appVersion.substring(0,1);
 var navok;
 if (navvers > 3)
    navok = true;
 else
    navok = false;
 
 var today = new Date;
 var day = today.getDay();
 var numero = today.getDate();
 if (numero<10)
    numero = "0"+numero;
 var month = today.getMonth();
 var year;
 if (navok)
    year = today.getFullYear();
 else
    year = today.getYear();
    
 var hours=today.getHours();
 if (hours<10)
    hours = "0"+hours;   
 var minutes=today.getMinutes();
 if (minutes<10)
    minutes = "0"+minutes;
 var TabDay = new Array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
 var TabMonth = new Array("janvier","f&eacute;vrier","mars","avril","mai","juin","juillet","aout","septembre","octobre","novembre","d&eacute;cembre");
 var messageDate = TabDay[day] + " " + numero + " " + TabMonth[month];
  
 if(!document.all || messageDate.length < 19 || (document.body && document.body.clientWidth > 1040))
  messageDate += " " + year;
 
 if(document.body && document.body.clientWidth > 1040)
  messageDate += " " + hours + "h" + minutes;
 
 //document.write(messageDate);
 if($('header_date'))
 	$('header_date').innerHTML=messageDate;
}
 
setInterval(writeCurrentDate,1000);
 
var isOverLoginPanelLink = false; 
function outLoginPanelLink(){
	isOverLoginPanelLink = false;
}

function overLoginPanelLink(){
	isOverLoginPanelLink = true;	
	setTimeout(showLoginPanelTimed, 100);
}

function ShowHideElement(id){
  if($(id).style.display=="block")
    $(id).style.display="none";
  else
    $(id).style.display="block";
}
function CheckUncheck(id){
  if($(id).checked==true)
    $(id).checked=false;
  else
    $(id).checked=true;
}

function showLoginPanelTimed(){
	if(isOverLoginPanelLink)
		showLoginPanel();
}
 
function showLoginPanel(){
 $('login_panel').style.display='block';
 if($('login_login'))
	 $('login_login').focus();
  
  if($('appletContainer'))
		$('appletContainer').style.marginTop="80px";
		
  if($('audioweb_player') && window.location.href.indexOf('audioweb_history') > 0)
  		$('audioweb_player').style.visibility='hidden';
}

function hideLoginPanel(){
	$('login_panel').style.display='none';
	
    if($('appletContainer'))
		$('appletContainer').style.marginTop="0px";

    if($('audioweb_player'))
  		$('audioweb_player').style.visibility='visible';		
}

Event.observe(window, 'load', pageLoaded, false);

var page_initialWidth;
var page_minWidth=995;
function pageLoaded(){
    page_initialWidth = Element.getStyle('mainDocument','width');
    
    if(document.all)
        ieWidthLimit();
   		
   	Event.observe(window, 'resize', eventResize, false);

   	if($('audioweb_history')){
   		audiowebHeightAjust();
   		Event.observe(window, 'resize', audiowebHeightAjust, false);
   	}
   	
	topPubbb();
/*   showHideTopPub2();*/
   	showHideJTSkycraper();
   	remargeForMegaBanner('topPub');
   	remargeForMegaBanner('topPub2');
}

function eventResize(){
   if(document.all)
        ieWidthLimit();
	topPubbb();
/*	showHideTopPub2();*/
	showHideJTSkycraper();
	
}

function topPubbb(){
var topReal=document.getElementById('topPubb').innerHTML;
if(_hasMegaBanner('topPubb2')){
if ($('mainDocument').getDimensions().width <= 1040) { 
/*ca s'affiche en haut*/
var objtop=document.getElementById('topPubb');
$('topPubb').style.display='block';
$('topPubb').style.visibility='visible';
$('topPubb2').style.display='none';
remargeForMegaBanner('topPubb');
}
else{
/*ca s'affiche en bas*/
var objtop=document.getElementById('topPubb2');
$('topPubb2').style.display='block';
$('topPubb2').style.visibility='visible';
$('topPubb').style.display='none';
remargeForMegaBanner('topPubb2');
}
objtop.innerHTML=topReal;
}
else
		if($('topPubb2'))
			$('topPubb2').style.display='none';
}

/*function showHideTopPub2(){
//	 alert(_hasMegaBanner('topPub2')+"/"+$('mainDocument').getDimensions().width );
   if(_hasMegaBanner('topPub2')){
   		if($('mainDocument').getDimensions().width <= (document.all?1065:1050)){
   			$('topPub2').style.display='none';
   			$('topPub').style.display='block';
   			remargeForMegaBanner('topPub');
   		} else {
	   		$('topPub2').style.display='block';
	   		$('topPub2').style.visibility='visible';
	   		$('topPub').style.display='none';
	   		remargeForMegaBanner('topPub2');
	   	}
	}
	else
		if($('topPub2'))
			$('topPub2').style.display='none';
}
*/
function showHideJTSkycraper(){
	if($('news_google3')){
		if(document.body.clientWidth > 1160)
			$('news_google3').style.display='block';
		else
			$('news_google3').style.display='none';
	}
}

function remargeForMegaBanner(divId){
	if(_hasMegaBanner(divId)){
		if($('debugNoRight'))
			$('debugNoRight').style.display='none';
	}
}

function _hasMegaBanner(divId){
	if(!$(divId)) 
		return false;
		
	_links = $(divId).getElementsByTagName('a');
	if(_links.length > 0){
		_imgs = _links.item(0).getElementsByTagName('img')
		if(_imgs.length == 0)
			return false;
	}
	
	return (_links.length == 0 || $(divId).getElementsByTagName('object').length > 0 || _imgs.item(0).width > 1);
}

function audiowebHeightAjust(){
	if($('audioweb_history')) {
		if(document.all && document.body.clientWidth > (page_minWidth+5))
				$('audioweb_history').style.width=($('main').offsetWidth-340)+"px";
		
		val = document.documentElement.clientHeight - $('audioweb_history').offsetTop - 5;
		if(val > 0)
			$('audioweb_history').style.height=val+"px";
	}

}

/* Forcer la taille mini pour IE */
function ieWidthLimit() {
    if(document.body.clientWidth <= page_minWidth)
        $('mainDocument').style.width=page_minWidth+"px";
     
     if(document.body.clientWidth > (page_minWidth+10) && $('mainDocument').getDimensions().width == page_minWidth)
          $('mainDocument').style.width=page_initialWidth;
}


/* Changer taille element si APPLET (non prise en compte z-index) */
var isInMenu = false;
function inMenu(){
	isInMenu = true;
	if($('appletContainer') || $('audioweb_player') || $('detailPlayer') || $('newsPlayer'))
		setTimeout(inMenuTimed,300);
}

function inMenuTimed(){
	if(isInMenu && $('appletContainer')){
		if(IE){
			$('appletContainer').style.marginLeft="150px";
			$('appletContainer').style.width="100%";
		}
		else {
			$('appletContainer').style.marginLeft="150px";
		}
	}
	if(isInMenu && $('detailPlayer')){
		if(IE){
			$('detailPlayer').style.marginLeft="180px";
			$('detailPlayer').style.width="100%";
		}
		else {
			$('detailPlayer').style.marginLeft="180px";
			$('detailPlayer').style.visibility='visible';
		}
	}
	if(isInMenu && $('audioweb_player'))
  		$('audioweb_player').style.visibility='hidden';
  		
	if(isInMenu && $('newsPlayer'))
		$('newsPlayer').style.visibility='hidden';
}

function outMenu(){
	isInMenu = false;
	
	if($('appletContainer') || $('audioweb_player') || $('detailPlayer') || $('newsPlayer'))
		setTimeout(outMenuTimed,300);
}
// Pour eviter le flash
function outMenuTimed(){
	if(!isInMenu && $('appletContainer')){
		$('appletContainer').style.marginLeft="0px";	
		$('appletContainer').style.width="100%";  
	}
	if(!isInMenu && $('detailPlayer')){
		$('detailPlayer').style.marginLeft="0px";
		$('detailPlayer').style.width="100%";
	}
	if(!isInMenu && $('audioweb_player'))
  		$('audioweb_player').style.visibility='visible';
	if(!isInMenu && $('newsPlayer'))
  		$('newsPlayer').style.visibility='visible';
}

// cacher partie droite pour afficher APPLETs
function fullAppletView(){
	noRight();
}


var currentWalletCode;
var currentWalletView;

function setCurrentWalletCode(val){
	currentWalletCode = val;
}

function setCurrentWalletView(val){
	currentWalletView = val;	
}

function walletLight(){
	walletAjax(currentWalletId, currentWalletCode, 'L');
}

function walletFull(){
	walletAjax(currentWalletId, currentWalletCode, 'F');
}

function walletCode(code){
	if(code != '')
		walletAjax(currentWalletId, code, currentWalletView);
}

function changeWalletHistory(){
	walletCode($('wallet_history_dates').options[$('wallet_history_dates').selectedIndex].value);
}


function playAudioweb(file){
	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	if(!hasReqestedVersion){
		alert('Flash n\'est pas installé sur votre navigateur ou il est trop ancien !');
		return false;	
	}	
	
	if(!$('audioweb_credit_count')){
		alert('Vous devez être identifié pour utiliser ce service.');
		return false;	
	}		
	cnt = parseInt($('audioweb_credit_count').innerHTML);
	if(cnt < 1){
		alert('Vous ne semblez pas disposez de suffisement de jetons audioweb !');
		return false;
	}
	
	valid = confirm('Vous désirez consulter l\'audioweb : '+audioweb_convertToCompare(file)+'\nVotre compte va être débité d\'un jeton.\n\nAttention, Si vous désirez continuer à naviguer sur Internet, ouvrez une nouvelle fenètre pour le faire. Faute de quoi la lecture audio sera stoppée.\nLe confirmez-vous ?');
	if(valid){
		$('audioweb_credit_count').innerHTML=(cnt-1);
		audiowebAjax(file);
		setTimeout(audiowebHeightAjust, 1500);
	}
	return false;
}

function audioweb_convertToCompare(file){
	tmp = file.substr(0,1);
	if(tmp=='b')
		tmp='Ouverture';
	if(tmp=='m')
		tmp='Millieu de séance';
	if(tmp=='e')
		tmp='Fin de séance';
	//d = new Date(file.substr(4,4), file.substr(8,2), file.substr(10,2));
	return tmp+" du "+file.substr(10,2)+"/"+file.substr(8,2)+"/"+file.substr(4,4);
}

function audiowebAjax(audioCode){
	//var myAjax = new Ajax.Updater('audioweb_player', audiowebAjaxUrl(), {method: 'get', parameters: 'audioCode='+audioCode+'&position='+audiowebPlayerPosition}); 		
	var request = new Ajax.Request(audiowebAjaxUrl(), { method: 'get', parameters: 'audioCode='+audioCode+'&position='+audiowebPlayerPosition, onSuccess: audiowebAjaxSuccess});
}

function audiowebAjaxSuccess(xhr){
	txt = xhr.responseText
	$('audioweb_player').innerHTML=txt;
	if(txt.indexOf('petite taille') >0 )
		audioweb_credit(1);
}

function audioweb_credit(val){
	cnt = parseInt($('audioweb_credit_count').innerHTML);
	$('audioweb_credit_count').innerHTML=(cnt+val);
}


// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 6;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// -----------------------------------------------------------------------------

function audioweb_checkFlash(){
	// Version check based upon the values entered above in "Globals"
	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	// Check to see if the version meets the requirements for playback
	if (hasReqestedVersion) 
		audiowebAjax('');
	else {  // flash is too old or we can't detect the plugin
		var alternateContent = 'Flash n\'est pas installé sur votre navigateur ou il est trop ancien !'
		+ '<br/><a href="http://www.adobe.com/go/getflash/">Obtenir Flash</a><br/>';
		$('audioweb_player').innerHTML = alternateContent;  // insert non-flash content
	}	
	
}


















// Report des JS de l'ancienne version



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function Livraison(){
	$('autreAdresse1').style.display="none";
	$('adresseLivraison').style.display="block";
	$('nouvelleLivraison').value=true;
}
function Facturation(){
	$('autreAdresse1').style.display="none";
	$('adresseFacturation').style.display="block";
	$('nouvelleFacturation').value=true;
}
function validCondition(){
	if($('condition').checked==true)
		$('form1').submit();
	else	
		alert("Vous devez avoir pris connaissance des conditions générales de vente");	
	
}
function quickLink(){
	url = $('quickLink').options[$('quickLink').selectedIndex].value;
	window.location=url;
}

function update(type) {
	if(type=='livraison'){	
			$('adresseLivraison').style.display='none';
			// reste a mettre a jour l'adresse affichée
			$('dispLivraison').innerHTML = $('societe_livraison').value+'<br/>'+$('civilite_livraison').value+" "+$('nom_livraison').value+" "+$('prenom_livraison').value+"<br/>"+$('adresse_livraison').value+"<br/>"+$('cp_livraison').value+" "+$('ville_livraison').value+"<br/>"+$('pays_livraison').value;
	}
	else{
			$('adresseFacturation').style.display='none';
			// reste a mettre a jour l'adresse affichée
			$('dispFacturation').innerHTML = $('societe_facturation').value+'<br/>'+$('civilite_facturation').value+" "+$('nom_facturation').value+" "+$('prenom_facturation').value+"<br/>"+$('adresse_facturation').value+"<br/>"+$('cp_facturation').value+" "+$('ville_facturation').value+"<br/>"+$('pays_facturation').value;
	
	}
}

function verifForm(typeSemFormID){
	form = $(typeSemFormID);
	idseminaire = form.idseminaire.value;
	nbpers = form.nbPersonne.value;
	url = "panier_ajout_"+idseminaire+"_"+nbpers+".fb";
	$(typeSemFormID).action=url;
	$(typeSemFormID).submit();
}

 function verifAccountForm(){
 	var objForm=document.forms.formMonCompte;
 
	 if (
	 (objForm.Civilite.options.selectedIndex!=0)
	 &&(objForm.Nom.value!='')
	 && (objForm.Prenom.value!='') 
	 && (objForm.Adresse.value!='')
	 && (objForm.CodePostal.value!='')
 	 && (objForm.Ville.value!='')
 	 && (objForm.codePaysIso.value!='')
 	  && (objForm.Portable.value!='' ||objForm.tel_fixe.value!='')
	 && (validMail(objForm.Mail.value))
     && (validMail(objForm.Mail2.value))   
	 && (validPasswdMonCompte(objForm.password.value,objForm.password2.value))
	
	 )
	 {
		
		objForm.submit();
	 }else{
	 	alert("Erreur dans la saisie des champs obligatoires");
	 }

 }
 
 function swapOnglet(onglet){
	$('infosPersonnelles').style.display="none";	
	$('gestionAboCommande').style.display="none";
	$(onglet).style.display="block";
}

function lireMail(id,type){
	document.forms.formMailComplet.typeMail.value=type;
	document.forms.formMailComplet.id.value=id;
	document.forms.formMailComplet.submit();	
}

function validationQuestion(){
	if (document.forms.formQuestionFaq.titre.value=="" ||document.forms.formQuestionFaq.question.value=="")
		alert("veuillez bien remplir les champs titres et questions , svp");
	else
		document.forms.formQuestionFaq.submit();
}

// Verif formulaire "payez moins cher"
function PMC_Valid_form(){
        var objForm=document.forms.form1;
 
         if (
         (objForm.Nom.value!='')
         && (objForm.Prenom.value!='') 
         && (objForm.Adresse.value!='')
         && (objForm.CodePostal!='')
         && (objForm.Ville.value!='')
         && (validMail(objForm.Email.value))
         )
                objForm.submit();
         else
                alert("Erreur dans la saisie des champs obligatoires");
 }
 
 
function retirerMnemo(mnemo){
		document.forms.validerForm.validation.value=0;
		document.forms.retirerForm.MnemoARetirer.value = mnemo;
		document.forms.retirerForm.submit();	
}
function ajouterMnemo(){
		document.forms.validerForm.validation.value=0;
		document.forms.ajouterForm.submit();	
}

function testTB(){
	if (document.forms.validerForm.validation.value !=1 || document.forms.ajouterForm.mnemoValeur.value!='' ) 
		alert('Vous devez préalablement valider votre tableau de bord avant de pouvoir afficher celui-ci');
	else
		document.location="affichageTableauDeBord.fb";
}

function validerTB(){
	document.forms.validerForm.validation.value=1;
	document.forms.validerForm.submit();
}

// Mot d epasse oublié
function FP_Valid_form(){
    var mail = document.forms.formOubliePass.mail.value;  
    if(validMail(mail)) 
    	document.forms.formOubliePass.submit();
}

function afficheAnalyseGraphique(nom){
    var objForm = document.forms.fluxListValeur;
    
    objForm.nomValeur.value=nom;
    objForm.submit();


}


function showTube(part){
	if($('part1'))
		$('part1').style.display="none";
		
	if($('part2'))
		$('part2').style.display="none";

	if($('part3'))
		$('part3').style.display="none";		
	
	$('part'+part).style.display="block";
}

function afp(){
	document.write('<img src="http://www.francebourse.com/images_v2/picto-afp.gif"/>');
	document.write('<br/><div id="afp1" onClick="afpDetail();">Tous droits de reproduction et de représentation réservées. &copy; '+((new Date()).getFullYear())+' Agence France-Presse.</div>');
	document.write('<div id="afp2">Toutes les informations reproduites sur cette page sont protégées par des droits de propriété intellectuelle détenus par l\'AFP. Par conséquent, aucune de ces informations ne peut être reproduite, modifiée, rediffusée, traduite, exploitée commercialement ou réutilisée de quelque manière que ce soit sans l\'accord préalable écrit de l\'AFP. L\'AFP ne pourra être tenue pour responsable des délais, erreurs, omissions qui ne peuvent être exclus, ni des conséquences des actions ou transactions effectuées sur la base de ces informations.</div>');
}

function afpDetail(){
	$('afp2').style.display=$('afp2').style.display=='block'?'none':'block';	
}

function productAlreadyAdded(oldQty,newQty){
	alert("ATTENTION : \nLe produit que vous venez d'ajouter se trouvait déjà dans votre panier.\nVous portez sa quantité de "+oldQty+" à "+(oldQty+newQty));
}








// Ajout pour la version 3 du site

Event.observe(document, 'click', function (evt) {
	var elt = Event.findElement(evt, 'DIV');
	
	if (elt && elt.className && elt.className.indexOf('module_header_right_o') >= 0) {
		elt.className = 'module_header_right_'+ ((elt.className == 'module_header_right_off')?'on':'off');
		realElt = _swapModuleView(elt);
		
		// A l'avenir faire un register de Hook plus propre !!!!
		if(realElt.id.indexOf('_news')>0)
			_hookNewsDivHeight();
		
		//alert('ajax...'+realElt.id);
		var request = new Ajax.Request('index.ajax', { method: 'get', parameters: 'elt='+realElt.id});
	}
	else
		if (elt && elt.className && elt.className.indexOf('module_header_right_rss') >= 0) 
		window.location='/rss.xml';
});

Event.observe(window, 'load', function () {
	document.getElementsByClassName('module_header_right_off').each(function(elt){
		_swapModuleView(elt);
	});
});

function swapModuleViewWithAjax(onlyIds){
	document.getElementsByClassName('module_header_right_off').each(function(elt){
		if(onlyIds.indexOf(elt.parentNode.parentNode.parentNode.id) >= 0)
			_swapModuleView(elt);
	});	
}

Event.observe(window, 'load', function () {
		setInterval("publishSwap();",10000);
});

function _getCollapsedElement(elt){
	var tmp = elt.parentNode.parentNode.parentNode;

	if(tmp.className.indexOf('module_') < 0)
		tmp = elt.parentNode.parentNode;
		
	return tmp;	
}	


function _swapModuleView(elt){
	var tmp = _getCollapsedElement(elt);
	
	//alert(tmp.id);
	var content = tmp.childNodes.item((document.all)?1:3);
	var footer = null;
	var nofooter = null; 
	
	/*
	log=tmp.id+":"+tmp.childNodes.length +"::";
	for(i=0;i<10;i++)
		log+=i+">"+(tmp.childNodes.item(i)?tmp.childNodes.item(i).className:'nop')+"|";
	alert(log);
	*/
	
	if((document.all && tmp.childNodes.length == 4) || (!document.all && tmp.childNodes.length == 8)) {
		footer = tmp.childNodes.item((document.all)?2:5);
		nofooter = tmp.childNodes.item((document.all)?3:7);
	}

	//alert(nofooter.className);
	content.style.display=(content.style.display != 'none')?'none':'block';
	if(footer) footer.style.display=(footer.style.display != 'none')?'none':'block';
	if(nofooter) nofooter.style.display=(nofooter.style.display != 'block')?'block':'none';
	
	return tmp;
}

function publishSwap(){
	if($('publish_QI').style.display != 'none') {
		$('publish_QI').style.display = 'none';
		$('publish_PE').style.display = 'block';
		$('publish_header').className='publish_header_PE';
	}
	else {
		$('publish_PE').style.display = 'none';
		$('publish_QI').style.display = 'block';
		$('publish_header').className='publish_header_QI';
	}
}

/* Forcage taille DIV consultation de news */
Event.observe(window, 'load', _hookNewsDivHeight);
if(!document.all)
	Event.observe(window, 'resize', _hookNewsDivHeight);
else
	setInterval(_hookNewsDivHeight,10000);

function _hookNewsDivHeight(){
	if($('news_text')) {
		$('news_text').style.height='auto';
		if($('news_text') && $('news_left') && $('news_text').getHeight() < $('news_left').getHeight())
			$('news_text').style.height=($('news_left').getHeight()+5)+'px';
	}
}


/* Signalisation d'un abus dans les commentaires */
var reported = new Array();
function reportUserComment(id){
	if (reported.indexOf(id) > -1){
		alert('Vous avez déjà signalé cet avis !');	
		return false;
	}
	
	var request = new Ajax.Request('fiche_news.ajax', { method: 'get', parameters: 'urc_id='+id});
	alert('Nous vous remercions d\'avoir siganlé cette abus. \nCela nous aidera certainement à améliorer ce service.');
	reported.push(id);
	
	return false;
}

/* Pagginaltion des commentaires */
var _commentsCurPage = 1;
Event.observe(window, 'load', initCommentPagging);	

var _commentsNbPages;

function setCommentsNbPagesValue(val){
	_commentsNbPages = val;
}

function initCommentPagging(){
	if(typeof(_commentsNbPages) != 'undefined') {
		setCommentsNbPages(_commentsNbPages);
		setCommentsCurPage(_commentsCurPage);
		goFirstCommentsPage();
	}	
}			

function submitCommentForm(){
	if($('comments_name').value.length == 0 || $('comments_mail').value.length == 0 || $('comments_title').value.length == 0 || $('comments_text').value.length == 0)
		alert('Veuillez renseigner tous les champs SVP.');
	else				
		$('commentsForm').submit();	
}

var pollUrl = "/pollVote.php";
function votePoll(poll,option){
	var myAjax = new Ajax.Updater('poll_ajax', pollUrl, {method: 'get', parameters: 'vote='+option+'&poll='+poll}); 		
	return false;	
}


/* analyse.fb*/
var currentAnalyseTab;
function viewAnalyse(code, el){
	if(currentAnalyseTab)
		currentAnalyseTab.className='analyse_off';
	
	$('ana_ANT').style.display='none';
	$('ana_ANE').style.display='none';
	$('ana_ANF').style.display='none';
	$('ana_INTRO').style.display='none';
	$('ana_REDRES').style.display='none';
	$('ana_AK').style.display='none';
	
	$('ana_'+code).style.display='block';
	el.className='analyse_on';
	currentAnalyseTab = el;
}


Event.observe(window, 'load', function () {
	if($('tab_ANT'))
		viewAnalyse('ANT', $('tab_ANT'));
});


/* Testez votre profile */
function profilHideAll(){
	$('profil_home').style.display='none';
	$('profil_pub').style.display='none';
	
	$('profil_newbye').style.display='none';
	$('profil_pro').style.display='none';
	
	$('profil_result_header').style.display='none';
	$('profil_result_footer').style.display='none';

	$('result_1_1').style.display='none';
	$('result_1_2').style.display='none';
	$('result_1_3').style.display='none';
	
	$('result_2_1').style.display='none';
	$('result_2_2').style.display='none';
	$('result_2_3').style.display='none';
	$('result_2_4').style.display='none';
}

function profilShowHome(){
	profilHideAll();
	$('profil_home').style.display='block';
	$('profil_pub').style.display='block';
}

function profilShowResult(id, code){
	profilHideAll();
	
	$('profil_result_header').style.display='block';
	$('result_'+id+'_'+code).style.display='block';

	$('profil_pub').style.display='block';
	$('profil_result_footer').style.display='block';
	
	window.location='#top';
}

function evalProfil(id){
	var formValues = Form.serialize("form"+id).toQueryParams([separator = '&']);
	var total = (id==1)?11:12;
	var a1=0, a2=0, a3=0;
	for(i=1;i<=total;i++){
		val = formValues['prof'+id+'_q'+i];
		if(val == 1)
			a1++;
		else if(val == 2)
			a2++;
		else
			a3++;	
	}
	var score = a1 + (a2*2) + (a3*3);
	var maxScore = [a1,a2,a3].max();
	
	if(id == 2){
		if (score<18)
			profilShowResult(id, 1);
		else if (score<24)
			profilShowResult(id, 2);
		else if (score<30)
			profilShowResult(id, 3);
		else
			profilShowResult(id, 4);
	} else {
		if(	maxScore == a1)
			profilShowResult(id, 1);
		else if(maxScore == a2)
			profilShowResult(id, 2);
		else
			profilShowResult(id, 3);
	}
	
	return false;	
}

/* Lexique boursier */
function lexiconShow(code){
	$('lexicon_home').style.display='none';
	$('lexicon_forum').style.display='none';
	$('lexicon_at').style.display='none';
	$('lexicon_af').style.display='none';
	$('lexicon_indice').style.display='none';

	$('lexicon_home_link').style.visibility='visible';
	$('lexicon_forum_link').style.visibility='visible';
	$('lexicon_at_link').style.visibility='visible';
	$('lexicon_af_link').style.visibility='visible';
	$('lexicon_indice_link').style.visibility='visible';
	
	$('lexicon_'+code).style.display='block';
	$('lexicon_'+code+'_link').style.visibility='hidden';
}

/* Journal JT */
var currentItem;
// these functions are caught by the JavascriptView object of the player.
function sendEvent(typ,prm) { if(getFlashVideoPlayer()) getFlashVideoPlayer().sendEvent(typ,prm);};
function removeItem(obj,idx) { if(getFlashVideoPlayer()) getFlashVideoPlayer().removeItem(obj,idx); }
function addItem(obj,idx) { if(getFlashVideoPlayer()) getFlashVideoPlayer().addItem(obj,idx); }
function getUpdate(typ,pr1,pr2,pid) {
	if(typ == "item") { currentItem = pr1; setTimeout("getItemData(currentItem)",100); }
};

function getFlashVideoPlayer(){
	if($("mpl"))
		return $("mpl");
	if($("mph"))
		return $("mph");
	return null;
}

// These functions are caught by the feeder object of the player.
function getItemData(idx) {
	var obj = getFlashVideoPlayer().itemData(idx);
	id = obj['id'];
	_getItemData(id);
};

function _getItemData(newsId) {
	if(newsId){
		var url = 'jt.ajax';
		var myAjax1 = new Ajax.Updater('ajaxNews_Content', url, {method: 'get', parameters: 'type=content&id='+newsId, evalScripts: true}); 		
		var myAjax2 = new Ajax.Updater('ajaxNews_Comments', url, {method: 'get', parameters: 'type=comments&id='+newsId, evalScripts: true}); 		
	}
};

var _JT_ORG='org';
var _JT_OTHER='other';
var currentJT=_JT_ORG;


var otherJtAdded = false;
function toggleOtherJT(){
	_loadOtherJT();
	if(currentJT == _JT_ORG){
		currentJT = _JT_OTHER;
		sendEvent('playitem',1);				
	} else {
		currentJT = _JT_ORG;
		sendEvent('playitem',0);						
	}
	
	_toggleJtBackground();			
}

function _toggleJtBackground(){
	if ($('module_header_JT').className == 'jt_bourse')
		$('module_header_JT').className = 'jt_actu';
	else
		$('module_header_JT').className = 'jt_bourse';

	$('jt_link').href=$('module_header_JT').className+'.fb';		
}

function _loadOtherJT(){
		if (!otherJtAdded)
			addItem({file:otherJTurl});
		otherJtAdded = true;				
}
/* FIN Journal JT */


/* GRAPH CAC 40 */
var cac_refresh=30000;

/* Affichage dynamique du module CAC40 */
function refreshCac(){
        $('cac-img').src='http://www.francebourse.com/cac40.png'+"?d="+(new Date()).getTime();
        new Ajax.Updater('cac-perf', 'cac40.html?d='+(new Date()).getTime(), {method: 'get'});
}

function refreshCacAmorce(){
	if($('cac-img')){
		refreshCac();
       	var cacTimer=setInterval("refreshCac()", cac_refresh);
	}
}

Event.observe(window, 'load', refreshCacAmorce , false);
/* FIN GRAPH CAC 40 */
