function ajaxPage(module,url,analyticsTag) {
	if(!onLoading){
		mosaic.activate(module == '' && url == '');
		onLoading = true;
		getNumInfo();

		if(module != '')
			pageTracker._trackPageview(analyticsTag == null ? '/'+module : analyticsTag);
		else
			pageTracker._trackPageview(window.mosaicFolder);

		var postBody = 'module='+module;
		if(url!='')
			postBody = postBody+url;

		if(window.noPageLoaded) loadCleanPage(postBody);
		else animFadePage(postBody);
		window.currentpage=module;
	}
}

function openMosaic(mosaicFolder)
{
	window.mosaicFolder = '/'+mosaicFolder;
	mosaic.paramsInit(mosaicFolder);
	if(!window.noPageLoaded)
		ajaxPage('','');
	else
		mosaic.activate(true);
}

function ajaxSubPage(module,url) {
	if(url=='')
	var postBody = 'module='+module;
	else
	var postBody = 'module='+module+url;
	animFadePage2(postBody);
	window.currentpage=module;
}
var onLoading=false;
var pageclosecallbacks=new Array;
var pagefadecallbacks=new Array;


var pageopenedcallbacks=new Array;

var pageopened=false;

var currentvideo=0;
window.noPageLoaded=false;

function setStyle(element, text) {
	$(element).setAttribute("style", text)
	$(element).style.cssText = text
}

function onBWDone(bandwidth) {
	new Ajax.Request('ajax/action.php', {method:'post',postBody:'action=setBandwidth&band='+bandwidth});
}

function animFadePage(postBody) {
	if(pagefadecallbacks.length>0) {
		var i;
		for(i=0; i<pagefadecallbacks.length; i++) {
			pagefadecallbacks[i]();
		}
		pagefadecallbacks=new Array;
	}
	pageopened=false;
  if($('div_content')) new Effect.Opacity('div_content',{from: 1.0, to: 0.0 ,duration: 0.5,afterFinish: function() { animHidePage(postBody); } });
	else animHidePage(postBody);
}
function animHidePage(postBody) {
	if(!$('pagecontent')) return;
	setStyle('pagecontent',"width:100%; text-align:center; position:relative; top:"+(parseInt($('pagecontent_holder').offsetHeight)-parseInt($('pagecontent').offsetHeight))+"px; left:0px;");
	if($('div_content')) $('div_content').innerHTML='&nbsp;';
	if(pageclosecallbacks.length>0) {
		var i;
		for(i=0; i<pageclosecallbacks.length; i++) {
			pageclosecallbacks[i]();
		}
		pageclosecallbacks=new Array;
	}
  new Effect.Move('pagecontent',{x:0,y:parseInt($('pagecontent').offsetHeight),mode:'relative',duration: 0.5, afterFinish: function() { $('pagecontent').innerHTML=''; loadCleanPage(postBody); } });
}
function loadCleanPage(postBody) {
	if(postBody=='module=' && !window.noPageLoaded) {
		/*var mtop=$('menu').cumulativeOffset().top;
		var mstop=$('mask').getHeight();
		$('top').clonePosition('menu');
		$('top').setStyle({'top': -(mtop+mstop)+'px'});
		$('divtop').setStyle({'height' : $('top').getHeight()+'px'});
		$('menu').setStyle({'top': (mtop+parseInt($('menu').getStyle('top')))+'px'});
		//$('menu').style.bottom='0px';
		$('menu').style.left='0px';
		$('pagecontent_holder').style.display='none';
		$('main').style.display='none';
		$('main2').style.display='none';*/
		$('top').setStyle({'display':'none'});
		window.noPageLoaded=true;
		pageopenedcall();
		onLoading = false;//rajouter pour controler le clic
		
	} else {
		if(window.noPageLoaded) {
			if(pageclosecallbacks.length>0) {
				var i;
				for(i=0; i<pageclosecallbacks.length; i++) {
					pageclosecallbacks[i]();
				}
				pageclosecallbacks=new Array;
			}
			//setStyle('top','position: relative; z-index: 1;');
			//$('top').style.top=-$('mask').getHeight()+'px';
			$('top').setStyle({'display':'block'});
			setStyle('menu','z-index: 100;');
			setStyle('divtop','');
			$('menu').style.left='';
			$('pagecontent_holder').style.display='';
			$('main').style.display='';
			$('main2').style.display='';
			window.noPageLoaded=false;
		}
		new Ajax.Updater('pagecontent', 'ajax/action.php', {
			method:'post',
			postBody:postBody+"&is_loading=1",
			onComplete: function() { animShowPage(postBody); },
			evalScripts: true
		});
	}
}

function animShowPage(postBody) {
	setStyle('pagecontent',"width:100%; text-align:center; position:relative; top:"+(parseInt($('pagecontent_holder').offsetHeight))+"px; left:0px;");
	if(supersleight) {supersleight.run('layer1');supersleight.run('layer2');supersleight.run('layer21');}
	new Effect.Move('pagecontent',{x:0,y:-parseInt($('pagecontent').offsetHeight),mode:'relative',duration: 1, afterFinish: function() { loadTruePage(postBody); } });
}

function loadTruePage(postBody) {
	new Ajax.Updater('pagecontent', 'ajax/action.php', {
		method:'post',
		postBody:postBody,
		onComplete: function() {
		if(supersleight) {supersleight.run('layer1');supersleight.run('layer2');supersleight.run('layer21');}	
		animUnfadePage();
		if(!$('div_content')){if(supersleight) {supersleight.run('divtop');}}  
		
		},
		evalScripts: true
	});	
}
function animUnfadePage() {
	if($('div_content'))	new Effect.Opacity('div_content',{from: 0.0, to: 1.0 ,duration: 0.5, afterFinish: function() { ismenuloaded=true; if(supersleight) {supersleight.run('divtop');} } });
	else 	ismenuloaded=true;
	pageopenedcall();
	pageopened=true;
	onLoading = false;//rajouter pour control� le clic
}

function animFadePage2(postBody) {
	if(pagefadecallbacks.length>0) {
		var i;
		for(i=0; i<pagefadecallbacks.length; i++) {
			pagefadecallbacks[i]();
		}
		pagefadecallbacks=new Array;
	}
	pageopened=false;
  if($('div_content')) new Effect.Opacity('div_content',{from: 1.0, to: 0.0 ,duration: 0.5,afterFinish: function() { loadTruePage(postBody); } });
	else loadTruePage(postBody);
}

function pageopenedcall() {
//	$('debug').innerHTML+="show: "+pageopenedcallbacks.length+"<br>";
	if(pageopenedcallbacks.length>0) {
		var i;
		for(i=0; i<pageopenedcallbacks.length; i++) {
			pageopenedcallbacks[i]();
		}
		pageopenedcallbacks=new Array;
	}
}

function showLoad() {
	$('loading').style.visibility='visible';
}

function hideLoad() {
	$('loading').style.visibility='hidden';
}
var imagesLoading={};
function checkImages() {
	var imgs=$('pagecontent').getElementsByTagName('IMG');
	for(var i in imgs) {
		imagesLoading[imgs[i].src]=true;
		$(imgs[i]).onload=imageLoaded;
	}
}


function initialiseAnimUpDown(id){
	if($$('.ImgScrollUp')[0]) $$('.ImgScrollUp')[0].setStyle({'visibility':'hidden'});
	if($(id).getHeight()<=$($(id).parentNode).getHeight() && $$('.ImgScrollDown')[0]) $$('.ImgScrollDown')[0].setStyle({'visibility':'hidden'});
}

function animUp(id) {
if(-parseInt($(id).style.top)>=$(id).getHeight()-$($(id).parentNode).getHeight()) return;
	var hauteur=null;
	if( ($(id).getHeight()-(-parseInt($(id).style.top)+$($(id).parentNode).getHeight()) )>=$($(id).parentNode).getHeight() )
		hauteur = $($(id).parentNode).getHeight() ;
	else
		hauteur = ($(id).getHeight()-(-parseInt($(id).style.top)+$($(id).parentNode).getHeight() ));		
	
	new Effect.Move(id,{x:0,y:-hauteur,mode:'relative',duration: 0.5 ,afterFinish : function(){if(-parseInt($(id).style.top)>=$(id).getHeight()-$($(id).parentNode).getHeight() && $$('.ImgScrollDown')[0]) $$('.ImgScrollDown')[0].setStyle({'visibility':'hidden'});}});
		if($$('.ImgScrollUp')[0]) $$('.ImgScrollUp')[0].setStyle({'visibility':'visible'});
}


function animDown(id) {

if(parseInt($(id).style.top)==0) return;
	var hauteur=null;
	if( -parseInt($(id).style.top)>=$($(id).parentNode).getHeight() )
		hauteur = $($(id).parentNode).getHeight() ;
	else
		hauteur = -parseInt($(id).style.top);
	
	new Effect.Move(id,{x:0,y:hauteur,mode:'relative',duration: 0.5 ,afterFinish : function(){if(parseInt($(id).style.top)==0 && $$('.ImgScrollUp')[0]) $$('.ImgScrollUp')[0].setStyle({'visibility':'hidden'});}});
	if($$('.ImgScrollDown')[0]) $$('.ImgScrollDown')[0].setStyle({'visibility':'visible'});
}

function setFaceContainerPosition(x, y)
{
	$('div_face_container').style.left = x+"px";
	$('div_face_container').style.top = y+"px";
}

function moveFaceContainerPosition(dx, dy)
{
	var container = $('div_face_container');
	setFaceContainerPosition(container.offsetLeft+dx, container.offsetTop+dy);
}

function showUserFace(id, x, y, firstname, country, opinion) {
	if(!noPageLoaded) {
		window.pageopenedcallbacks.push(function() { showUserFace(id, x, y, firstname, country, opinion); });
		ajaxPage('','');
		return;
	}
	if($('div_face_container').style.display!="none") {
		for(var i=0; i<window.pageclosecallbacks.length; i++) {
			if(window.pageclosecallbacks[i]==window.closeFace) {
				window.pageclosecallbacks.splice(i,i);
			}
		}
		closeFace();
		return;
	}
	
	var size = windowSize();

	setFaceContainerPosition(x, y-10);
	new Effect.Appear('div_face_container',{duration:0.5, afterFinish:function() {
		window.pageclosecallbacks.push(window.closeFace);
	if (supersleight)
	{
		$('userFaceCloseButton').style.width="21px";
		$('userFaceCloseButton').style.height="20px";
		$('userFaceCloseButton').src="images/5_traduction_06_05.png";
		supersleight.run('div_face_container');
	}
	} });
	
	$('face_content').hide();
	new Ajax.Request('ajax/action.php', {
		method:'post',
		parameters:{action:'getFaceData',idu:id, firstname:firstname, country:country, opinion: opinion},
		onSuccess: function(t) { 
				$('face_content').innerHTML=t.responseXML.documentElement.getElementsByTagName('name')[0].childNodes[0].nodeValue;

				if(t.responseXML.documentElement.getAttribute('is6ma')=="1" && id) {
					updateList('theme_list', t.responseXML, 'themes', 'thematicsLink');
					updateList('podcast_list', t.responseXML, 'podcasts', 'podcastsLink');
				}

				$('face_content').show();
		}
	});	
}

function updateList(id, response, xmlId, idLink)
{
	var nodes = response.documentElement.getElementsByTagName(xmlId)[0].childNodes;
	if (nodes.length == 0 || nodes[0].nodeValue == "") {
		if ($(idLink))
			$(idLink).hide();
	}
	else
	{
		$(id).innerHTML=nodes[0].nodeValue;
		$(idLink).show();
	}
}

function closeFace() {
	$('div_face_container').hideVeil();
	mosaic.closeContainer();
}

function hideUserFace() {
	if ($("div_face_container"))
	{
		if ($("subPanel").subPanelShown)
			$("subPanel").hideSubPanel(null);	
		new Effect.Fade('div_face_container', {duration: 0.5, afterFinish: function() {$('div_face_container').hideVeil();}});
	}
}

function flashPause()
{
	var flash = getFlashObject('vidplayer_flash');
	if (flash && flash.flashPauseCallback)
		flash.flashPauseCallback()
}

function showLoginOverlay() {
	flashPause();
	$(document.body).insert('<div id="login_overlay" style="display:none;"></div>',{position:'bottom'});
	var postBody = 'module=login_overlay';
	new Ajax.Updater('login_overlay','ajax/action.php', {method:'post',evalScripts: true, postBody:postBody, onLoading: showLoad, onComplete:
			function(t){
				hideLoad();
				setStyle('login_overlay','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2008; display:block; background-color:black; text-align:center;');
				$('div_container_over').style.top=($('login_overlay').getHeight()-$('div_container_over').getHeight()-25)/2+'px';
				if(supersleight){supersleight.run('div_container_over');}
	    }
		});
}

