var counter = 0;
var timer1 = "";
var text_pages = new Array();
var media_pages = new Array();
var media_pages2 = new Array();
var media_pages3 = new Array();
var type_affichage = "";
var id_page = "";
var id_open_player = "";
var curr_player = "";
var lg = "";
var texte = new Array();
var player_open = false;

function set_lg(lg_actu) {
	lg = lg_actu;
	if(lg == 'fr') {
		texte['excerpt'] = "Extrait";
		texte['excerpts'] = "Extraits";
		texte['of']	= "de";
		texte['excerpt_nfb'] = "Extraits de films ONF";
		texte['whole_film'] = "Films complets ONF";
		texte['photos'] = "Photographies";
		texte['photo'] = "Photographie";
		texte['film'] = "Film";
		texte['films'] = "Films";
		texte['vp'] = "Vox Populi";
		texte['close'] = "Fermer";
		texte['open'] = "Ouvrir";
		
	} else if(lg == 'en') {
		texte['excerpt'] = "Excerpt";
		texte['excerpts'] = "Excerpts";
		texte['of']	= "of";
		texte['excerpt_nfb'] = "Excerpts from NFB films";
		texte['whole_film'] = "Entire NFB Films";
		texte['photos'] = "Photographs";
		texte['photo'] = "Photo";
		texte['film'] = "Film";
		texte['films'] = "Films";
		texte['vp'] = "Vox Populi";
		texte['close'] = "Close";
		texte['open'] = "Open";
	}
}

function load_dropdown() {
	document.getElementById('zone_dd').className='visible';
}



function load_table(text, nb) {
	text_pages[nb] = text;
}

function load_table_media(no, id, title, year, thumb, desc, time, link, title_whole) {
	media_pages[no] = new Array();
	media_pages[no]['id'] = id;
	media_pages[no]['title'] = title;
	media_pages[no]['year'] = year;
	media_pages[no]['thumb'] = thumb;
	
	desc = desc.replace(/\\/g, '');
	
	media_pages[no]['desc'] = desc;
	media_pages[no]['time'] = time;
	
	media_pages[no]['link'] = link;
	media_pages[no]['title_whole'] = title_whole;
}

function load_page_courante(parentid, type) {
	id_page = parentid;
	type_affichage = type;
}

function load_table_media2(no, id, title, year, thumb, desc, time) {
	media_pages2[no] = new Array();
	media_pages2[no]['id'] = id;
	media_pages2[no]['title'] = title;
	media_pages2[no]['year'] = year;
	media_pages2[no]['thumb'] = thumb;
	desc = desc.replace(/\\/g, '');
	media_pages2[no]['desc'] = desc;
	media_pages2[no]['time'] = time;
}

function load_table_media3(no, id, title, year, thumb, desc, time) {
	media_pages3[no] = new Array();
	media_pages3[no]['id'] = id;
	media_pages3[no]['title'] = title;
	media_pages3[no]['year'] = year;
	media_pages3[no]['thumb'] = thumb;
	desc = desc.replace(/\\/g, '');
	media_pages3[no]['desc'] = desc;
	media_pages3[no]['time'] = time;
}


/**** FONCTIONS POUR LES MOTS-CL�S ****/

function switch_mc_sel(element, nbel) {
	if(element != "no_sel") {
		var psel = document.getElementById('mc'+element);
		var next_class = "";
		
		if(psel.className == 'pnonsel') {
			next_class = 'psel';
		}
		else if(psel.className == 'psel') {
			next_class = 'pnonsel';
		}
	}
	
	for(k=0; k<nbel; k++) {
		document.getElementById('mc'+k).className = 'pnonsel';
	}

	if(element != "no_sel") {
		psel.className = next_class;
	}
	
	
}

function hide_letters(letters, nbel) {
	switch_mc_sel('no_sel', nbel)

	if(letters != 'abc') {
		document.getElementById('mc_abc').style.visibility="hidden";
		document.getElementById('mc_abc').style.height="0px";
		document.getElementById('mc_abc').style.position="absolute";
		document.getElementById('choix_lettres_abc').className="choix_lettres";
	} else {
		document.getElementById('mc_abc').style.visibility="visible";
		document.getElementById('mc_abc').style.height="auto";
		document.getElementById('mc_abc').style.position="static";
		document.getElementById('choix_lettres_abc').className="choix_lettres_on";
	}
	if(letters != 'def') {
		document.getElementById('mc_def').style.visibility="hidden";
		document.getElementById('mc_def').style.height="0px";
		document.getElementById('mc_def').style.position="absolute";
		document.getElementById('choix_lettres_def').className="choix_lettres";
	} else {
		document.getElementById('mc_def').style.visibility="visible";
		document.getElementById('mc_def').style.height="auto";
		document.getElementById('mc_def').style.position="static";
		document.getElementById('choix_lettres_def').className="choix_lettres_on";
	}	
	if(letters != 'ghi') {
		document.getElementById('mc_ghi').style.visibility="hidden";
		document.getElementById('mc_ghi').style.height="0px";
		document.getElementById('mc_ghi').style.position="absolute";
		document.getElementById('choix_lettres_ghi').className="choix_lettres";
	} else {
		document.getElementById('mc_ghi').style.visibility="visible";
		document.getElementById('mc_ghi').style.height="auto";
		document.getElementById('mc_ghi').style.position="static";
		document.getElementById('choix_lettres_ghi').className="choix_lettres_on";
	}	
	if(letters != 'jkl') {
		document.getElementById('mc_jkl').style.visibility="hidden";
		document.getElementById('mc_jkl').style.height="0px";
		document.getElementById('mc_jkl').style.position="absolute";
		document.getElementById('choix_lettres_jkl').className="choix_lettres";
	} else {
		document.getElementById('mc_jkl').style.visibility="visible";
		document.getElementById('mc_jkl').style.height="auto";
		document.getElementById('mc_jkl').style.position="static";
		document.getElementById('choix_lettres_jkl').className="choix_lettres_on";
	}	
	if(letters != 'mno') {
		document.getElementById('mc_mno').style.visibility="hidden";
		document.getElementById('mc_mno').style.height="0px";
		document.getElementById('mc_mno').style.position="absolute";
		document.getElementById('choix_lettres_mno').className="choix_lettres";
	} else {
		document.getElementById('mc_mno').style.visibility="visible";
		document.getElementById('mc_mno').style.height="auto";
		document.getElementById('mc_mno').style.position="static";
		document.getElementById('choix_lettres_mno').className="choix_lettres_on";
	}	
	if(letters != 'pqr') {
		document.getElementById('mc_pqr').style.visibility="hidden";
		document.getElementById('mc_pqr').style.height="0px";
		document.getElementById('mc_pqr').style.position="absolute";
		document.getElementById('choix_lettres_pqr').className="choix_lettres";
	} else {
		document.getElementById('mc_pqr').style.visibility="visible";
		document.getElementById('mc_pqr').style.height="auto";
		document.getElementById('mc_pqr').style.position="static";
		document.getElementById('choix_lettres_pqr').className="choix_lettres_on";
	}	
	if(letters != 'stu') {
		document.getElementById('mc_stu').style.visibility="hidden";
		document.getElementById('mc_stu').style.height="0px";
		document.getElementById('mc_stu').style.position="absolute";
		document.getElementById('choix_lettres_stu').className="choix_lettres";
	} else {
		document.getElementById('mc_stu').style.visibility="visible";
		document.getElementById('mc_stu').style.height="auto";
		document.getElementById('mc_stu').style.position="static";
		document.getElementById('choix_lettres_stu').className="choix_lettres_on";
	}	
	if(letters != 'vwxyz') {
		document.getElementById('mc_vwxyz').style.visibility="hidden";
		document.getElementById('mc_vwxyz').style.height="0px";
		document.getElementById('mc_vwxyz').style.position="absolute";
		document.getElementById('choix_lettres_vwxyz').className="choix_lettres_last";
	} else {
		document.getElementById('mc_vwxyz').style.visibility="visible";
		document.getElementById('mc_vwxyz').style.height="auto";
		document.getElementById('mc_vwxyz').style.position="static";
		document.getElementById('choix_lettres_vwxyz').className="choix_lettres_last_on";
	}
}



