Array.prototype.contient = function(valeur) {
	for (var i in this) {
		if (this[i] == valeur)
			return true;
	}
	return false;
}

function popupConfirm(message, url_yes, url_no) {
	var agree = confirm(message);
	if (agree)
		document.location = url_yes;
	else
		if (url_no.length != 0)
			document.location = url_no;
}

function vide() {
	return ;
}

var photoWindow;
function showPhoto(id, width, height){
	if (photoWindow)
		photoWindow.close();
	photoWindow = window.open('photoWindow.php?id='+id, 'photoWindow', 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,fullscreen=no,channelmode=no,width='+width+',height='+height+',top=200,left=300');
}

var popup_win;
function popup(url) {
	if (popup_win)
		popup_win.close();
	popup_win = window.open(url);
	return false;
}

function validSelectGenre(liste) {
	NbCol1 = document.getElementById("selectGenre").options.length;
	for(a=0; a<NbCol1; a++){
		document.getElementById("selectGenre").options[a].selected = true;
	}
	document.getElementById("selectGenre").name = "selectGenre[]";
	document.forms[liste].submit();
}

function validSelectHome(liste) {
	NbCol1 = document.getElementById("selectAffiche").options.length;
	for(a=0; a<NbCol1; a++){
		document.getElementById("selectAffiche").options[a].selected = true;
	}
	NbCol1 = document.getElementById("selectFALaUne").options.length;
	for(a=0; a<NbCol1; a++){
		document.getElementById("selectFALaUne").options[a].selected = true;
	}
	NbCol1 = document.getElementById("selectVALaUne").options.length;
	for(a=0; a<NbCol1; a++){
		document.getElementById("selectVALaUne").options[a].selected = true;
	}
	document.getElementById("selectAffiche").name = "selectAffiche[]";
	document.getElementById("selectFALaUne").name = "selectFALaUne[]";
	document.getElementById("selectVALaUne").name = "selectVALaUne[]";
	document.forms[liste].submit();
}

function move(start, to) {
	var begin = document.getElementById(start);
	var end = document.getElementById(to);
	for (i=0; i < begin.length ; i++) {
		if (begin.options[i].selected && begin.options[i] != "" ) {
			new_element = new Option(begin.options[i].text,begin.options[i].value);
			end.options[end.options.length] = new_element;
			begin.options[i] = null;
			i = i -1 ;
		}
	}
}

function moveAll(start, to)
{
	var begin = document.getElementById(start);
	var end = document.getElementById(to);
	for (i=0; i < begin.length ; i++)
	{
		new_element = new Option(begin.options[i].text,begin.options[i].value);
		end.options[end.options.length] = new_element;
		begin.options[i] = null;
		i = i -1 ;
	}
}

function menuswitch(select, way) {
	var menu = document.getElementById(select);
	var menumax = menu.length -2;
	var menusel = menu.selectedIndex;
	if ((menusel < 0) || (menusel < 1 && way == -1) || (menusel > menumax && way == 1))
		return false;
	tmpopt = new Option( menu.options[menusel+way].text, menu.options[menusel+way].value );
	menu.options[menusel+way].text = menu.options[menusel].text;
	menu.options[menusel+way].value = menu.options[menusel].value;
	menu.options[menusel+way].selected = true;
	menu.options[menusel].text = tmpopt.text;
	menu.options[menusel].value = tmpopt.value;
	menu.options[menusel].selected = false;
	return true;
}

function openFrame(container, bt) {
	containerFr = document.getElementById(container+'_fr___Frame');
	containerEn = document.getElementById(container+'_en___Frame');
	bt = document.getElementsByName(bt);
	if (containerFr.height == 150) {
		bt[0].value = 'Reduire';
		containerFr.height = 500;
	} else if (containerFr.height == 500) {
		bt[0].value = 'Agrandir';
		containerFr.height = 150;
	}
	if (containerEn.height == 150) {
		bt[1].value = 'Reduire';
		containerEn.height = 500;
	} else if (containerEn.height == 500) {
		bt[1].value = 'Agrandir';
		containerEn.height = 150;
	}
}

function showVideo(id) {
	new Ajax.Updater($('ajaxVideo'), 'video.php?id='+id);
}

function loadDailymotion(id) {
	var s1 = new SWFObject('http://www.dailymotion.com/swf/' + id + '',"mediaplayer","420","249","7");
	s1.addParam("allowfullscreen","true");
	s1.addVariable("width","420");
	s1.addVariable("height","249");
	s1.addVariable("file",'http://www.dailymotion.com/swf/' + id + '');
	s1.write("ajaxVideo");
}

function loadDailymotion2(id) {
	var html = '';
	html += '<object width="420" height="249">';
	html += '	<param name="movie" value="http://www.dailymotion.com/swf/' + id + '"></param>';
	html += '	<param name="allowFullScreen" value="true"></param>';
	html += '	<param name="allowScriptAccess" value="always"></param>';
	html += '	<embed src="http://www.dailymotion.com/swf/' + id + '" type="application/x-shockwave-flash" width="420" height="249" allowFullScreen="true" allowScriptAccess="always"></embed>';
	html += '</object>';

	$('ajaxVideo').innerHTML = html;
}

function updateBorder() {
	var videoHeight = $('filmVideoBorder').offsetHeight;
	var ajaxHeight = $('ajaxVideo').offsetHeight;
	$('filmVideoBorder').style.height = ajaxHeight+'px';
}

function updateDivBorder (left, right, color) {
	var left = $(left);
	var right = $(right);
	var H1 = left.offsetHeight;
	var H2 = right.offsetHeight;
	if (H1>H2) {
		left.style.borderRight = "solid 1px #"+color;
	} else if(H1<H2) {
		right.style.borderLeft = "solid 1px #"+color;
	}
}

function updateDivBorderHome () {
	var content = $('content');
	var leftPanel = $('leftPanel');
	var leftPanelBorder = $('leftPanelBorder');
	if (content.offsetHeight > leftPanel.offsetHeight)
		leftPanelBorder.style.height = content.offsetHeight+'px';
	leftPanelBorder.style.borderRight = "solid 1px #000000";
}

function updateSearch(numPage){
	var search = $F('search');
	var table = $F('table');
	$('all').selectedIndex = 0;
	if (numPage != '')
		_pp = numPage;
	else
		_pp = 0;
	new Ajax.Updater($('resultSearch'), 'searchResult.php?search='+search+'&table='+table+'&__p='+_pp);
}

function updateAllSearch(numPage){
	$('search').value = '';
	$('table').selectedIndex = 0;
	var all = $F('all');
	if (numPage != '')
		_pp = numPage;
	else
		_pp = 0;
	new Ajax.Updater($('resultSearch'), 'searchResult.php?all='+all+'&__p='+_pp);
}

function updateHeadlines(numPage){
	if (numPage != '')
		_pp = numPage;
	else
		_pp = 0;
	new Ajax.Updater($('headLines'), 'headLines.php?__p='+_pp);
}