function showPortrait6ma(id, hideTop) {
	$('div_face_container').showVeil();
	var postBody = 'module=portraits_6ma&id_user='+id+(hideTop != null ? '&hideTop='+hideTop : '');
	var f = function() {
	new Ajax.Updater('main2','ajax/action.php', {method:'post',evalScripts: true, postBody:postBody, onLoading: showLoad, onComplete:
			function(t){
				closeFace();
				pageTracker._trackPageview("/portraits_6ma");
				$('top').style.display="none";
				setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:none;');
				setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%; opacity: 0;filter:alpha(opacity=0);');
				$('main').className="mainBlack";
				new Effect.Opacity('main',{from:0, to: 1, duration: 1, afterFinish: function() { $('main2').style.display="block"; $('main').style.opacity=1;$('main').style.filter='alpha(opacity=100)'; if(supersleight){supersleight.run('videocloser');}} });
     }
		});
	};
	if(supersleight) setTimeout(f, 200);
	else f();
	if(window.currentpage=='intro') ajaxPage('','');
}
function showPortraitUser(id) {
	$('div_face_container').showVeil();
	var postBody = 'module=portraits_user&id_user='+id;
	new Ajax.Updater('main2','ajax/action.php', {method:'post',evalScripts: true, postBody:postBody, onLoading: showLoad, onComplete:
			function(t){
				closeFace();
				pageTracker._trackPageview("/portraits_user");
				$('top').style.display="none";
				setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:none;');
				setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%; opacity: 0;filter:alpha(opacity=0);');
				$('main').className="mainBlack";
				new Effect.Opacity('main',{from:0, to: 1, duration: 1, afterFinish: function() { $('main2').style.display="block"; $('main').style.opacity=1;$('main').style.filter='alpha(opacity=100)'; } });
     }
		});
	if(window.currentpage=='intro') ajaxPage('','');
}
function showThematic(id) {
	$('div_face_container').showVeil();
	var postBody = 'module=themes&id_thematic='+id;
	var f = function() {
	new Ajax.Updater('main2','ajax/action.php', {method:'post', evalScripts: true,postBody:postBody, onLoading: showLoad, onComplete:
			function(t){
				closeFace();
				pageTracker._trackPageview("/themes");
				$('top').style.display="none";
				setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:none;');
				setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%; opacity: 0;filter:alpha(opacity=0);');
				$('main').className="mainBlack";
				new Effect.Opacity('main',{from:0, to: 1, duration: 1, afterFinish: function() { $('main2').style.display="block"; $('main').style.opacity=1;$('main').style.filter='alpha(opacity=100)'; if(supersleight){supersleight.run('videocloser');}} });
     }
		});
	};
	if(supersleight) setTimeout(f, 200);
	else f();
	if(window.currentpage=='intro') ajaxPage('','');
}
function showQuestion(id,user,hideTop) {
	$('div_face_container').showVeil();
	var postBody = 'module=questions&id_question='+id+'&id_user='+user+(hideTop != null ? '&hideTop='+hideTop : '');
	var f = function() {
	new Ajax.Updater('main2','ajax/action.php', {method:'post', evalScripts: true,postBody:postBody, onLoading: showLoad, onComplete:
			function(t){
				closeFace();
				pageTracker._trackPageview("/questions");
				$('top').style.display="none";
				setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:none;');
				setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%; opacity: 0;filter:alpha(opacity=0);');
				$('main').className="mainBlack";
				new Effect.Opacity('main',{from:0, to: 1, duration: 1, afterFinish: function() { $('main2').style.display="block"; $('main').style.opacity=1;$('main').style.filter='alpha(opacity=100)';if(supersleight){supersleight.run('videocloser');} } });
     }
		});
			};
	if(supersleight) setTimeout(f, 200);
	else f();
		
	if(window.currentpage=='intro') ajaxPage('','');
}
function showQuestionOp(id,opinion) {
	var postBody = 'module=questions&id_question='+id+'&id_opinion='+opinion;
	new Ajax.Updater('main2','ajax/action.php', {method:'post', evalScripts: true,postBody:postBody, onLoading: showLoad, onComplete:
			function(t){
				hideLoad();
				pageTracker._trackPageview("/questions");
				$('top').style.display="none";
				setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:none;');
				setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%; opacity: 0;filter:alpha(opacity=0);');
				$('main').className="mainBlack";
				new Effect.Opacity('main',{from:0, to: 1, duration: 1, afterFinish: function() { $('main2').style.display="block"; $('main').style.opacity=1;$('main').style.filter='alpha(opacity=100)'; } });
     }
		});
	if(window.currentpage=='intro') ajaxPage('','');
}
function showPortraitOp(id,opinion,hideTop) {
	var postBody = 'module=portraits_6ma&id_user='+id+'&id_opinion='+opinion+(hideTop != null ? '&hideTop='+hideTop : '');;
	new Ajax.Updater('main2','ajax/action.php', {method:'post',evalScripts: true, postBody:postBody, onLoading: showLoad, onComplete:
			function(t){
				closeFace();
				pageTracker._trackPageview("/portraits_6ma");
				$('top').style.display="none";
				setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:none;');
				setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%; opacity: 0;filter:alpha(opacity=0);');
				$('main').className="mainBlack";
				new Effect.Opacity('main',{from:0, to: 1, duration: 1, afterFinish: function() { $('main2').style.display="block"; $('main').style.opacity=1;$('main').style.filter='alpha(opacity=100)'; } });
     }
		});
	if(window.currentpage=='intro') ajaxPage('','');
}
function showPodcasts(id) {
	$('div_face_container').showVeil();
	var postBody = 'module=podcasts&id_podcast='+id;
	var f = function() {
	new Ajax.Updater('main2','ajax/action.php', {method:'post',evalScripts: true, postBody:postBody, onLoading: showLoad, onComplete:
			function(t){
				closeFace();
				pageTracker._trackPageview("/podcasts");
				$('top').style.display="none";
				setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:none;');
				setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%; opacity: 0;filter:alpha(opacity=0);');
				$('main').className="mainBlack";
				new Effect.Opacity('main',{from:0, to: 1, duration: 1, afterFinish: function() { $('main2').style.display="block"; $('main').style.opacity=1;$('main').style.filter='alpha(opacity=100)';if(supersleight){supersleight.run('vidcontainer');}} });
     }
		});
	};
	if(supersleight) setTimeout(f, 200);
	else f();
	if(!window.noPageLoaded) ajaxPage('','');
}

function showSinglePlayer(id) {
	var postBody = 'module=singleplayer&id_opinion='+id;
	new Ajax.Updater('main2','ajax/action.php', {method:'post',evalScripts: true, postBody:postBody, onLoading: showLoad, onComplete:
			function(t){
				hideLoad();
				pageTracker._trackPageview("/singleplayer");
				$('top').style.display="none";
				setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:none;');
				setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%; ');
				$('main').className="mainBlack";
     }
		});
	if(window.currentpage=='intro') ajaxPage('','');
}

function showMakingOf(id) {
	var postBody = 'module=makingof&idflash=flashsub';
	if(id) postBody += '&name_makingof='+id;
	new Ajax.Updater('main2','ajax/action.php', {method:'post',evalScripts: true, postBody:postBody, onLoading: showLoad, onComplete:
		function(t){
			hideLoad();
			pageTracker._trackPageview("/makingof_"+id);
			$('top').style.display="none";
			setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:none;');
			setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%; opacity: 0;filter:alpha(opacity=0);');
			$('main').className="mainBlack";
			new Effect.Opacity('main',{from:0, to: 1, duration: 1, afterFinish: function() { $('main2').style.display="block"; $('main').style.opacity=1;$('main').style.filter='alpha(opacity=100)'; } });
     	}
	});
	if(window.currentpage=='intro') ajaxPage('','');
}

function showFilmsThematiques(id) {
	var postBody = 'module=filmsThematiques&id='+id;
	new Ajax.Updater('main2', 'ajax/action.php', {method:'post',evalScripts: true, postBody:postBody, onLoading: showLoad, onComplete:
		function(t){
			hideLoad();
			pageTracker._trackPageview("/filmsthematiques");
			$('top').style.display="none";
			setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:none;');
			setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%; opacity: 0;filter:alpha(opacity=0);');
			$('main').className="mainBlack";
			new Effect.Opacity('main',{from:0, to: 1, duration: 1, afterFinish: function() { $('main2').style.display="block"; $('main').style.opacity=1;$('main').style.filter='alpha(opacity=100)'; } });
     	}
	});
	if(window.currentpage=='intro') ajaxPage('','');
}

function showClimateVoices(id) {
	var postBody = 'module=filmsThematiques&type=climatevoices&id='+id;
	new Ajax.Updater('main2', 'ajax/action.php', {method:'post',evalScripts: true, postBody:postBody, onLoading: showLoad, onComplete:
		function(t){
			hideLoad();
			pageTracker._trackPageview("/climateVoices");
			$('top').style.display="none";
			setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:none;');
			setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%; opacity: 0;filter:alpha(opacity=0);');
			$('main').className="mainBlack";
			new Effect.Opacity('main',{from:0, to: 1, duration: 1, afterFinish: function() { $('main2').style.display="block"; $('main').style.opacity=1;$('main').style.filter='alpha(opacity=100)'; } });
     	}
	});
	if(window.currentpage=='intro') ajaxPage('','');
}

function showFilmsThematiques(id) {
	var postBody = 'module=filmsThematiques&type=filmsthematiques&id='+id;
	new Ajax.Updater('main2', 'ajax/action.php', {method:'post',evalScripts: true, postBody:postBody, onLoading: showLoad, onComplete:
		function(t){
			hideLoad();
			pageTracker._trackPageview("/filmsthematiques");
			$('top').style.display="none";
			setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:none;');
			setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%; opacity: 0;filter:alpha(opacity=0);');
			$('main').className="mainBlack";
			new Effect.Opacity('main',{from:0, to: 1, duration: 1, afterFinish: function() { $('main2').style.display="block"; $('main').style.opacity=1;$('main').style.filter='alpha(opacity=100)'; } });
     	}
	});
	if(window.currentpage=='intro') ajaxPage('','');
}

function showNote(n) {
	var i=0;
	for(i=1; i<=5; i++) $('noter'+i).src='images/noter_'+(i<=n?'on':'off')+'.png';
}

function setNote(n) {
	new Ajax.Updater('noterbox','ajax/action.php',{method:'post',parameters:{action:'setNote',id_opinion:window.currentvideo,note:n}});
}

function animPagedTable(prefix,variable,dir,direction,idup,iddown,pages) {
	var from=window[variable];
	var to=window[variable]+dir;
	if(to<1 || to>pages) {from = 1;to = 2;window[variable]=1};
	var pf=$(prefix+from);
	var pt=$(prefix+to);
	if(!pf || !pt) return;

	var pr=$(pt.parentNode);
	var ps=0;

	if(to==1) $(idup).style.visibility='hidden';
	if(from==1) $(idup).style.visibility='visible';

	if(to==pages) $(iddown).style.visibility='hidden';
	if(from==pages) $(iddown).style.visibility='visible';
	
	var pro=pr.style.overflow;
	pr.style.overflow="hidden";
	if(direction=='h') {
		ps=pr.getWidth();
		window[variable]+=dir;
		if(from>to) {
			pt.style.left=(-ps)+'px';
			pt.style.display="";
			if(pf.style.position=="relative")
				new Effect.Morph(prefix+to,{ style: 'left: 0px;', duration: 1.0, afterUpdate: function() { pf.style.left=(parseInt(pt.style.left))+'px'; }, afterFinish: function() { pf.style.display='none'; pr.style.overflow=pro; } });
			else
				new Effect.Morph(prefix+to,{ style: 'left: 0px;', duration: 1.0, afterUpdate: function() { pf.style.left=(parseInt(pt.style.left)+ps)+'px'; }, afterFinish: function() { pf.style.display='none'; pr.style.overflow=pro; } });
		} else {
			if(pf.style.position=="relative") {
				pt.style.left='0px';			
				pt.style.display="";
				new Effect.Morph(prefix+to,{ style: 'left: '+(-ps)+'px;', duration: 1.0, afterUpdate: function() { pf.style.left=(parseInt(pt.style.left))+'px'; }, afterFinish: function() { pf.style.display='none'; pt.style.left='0px'; pr.style.overflow=pro; } });
			} else {
				pt.style.left=ps+'px';			
				pt.style.display="";
				new Effect.Morph(prefix+to,{ style: 'left: 0px;', duration: 1.0, afterUpdate: function() { pf.style.left=(parseInt(pt.style.left)-ps)+'px'; }, afterFinish: function() { pf.style.display='none'; pr.style.overflow=pro; } });
			}
		}
	}
	else if(direction=='v') {
		ps=pr.getHeight();
		window[variable]+=dir;
		if(from>to) {
			pt.style.top=(-ps)+'px';
			pt.style.display="";
			new Effect.Morph(prefix+to,{ style: 'top: 0px;', duration: 1.0, afterUpdate: function() { pf.style.top=(parseInt(pt.style.top))+'px'; }, afterFinish: function() { pf.style.display='none'; pr.style.overflow=pro; } });
		} else {
			pt.style.top='0px';
			pt.style.display="";
			new Effect.Morph(prefix+to,{ style: 'top: '+(-ps)+'px;', duration: 1.0, afterUpdate: function() { pf.style.top=(parseInt(pt.style.top))+'px'; }, afterFinish: function() { pf.style.display='none'; pt.style.top='0px'; pr.style.overflow=pro; } });
		}
	}
}