function show_letters() {
	document.getElementById('mc_abc').style.visibility="visible";
	document.getElementById('mc_abc').style.height="auto";
	document.getElementById('mc_abc').style.position="static";
	document.getElementById('choix_lettres_abc').className="choix_lettres";
	document.getElementById('mc_def').style.visibility="visible";
	document.getElementById('mc_def').style.height="auto";
	document.getElementById('mc_def').style.position="static";
	document.getElementById('choix_lettres_def').className="choix_lettres";
	document.getElementById('mc_ghi').style.visibility="visible";
	document.getElementById('mc_ghi').style.height="auto";
	document.getElementById('mc_ghi').style.position="static";
	document.getElementById('choix_lettres_ghi').className="choix_lettres";
	document.getElementById('mc_jkl').style.visibility="visible";
	document.getElementById('mc_jkl').style.height="auto";
	document.getElementById('mc_jkl').style.position="static";
	document.getElementById('choix_lettres_jkl').className="choix_lettres";
	document.getElementById('mc_mno').style.visibility="visible";
	document.getElementById('mc_mno').style.height="auto";
	document.getElementById('mc_mno').style.position="static";
	document.getElementById('choix_lettres_mno').className="choix_lettres";
	document.getElementById('mc_pqr').style.visibility="visible";
	document.getElementById('mc_pqr').style.height="auto";
	document.getElementById('mc_pqr').style.position="static";
	document.getElementById('choix_lettres_pqr').className="choix_lettres";
	document.getElementById('mc_stu').style.visibility="visible";
	document.getElementById('mc_stu').style.height="auto";
	document.getElementById('mc_stu').style.position="static";
	document.getElementById('choix_lettres_stu').className="choix_lettres";
	document.getElementById('mc_vwxyz').style.visibility="visible";
	document.getElementById('mc_vwxyz').style.height="auto";
	document.getElementById('mc_vwxyz').style.position="static";
	document.getElementById('choix_lettres_vwxyz').className="choix_lettres_last";
}

function findKw(nbel) {


	var mcsel = -1;
	for(k=0; k<=nbel; k++) {
		if(document.getElementById('mc'+k).className == 'psel') {
			mcsel = k;
		}
	}
		
	document.FormulaireKW.method = "post";
	
	if(parseInt(mcsel) > -1 ) {
		document.FormulaireKW.action = "toutvoir.php?mc="+mcsel;
	} else {
		document.FormulaireKW.action = "toutvoir.php";
	}
	document.FormulaireKW.submit();
}


/**** PAGING ****/