function webcamRecorded() {
}

function checkLogin(login){
  
  var url='&login='+login;
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	var postBody = 'action=login'+url;
		new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){ 
			var stat=t.responseXML.documentElement.getAttribute("status");
				if(stat==1) {
					//var media=t.responseXML.documentElement.getAttribute("id_media");
					//addflash('pagecontent','6ma','id_user='+iduser+'&id_media='+media+'&id_lang='+id_lang+'&id_lang_int='+lang);
					$('log').addClassName('pseudo_occupied2');
					$('log').removeClassName('pseudo_occupied');
				}
				else{
					$('log').addClassName('pseudo_occupied');
					$('log').removeClassName('pseudo_occupied2');
				}
      }
		});

}

function showSearchPage(ids,page,type) {
	new Ajax.Updater('searchresultsAffiche','ajax/action.php',{method:'post',parameters:{action:'getSearchPage',ids:ids,page:page,type:type}, onLoading: showLoad, onComplete: function() { hideLoad(); if(supersleight)supersleight.run('ResultatsFromRecherche'); }});
}

function checkEmail(email){
  var email = email.replace(/^\s*/gim, "");
  var email = email.replace(/\s*$/gim, "");
  var url='&email='+email;
  var ajaxRequest;  // The variable that makes Ajax possible!
	
	
	
	var postBody = 'action=email'+url;
		new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){ 
			var stat=t.responseXML.documentElement.getAttribute("status");
				if(stat==1) {
					//var media=t.responseXML.documentElement.getAttribute("id_media");
					//addflash('pagecontent','6ma','id_user='+iduser+'&id_media='+media+'&id_lang='+id_lang+'&id_lang_int='+lang);
					$('email_div').addClassName('pseudo_occupied2');
					$('email_div').removeClassName('pseudo_occupied');
				}
				else{
					$('email_div').addClassName('pseudo_occupied');
					$('email_div').removeClassName('pseudo_occupied2');
				}
      }
		});

}

function checkPassword2(pass1,len){
	if(pass1.length<len){
		$('pass_div').addClassName('pseudo_occupied');
		$('pass_div').removeClassName('pseudo_occupied2');
	}
	else{
		$('pass_div').addClassName('pseudo_occupied2');
		$('pass_div').removeClassName('pseudo_occupied');
	}
}

function checkPassword(pass1,pass2){
  	if(pass1==pass2){
		$('pass2_div').addClassName('pseudo_occupied2');
					$('pass2_div').removeClassName('pseudo_occupied');
	}
	else{
	$('pass2_div').addClassName('pseudo_occupied');
					$('pass2_div').removeClassName('pseudo_occupied2');
	}

/*  var url='&password='+pass1+'&password2='+pass2;
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	
	
	var postBody = 'action=password'+url;
		new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){ 
			var stat=t.responseXML.documentElement.getAttribute("status");
				if(stat==1) {
					//var media=t.responseXML.documentElement.getAttribute("id_media");
					//addflash('pagecontent','6ma','id_user='+iduser+'&id_media='+media+'&id_lang='+id_lang+'&id_lang_int='+lang);
					$('pass2_div').addClassName('pseudo_occupied2');
					$('pass2_div').removeClassName('pseudo_occupied');
				}
				else{
					$('pass2_div').addClassName('pseudo_occupied');
					$('pass2_div').removeClassName('pseudo_occupied2');
				}	
      }
		});
*/
}
function checkPassW(len){
	var pass1 = $('password').value;
	var pass2 = $('passe2').value;
	if(pass1 && (pass1.length >= len)){
		$('pass_div').addClassName('pseudo_occupied2');
		$('pass_div').removeClassName('pseudo_occupied');
	}else{
		$('pass_div').addClassName('pseudo_occupied');
		$('pass_div').removeClassName('pseudo_occupied2');
		$('pass2_div').addClassName('pseudo_occupied');
		$('pass2_div').removeClassName('pseudo_occupied2');
		return false;
	}
	if(pass2 && pass2 == pass1){
		$('pass2_div').addClassName('pseudo_occupied2');
		$('pass2_div').removeClassName('pseudo_occupied');
	}else{
		$('pass2_div').addClassName('pseudo_occupied');
		$('pass2_div').removeClassName('pseudo_occupied2');
		
	}
	
	
}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function checkForm(){
	  var login=document.reg.login.value;
	  var name=document.reg.first_name.value;
	  var last_name=document.reg.last_name.value;
	  var lang=document.reg.lang.value;
	  var email=trim(document.reg.email.value);
	  var password=document.reg.password.value;
	  var password2=document.reg.password2.value;
	  var sex=document.reg.sex.value;
	  var birth_year=document.reg.birth_year1.value;
	  var captcha=document.reg.captcha.value;
	  var lang=document.reg.lang.value;
	  var country=document.reg.country.value;
	  var city=document.reg.city.value;
	  var is_6ma=document.reg.is_6ma.value;
	  if(document.reg.rules.checked)
	  var rules=1;
	  else
	  var rules=0;
	  if(document.reg.moderator.checked)
	  var moderator=1;
	  else
	  var moderator=0;
	  if(document.reg.moderator_rules.checked)
	  var moderator_rules=1;
	  else
	  var moderator_rules=0;
	  if(document.reg.translator.checked)
	  var translator=1;
	  else
	  var translator=0;
	  if(document.reg.trans_rules.checked)
	  var trans_rules=1;
	  else
	  var trans_rules=0;
	  if(document.reg.newsletter.checked)
	  var newsletter=1;
	  else
	  var newsletter=0;
	  if(document.reg.sendEmail.checked)
	  var sendEmail=1;
	  else
	  var sendEmail=0;
	  if(document.reg.getMessage.checked)
	  var getMessage=1;
	  else
	  var getMessage=0;
	  var r2='';
	  var r1='';
	  var e=0;
	  var err=0;

	    var idf=new Array('city','check2','nom','prenom','pseudo','email','password','passe2','captcha', 'country', 'sex');
	    if(translator==1){idf.push('check6_1');}
	    if(moderator==1){idf.push('check1_1');}
	    
	    var len=idf.length;
	    
		for(var i=0;i<len;i++){
			var elmt = $(idf[i]);
			 var labels = document.getElementsByTagName("label");
			 var myLabel;
		     for(var j=0;j<labels.length;j++){
		    	 if($(labels[j]).hasAttribute("for") && $(labels[j]).readAttribute("for").toLowerCase()==idf[i].toLowerCase() ){
		    		  myLabel = labels[j];
		    		  break;
		    		  }
		      }
		    if(myLabel != undefined){
				if(	elmt.value=='' || (elmt.type=="checkbox" && elmt.checked==false)){
					err=1;
					myLabel.className=myLabel.className +' req';
				}else if(idf[i]=='captcha'){
					myLabel.className='s84d_txt2';
				}else {
					myLabel.className=myLabel.className.replace(/req/g,"");
					}
			    }else{
			    	//alert(idf[i] + " undefined");
			    }
		    }
		
	    if(err || !$('log').hasClassName('pseudo_occupied2') || !$('email_div').hasClassName('pseudo_occupied2') || !$('pass_div').hasClassName('pseudo_occupied2') || !$('pass2_div').hasClassName('pseudo_occupied2') || !$('capt').hasClassName('pseudo_occupied2')){
	    	e=1;
			document.getElementById('alertBox').style.display='block';
		}
		
	  
	  if(e!='1' && $('log').hasClassName('pseudo_occupied2') && $('email_div').hasClassName('pseudo_occupied2') && $('pass_div').hasClassName('pseudo_occupied2') && $('pass2_div').hasClassName('pseudo_occupied2') && $('capt').hasClassName('pseudo_occupied2')){ 
		  if(moderator==1 && moderator_rules==1){
			  var mod=1;}
		  else{
			  var mod=0;}
		  if(translator==1 && trans_rules==1){
			  var tran=1;}
		  else{
			  var tran=0;}
		  var url='&login='+login+'&name='+name+'&last_name='+last_name+'&email='+email+'&password='+password+'&sex='+sex+'&birth_year='+birth_year+'&lang='+lang+'&country='+country+'&city='+city+'&is_6ma='+is_6ma+'&rules='+rules+'&moderator='+moderator+'&newsletter='+newsletter+'&getMessage='+getMessage+'&sendEmail='+sendEmail+'&captcha='+captcha+'&mod='+mod+'&tran='+tran;
		  var ajaxRequest;  // The variable that makes Ajax possible!
		  var postBody = 'action=register'+url;
	  		new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
				function(t){ 
	  				ajaxSubPage('register_complite','&email='+email);
	  			}
			});
		}
	}
function EditProfile(){
	  var login=document.reg.login.value;
	  var name=document.reg.first_name.value;
	  var last_name=document.reg.last_name.value;
	  var lang=document.reg.lang.value;
	  var email=document.reg.email.value;
	  var password=document.reg.password.value;
	  var password2=document.reg.password2.value;
	  var sex=document.reg.sex.value;
	  var birth_year=document.reg.birth_year1.value;
	  var country=document.reg.country.value;
	  var city=document.reg.city.value;
	  var is_6ma=document.reg.is_6ma.value;
	  if(document.reg.rules.checked)
	  var rules=1;
	  else
	  var rules=0;
	  if(document.reg.newsletter.checked)
	  var newsletter=1;
	  else
	  var newsletter=0;
	  if(document.reg.moderator.checked)
	  var moderator=1;
	  else
	  var moderator=0;
	  if(document.reg.moderator_rules.checked)
	  var moderator_rules=1;
	  else
	  var moderator_rules=0;
	  if(document.reg.sendEmail.checked)
	  var sendEmail=1;
	  else
	  var sendEmail=0;
	  if(document.reg.getMessage.checked)
	  var getMessage=1;
	  else
	  var getMessage=0;
	  if(document.reg.translator.checked)
	  var translator=1;
	  else
	  var translator=0;
	  if(document.reg.trans_rules.checked)
	  var trans_rules=1;
	  else
	  var trans_rules=0;
	  var e=0;
	  var err=0;
		var len=8;
		var k=new Array();
		for(var i=1;i<len;i++){
			k[i]=document.getElementById('k'+i);
		}

	    var idf=new Array('city','country','check2','nom','prenom','pseudo','email');
	    if(translator==1){idf.push('check6_1');}
	    if(moderator==1){idf.push('check1_1');}
	    
	    var len=idf.length;
	    
		for(var i=0;i<len;i++){
			var elmt = $(idf[i]);
			var labels = document.getElementsByTagName("label");
			var myLabel;
		     for(var j=0;j<labels.length;j++){
		    	 if($(labels[j]).hasAttribute("for") && $(labels[j]).readAttribute("for").toLowerCase()==idf[i].toLowerCase() ){
		    		  myLabel = labels[j];
		    		  break;
		    		  }
		      }
		    if(myLabel != undefined){
				if(	elmt.value=='' || (elmt.type=="checkbox" && elmt.checked==false)){
					err=1;
					myLabel.className=myLabel.className +' req';
				}else {
					myLabel.className=myLabel.className.replace(/req/g,"");
					}
			    }else{
			    	//alert(idf[i] + " undefined");
			    }
		    }
	    if(err ||$('email_div').hasClassName('pseudo_occupied') || $('pass_div').hasClassName('pseudo_occupied') || $('pass2_div').hasClassName('pseudo_occupied')){
	    	e=1;
			document.getElementById('alertBox').style.display='block';
		}
	    
	  if(e!='1'){
		  
	  if(moderator==1 && moderator_rules==1){
		  var mod=1;}
	  else{
		  var mod=0;}
	  if(translator==1 && trans_rules==1){
		  var tran=1;}
	  else{
		  var tran=0;}
		  
	  var url='&login='+login+'&name='+name+'&last_name='+last_name+'&email='+email+'&password='+password+'&sex='+sex+'&birth_year='+birth_year+'&lang='+lang+'&country='+country+'&city='+city+'&is_6ma='+is_6ma+'&rules='+rules+'&newsletter='+newsletter+'&getMessage='+getMessage+'&sendEmail='+sendEmail+'&mod='+mod+'&tran='+tran;
	  var ajaxRequest;  // The variable that makes Ajax possible!
	  var postBody = 'action=editProfile'+url;
	  	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
				function(t){ 

					ajaxSubPage('profile','');
	      }
			});
			}
	}