function avance(nb, last, page, max, table, page_url) {
	var next = true;
	
	var first = parseInt(last) + 1;
	
	
	var nextlast = first + parseInt(nb) - 1;
	if (nextlast >= parseInt(max))
		next = false;
	
	var nextpage = parseInt(page) + 1;
	
	var apercus = '';
	var apercutemp;
	
	var newnb = nb;
	if(parseInt(max) < parseInt(nextlast)) {
		newnb = parseInt(max)%parseInt(nb);
		nextlast = max;
	}
	
	var id_temp = last;
	
	var typevp = false;
	
	if(table == '1') {
		media_table_temp = media_pages;
	} else if(table == '2') {
		media_table_temp = media_pages2;
	} else if(table == '3') {
		media_table_temp = media_pages3;
	} else if(table == '4') {
		media_table_temp = media_pages;
		table = '1';
		typevp = true;
	}
	
	if(type_affichage == '4') {
		apercus += '<div class="theme_vis_nav">';
	}
	
	var param_full = "";
	var page_url_nav = page_url;
	if(page_url == "toutvoir_vis_full") {
		page_url = "toutvoir_vis";
		param_full = "&full";
	}
	
	
	for(var k = 0; k < newnb; k++) {
		apercutemp = parseInt(first) + parseInt(k);
		
		if(type_affichage == '1' || type_affichage == '2') {
			apercus += '<div class="zonedesc"><div class="desc-photo"><div class="bloc-photo-120">';
			
			if(media_table_temp[id_temp]['thumb'].lastIndexOf("http") > -1) {	
				if(table == "3") {
					var oImg = new Image();
					oImg.src = media_table_temp[id_temp]['thumb'];
					
					var padtop = "0";
					var padleft = "0";
					
					if(oImg.width != "0") {
						padleft = (120 - parseInt(oImg.width)) / 2;
						padtop = (90 - parseInt(oImg.height)) / 2;
					}
					
					apercus += '<div class="img_120-90"><a href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'"><img src="'+media_table_temp[id_temp]['thumb']+'" style="position:absolute; z-index:10; padding:'+padtop+'px 0px 0px '+padleft+'px;" class="nobord" alt="" /></a></div>';
				} else {
					apercus += '<a href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'"><img src="'+media_table_temp[id_temp]['thumb']+'" width="120" height="90" style="position:absolute; z-index:10;" class="nobord" alt="" /></a>';
				}
			}
			else {
				apercus += '<a href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'"><img src="images/noimg.jpg" width="120" height="90" style="position:absolute; z-index:10;" class="nobord" alt="" /></a>';
			}
			
			var description = media_table_temp[id_temp]['desc'].substring(0, 85);
			description = description.substr(0, (description.lastIndexOf(" ")));
			
			if(description.substr(description.length-1, description.length) == ",") {
				description = description.substr(0, description.length-1);
			}
			
			if(table == '3') {
				apercus += '<img src="images/ico_img.gif" class="lbl_type" alt="" /></div><br />';
				
				apercus += '<p class="p1"><strong><a title="'+media_table_temp[id_temp]['title']+'" href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'">'+ media_table_temp[id_temp]['title'] +'</a></strong> <span class="annee">['+ media_table_temp[id_temp]['year'] +']</span></p>';
				
				apercus += '<a title="'+media_table_temp[id_temp]['title']+'" href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'">'+texte['photo']+'</a></div><p>'+description+'...</p></div>';
			} else {
				apercus += '<img src="images/ico_ex.gif" class="lbl_type" alt="" /></div><br />';
				
				apercus += '<p class="p1"><strong><a title="'+media_table_temp[id_temp]['title']+'" href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'">'+ media_table_temp[id_temp]['title'] +'</a></strong> <span class="annee">['+ media_table_temp[id_temp]['year'] +']</span></p>';
				
				apercus += '<a title="'+media_table_temp[id_temp]['title']+'" href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'">'+texte['excerpt']+' - '+media_table_temp[id_temp]['time']+'</a></div><p>'+description+'...</p></div>';
			}
		
			if((k+1) % 4 == 0) {
				apercus += '<div class="clear"></div>';
			}
 		} else {
 			total_url = "";
 			
 			if(page_url == 'theme_vis') {
 				param = 'id='+id_page+'&mediaid='+media_table_temp[id_temp]['id'];
 				total_url = page_url+'.php?'+param;
 			} else {
 				if(media_table_temp[id_temp]['link'] != "undefined" && media_table_temp[id_temp]['link'] != "" && media_table_temp[id_temp]['link'] != undefined) {
 					total_url = media_table_temp[id_temp]['link']; 					
 				} else {
	 				param = 'mediaid='+media_table_temp[id_temp]['id'];
 					if(param_full != "") {
 						param += param_full;
 					}
 					total_url = page_url+'.php?'+param;
 				}
 			}
 			
			apercus += '<div class="zonedesc"><div class="desc-photo"><div class="bloc-photo-120">';
			
			
			if(media_table_temp[id_temp]['thumb'].lastIndexOf("http") > -1) {	
				if(table == "3") {
					var oImg = new Image();
					oImg.src = media_table_temp[id_temp]['thumb'];
					
					var padtop = "0";
					var padleft = "0";
					
					if(oImg.width != "0") {
						padleft = (120 - parseInt(oImg.width)) / 2;
						padtop = (90 - parseInt(oImg.height)) / 2;
					}
										
					apercus += '<div class="img_120-90"><a href="'+total_url+'"><img src="'+media_table_temp[id_temp]['thumb']+'" style="position:absolute; z-index:10; padding:'+padtop+'px 0px 0px '+padleft+'px;" class="nobord" alt="" /></a></div>';
				} else {
					apercus += '<a href="'+total_url+'"><img src="'+media_table_temp[id_temp]['thumb']+'" width="120" height="90" style="position:absolute; z-index:10;" class="nobord" alt="" /></a>';
				}
			
				
			}
			else {
				apercus += '<a href="'+total_url+'"><img src="images/noimg.jpg" width="120" height="90" style="position:absolute; z-index:10;" class="nobord" alt="" /></a>';
			}
			
			if(table == '3') {
				apercus += '<img src="images/ico_img.gif" class="lbl_type" alt="" /></div><br />';
				apercus += '<a href="'+total_url+'">'+texte['photo']+'</a></div>';
			} else if(page_url == 'toutvoir_vis' && param_full == "&full") { 
				apercus += '<img src="images/ico_ex.gif" class="lbl_type" alt="" /></div><br />';
				apercus += '<a href="'+total_url+'">'+texte['film']+' - '+media_table_temp[id_temp]['time']+'</a></div>';
			} else if(typevp) { 
				apercus += '<img src="images/ico_ex.gif" class="lbl_type" alt="" /></div><br />';
				apercus += '<a href="'+total_url+'">'+media_table_temp[id_temp]['time']+'</a></div>';
			} else {
				apercus += '<img src="images/ico_ex.gif" class="lbl_type" alt="" /></div><br />';
				apercus += '<a href="'+total_url+'">'+texte['excerpt']+' - '+media_table_temp[id_temp]['time']+'</a></div>';
			}
			
			
			
			var description = media_table_temp[id_temp]['desc'].substring(0, 85);
			description = description.substr(0, (description.lastIndexOf(" ")));
			
			if(description.substr(description.length-1, description.length) == ",") {
				description = description.substr(0, description.length-1);
			}
			
			apercus += '<div class="left" style="width:125px;"><p class="p1"><strong><a href="'+total_url+'">';
			
			apercus += media_table_temp[id_temp]['title']+'</a></strong><br /><span class="annee">['+media_table_temp[id_temp]['year']+']</span><br />';
			
			apercus += description+'...</p></div></div>';
			
 			if((k+1) % 2 == 0) {
				apercus += '<div class="clear"></div>';
			}
 		}
		
		id_temp++;
	}
		
	if(table == '3') {
		var codenav = '<div class="nav"><table cellspacing="0" cellpadding="0"><tr><td><a href="#" onclick="recule('+nb+','+first+','+nextpage+','+max+','+table+',\''+page_url_nav+'\'); return false;"><img src="images/fleche_gauche.gif" class="nobord" alt="" /></a></td><td>&nbsp;&nbsp;'+texte['photos']+' '+first+'-'+nextlast+' '+texte['of']+' '+max+'&nbsp;&nbsp;</td><td>';
	} else if(page_url == 'toutvoir_vis' && param_full == "&full") { 
		var codenav = '<div class="nav"><table cellspacing="0" cellpadding="0"><tr><td><a href="#" onclick="recule('+nb+','+first+','+nextpage+','+max+','+table+',\''+page_url_nav+'\'); return false;"><img src="images/fleche_gauche.gif" class="nobord" alt="" /></a></td><td>&nbsp;&nbsp;'+texte['films']+' '+first+'-'+nextlast+' '+texte['of']+' '+max+'&nbsp;&nbsp;</td><td>';
	} else if(typevp) { 
		var codenav = '<div class="nav"><table cellspacing="0" cellpadding="0"><tr><td><a href="#" onclick="recule('+nb+','+first+','+nextpage+','+max+','+table+',\''+page_url_nav+'\'); return false;"><img src="images/fleche_gauche.gif" class="nobord" alt="" /></a></td><td>&nbsp;&nbsp;'+texte['vp']+' '+first+'-'+nextlast+' '+texte['of']+' '+max+'&nbsp;&nbsp;</td><td>';
	} else { 
		var codenav = '<div class="nav"><table cellspacing="0" cellpadding="0"><tr><td><a href="#" onclick="recule('+nb+','+first+','+nextpage+','+max+','+table+',\''+page_url_nav+'\'); return false;"><img src="images/fleche_gauche.gif" class="nobord" alt="" /></a></td><td>&nbsp;&nbsp;'+texte['excerpts']+' '+first+'-'+nextlast+' '+texte['of']+' '+max+'&nbsp;&nbsp;</td><td>';
	}
	
	if(next) {
		codenav += '<a href="#" onclick="avance('+nb+','+nextlast+','+nextpage+','+max+','+table+',\''+page_url_nav+'\'); return false;"><img src="images/fleche_droit.gif" class="nobord" alt="" /></a>';
	}
	else {
		codenav += '<img src="images/fleche_droit_off.gif" class="nobord" alt="" />';
	}
	
	codenav += '</td></tr></table></div>';
	
	var codenav2 = '<div class="nav2">&nbsp;';
	
	var nbpage = '';
	if(parseInt(max)%parseInt(nb) == 0) {
		nbpage = parseInt(max)/parseInt(nb);
	} else {
		nbpage = parseInt(max)/parseInt(nb) + 1;
	}
	
	var templast = '';
	var temppage = '';
	
	for(var m = 1; m < parseInt(nbpage); m++) {
		if(m == nextpage) {
			codenav2 += m;
		} else {
			templast = (parseInt(m) - 1) * nb;
			temppage = parseInt(m) - 1;
			codenav2 += '<a href="#" onclick="avance('+nb+','+templast+','+temppage+','+max+','+table+',\''+page_url_nav+'\'); return false;">'+m+'</a>';
		}
		codenav2 += "&nbsp;|&nbsp;";
	}
	
	if(m == nextpage) {
		codenav2 += m;
	} else {
		templast = (parseInt(m) - 1) * nb;
		temppage = parseInt(m) - 1;
		codenav2 += '<a href="#" onclick="avance('+nb+','+templast+','+temppage+','+max+','+table+',\''+page_url_nav+'\'); return false;">'+m+'</a>';
	}
	
	if(type_affichage == '4') {
		apercus += '</div>';
	}
		
	if(table == '3') {
		document.getElementById('navig'+table).innerHTML = codenav+'<h3>'+texte['photos']+'</h3>'+apercus+'<div class="clear"></div><div class="spacer10"></div>'+codenav2;
	} else {
				
		if(media_table_temp[0]['title_whole'] != "undefined" && media_table_temp[0]['title_whole'] != "" && media_table_temp[0]['title_whole'] != undefined) {
			title_whole = media_table_temp[0]['title_whole']; 					
		} else {
			title_whole = texte['excerpt_nfb'];
		}
		
		if(param_full == "&full") {
			title_whole = texte['whole_film'];
		}
	
		document.getElementById('navig'+table).innerHTML = codenav+'<h3>'+title_whole+'</h3>'+apercus+'<div class="clear"></div><div class="spacer10"></div>'+codenav2;
	}
}