function imageReload(){
var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	
	var postBody = 'reload=1';
		new Ajax.Request('captcha/reload_captcha.php', {method:'post', 'postBody':postBody, onSuccess: 
			function(t){ 
			
					$('img').innerHTML='';
				
				$('img').innerHTML=t.responseText;
	
		
      }
		});
}

function addflash(idcont,movie,flashvars,width,height) {
/*	$(idcont).innerHTML=AC_FL_GetContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', width,
			'height', height,
			'src', movie,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', idcont+'_flash',
			'bgcolor', '#ffffff',
			'name', idcont+'_flash',
			'menu', 'true',
			'allowFullScreen', 'true',
			'allowScriptAccess','sameDomain',
			'movie', movie,
			'salign', '',
			'flashvars', flashvars
	); */

	if(flashvars && typeof(flashvars)!="object") {
		var fv=flashvars.split("&");
		flashvars={};
		for(var i=0; i<fv.length; i++) {
			var fi=fv[i].split("=");
			flashvars[fi[0]]=fi[1];
		}
	} else if(typeof(flashvars)!="object") flashvars=false;
	
	if(movie.indexOf(".swf")==-1) {
		if(movie.indexOf("?")==-1) movie+=".swf";
		else movie=movie.replace(/\?/,".swf?");
	}
	
	$(idcont).innerHTML='<div id="'+idcont+'_flash">&nbsp;</div>';
	swfobject.embedSWF(movie,idcont+"_flash",width,height,"8.0.0",false,flashvars,
		{
			wmode:'transparent',
			allowscriptaccess:true,
			allowfullscreen:true,
			salign:'',
			scale:'showall'
		});
	swfobject.createCSS("#"+idcont+"_flash","outline:none");
}

function addflashLoading(idcont,movie,width,height) {
	$(idcont).innerHTML=AC_FL_GetContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', width,
			'height', height,
			'src', movie,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', idcont+'_flash',
			'bgcolor', '#ffffff',
			'name', idcont+'_flash',
			'menu', 'true',
			'allowFullScreen', 'true',
			'allowScriptAccess','sameDomain',
			'movie', movie,
			'salign', ''
	);
}

function TestInfosTemoignages(info){
var error=false
	
	if($('load')){
		if($('load').value==1 ){
			$$('.error_load')[0].setStyle({'color':'red','display':'block'});
			error=true;
		}else $$('.error_load')[0].setStyle({'color':'#000000','display':'none'});
	}
		
	if($F('id_theme')=='' ){
		$$('.error_id_theme')[0].setStyle({'color':'red'});
		error=true;
	}else
		$$('.error_id_theme')[0].setStyle({'color':'#000000'});
		
	if ($F('keywords')==''){
		$$('.error_keywords')[0].setStyle({'color':'red'});
		error=true;
	}else
		$$('.error_keywords')[0].setStyle({'color':'#000000'});
	
	if($('content').type=='textarea'){
		if($F('content')==""){
			$$('.error_content')[0].setStyle({'color':'red','display':'block'});
			error=true;
		}
		else $$('.error_content')[0].setStyle({'color':'#000000','display':'none'});
	}
		if(error)
			$('obl').update(info);
		else
			$('obl').update('');
			return error;
}
function addTemoignages(iduser,lang,dest,info){
if(TestInfosTemoignages(info))return 0;
  var id_question=document.getElementById('id_question').value;
  var act=document.getElementById('act').value;
  var type=document.getElementById('type').value;
  var id_lang=$F($('id_lang'));
  var id_subject=$F($('id_theme'));
  var keywords=document.getElementById('keywords').value;
  var content=document.getElementById('content').value;
  var clip=document.getElementById('photoclip').value;
  var url='&id_question='+id_question+'&act='+act+'&type='+type+'&id_lang='+id_lang+'&id_subject='+id_subject+'&keywords='+keywords+'&photoclip='+clip+'&content='+content+'&dest='+dest;
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	
	
	var postBody = 'action=addTemoignages'+url;
		new Ajax.Request('ajax/action.php', {method:'post', 'postBody':postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){ 
				if(dest=='show'){
					$('top').style.display="none";
					$('main').className="mainBlack";
					setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%;');
					setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:block;');
        
				
          $('main2').innerHTML=t.responseXML.documentElement.childNodes[0].nodeValue;
          if(supersleight){supersleight.run('main2');}
          if(type!='text')
					addflash('movXXX','6ma_player?mode=single','mode=single&type=landscape&groupID='+t.responseXML.documentElement.getAttribute('id')+'&langID='+id_lang,602,439);
				}
				else{
					ajaxPage('temoignage_online','&id='+t.responseText);
				}
      
/*			 if(t.responseXML.documentElement.getAttribute("status")){
				var stat=t.responseXML.documentElement.getAttribute("status");
				if(stat==1) {
					var media=t.responseXML.documentElement.getAttribute("id_media");
					document.innerHTML+='<div id="translator" align="center" style="position:absolute; width:1200px; height:900px; top=0px; z-index: 34;"></div>';
					addflash('translator','6ma','id_user='+iduser+'&id_media='+media+'&id_lang='+id_lang+'&id_lang_int='+lang,1200,900);
				}
			} else {
				$('pagecontent').innerHTML=t.responseText;
				
				}
      } */
			}
		});
}

function editTemoignages(opinion,dest,info){
if(TestInfosTemoignages(info))return false;
  var id_question=document.getElementById('id_question').value;
  var act=document.getElementById('act').value;
  var type=document.getElementById('type').value;
  var id_lang=$F($('id_lang'));
  var id_subject=$F($('id_theme'));
  var keywords=document.getElementById('keywords').value;
  var content=document.getElementById('content').value;
  var url='&id_question='+id_question+'&act='+act+'&type='+type+'&id_lang='+id_lang+'&id_subject='+id_subject+'&keywords='+keywords+'&content='+content+'&opinion='+opinion+'&dest='+dest;
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	
	var postBody = 'action=editTemoignages'+url;
		new Ajax.Request('ajax/action.php', {method:'post', 'postBody':postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      	if(dest=='show'){ 
				$('top').style.display="none";
					$('main').className="mainBlack";
					setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%;');
					setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:block;');
        
				
          $('main2').innerHTML=t.responseXML.documentElement.childNodes[0].nodeValue;
          if(supersleight){supersleight.run('main2');}
          if(type!='text')
					addflash('movXXX','6ma_player?mode=single','mode=single&type=landscape&groupID='+t.responseXML.documentElement.getAttribute('id')+'&langID='+id_lang,602,439);
				}
		else{
				ajaxPage('temoignage_online','&id='+t.responseText);
				}
				

/*			 if(t.responseXML.documentElement.getAttribute("status")){
				var stat=t.responseXML.documentElement.getAttribute("status");
				if(stat==1) {
					var media=t.responseXML.documentElement.getAttribute("id_media");
					document.innerHTML+='<div id="translator" align="center" style="position:absolute; width:1200px; height:900px; top=0px; z-index: 34;"></div>';
					addflash('translator','6ma','id_user='+iduser+'&id_media='+media+'&id_lang='+id_lang+'&id_lang_int='+lang,1200,900);
				}
			} else {
				$('pagecontent').innerHTML=t.responseText;
				
				}
      } */
			}
		});
}

function logon(login,password){
	var url='&login='+login+'&password='+password;
	var ajaxRequest;  // The variable that makes Ajax possible!
	var postBody = 'action=logon'+url;
		new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){ 
//					document.getElementById('debug').innerHTML='';
					var stat=t.responseXML.documentElement.getAttribute("status");
					if(stat==1) {
					var pageReferers = t.responseXML.documentElement.getElementsByTagName('pageReferer')[0].childNodes;
	//				var pageReferer = t.responseXML.documentElement.getElementsByTagName('pageReferer')[0].childNodes[0].nodeValue;
					if(pageReferers.length == 0 || pageReferers[0].nodeValue == "")
						pageReferer="profile";
					else
						pageReferer=pageReferers[0].nodeValue;
						
						ajaxPage(pageReferer,'');
					}
				else{
					var alertBox = $('alertBox');
					if(alertBox) alertBox.show();
					//alert('Invalid login/pass');
				}
      }
		});

}

function deleteAccount(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	var postBody = 'action=deleteAccount';
		new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){ 
      }
		});

}

function forgotpass(email){
var url='&email='+email;
	var ajaxRequest;  // The variable that makes Ajax possible!
	var postBody = 'action=forgotpass'+url;
		new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){ 
//					document.getElementById('debug').innerHTML='';
				var stat=t.responseText;
				if(stat=='0'){ 
					var alertBox = $('alertBoxWrongEmail');
					if(alertBox) alertBox.show();
				}
				else{ 
					var emailSent = $('alertEmailSent');
					if(emailSent) emailSent.show();
				}
      }
		});

}

function toggle(id){
	el = $(id);
	var display = el.style.display ? '' : 'none';
	el.style.display = display;
}

function sendPlayerMessage(id_user,message) {
	new Ajax.Updater('pagecontent', 'ajax/action.php', {
		method:'post',
		parameters:{
			'id_user':id_user,
			'message':message,
			'action':'player_msg'
		},
		onLoading: showLoad,
		onComplete: hideLoad,
		evalScripts: true
	});
}

function showContent(id,hide){
if(hide!=''){
var tabh=hide.split(',');
var i=0;
while(tabh[i]){
if(tabh[i]!=id)document.getElementById(tabh[i]).style.display='none';
document.getElementById('login_'+tabh[i]).className='s91_txt4';
i++;
}
}
	el = document.getElementById(id);
	el1 = document.getElementById('login_'+id);
	var style;
	var display = el.style.display ? '' : 'none';
	if(display=='none') style='s91_txt4';
	else style='s91_txt1';
	el.style.display = display;
	el1.className = style;
}

function showContent1(id,hide,l){

	if(hide!=''){
		var tabh=hide.split(',');
		var tabl=l.split(',');
		var i=0;
		var im;
		while(tabh[i]){
			if(tabh[i]!=id) document.getElementById(tabh[i]).style.display='none';
			if(tabh[i]==id) im=tabl[i];
			document.getElementById('block_'+tabh[i]).style.display='none';
			document.getElementById('login_'+tabh[i]).className='s91_txt4';
			if(tabl[i]=='e') 	document.getElementById('dot_'+tabh[i]).innerHTML='<img src="images/ico_91'+tabl[i]+'.jpg" width="11" height="11" />';
			else document.getElementById('dot_'+tabh[i]).innerHTML=document.getElementById('dot_'+tabh[i]).innerHTML;
			//if(tabl[i]=='x')
			//document.getElementById('dot_'+tabh[i]).innerHTML='&nbsp;';
			//else{
			//if(tabh[i]==id && tabl[i]=='e'){
			//document.getElementById('dot_'+tabh[i]).innerHTML='&nbsp;';
			//}
			//document.getElementById('dot_'+tabh[i]).innerHTML='<img src="images/ico_91'+tabl[i]+'.jpg" width="11" height="11" />';
			//}
			
			//alert('dot_'+tabh[i]+'=ico_91'+tabl[i]);
			i++;
		}
	}
	el = document.getElementById(id);

	var display = el.style.display ? '' : 'none';
	if(display=='none'){
		document.getElementById('dot_'+id).innerHTML='&nbsp;';
		document.getElementById('login_'+id).className='s91_txt4';
		document.getElementById('block_'+id).style.display = 'none';
		el.style.display = 'none';
	}
	else{
		document.getElementById('dot_'+id).innerHTML='';
		document.getElementById('login_'+id).className='s91_txt1';
		document.getElementById('block_'+id).style.display = '';
		el.style.display = '';
	}
	var params={action:'messRead',id:id};
	new Ajax.Request('ajax/action.php', {method:'post', 'parameters':params });	
}

function showContentBlock(id,hide){
if(hide!=''){
var tabh=hide.split(',');
var i=0;
while(tabh[i]){
document.getElementById('block_'+tabh[i]).style.display='none';

i++;
}
}
	el = document.getElementById(id);
	el1 = document.getElementById('block_'+id);
	var display = el.style.display ? '' : 'none';
	var style = el1.className='s91_txt4' ? 's91_txt1' : 's91_txt4';
	el.style.display = display;
	el1.className=style;
	
}
function showContentDot(dot,l){
  if($(dot).innerHTML!='')
	$(dot).innerHTML='';
	else
	$(dot).innerHTML='<img src="images/ico_91'+l+'.jpg" width="11" height="11" />';
}

function addAlert(){
//  alert("add the alert");
  var typ=$('typeAlert').value;
  var lastname=$('alertLastName').value;
  var tran1=$F('abcbox_select');
  var tran2=$('trans').value;
  var trans;
  if(typ==1)
  {
  	trans=tran1;
  }else{
  	trans=tran2;
  }
  var name=$('alertName').value;
  var email=$('alertEmail').value;
  //radioval && safari does it work ???
  var err=radioval(document.formAlerts,'error');
  //alert(err);
  //var error=$$('input[name="error"]').any(function(el) { return el.checked; });
  var message=$('alertTextAreaMessage').value;

//  if(lastname!='' && name!='' && email!='' && error!='' && message!=''){
		var params={'lastname':lastname, 'name':name, 'email':email, 'trans':trans, 'error':err,'message':message, 'action':'addAlert'}
		//alert( Object.values(params) );
//		var url='&lastname='+lastname+'&name='+name+'&email='+email+'&trans='+trans+'&error='+error+'&message='+message;
		var ajaxRequest;
//		var postBody = 'action=addAlert'+url;
		new Ajax.Request('ajax/action.php', {method:'post', 'parameters':params, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      showCloudMsg('signaler_div',100,$('signaler_div').getHeight(),t.responseText);
			closeAlertDiv(t.responseText);//must be defined by opening page
     }
		});
/*  } else {			
		$('lastname').style.backgroundColor=(lastname==''?"#FFBBBB":"");
		$('name').style.backgroundColor=(name==''?"#FFBBBB":"");
		$('email').style.backgroundColor=(email==''?"#FFBBBB":"");
		$('errorcell').style.backgroundColor=(error==''?"#FFBBBB":"");
		$('message').style.backgroundColor=(message==''?"#FFBBBB":"");
	}
	* */
}

function appearElement(id) {
	var elt=parseInt($(id).style.top);
	$(id).style.opacity="0";
	$(id).style.filter="alpha(opacity=0)";
	$(id).style.top=(elt+10)+"px";
	$(id).style.display="block";
	if(supersleight)supersleight.run(id);
	new Effect.Parallel([
		new Effect.Opacity(id,{from: 0.0, to: 1.0, sync:true}),
		new Effect.Morph(id,{style: 'top:'+(elt-7)+'px;', sync:true} )
		], { duration: 0.4, afterFinish: function(){ new Effect.Morph(id,{style: 'top:'+elt+'px;',duration: 0.2}); } });
}

function unfurlElement(id) {
	var el=$(id);
	el.style.visibility='hidden';
	el.style.display="block";
	var elh=el.getHeight();
	var elt=parseInt(el.style.top);
	var elov=el.style.overflow;
	el.style.opacity="0";
	el.style.filter="alpha(opacity=0)";
	el.style.top=(elt+elh)+"px";
	el.style.height="1px";
	el.style.overflow="hidden";
	el.style.visibility='visible';
	var elc=$(id+'_content');
	new Effect.Parallel([
		 new Effect.Opacity(id,{from: 0.0, to: 1.0, sync:true}),
		 new Effect.Morph(id,{style: 'height:'+elh+'px;', sync:true, afterUpdate: function() { el.style.top=(elt+elh-el.getHeight())+'px'; elc.style.top=(el.getHeight()-elh)+'px';  }} )
		 ], { duration: 0.4, afterFinish: function(){ el.style.overflow=elov; } });
}

function disappearElement(id) {
	var elt=parseInt($(id).style.top);
	new Effect.Parallel([
		 new Effect.Opacity(id,{from: 1.0, to: 0.0, sync:true}),
		 new Effect.Morph(id,{style: 'top:'+(elt+10)+'px;', sync:true} )
		 ], { duration: 0.5, afterFinish: function() { $(id).style.display="none"; $(id).style.top=(elt)+"px"; } });
}

//disappears and removes element
function vanishElement(id) {
	var elt=parseInt($(id).style.top);
	new Effect.Parallel([
		 new Effect.Opacity(id,{from: 1.0, to: 0.0, sync:true}),
		 new Effect.Morph(id,{style: 'top:'+(elt+10)+'px;', sync:true} )
		 ], { duration: 0.5, afterFinish: function() { setTimeout(function() { $(id).remove(); },200); } });
}

function showTradErrorForm(id,px,py) {
	flashPause();
	params={module:'alert',type: 1, id_content: window.currentvideo, 'foot':1};
	new Ajax.Request('ajax/action.php',{method:'post', 'parameters':params, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t) {
      $(id).insert(t.responseText,{position: 'bottom'});
      $('signaler_div').style.left=px+'px';
      $('signaler_div').style.top=py+'px';
      $('signaler_div').style.zIndex=2007;
			appearElement('signaler_div');
			if(supersleight)supersleight.run('signaler_div');
     }
	});
}

function showInappropriateForm(id,px,py) {
	params={module:'alert',type: 2, id_content: window.currentvideo, 'foot':1};
	new Ajax.Request('ajax/action.php',{method:'post', 'parameters':params, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t) {
      $(id).insert(t.responseText,{position: 'bottom'});
      $('signaler_div').style.left=px+'px';
      $('signaler_div').style.top=py+'px';
      $('signaler_div').style.zIndex=2007;
			appearElement('signaler_div');
			if(supersleight)supersleight.run('signaler_div');
     }
	});
}

function showCloudMsg(element,px,py,msg) {
	if(!$('customMsgCloud')) {
		params={module:'msgcloud',type: 2, id_content: window.currentvideo, 'foot':1};
		new Ajax.Request('ajax/action.php',{method:'post', 'parameters':params, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
				function(t) {
					$(document.body).insert(t.responseText,{position:'bottom'});
					$('customMsgCloud').style.visibility='hidden';
					$('customMsgCloud').style.display='block';
					$('customMsgCloud_text').innerHTML=msg;
					$('customMsgCloud').clonePosition(element,{setWidth:false,setHeight:false,offsetLeft:px-32,offsetTop:py-$('customMsgCloud').getHeight() });
					$('customMsgCloud').style.visibility='visible';
					$('customMsgCloud').style.display='none';
					appearElement('customMsgCloud');
					setTimeout(function() { disappearElement('customMsgCloud'); }, 2000);
			 }
		});
	} else {
		$('customMsgCloud').style.visibility='hidden';
		$('customMsgCloud').style.display='block';
		$('customMsgCloud_text').innerHTML=msg;
		$('customMsgCloud').clonePosition(element,{setWidth:false,setHeight:false,offsetLeft:px-32,offsetTop:py-$('customMsgCloud').getHeight() });
		$('customMsgCloud').style.visibility='visible';
		$('customMsgCloud').style.display='none';
		appearElement('customMsgCloud');
		setTimeout(function() { disappearElement('customMsgCloud'); }, 2000);
	}	
}

function showSendFriendForm(id,px,py) {
	flashPause();
	var hdir = location.href;
	if(hdir.indexOf('/index.php'))
		hdir = hdir.replace(/index.php/gi,'');
	if(hdir.indexOf('?'))
		hdir = hdir.replace(/\?.*/gi,'');
	if(hdir.indexOf('#'))
		hdir = hdir.replace(/[#]/gi,'');	
	params={module:'sendfriend',link: (hdir)+'index.php?module=showsingle&id='+window.currentvideo};
	new Ajax.Request('ajax/action.php',{method:'post', 'parameters':params, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t) {			
      $(id).insert(t.responseText,{position: 'bottom'});
			
			$('sendfriend').style.visibility="hidden";
			$('sendfriend').style.display="";
			py-=$('id02_mos6ma_05d_02006').cumulativeOffset().top-$('sendfriend').cumulativeOffset().top + 15;
			$('sendfriend').style.display="none";
			$('sendfriend').style.visibility="visible";
			
      $('sendfriend').style.left=px+'px';
      $('sendfriend').style.top=py+'px';
			$('sendfriend').style.zIndex=2005;
      $('sendfriend2').style.left=(px+93)+'px';
      $('sendfriend2').style.top=(py+236)+'px';
			$('sendfriend2').style.zIndex=2006;
			appearElement('sendfriend');
     }
	});
}


function sendMessage(){
	var content=document.mess.content.value;
	var title=document.mess.title.value;
	var hash=document.mess.id.value;
	var url='&id='+hash+'&title='+title+'&content='+escape(content);
	var ajaxRequest;  // The variable that makes Ajax possible!
	var postBody = 'action=sendMessage'+url;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad,
		onSuccess:function(t){
			//doesn't work localy with ie6 cause of the php function getTemplate() (=sendmail)
			$('on').style.display='block';
      setTimeout("ajaxSubPage('message','')", 2000);
      }
		});
}

function radioval(form,rad){
	//previous version was using  
	// f.item(i) buy doesn't work with safari
	var f=form[rad];
	for(var i=0;i<f.length;i++){
		//alert(f[i].value);
		if(f[i].checked==true){
			return f[i].value;
		}
	}
	return f.value;
}


function changeSearchTheme(id, is6ma) {
	new Ajax.Request('ajax/action.php',	{method: 'post',parameters: {'action':'getSubThemes','id_subject':id, 'is6ma':is6ma},
		onSuccess: function(t){ 
			var dd=$('subjectDiv').select('a.selectLinkS').each(function(e) { e.removeClassName('selectLinkS'); });
    	$('themeDiv').innerHTML=t.responseText;
			$('themeDiv').style.top='0px';
			$('theme'+id).addClassName('selectLinkS');
			$('id_subject').value=id;
			$('id_theme').value=0;
    }
	});
}

function changeSearchSubTheme(id) {
	var dd=$('themeDiv').select('a.selectLinkS').each(function(e) { e.removeClassName('selectLinkS'); });
	$('subtheme'+id).addClassName('selectLinkS');
	$('id_theme').value=id;
}

function showSearchTheme(id) {
	$('searchform').reset();
	changeSearchTheme(id);
	submitForm('searchform','searchresults');
	$('refinesearch').style.display='table-row-group';
}

function traiteReponseText(texte){
	var tab=new Array();	
	tab = texte.split('----/----');
	return tab;
}

function submitSearch() {
	$('Layer21').setStyle({'display':'block'});
	$('searchform').request( {onSuccess: function(t){ 
			var tableauRetour = traiteReponseText(t.responseText);
			$('infosMurTag').setStyle({'display':'none'});
			$('searchresultsAffiche').innerHTML=tableauRetour[1]; if(supersleight)supersleight.run('ResultatsFromRecherche');
			if($('murTag'))	$('murTag').setStyle({'display':'none'});
			if($('ResultatsFromRecherche'))	$('ResultatsFromRecherche').setStyle({'display':'block'});
			/*if(tableauRetour[0]==1 || tableauRetour[0]==2){
				if($('ResultatsFromRecherche'))	$('ResultatsFromRecherche').setStyle({'display':'none'});
				if($('murTag'))	$('murTag').setStyle({'display':'block'});
				initTagCloud("murTag", window.tagCloudTab);
			}
			if(tableauRetour[0]==3){
				if($('murTag'))	$('murTag').setStyle({'display':'none'});
				if($('ResultatsFromRecherche'))	$('ResultatsFromRecherche').setStyle({'display':'block'});
			}*/
		}});
}

function resetFormRecherche (){
	document.getElementById('searchform').reset();
	$('infosMurTag').setStyle({'display':'block'});
	if($$('.infosResultatsRecherche')[0])
	$$('.infosResultatsRecherche')[0].setStyle({'display':'none'});
	if($('ResultatsFromRecherche'))	$('ResultatsFromRecherche').setStyle({'display':'none'});
	if($('murTag'))	$('murTag').setStyle({'display':'block'});
	initTagCloud('murTag', window.tagCloudTab);
}

function submitForm(from,into) {
//	alert("submit "+from+" to "+into);
	$(from).request( {onSuccess: function(t){ $(into).innerHTML=t.responseText; } });
}
function prepareFavoriteForSend(checkBox){
	var action;
	var messageUrl="";
	var idOpinion=checkBox.value;
	if(checkBox.checked){
		action="storeFavorite";
	}else{
		action="removeFavorite";		
	}
	var ajaxRequest;
	var postBody = 'action='+action +'&idOpinion='+ idOpinion;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onSuccess: 
			function(t){
				var selectedFavs=$('selectedFavs').getValue();
				if(t.responseText.match(/added/)){
					selectedFavs++;
				}else if(t.responseText.match(/removed/)){
					selectedFavs--;
				}
				$('selectedFavs').value=selectedFavs;
      			}
		});
		
}
function updateFavoriteComment(textarea,idOpinion){
	var message=$(textarea).getValue();
	var ajaxRequest;
	var postBody = 'action=updateMessageFromFavorite&idOpinion='+ idOpinion + "&message="+message;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onSuccess: 
			function(t){
				//alert(t.responseText);
				}
		});	
}
function sendFav(mess){
	var selectedFavs=$('selectedFavs').getValue();
	if(selectedFavs>5 || selectedFavs<1){
		showCloudMsg('send',0,0,mess);
	}else{
		var url ="";
		var is6maFavorites=$('is6maFavorites').getValue();
		if(is6maFavorites!=0)url='&type=6ma';
		//alert(url);
		ajaxPage('myfavsend',url);	
	}
  	
}
function delFav(id, is6ma){
	var ajaxRequest;
	var postUrl="";
	if(is6ma==1){
		postUrl='&type=6ma';
		}
	var postBody = 'action=delFav&id='+id + postUrl;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      $('pagecontent').innerHTML=t.responseText;      
     }
		});
}