function recule(nb, first, page, max, table, page_url) {

	var previous = true;
	
	var nextfirst = parseInt(first) - parseInt(nb);	
	var nextlast = first - 1;
	
	var nextpage = parseInt(page) - 1;
	if(nextpage <= 1) {
		previous = false;
	}
	
	var apercus = '';
	var apercutemp;
	
	var id_temp = first - nb - 1;
	
	var media_table_temp = "";
	
	var typevp = false;
	
	if(table == '1') {
		media_table_temp = media_pages;
	} else if(table == '2') {
		media_table_temp = media_pages2;
	} else if(table == '3') {
		media_table_temp = media_pages3;
	} else if(table == '4') {
		table = '1';
		typevp = true;
	}
	
	if(type_affichage == '4') {
		apercus += '<div class="theme_vis_nav">';
	}
	
	var param_full = "";
	var page_url_nav = page_url;
	if(page_url == "toutvoir_vis_full") {
		page_url = "toutvoir_vis";
		param_full = "&full";
	}
	
	for(var k = 0; k < nb; k++) {
		apercutemp = parseInt(nextfirst) + parseInt(k);
		if(type_affichage == '1' || type_affichage == '2') {
			apercus += '<div class="zonedesc"><div class="desc-photo"><div class="bloc-photo-120">';
			
			if(media_table_temp[id_temp]['thumb'].lastIndexOf("http") > -1) {	
				if(table == "3") {
					var oImg = new Image();
					oImg.src = media_table_temp[id_temp]['thumb'];
					
					var padtop = "0";
					var padleft = "0";
					
					if(oImg.width != "0") {
						padleft = (120 - parseInt(oImg.width)) / 2;
						padtop = (90 - parseInt(oImg.height)) / 2;
					}
					
					apercus += '<div class="img_120-90"><a href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'"><img src="'+media_table_temp[id_temp]['thumb']+'" style="position:absolute; z-index:10; padding:'+padtop+'px 0px 0px '+padleft+'px;" class="nobord" alt="" /></a></div>';
				} else {
					apercus += '<a href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'"><img src="'+media_table_temp[id_temp]['thumb']+'" width="120" height="90" style="position:absolute; z-index:10;" class="nobord" alt="" /></a>';
				}
			}
			else {
				apercus += '<a href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'"><img src="images/noimg.jpg" width="120" height="90" style="position:absolute; z-index:10;" class="nobord" alt="" /></a>';
			}
			
			var description = media_table_temp[id_temp]['desc'].substring(0, 85);
			description = description.substr(0, (description.lastIndexOf(" ")));
			
			if(description.substr(description.length-1, description.length) == ",") {
				description = description.substr(0, description.length-1);
			}
			
			if(table == '3') {
				apercus += '<img src="images/ico_img.gif" class="lbl_type" alt="" /></div><br />';
				
				apercus += '<p class="p1"><strong><a href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'">'+ media_table_temp[id_temp]['title'] +'</a></strong> <span class="annee">['+ media_table_temp[id_temp]['year'] +']</span></p>';
				
				apercus += '<a href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'">'+texte['photo']+'</a></div><p>'+description+'...</p></div>';
			} else {
				apercus += '<img src="images/ico_ex.gif" class="lbl_type" alt="" /></div><br />';
				
				apercus += '<p class="p1"><strong><a href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'">'+ media_table_temp[id_temp]['title'] +'</a></strong> <span class="annee">['+ media_table_temp[id_temp]['year'] +']</span></p>';
				
				apercus += '<a href="'+page_url+'.php?id='+id_page+'&mediaid='+media_table_temp[id_temp]['id']+'">'+texte['excerpt']+' - '+media_table_temp[id_temp]['time']+'</a></div><p>'+description+'...</p></div>';
			}
			
		
			
			
		
		
			if((k+1) % 4 == 0) {
				apercus += '<div class="clear"></div>';
			}
 		} else {
 			total_url = "";
 			
 			if(page_url == 'theme_vis') {
 				param = 'id='+id_page+'&mediaid='+media_table_temp[id_temp]['id'];
 				total_url = page_url+'.php?'+param;
 			} else {
 				if(media_table_temp[id_temp]['link'] != "undefined" && media_table_temp[id_temp]['link'] != "" && media_table_temp[id_temp]['link'] != undefined) {
 					total_url = media_table_temp[id_temp]['link']; 					
 				} else {
	 				param = 'mediaid='+media_table_temp[id_temp]['id'];
 					if(param_full != "") {
 						param += param_full;
 					}
 					total_url = page_url+'.php?'+param;
 				}
 			}
 			
			apercus += '<div class="zonedesc"><div class="desc-photo"><div class="bloc-photo-120">';
			
			
			if(media_table_temp[id_temp]['thumb'].lastIndexOf("http") > -1) {	
				if(table == "3") {
					var oImg = new Image();
					oImg.src = media_table_temp[id_temp]['thumb'];
					
					var padtop = "0";
					var padleft = "0";
					
					if(oImg.width != "0") {
						padleft = (120 - parseInt(oImg.width)) / 2;
						padtop = (90 - parseInt(oImg.height)) / 2;
					}
					
					apercus += '<div class="img_120-90"><a href="'+total_url+'"><img src="'+media_table_temp[id_temp]['thumb']+'" style="position:absolute; z-index:10; padding:'+padtop+'px 0px 0px '+padleft+'px;" class="nobord" alt="" /></div></a>';
				} else {
					apercus += '<a href="'+total_url+'"><img src="'+media_table_temp[id_temp]['thumb']+'" width="120" height="90" style="position:absolute; z-index:10;" class="nobord" alt="" /></a>';
				}
			}
			else {
				apercus += '<a href="'+total_url+'"><img src="images/noimg.jpg" width="120" height="90" style="position:absolute; z-index:10;" class="nobord" alt="" /></a>';
			}
			
			if(table == '3') {
				apercus += '<img src="images/ico_img.gif" class="lbl_type" alt="" /></div><br />';
				apercus += '<a href="'+total_url+'">'+texte['photo']+'</a></div>';
			} else if(page_url == 'toutvoir_vis' && param_full == "&full") { 
				apercus += '<img src="images/ico_ex.gif" class="lbl_type" alt="" /></div><br />';
				apercus += '<a href="'+total_url+'">'+texte['film']+' - '+media_table_temp[id_temp]['time']+'</a></div>';
			} else if(typevp) { 
				apercus += '<img src="images/ico_ex.gif" class="lbl_type" alt="" /></div><br />';
				apercus += '<a href="'+total_url+'">'+media_table_temp[id_temp]['time']+'</a></div>';
			} else {
				apercus += '<img src="images/ico_ex.gif" class="lbl_type" alt="" /></div><br />';
				apercus += '<a href="'+total_url+'">'+texte['excerpt']+' - '+media_table_temp[id_temp]['time']+'</a></div>';
			}
			
			
			
			var description = media_table_temp[id_temp]['desc'].substring(0, 85);
			description = description.substr(0, (description.lastIndexOf(" ")));
			
			if(description.substr(description.length-1, description.length) == ",") {
				description = description.substr(0, description.length-1);
			}
			
			apercus += '<div class="left" style="width:125px;"><p class="p1"><strong><a href="'+total_url+'">';
			
			apercus += media_table_temp[id_temp]['title']+'</a></strong><br /><span class="annee">['+media_table_temp[id_temp]['year']+']</span><br />';
			
			apercus += description+'...</p></div></div>';
			
 			if((k+1) % 2 == 0) {
				apercus += '<div class="clear"></div>';
			}
 		}
		id_temp++;
	}
	
	var codenav = '<div class="nav"><table cellspacing="0" cellpadding="0"><tr><td>';
	
	if(previous) {
		codenav += '<a href="#" onclick="recule('+nb+','+nextfirst+','+nextpage+','+max+','+table+',\''+page_url_nav+'\'); return false;"><img src="images/fleche_gauche.gif" class="nobord" alt="" /></a>';
	}
	else {
		codenav += '<img src="images/fleche_gauche_off.gif" class="nobord" alt="" />';
	}
	
	if(table == '3') {
		codenav += '</td><td>&nbsp;&nbsp;'+texte['photos']+' '+nextfirst+'-'+nextlast+' '+texte['of']+'&nbsp;'+max+'&nbsp;&nbsp;</td><td><a href="#" onclick="avance('+nb+','+nextlast+','+nextpage+','+max+','+table+',\''+page_url_nav+'\'); return false;"><img src="images/fleche_droit.gif" class="nobord" alt="" /></a></td></tr></table></div>';
	} else if(page_url == 'toutvoir_vis' && param_full == "&full") { 
		codenav += '</td><td>&nbsp;&nbsp;'+texte['films']+' '+nextfirst+'-'+nextlast+' '+texte['of']+'&nbsp;'+max+'&nbsp;&nbsp;</td><td><a href="#" onclick="avance('+nb+','+nextlast+','+nextpage+','+max+','+table+',\''+page_url_nav+'\'); return false;"><img src="images/fleche_droit.gif" class="nobord" alt="" /></a></td></tr></table></div>';
	} else if(typevp) { 
		codenav += '</td><td>&nbsp;&nbsp;'+texte['vp']+' '+nextfirst+'-'+nextlast+' '+texte['of']+'&nbsp;'+max+'&nbsp;&nbsp;</td><td><a href="#" onclick="avance('+nb+','+nextlast+','+nextpage+','+max+','+table+',\''+page_url_nav+'\'); return false;"><img src="images/fleche_droit.gif" class="nobord" alt="" /></a></td></tr></table></div>';
		
	} else {
		codenav += '</td><td>&nbsp;&nbsp;'+texte['excerpts']+' '+nextfirst+'-'+nextlast+' '+texte['of']+'&nbsp;'+max+'&nbsp;&nbsp;</td><td><a href="#" onclick="avance('+nb+','+nextlast+','+nextpage+','+max+','+table+',\''+page_url_nav+'\'); return false;"><img src="images/fleche_droit.gif" class="nobord" alt="" /></a></td></tr></table></div>';
	}
	
	
	var codenav2 = '<div class="nav2">&nbsp;';
	
	var nbpage = '';
	if(parseInt(max)%parseInt(nb) == 0) {
		nbpage = parseInt(max)/parseInt(nb);
	} else {
		nbpage = parseInt(max)/parseInt(nb) + 1;
	}
	
	var templast = '';
	var temppage = '';
	
	for(var m = 1; m < parseInt(nbpage); m++) {
		if(m == nextpage) {
			codenav2 += m;
		} else {
			templast = (parseInt(m) - 1) * nb;
			temppage = parseInt(m) - 1;
			codenav2 += '<a href="#" onclick="avance('+nb+','+templast+','+temppage+','+max+','+table+',\''+page_url_nav+'\'); return false;">'+m+'</a>';
		}
		codenav2 += "&nbsp;|&nbsp;";
	}
	
	if(m == nextpage) {
		codenav2 += m;
	} else {
		templast = (parseInt(m) - 1) * nb;
		temppage = parseInt(m) - 1;
		codenav2 += '<a href="#" onclick="avance('+nb+','+templast+','+temppage+','+max+','+table+',\''+page_url_nav+'\'); return false;">'+m+'</a>';
	}
	
	if(type_affichage == '4') {
		apercus += '</div>';
	}

	if(table == '3') {
		document.getElementById('navig'+table).innerHTML = codenav+'<h3>'+texte['photos']+'</h3>'+apercus+'<div class="clear"></div><div class="spacer10"></div>'+codenav2;
	} else {
		if(media_pages[0]['title_whole'] != "undefined" && media_pages[0]['title_whole'] != "" && media_pages[0]['title_whole'] != undefined) {
			title_whole = media_pages[0]['title_whole']; 					
		} else {
			title_whole = texte['excerpt_nfb'];
		}
		
		if(param_full == "&full") {
			title_whole = texte['whole_film'];
		}
		
	
		document.getElementById('navig'+table).innerHTML = codenav+'<h3>'+title_whole+'</h3>'+apercus+'<div class="clear"></div><div class="spacer10"></div>'+codenav2;
	}

	
}
	
	