function addFav(id,opinion) {
	var ajaxRequest;
	var postBody = 'action=addfav&id_user='+id+'&opinion='+opinion;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onSuccess: 
			function(t){
				//alert(t.responseText);
     }
		});
}

function emailFav(){
  var name=document.fav_send.name.value;
  var last_name=document.fav_send.last_name.value;
  var email=document.fav_send.email.value;
  var dest_email=document.fav_send.dest_email.value;
  var subject=document.fav_send.subject.value;
  var message=document.fav_send.message.value;
  var is6maFavorites=document.fav_send.is6maFavorites.value;
  
  var url='&name='+name+'&last_name='+last_name+'&email='+email+'&dest_email='+dest_email+'&subject='+subject+'&message='+message+'&is6maFavorites='+is6maFavorites;
	var ajaxRequest;
	var postBody = 'action=emailFav'+url;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
			//	alert(t.responseText);
     			ajaxPage('myfav','');      
     }
		});
}

function sendFriend() {
		$('sf_form').request({onSuccess:
			function(t) { 
				$('sendfriendmsg').innerHTML=t.responseText;
				vanishElement('sendfriend');
				appearElement('sendfriend2');
				setTimeout(function() { vanishElement('sendfriend2'); }, 2000);
			}
		});
}

function changeClass(id){
  el = $(id);
	var display = (el.className=='s91_txt4') ? 's91_txt1' : 's91_txt4';
	el.className = display;
}

function blockUser(user){
  var ajaxRequest;
	var postBody = 'action=blockUser&user='+user;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      
     }
		});
}


function removeLang(smallElement, idLang){
	var numLanguage = $('numLanguages');
	var valNumLanguage = Number(numLanguage.value);
	if(numLanguage) {
			numLanguage.value = valNumLanguage - 1;
			$('select_menu_lang').show();
		}
	
	$(smallElement).remove();
	
	var valuesAr = $('lang').value.split(",");
	valuesAr = valuesAr.without(idLang);
	$('lang').value=valuesAr.join(",");
}


function preventRemovingLanguage(smallElement){
	var small = $(smallElement);
	small.setStyle({color: 'red'});
	if(small.onmouseout == undefined ){
		small.onmouseout=setBackToNormal;
	}
}
function setBackToNormal(){
		$(this).setStyle({color: 'black'});
}

function addLang(idLang, labelLang){
	var numLanguage = $('numLanguages');
	var valNumLanguage = Number(numLanguage.value);
	var limit = 5;
	if(!numLanguage || valNumLanguage < limit){
		if(numLanguage) {
			numLanguage.value = valNumLanguage + 1;
			if(valNumLanguage == limit-1) $('select_menu_lang').hide();
		}
		var valuesAr = $('lang').value.split(",");
		valuesAr.push(idLang);
		$('lang').value=valuesAr.join(",");
		var htmlToInsert="<small class='text_color mouse' onClick='removeLang(this,"+ idLang +")' onmouseover='preventRemovingLanguage(this);'>" + labelLang + "</small>";
		$('langs').insert(htmlToInsert);
	}
}





function buttonSwitch(id,src){
	$(id).src=src;
}

function sendError(trans){
  if($('err').style.display=="none"){
  $('err').style.display="";
  }
  else{
  var trans=trans;
  var error=$('error').value;
  var url='&trans='+trans+'&error='+error;
	
  var ajaxRequest;
	var postBody = 'action=addAlert'+url;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      //$('pagecontent').innerHTML=t.responseText;  
      //alert(t.responseText);
      removeBlackDiv();
      ajaxPage('moderation2','');
     }
		});
		}
}

function removeTranslation(trans){
  if($('err').style.display=="none"){
  $('err').style.display="";
  }
  else{
  var ajaxRequest;
	var postBody = 'action=removeTranslation&id='+trans;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      removeBlackDiv();
      ajaxPage('moderation2','');
     }
		});
		}
}

function approveTrans(trans){
var trans=trans;
  var url='&trans='+trans;
	
  var ajaxRequest;
	var postBody = 'action=approveTrans'+url;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      $('pagecontent').innerHTML=t.responseText;  
     }
		});

}
function acceptTranslator(id_translator){
	var checkBox=$("checkBoxAcceptTranslator");
	if(checkBox && checkBox.checked){
		var url='&id_translator='+id_translator;
		var ajaxRequest;
		var postBody = 'action=acceptTranslator'+url;
		new Ajax.Request('ajax/action.php', { method:'post', postBody:postBody });
	}

}

function clearOptions(el)
{
var i;
for(i=0;i<el.length;i++){
el[i].disabled=false;
}

}

function validateModLangForm(form)
{
    
    var check=0;
    if (form.cat.options[form.cat.selectedIndex].value==0 ){check=check+1;document.getElementById('category').style.color='red';}else{document.getElementById('category').style.color='#111111';}
    if (form.t_lang.options[form.t_lang.selectedIndex].value==0 ){check=check+1;document.getElementById('t_language').style.color='red';}else{document.getElementById('t_language').style.color='#111111';}
    if (form.h_lang1.options[form.h_lang1.selectedIndex].value==0 ){check=check+1;document.getElementById('h_language').style.color='red';}else{document.getElementById('h_language').style.color='#111111';}
    
    if (check>0)
    {
        return false;
    } 
    else 
    {
    ajaxPage('moderation_lang_do','&id_cat='+document.getElementById('cat').value+'&id_tlang='+document.getElementById('t_lang').value+'&id_hlang1='+document.getElementById('h_lang1').value+'&id_hlang2='+document.getElementById('h_lang2').value);
    }
}

function validateModLangFormXLS(form)
{
    
    var check=0;
    if (form.cat.options[form.cat.selectedIndex].value==0 ){check=check+1;document.getElementById('category').style.color='red';}else{document.getElementById('category').style.color='#111111';}
    if (form.t_lang.options[form.t_lang.selectedIndex].value==0 ){check=check+1;document.getElementById('t_language').style.color='red';}else{document.getElementById('t_language').style.color='#111111';}
    if (form.h_lang1.options[form.h_lang1.selectedIndex].value==0 ){check=check+1;document.getElementById('h_language').style.color='red';}else{document.getElementById('h_language').style.color='#111111';}
    
    if (check>0)
    {
        return false;
    } 
    else 
    {
    return window.open('moderation_lang_do_xls.php?id_cat='+document.getElementById('cat').value+'&id_tlang='+document.getElementById('t_lang').value+'&id_hlang1='+document.getElementById('h_lang1').value+'&id_hlang2='+document.getElementById('h_lang2').value, 'xls', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,fullscreen=yes,channelmode=no');
}
}
function validateModLangFormToCart(form)
{
    
    var check=0;
    if (form.cat.options[form.cat.selectedIndex].value==0 ){check=check+1;document.getElementById('category').style.color='red';}else{document.getElementById('category').style.color='#111111';}
    if (form.t_lang.options[form.t_lang.selectedIndex].value==0 ){check=check+1;document.getElementById('t_language').style.color='red';}else{document.getElementById('t_language').style.color='#111111';}
    if (form.h_lang1.options[form.h_lang1.selectedIndex].value==0 ){check=check+1;document.getElementById('h_language').style.color='red';}else{document.getElementById('h_language').style.color='#111111';}
    
    if (check>0)
    {
        return false;
    } 
    else 
    {
    translationToCart(form.cat.value,form.t_lang.value,form.h_lang1.value,form.h_lang2.value); 
    }
}

function approveModLang(cat,label,tlang,hlang1,hlang2,val){

  var url='&cat='+cat+'&label='+label+'&tlang='+tlang+'&val='+val+'&hlang1='+hlang1+'&hlang2='+hlang2;
	
  var ajaxRequest;
	var postBody = 'action=approveModLang'+url;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      ajaxSubPage('moderation_lang_do','&id_cat='+cat+'&id_tlang='+tlang+'&id_hlang1='+hlang1+'&id_hlang2='+hlang2+'&label='+label);
    
     }
		});

}
function translationToCart(cat,tlang,hlang1,hlang2){

  var url='&cat='+cat+'&tlang='+tlang+'&hlang1='+hlang1+'&hlang2='+hlang2;
	
  var ajaxRequest;
	var postBody = 'action=translationToCart'+url;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      ajaxPage('mes_traduction1','');
    
     }
		});

}

function selectLang(){
if($('lang').className=='select_menu m_hide')
$('lang').className='select_menu';
else
$('lang').className='select_menu m_hide';
}

function sendNewsletter(){
  var name=$('name').value;
  var last_name=$('last_name').value;
  var email=$('email').value;
  var country=$('country').value;
  var language=$('language').value;
var url='&name='+name+'&last_name='+last_name+'&email='+email+'&lang='+language+'&country='+country;
	
  var ajaxRequest;
	var postBody = 'action=sendNewsletter'+url;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      ajaxPage('newsletter','&step=subscribed');
     }
		});
}

function guestBookSend(){
var name=$('name').value.replace(/"/g, "''");
  var last_name=$('last_name').value.replace(/"/g, "''");
  var email=$('email').value.replace(/"/g, "''");
  var country=$('country').value.replace(/"/g, "''");
  var language=$('language').value.replace(/"/g, "''");
  var titleOfPost=$('titleOfPost').value.replace(/"/g, "''");
  var content=$('content_guestbook').value.replace(/"/g, "''");
var url="&name="+name+"&last_name="+last_name+"&email="+email+"&lang="+language+"&country="+country+"&title="+titleOfPost+"&content="+content;
	
  var ajaxRequest;
	var postBody = 'action=guestBookSend'+url;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      ajaxPage('guest_book_complite','');
     }
		});

}

  function _hide(id){
	var el=document.getElementById(id);
	el.className="m_hide";
	
	}
	
	function _hideAll(){
	$('ul_lang').className="m_hide";
	$('ul_sexe').className="m_hide";
	$('ul_country').className="m_hide";
	$('ul_anne').className="m_hide";
	$('ul_lang').style.zIndex=1;
	$('ul_country').style.zIndex=1;
	$('ul_sexe').style.zIndex=1;
	$('ul_anne').style.zIndex=1;
	}
	
	function _show(id){
		var el=document.getElementById(id);
		//alert(el.className);
		el.className=(el.className!="m_hide"?"m_hide":"");
		el.style.zIndex=2;
	}
	
	//insert into hidden form elements named id="where" value="val"
	function _hidden(where,val){
		var el=document.getElementById(where);
		el.value=val;
	}
	
	function selected2(id,end,label){
	for(var i=0;i<end;i++){
		if('l'+i==id){
			document.getElementById(id).style.backgroundColor='#0000ff';
			//document.getElementById(id).className="selected";
			continue;
		}
		document.getElementById('l'+i).style.backgroundColor='white';
	}
	document.getElementById('lg1').style.display='none';
	document.getElementById('lg2').style.display='';
	document.getElementById('lg2').innerHTML=label;
	}
	
	function selectTemoType(type,text) {
	if($F('id_question')==0) {
		$('choose_question').innerHTML=text;
	} else {
		ajaxPage('temoignages','&id_question='+$F('id_question')+'&type='+type);
	}
}

function checkIfSelected(){
	if($('choose_question').innerHTML!=""){
		$('choose_question').innerHTML="";
	}
}

function recommendedSend(){
  var name=$('name').value;
  var last_name=$('last_name').value;
  var email=$('email').value;
  var email_to=$('email_to').value;
  var subjet=$('subjet').value;
  var content=$('messageToFriend').value;
  var link=$('link').value;
var url='&name='+name+'&last_name='+last_name+'&email='+email+'&email_to='+email_to+'&subjet='+subjet+'&content='+content+'&link='+link;
	
  var ajaxRequest;
	var postBody = 'action=recommendedSend'+url;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      ajaxPage('recommended_send','');
     }
		});
}

function removeBlackDiv(){
$('main2').innerHTML='';
	setStyle('main2','z-index: 2000; position: relative;');
	$('top').style.display="";
	$('main').className="";
	setStyle('main','');
} 

function clearMain2(){
$('main2').innerHTML="";
}

function temoViewlackBg(id){
  $('top').style.display="none";
				$('main').className="mainBlack";
				setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:block;');
				setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%;');
}

function deleteTemo(id){
  var ajaxRequest;
	var postBody = 'action=deleteTemo&id='+id;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
			ajaxPage('mon_temoignages','');
     }
		});

}