function avance_text(page, nb_page) {
	if(!player_open) {
	
		var next = true;
		var next_page = parseInt(page) + 1;
		
		if (next_page >= parseInt(nb_page))
			next = false;
		
	
		
		var codenav = '<div class="nav"><table cellspacing="0" cellpadding="0"><tr><td><a href="#" onclick="recule_text('+next_page+', '+nb_page+'); return false;"><img src="images/fleche_gauche.gif" class="nobord" alt="" /></a></td><td>&nbsp;&nbsp;Page '+next_page+' '+texte['of']+' '+nb_page+'&nbsp;&nbsp;</td><td>';
		
		if(next) {
			codenav += '<a href="#" onclick="avance_text('+next_page+', '+nb_page+'); return false;"><img src="images/fleche_droit.gif" class="nobord" alt="" /></a>';
		}
		else {
			codenav += '<img src="images/fleche_droit_off.gif" class="nobord" alt="" />';
		}
		
		codenav += '</td></tr></table></div>';
		
		document.getElementById('navig1').innerHTML = codenav+'<div class="clear"></div><div class="spacer10"></div><hr />'+text_pages[page]+'<hr /><div class="spacer10"></div>'+codenav;
	}
}



function recule_text(page, nb_page) {
	if(!player_open) {
		var previous = true;
		
		var next_page = parseInt(page) - 1;
		if(next_page <= 1) {
			previous = false;
		}
		
		var codenav = '<div class="nav"><table cellspacing="0" cellpadding="0"><tr><td>';
		
		if(previous) {
			codenav += '<a href="#" onclick="recule_text('+next_page+', '+nb_page+'); return false;"><img src="images/fleche_gauche.gif" class="nobord" alt="" /></a>';
		}
		else {
			codenav += '<img src="images/fleche_gauche_off.gif" class="nobord" alt="" />'
		}
		
		codenav += '</td><td>&nbsp;&nbsp;Page '+next_page+' '+texte['of']+' '+nb_page+'&nbsp;&nbsp;</td><td><a href="#" onclick="avance_text('+next_page+', '+nb_page+'); return false;"><img src="images/fleche_droit.gif" class="nobord" alt="" /></a></td></tr></table></div>';
		
		
		document.getElementById('navig1').innerHTML = codenav+'<div class="clear"></div><div class="spacer10"></div><hr />'+text_pages[next_page-1]+'<hr /><div class="spacer10"></div>'+codenav;
	}
}
	
	
	
	
function findPos(obj) {
	var curtop = 0;
	var curleft = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function verify_player() {
	if(id_open_player != "") {
		document.getElementById(id_open_player).className = 'zonedesc';
		document.getElementById(curr_player).style.visibility = 'hidden';
		id_open_player = "";
	}
}

function switch_class_player(idplayer) {
	document.getElementById(idplayer).className = 'player_ouvert';
}

function open_player(idfilm, nbcol) { 
	player_open = true;


	if(nbcol == '1') {
		leftpos = 290;
	} else {
		leftpos = 157;
	}
	
	var diff_pos = parseInt(document.getElementById('player_ouvert_film0').scrollWidth) - 330;
	
	leftpos = leftpos - diff_pos;
	
	
	if(id_open_player != "") {
		document.getElementById(id_open_player).className = 'zonedesc';
		document.getElementById(curr_player).style.visibility = 'hidden';
		id_open_player = "";
	}
	
	//document.getElementById(idfilm).className = 'zonedesc_on';
	curr_player = 'player_ouvert_'+idfilm;
	
	/*if(parseInt(document.getElementById('col2').scrollHeight) > parseInt(document.getElementById(curr_player).scrollHeight)) {
		document.getElementById(curr_player).style.height = document.getElementById('col2').scrollHeight + 'px';
	}
	else if(parseInt(document.getElementById(curr_player).scrollHeight) > parseInt(document.getElementById('col2').scrollHeight)) {
		document.getElementById('col2').style.height = document.getElementById(curr_player).scrollHeight + 'px';
	}*/

	var pos = findPos(document.getElementById('intbg'));
	var leftfin = parseInt(pos[0]) + parseInt(leftpos);
	var pos = findPos(document.getElementById('col2'));
	var top = pos[1];

	var left = parseInt(pos[0]) - 58;

	document.getElementById(curr_player).style.top = top +'px';
	document.getElementById(curr_player).style.left = left+'px';
	document.getElementById(curr_player).style.visibility = 'visible';

	document.getElementById('ouvrir1').innerHTML = '<table><tr><td><p class="left"><a href="#"  onclick="close_player(\''+idfilm+'\',\''+nbcol+'\');">'+texte['close']+'</a>&nbsp;</p></td><td><a href="#" onclick="close_player(\''+idfilm+'\',\''+nbcol+'\'); return false;"><img src="images/fermer.gif" class="nobord left" alt="fermer" /></a></td></tr></table>';
	
	
	var diff = parseInt(left) - parseInt(leftfin);	
	var newpos = left;
	
	if(timer1) {
		clearTimeout(timer1);
	}
	
	timer1 = setInterval("setnewpos("+left+","+diff+")", 1);
	//timer1 = setInterval("petite()", 1);
	
	id_open_player = idfilm; 
}


function setnewpos(left, diff) {
	counter = parseInt(counter)+15;
	if (parseInt(counter) < parseInt(diff)) {
		newpos = parseInt(left) - parseInt(counter);
		document.getElementById(curr_player).style.left = newpos+'px';
	} else { 
		clearTimeout(timer1); 
		counter = 0;
	}
}

function close_player(idfilm, nbcol) { 
	player_open = false;
	
	if(nbcol == '1') {
		leftpos = 290;
	} else {
		leftpos = 157;
	}

	//document.getElementById(idfilm).className = 'zonedesc';

	var pos = findPos(document.getElementById('intbg'));
	var leftdebut = parseInt(pos[0]) + parseInt(leftpos);
	var pos = findPos(document.getElementById('col2'));
	var left = parseInt(pos[0]) - 58;

	document.getElementById('ouvrir1').innerHTML = '<table><tr><td><p class="left"><a href="#"  onclick="open_player(\''+idfilm+'\',\''+nbcol+'\'); return false;">'+texte['open']+'</a>&nbsp;</p></td><td><a href="#" onclick="open_player(\''+idfilm+'\',\''+nbcol+'\'); return false;"><img src="images/ouvrir.gif" class="nobord left" alt="fermer" /></a></td></tr></table>';
	
	var diff = parseInt(left) - parseInt(leftdebut);	
	var newpos = leftdebut;
	
	timer1 = setInterval("setnewpos_close("+leftdebut+","+diff+")", 1);	
	
	id_open_player = "";
}

function setnewpos_close(left, diff) {
	counter = parseInt(counter)+15;
	if (parseInt(counter) < parseInt(diff)) {
		newpos = parseInt(left) + parseInt(counter);
		document.getElementById(curr_player).style.left = newpos+'px';
	} else { 
		clearTimeout(timer1); 
		counter = 0;
		document.getElementById(curr_player).style.visibility = 'hidden';
	}
}

function fixheight(reference, toadjust, diff) {
	if(parseInt(document.getElementById(reference).scrollHeight) > (parseInt(document.getElementById(toadjust).scrollHeight) + parseInt(diff))) {
		var hauteur = parseInt(document.getElementById(reference).scrollHeight) - parseInt(diff);
		document.getElementById(toadjust).style.height = hauteur + 'px';
	} else {
		var hauteur = parseInt(document.getElementById(toadjust).scrollHeight) + parseInt(diff);
		document.getElementById(reference).style.height = hauteur + 'px';
	}
}


function ControleVide(lg) {
	if(lg == 'fr') {
		if(document.Formulaire.email.value=='')
		{
		alert('Veuillez entrer votre adresse de courriel');
		document.Formulaire.email.focus();}
		
		else if(document.Formulaire.email.value.indexOf("@")==-1)
		{
		alert('Veuillez entrer une adresse de courriel valide');
		document.Formulaire.email.focus();}
		
		else if(document.Formulaire.email.value.indexOf(".")==-1)
		{
		alert('Veuillez entrer une adresse de courriel valide');
		document.Formulaire.email.focus();}
		
		else if(document.Formulaire.nomAmiCourriel.value=='')
		{
		alert('Veuillez entrer le courriel de votre ami');
		document.Formulaire.nomAmiCourriel.focus();}
		
		else if(document.Formulaire.nomAmiCourriel.value.indexOf("@")==-1)
		{
		alert('Veuillez entrer une adresse de courriel valide');
		document.Formulaire.nomAmiCourriel.focus();}
		
		else if(document.Formulaire.nomAmiCourriel.value.indexOf(".")==-1)
		{
		alert('Veuillez entrer une adresse de courriel valide');
		document.Formulaire.nomAmiCourriel.focus();}
		
		else
		{
		document.Formulaire.method = "post";
		document.Formulaire.action = "mail.php";
		document.Formulaire.submit();
		}
	} else {
		if(document.Formulaire.email.value=='')
		{
		alert('Please enter a valid email address');
		document.Formulaire.email.focus();}
		
		else if(document.Formulaire.email.value.indexOf("@")==-1)
		{
		alert('Please enter a valid email address');
		document.Formulaire.email.focus();}
		
		else if(document.Formulaire.email.value.indexOf(".")==-1)
		{
		alert('Please enter a valid email address');
		document.Formulaire.email.focus();}
		
		else if(document.Formulaire.nomAmiCourriel.value=='')
		{
		alert('Please enter your friend\'s email address');
		document.Formulaire.nomAmiCourriel.focus();}
		
		else if(document.Formulaire.nomAmiCourriel.value.indexOf("@")==-1)
		{
		alert('Please enter a valid email address');
		document.Formulaire.nomAmiCourriel.focus();}
		
		else if(document.Formulaire.nomAmiCourriel.value.indexOf(".")==-1)
		{
		alert('Please enter a valid email address');
		document.Formulaire.nomAmiCourriel.focus();}
		
		else
		{
		document.Formulaire.method = "post";
		document.Formulaire.action = "mail.php";
		document.Formulaire.submit();
		}
	}
}

function getIdOpenPlayer() {
	return id_open_player;
}


/*** GROSSISSEMENT DU TEXTE ***/

var globalTitle = "small";

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) {
      	a.disabled = false;
      	
      	var posLastSlash = (document.getElementById('image_txt').src).lastIndexOf('/');
      	var urlImg = (document.getElementById('image_txt').src).substring(0, posLastSlash);
      	
      	if(title == "small") {
      	   	document.getElementById('image_txt').src=urlImg+'/btn_txt.gif';
      	} else if(title == "medium") {
      		document.getElementById('image_txt').src=urlImg+'/btn_txt2.gif';
      	} else {
      		document.getElementById('image_txt').src=urlImg+'/btn_txt3.gif';
      	}
      	
      	globalTitle = title;
      	createCookie("style", title, 365);
	
      }
    }
  }
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function loadStyle() {
	var cookie = readCookie("style");
  	var title = cookie ? cookie : getPreferredStyleSheet();
  	setActiveStyleSheet(title);
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

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

function desactForm(type) {
	if(type == 'theme') {
		if(document.getElementById('select_theme').selectedIndex != 0) {
			document.getElementById('select_contenu').className = 'choixdesac';
			document.getElementById('select_contenu').selectedIndex = 0;
			document.getElementById('select_real').className = 'choixdesac';
			document.getElementById('select_real').selectedIndex = 0;
			document.getElementById('select_film').className = 'choixdesac';
			document.getElementById('select_film').selectedIndex = 0;
		}
		if(document.getElementById('select_theme').selectedIndex == 0) {
			document.getElementById('select_contenu').className = 'choixac';
			document.getElementById('select_real').className = 'choixac';
			document.getElementById('select_film').className = 'choixac';
		}
	}
	else if(type == 'type') {
		if(document.getElementById('select_contenu').selectedIndex != 0) {
			document.getElementById('select_theme').className = 'choixdesac';
			document.getElementById('select_theme').selectedIndex = 0;
			document.getElementById('select_real').className = 'choixdesac';
			document.getElementById('select_real').selectedIndex = 0;
			document.getElementById('select_film').className = 'choixdesac';
			document.getElementById('select_film').selectedIndex = 0;
		}
		if(document.getElementById('select_contenu').selectedIndex == 0) {
			document.getElementById('select_theme').className = 'choixac';
			document.getElementById('select_real').className = 'choixac';
			document.getElementById('select_film').className = 'choixac';
		}
	}
	else if(type == 'real') {
		if(document.getElementById('select_real').selectedIndex != 0) {
			document.getElementById('select_theme').className = 'choixdesac';
			document.getElementById('select_theme').selectedIndex = 0;
			document.getElementById('select_contenu').className = 'choixdesac';
			document.getElementById('select_contenu').selectedIndex = 0;
			document.getElementById('select_film').className = 'choixdesac';
			document.getElementById('select_film').selectedIndex = 0;
		}
		if(document.getElementById('select_real').selectedIndex == 0) {
			document.getElementById('select_theme').className = 'choixac';
			document.getElementById('select_contenu').className = 'choixac';
			document.getElementById('select_film').className = 'choixac';
		}
	}
	else if(type == 'film') {
		if(document.getElementById('select_film').selectedIndex != 0) {
			document.getElementById('select_theme').className = 'choixdesac';
			document.getElementById('select_theme').selectedIndex = 0;
			document.getElementById('select_contenu').className = 'choixdesac';
			document.getElementById('select_contenu').selectedIndex = 0;
			document.getElementById('select_real').className = 'choixdesac';
			document.getElementById('select_real').selectedIndex = 0;
		}
		if(document.getElementById('select_film').selectedIndex == 0) {
			document.getElementById('select_theme').className = 'choixac';
			document.getElementById('select_contenu').className = 'choixac';
			document.getElementById('select_real').className = 'choixac';
		}
	}

}

function fixpostop(ref, toadjust) {
	pos = findPos(document.getElementById(ref));
	pos2 = findPos(document.getElementById('zoneright-lrg'));
	
	posfinal = pos[1] - pos2[1];
	
	document.getElementById(toadjust).style.top = posfinal+"px";
}