function addPageMain2(module,id_opinion,lang,trans,id_alert_name,type,id_alert){
  var ajaxRequest;
	var postBody = 'action='+module+'&id_opn='+id_opinion+'&lang='+lang+'&id='+id_alert+'&id_alert_name='+id_alert_name+"&id_trans="+trans;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
				$('top').style.display="none";
				$('main').className="mainBlack";
				setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:block;');
				setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%;');
				$('main2').innerHTML=t.responseText;
			   	if($('vidplayer')){
			   		addflash('vidplayer','6ma_player?mode=single','mode=single&type='+(type?'portrait':'landscape')+'&groupID='+id_opinion+'&langID='+lang+'&params='+escape('id_translation='+trans),602,439);
			   		}
			   	if(supersleight){supersleight.limitTo(false);supersleight.run();}
     }
		});
	//fix for stubborn video translator
	window.removeTranslator=function() {
		if(module=="moderation_error2")
			updateTranslationsAlerts(id_opinion,trans,id_alert_name);
		removeBlackDiv();
	}
}


function updateTranslationsAlerts(id_opinion,id_translation,id_alert_name) {
	var ajaxRequest;
	var postBody = 'action=updateTranslationsAlerts&id_opinion='+id_opinion+'&id_translation='+id_translation+'&id_alert_name='+id_alert_name;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onSuccess: 
			function(t){
				if(t.responseText.match("translationsAlertsUpdated") && id_alert_name!="all"){
					ajaxPage('moderation2','');
				}
			}
		});
}



function checkCaptcha(captcha){
var url='&captcha='+captcha;
	var ajaxRequest;  // The variable that makes Ajax possible!
	var postBody = 'action=captcha'+url;
		new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){ 
			var stat=t.responseXML.documentElement.getAttribute("status");
				if(stat==1) {
					//var media=t.responseXML.documentElement.getAttribute("id_media");
					//addflash('pagecontent','6ma','id_user='+iduser+'&id_media='+media+'&id_lang='+id_lang+'&id_lang_int='+lang);
					$('capt').addClassName('pseudo_occupied2');
					$('capt').removeClassName('pseudo_occupied');
				}
				else{
					$('capt').addClassName('pseudo_occupied');
					$('capt').removeClassName('pseudo_occupied2');
				}
      }
		});

}

function removeAlert(id,trans,type,id_alert){
 var ajaxRequest;
	var postBody = 'action=removeAlert&id='+id+'&trans='+trans+'&type='+type+'&id_alert='+id_alert;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      removeBlackDiv();
      if(trans || id_alert)
      ajaxPage('moderation2','');
      else
      ajaxPage('moderation','');
     }
		});

}

function removeOpinion(id,type){
 var ajaxRequest;
	var postBody = 'action=removeOpinion&id='+id+'&type='+type;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      removeBlackDiv();
      ajaxPage('moderation','');
     }
		});

}
function translate(user,opinion,lang,lang1,lang2,trans){
if(lang1!='')
lg1='&id_lang1='+lang1;
else
lg1='';
if(lang2!='')
lg2='&id_lang2='+lang2;
else
lg2='';
$('top').style.display="none";
					$('main').className="mainBlack";
					setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:block;');
					$('main2').innerHTML='<img src="images/x.png" onClick="removeOpac();removeBlackDiv();ajaxSubPage(\'mes_traduction1\',\'\');" id="close" style="cursor: pointer;position: absolute; z-index: 5000;"><div id="mov2" style="margin-top: 20px;position: relative; z-index: 3000;"></div>';
					setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%;');
					$('close').clonePosition($('mov2'),{setWidth:false,setHeight:false,offsetLeft:1002,offsetTop:-10});
					addOpac();
					var height = document.body.offsetHeight;
          if(height<800){
            $('mov2').style.height="560px";
            $('mov2').style.width="900px";
            $('mov2').style.overflow="auto";
          }
          addflash('mov2','6ma','id_user='+user+'&id_media='+opinion+'&id_lang='+lang+'&id_lang1='+lg1+'&id_lang2='+lg2+'&id_translation='+trans+'&id_lang_int='+lang,850,718);
	//fix for stubborn video translator
	window.removeTranslator=function() {
			updateTranslationsAlerts(opinion,trans,"all");
			removeBlackDiv();
		}
}

function showMovie(id,lang,types,button,text){
if(types=='text'){
 var ajaxRequest;
	var postBody = 'action=showMovie&id='+id;
	new Ajax.Updater('main2','ajax/action.php', {method:'post', evalScripts:true, postBody:postBody, onLoading: showLoad, onComplete: 
			function(t){
				hideLoad();
	      $('top').style.display="none";
				$('main').className="mainBlack";
				setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:block;');
				setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%;');
//  $('main2').innerHTML=t.responseText;
      }
		});
  }
else{
var ajaxRequest;
	var postBody = 'action=showMovie&id='+id+'&text='+text;
	new Ajax.Updater('main2','ajax/action.php', {method:'post', evalScripts:true, postBody:postBody, onLoading: showLoad, onComplete:
			function(t){
				hideLoad();
  			$('top').style.display="none";
				$('main').className="mainBlack";
				setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:block;');
				setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%;');
//  $('main2').innerHTML=t.responseText;
  addflash('movie','6ma_player?mode=single','mode=single&type=landscape&groupID='+id+'&langID='+lang,602,439);
   }
		});
  }
}

function showDiv(id,where){
el = document.getElementById(id);
if(el.style.display == 'none')
el.style.display = 'block';
else
hideDiv(id,where,13)
}
function hideDiv(id,where,key){
  if(key=='13'){
  var comment=$(where).value.replace(/\n/,'');
  $(where).value = comment;
  $(where).onchange();
  $(id).style.display = 'none';
  if(comment!='')
  $('img_'+id).src='images/6_favoris_03_54.jpg';
  else
  $('img_'+id).src='images/6_favoris_03_33-51.jpg';
  //   }});
  }
}

function removeWebcam(){
setTimeout("removeWebcam1()", 100);
}

function removeWebcam1(){
document.getElementById('cam1').innerHTML="";
$('cam1').setStyle({'display':'none'});
document.getElementById('cam').style.display="block";
document.getElementById('webcam_show').style.display="";
var ajaxRequest;
	var postBody = 'action=removeWebcam';
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      if(t.responseText)
      $('photoimg').src=t.responseText;  
     }
		});

}

function resolution(){
//  var width = 1280;
//  var height = 800;
  var width = screen.width;
  var height = screen.height;
  var ajaxRequest;
	var postBody = 'action=resolution&height='+height+'&width='+width;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
     }
		});
}

function togg(id){
	el = $(id);
	var display = el.style.display ? '' : 'none';
	el.style.display = display;
}

function showRules(name,mainPage){
$(mainPage).style.display='none';
$(name).style.display='block';
setStyle('pagecontent',"width:100%; text-align:center; position:relative; top:"+(parseInt($('pagecontent_holder').offsetHeight)-parseInt($('pagecontent').offsetHeight))+"px; left:0px;");
if(supersleight) { imgs=$$('img.21x20');for(var i=0;i<imgs.length;i++){imgs[i].style.width="21px";imgs[i].style.height="20px";}}
}

function hideRules(name,mainPage){
$(mainPage).style.display='';
$(name).style.display='none';
setStyle('pagecontent',"width:100%; text-align:center; position:relative; top:"+(parseInt($('pagecontent_holder').offsetHeight)-parseInt($('pagecontent').offsetHeight))+"px; left:0px;");
}
function showRulesFromHome(){
		if(!onLoading){
		mosaic.activate(false);
		onLoading = true;
		getNumInfo();
		var postBody = 'module=rules&isfromHome=1';
		animFadePage(postBody);
		window.currentpage="rules";
	}
}
function menu_color_show(photo,where){
	$(where).src=photo;
	if(supersleight)supersleight.run('fixateurBarreMenu'); 
}

function menu_color_hide(photo,where){
	$(where).src=photo;
	if(supersleight)supersleight.run('fixateurBarreMenu'); 
}
	
function possCloud(time){
if($('cloudPosition')){
var initBottomCloud = -($('cloud').getHeight()-92);
var initHeightCloudPosition=$('cloud').getHeight()+92;
$('cloudPosition').setStyle({visibility: "visible" , "height" : initHeightCloudPosition+"px" ,"zIndex":10,"left" : $('menu').cumulativeOffset().left+80+"px" });
$('cloud').setStyle({'bottom':initBottomCloud+"px"});
$('cloud').morph({"bottom" : "92px"}, {duration: 2.2, afterFinish: function() {setTimeout("hideCloud("+initBottomCloud+")", time);ajaxPage('intro','');}});
}
else
return false;
}

function hideCloud(destHeight){
$('cloud').morph({"bottom" : destHeight + "px"}, {duration: 1.2, afterFinish: function() {$('cloudPosition').style.display='none';}});
}

function backSearch(url){
	$('Layer21').style.display="none";
	ajaxSubPage('recherche',url);
	return;
  var ajaxRequest;
	var postBody = 'action=backSearch';
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
		function(t){			
      showSearchPage(t.responseXML.documentElement.getAttribute('lastid'),0,'');
			if(t.responseXML.documentElement.getAttribute('left')=='0') $('Layer21').style.display="none";
     }
		});
}

function getNumTrans(){
  var ajaxRequest;
	var postBody = 'action=getNumTrans';
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      //alert(t.responseText);
      $('user_trans_count').innerHTML=t.responseText;
     }
		});
}

function getNumMod(){
  var ajaxRequest;
	var postBody = 'action=getNumMod';
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      //alert(t.responseText);
      $('user_mod_count').innerHTML=t.responseText;
     }
		});
}

function getNumMess(){
  var ajaxRequest;
	var postBody = 'action=getNumMess';
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      //alert(t.responseText);
      $('user_message_count').innerHTML=t.responseText;
     }
		});
}

function changeMenu(){
	//alert("changeMenu");
  var ajaxRequest;
	var postBody = 'action=changeMenu';
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
				
				//$('menulayer4').innerHTML=t.responseText;
				var user_message_count="";
				var user_mod_count="";
				var user_trans_count="";
				var user_mess_count="";
				var isuserlogged=false;
				try{user_message_count = t.responseXML.documentElement.getElementsByTagName('usermessagecount')[0].childNodes[0].nodeValue;}catch(er){}
				try{user_mod_count = t.responseXML.documentElement.getElementsByTagName('usermodcount')[0].childNodes[0].nodeValue;}catch(er){}
				try{user_trans_count = t.responseXML.documentElement.getElementsByTagName('usertranscount')[0].childNodes[0].nodeValue;}catch(er){}
				try{user_mess_count = t.responseXML.documentElement.getElementsByTagName('usermesscount')[0].childNodes[0].nodeValue;}catch(er){}
				try{isuserlogged = t.responseXML.documentElement.getAttribute('islogged')==1;}catch(er){}
				//alert("user_message_count="+ user_message_count + "\nuser_mod_count="+user_mod_count+"\nuser_trans_count="+ user_trans_count + "\nuser_mess_count="+user_mess_count  + "\nisuserlogged="+isuserlogged ) ;
				
				$('user_message_count').innerHTML=user_message_count;
				$('user_mod_count').innerHTML=user_mod_count;
				$('user_trans_count').innerHTML=user_trans_count;
				$('user_mess_count').innerHTML=user_mess_count;
				if(isuserlogged) {
					$('b46').style.display='block';
					$('b47').style.display='none';
				}
				else{
					$('b46').style.display='none';
					$('b47').style.display='block';
				}
				window.isuserlogged=isuserlogged;
     		}
		});
}
function getNumInfo(){
changeMenu();
}

function logout(){
var ajaxRequest;
	var postBody = 'action=logout';
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
      $('user_message_count').innerHTML=t.responseText;
     }
		});
}

function setSurePoss(idCloud,idDiv){
  $(idCloud).clonePosition($(idDiv),{setWidth:false,setHeight:false,offsetLeft:60,offsetTop:10});
}

function translateView(id){
  var content=$('content').value;
  var ajaxRequest;
	var postBody = 'action=translateView&content='+content+'&id='+id;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
	     addBlackBg();		
      $('main2').innerHTML=t.responseText;
      }
		});
}

function addTransText(id,action,where){
   if($('lang')){
		 if($F('lang')==0){
			$('error_lang').style.display="";
  			$('error_lang').clonePosition($('lang'),{setWidth:false,setHeight:false,offsetLeft:-50,offsetTop:-80});
			return false;
		}
		else $('error_lang').setStyle({'display':'none'});			
	}
  if($('Validation_traduction')&&$('Validation_traduction').visible()) $('Validation_traduction').setStyle({'display':'none'});
  var content=$('content').value;
  var lang1=$('lang1').value;
  var lang2=$('lang2').value;
  var lang=$('lang').options[$('lang').selectedIndex].value;
  var ajaxRequest;
	var postBody = 'action=addTransText&content='+content+'&id='+id+'&type='+action+'&lang='+lang+'&lang1='+lang1+'&lang2='+lang2;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
			if(t.responseText){
				$('Validation_traduction').setStyle({'display':'block'});
  				$('messageValidation').update(t.responseText);
  				mettrePanierTraduction('mettrePanier','lang');
			}
			if(where=='1')
				ajaxPage('mes_traduction1','');
/*
			else{
 			     $('top').style.display="none";
					$('main').className="mainBlack";
					setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%;');
					setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:block;');
        
				
          $('main2').innerHTML=t.responseText;
          //if(supersleight){supersleight.run('main2');}
					//addflash('movXXX','6ma_player?mode=single','mode=singleNoaccepted&type=portrait|landscape&groupID='+t.responseXML.documentElement.getAttribute('id')+'&langID='+t.responseXML.documentElement.getAttribute('lang'),602,439);
      
      
     }

*/     }
		});
}


function showQuestionMark(id,moveLeft,moveTop){
var q='question_'+id;
var p='pos_'+id;
if($(q).style.display==''){
$(q).style.display='none';
}
else{
$(q).style.display='';
$(q).clonePosition($(p),{setWidth:false,setHeight:false,offsetLeft: moveLeft,offsetTop: moveTop});
}
}

function temoView(id){
          var ajaxRequest;
	var postBody = 'action=temoView&temo='+id;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
			    $('top').style.display="none";
					$('main').className="mainBlack";
					setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:block;');
					$('main2').innerHTML=t.responseText;
					setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%;');
     }
		});
          
}

function addBlackBg(){
          $('top').style.display="none";
					$('main').className="mainBlack";
					setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:block;');
					setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%;');
}

function addClose(id){

$('main2').innerHTML='<div id="translatordiv" style="position:relative;" align="center"><div id="transcell" style="position:relative; top:10px; width:1200px;"></div><img src="images/5_traduction_06_05.png" width="21" height="20" alt="" onClick="TemoPriv('+id+');" style="cursor:pointer;position:absolute;z-index:25;top:0px;left:1002px; display:;" id="videocloser"></div>';
var height = document.body.offsetHeight;
          if(height<800){
            $('transcell').style.height="560px";
            $('transcell').style.width="900px";
            $('transcell').style.overflow="auto";
          }

}

function TemoPriv(id){
      var ajaxRequest;
	var postBody = 'action=temoPriv&temo='+id;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
					$('main2').innerHTML=t.responseXML.documentElement.childNodes[0].nodeValue;
          if(t.responseXML.documentElement.getAttribute('type')!='text')
					addflash('movXXX','6ma_player?mode=single','mode=single&type=landscape&groupID='+t.responseXML.documentElement.getAttribute('id')+'&langID='+t.responseXML.documentElement.getAttribute('lang'),602,439);
     }
		});
}

function addToCart(opinion,lang,lg1,lg2,where){
 if($('lang')){
		 if($F('lang')==0){
			//$$('.error_lang')[0].setStyle({'color':'red'});
			$('error_lang').style.display="";
  			$('error_lang').clonePosition($('lang'),{setWidth:false,setHeight:false,offsetLeft:-50,offsetTop:-80});
			return false;
		}
		else $('error_lang').setStyle({'display':'none'});
	}
 var ajaxRequest;
	var postBody = 'action=addToCart&opinion='+opinion+'&lang='+lang+'&lg1='+lg1+'&lg2='+lg2;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
			//alert(t.responseText);
			if(where==1)
			ajaxPage('mes_traduction1','');
			else{
      $('top').style.display="none";
					$('main').className="mainBlack";
					setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%;');
					setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:block;');
        
				
          $('main2').innerHTML=t.responseText;
          //if(supersleight){supersleight.run('main2');}
					//addflash('movXXX','6ma_player?mode=single','mode=singleNoaccepted&type=portrait|landscape&groupID='+t.responseXML.documentElement.getAttribute('id')+'&langID='+t.responseXML.documentElement.getAttribute('lang'),602,439);
      
      
     }
			
     }
		});
}

var Browser = Class.create({
	  initialize: function() {
	    var userAgent = navigator.userAgent.toLowerCase();
	    this.version = (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1];
	    this.safari = /webkit/.test( userAgent );
	    this.opera = /opera/.test( userAgent );
	    this.msie = /msie/.test( userAgent ) && !/opera/.test( userAgent );
	    this.mozilla = /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent );
	  }
	});


function showQuestionById(idImg, idSpan, topOrBottom, idBubble, offsetLeft, offsetTop, observeMouseOut, minHeight, maxHeight, onclick){
	var idBubble = (idBubble == null) ? "helpDiv" : idBubble;
	var helpDiv =$(idBubble);
	var txtToShow = $(idSpan).innerHTML;
	if(!helpDiv && txtToShow){
		var offsetLeft = (offsetLeft == null) ? -100 : offsetLeft;
		var offsetTop = (offsetTop == null) ? 20 : offsetTop;
		var posX=$(idImg).positionedOffset().left + offsetLeft;
		var minmaxHeight = (minHeight == null ? "min-height:40px;" : (minHeight < 0 ? "" : "min-height:"+minHeight+"px;"))
		minmaxHeight += (maxHeight == null ? "max-height:200px;" : (maxHeight < 0 ? "" : "max-height:"+maxHeight+"px;"))
		var onclickString = onclick == null ? '' : ' onclick="'+onclick+'"';
		var posY;
		var htmlToShow;
		if(topOrBottom =="top"){
			htmlToShow = "<div id=\""+idBubble+"\" "+onclickString+"\" style=\"position:absolute;text-align: center;z-index:200;display:none;width:252px;left:"+posX+"px;\"><div style=\"height:15px;background-image:url('images/empty_div_1_top.png');background-repeat:no-repeat;font-size:1px;\"></div><div style=\"background-image:url('images/empty_div_1_middle.png');background-repeat:repeat-y;width:252px;\"><div style=\"color: #333333; font-size: 11px;padding:5px 15px;text-align: left;overflow-x: hidden; overflow-y: auto;"+minmaxHeight+"\">"+txtToShow+"</div></div><div style=\"height:10px;background-image:url('images/empty_div_1_bottom.png');background-repeat:no-repeat;font-size:1px;\"></div></div>";
		}else{
			htmlToShow = "<div id=\""+idBubble+onclickString+"\" style=\"text-align:center;position:absolute;z-index:200;display:none;width:252px;left:"+posX+"px;\"><div style=\"height:10px;background-image:url('images/empty_div_2_top.png');background-repeat:no-repeat;font-size:1px;\"></div><div style=\"background-image:url('images/empty_div_2_middle.png');background-repeat:repeat-y;width:252px;\"><div style=\"color:#333333;font-size:11px;padding:5px 15px;text-align:left;overflow-x: hidden; overflow-y: auto;"+minmaxHeight+"\">"+txtToShow+"</div></div><div style=\"height:15px;background-image:url('images/empty_div_2_bottom.png');background-repeat:no-repeat;font-size:1px;\"></div></div>";
		}
		$($(idImg).parentNode).insert(htmlToShow);
		if(topOrBottom =="top"){
			posY=$(idImg).positionedOffset().top + offsetTop;
		}else{
			posY=$(idImg).positionedOffset().top - $(idBubble).getHeight();
		}
		$(idBubble).setStyle({top:posY+"px"});
		var browser = new Browser();
		if(browser.msie && browser.version < 7 ){
			supersleight.limitTo(idBubble);
			supersleight.run();
			supersleight.limitTo(false);
			}
		$(idBubble).appear({ duration: 0.5 });
		if (observeMouseOut == null || observeMouseOut == true)
			$(idImg).observe('mouseout',function(e){
				var helpDiv =$(idBubble);
				if(helpDiv){
					helpDiv.remove();
				}
				$(this).stopObserving('mouseout');
			});
		
	}
}

function getFlashObject(name) {
	if(document.embeds[name]) return document.embeds[name];
	else if(document[name] && document[name].id==name) return document[name];
	else return false;
}


function delTrans(id){
 var ajaxRequest;
	var postBody = 'action=delTrans&id='+id;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
			if(t.responseText!='')
			ajaxPage('mes_traduction3',t.responseText);
			else
			ajaxPage('mes_traduction1','');
     }
		});
}

function resumeTrans(id){
 var ajaxRequest;
	var postBody = 'action=resumeTrans&id='+id;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
			if(t.responseText!='')
			ajaxPage('mes_traduction3',t.responseText);
     }
		});
}
function unlockBottomMenu(){
	var allElements = $$("#menu2cont1 p, #menu2cont2 p, #menu2cont3 p");
	var elementToUnlock = allElements.find(function(el){
		return !el.onmouseover && !el.onmouseout;
	});
	if(elementToUnlock !=undefined){
		elementToUnlock.onmouseover=elementToUnlock.oldOnMouseOver;
		elementToUnlock.onmouseout=elementToUnlock.oldOnMouseOut;
		elementToUnlock.onmouseout();
	}
}
function lockAndLoadPage(module, url, element, name){
	if(!onLoading){
		ajaxPage(module,url, name);
		unlockBottomMenu();
		element.oldOnMouseOver = element.onmouseover; 
		element.oldOnMouseOut = element.onmouseout; 
		element.onmouseover="";
		element.onmouseout="";
	}
}

function showBack(id){
var ajaxRequest;
	var postBody = 'action=backShow&id='+id;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
			$('top').style.display="none";
					$('main').className="mainBlack";
					setStyle('main','position:absolute; top:0px; left:0px; width:100%; height:100%;');
					setStyle('main2','position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:2000; display:block;');
        
				
          $('main2').innerHTML=t.responseXML.documentElement.childNodes[0].nodeValue;
          if(supersleight){supersleight.run('main2');}
					addflash('movXXX','6ma_player?mode=single','mode=single&type=landscape&groupID='+t.responseXML.documentElement.getAttribute('id')+'&langID='+t.responseXML.documentElement.getAttribute('lang'),602,439);
     }
		});
}

function addOpac(){
$('main2').style.background='#000000';
}
function removeOpac(){
$('main2').style.background='transparent';
}


function addTextStatic(id,lang,hlang,hlang2){
var text=$('content').value;
var ajaxRequest;
	var postBody = 'action=addTextStatic&id='+id+'&lang='+lang+'&hlang='+hlang+'&hlang2='+hlang2+'&text='+text;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
			ajaxSubPage('moderation_lang_do',t.responseText);
     }
		});
}

function insertReservationJavascript(id,id_lang,type){
	var ajaxRequest;
	var postBody = 'action=insertReservationAction&id='+id+'&lang='+id_lang+'&type='+type;
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody, onLoading: showLoad, onComplete: hideLoad, onSuccess: 
			function(t){
     }
		});
}


function disabledValeurMenu(idLang,idSelect){
	if($(idLang)){
		$$('#'+idSelect+' option').each(function(elem){
			if($(elem).disabled){
				$(elem).writeAttribute("disabled", false)
				$(elem).removeClassName('optionDisabled');
			}
			if(elem.value == $F(idLang) && $F(idLang)!=0 ){
				$(elem).writeAttribute("disabled", true);
				$(elem).addClassName('optionDisabled');
			}
        });
	}
	
} 

/*FUNCTION SUR LES COOKIES*/
function EcrireCookie(nom, valeur)
{
var argv=EcrireCookie.arguments;
var argc=EcrireCookie.arguments.length;
var expires=(argc > 2) ? argv[2] : null;
var path=(argc > 3) ? argv[3] : null;
var domain=(argc > 4) ? argv[4] : null;
var secure=(argc > 5) ? argv[5] : false;
document.cookie=nom+"="+escape(valeur)+
((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
((path==null) ? "" : ("; path="+path))+
((domain==null) ? "" : ("; domain="+domain))+
((secure==true) ? "; secure" : "");
}
function getCookieVal(offset)
{
var endstr=document.cookie.indexOf (";", offset);
if (endstr==-1) endstr=document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function LireCookie(nom)
{
var arg=nom+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen)
{
var j=i+alen;
if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;
}
return null;
}
function EffaceCookie(nom)
{
date=new Date;
date.setFullYear(date.getFullYear()-1);
EcrireCookie(nom,null,date);
}
/*FIN DES FONCTION SUR LES COOKIES*/

function EcrireCookieInfosForm(){
	EcrireCookie('last_name',$F('last_name'));
	EcrireCookie('name',$F('name'));
	EcrireCookie('email',$F('email'));
	EcrireCookie('country',$F('country'));
	EcrireCookie('language',$F('language'));
		
}

function AfficherCookieInfosForm(){
var last_name=LireCookie("last_name");
var name=LireCookie("name");
var email=LireCookie("email");
var country=LireCookie("country");
var language=LireCookie("language");

if ( last_name ) $('last_name').writeAttribute('value',last_name);
if ( name ) $('name').writeAttribute('value',name);
if ( email ) $('email').writeAttribute('value',email);
if ( country ) $('country').writeAttribute('value',country);
if ( language ) {_hide('ul_lang');_hidden('language',language);$('choose_lang').innerHTML=$('lang'+language).innerHTML;}

}

function VideSessionAlert(){
var ajaxRequest;
	var postBody = 'action=VideSessionAlert';
	new Ajax.Request('ajax/action.php', {method:'post', postBody:postBody});	
}
