
	function rightPanel (videoObject,IDs,params) {
		this.init(videoObject,IDs,params); }

	rightPanel.prototype.init = function (videoObject,IDs,params) {
	 		this.messages=new Array();
	 		this.video=videoObject;
	 		this.IDs=IDs;
	 		this.selectedRow='';
	 		this.videoLength=0;
	 		this._hasChanged=false;
	 		this.mySelect=document.getElementById('selectFolder');
	 		this.messages['titreDefaut']='No title';
	 		this.formName='form1';
	 		this.mode='extrait';
	 		this.defaultTCIN='00:00:00:00';
	 		this.displayBar=true;
	 		this.selectAllButton=true;
	 		this.addButton=true;
	 		this.TCButton=true;
	 		this.playButton=false;
	 		this.selectButton=false;
	 		this.removeAllButton=false;
	 		this.language='fr';
	 		this.content_id_lang='fr';
	 		this.toggleAllDeleted=false;
	 		this.xslForm='';

			this.page=1;
			this.nbLignes=10;

			tooltips_fr				= {
				'rp_select_movie' 				: 'SÃ©lectionner le film entier',
				'rp_add_new'					: 'Ajouter une ligne',
				'rp_set_tcin'					: 'Utiliser la position comme dÃ©but',
				'rp_set_tcout'					: 'Utiliser la position comme fin',
				'rp_save'						: 'Sauver les changements',
				'rp_select_document'			: 'SÃ©lectionner un document Ã  ajouter',
				'rp_play_video'					: 'Voir la vidÃ©o',
				'rp_capture_image'				: 'Capturer une image',
				'rp_loose_changes'				: 'Abandonner les modifications ?',
				'rp_remove_all'					: 'Supprimer/Restaurer tout'
			}

			tooltips_en				= {
				'rp_select_movie' 				: 'Select whole movie',
				'rp_add_new'					: 'Add a new line',
				'rp_set_tcin'					: 'Use current position for start',
				'rp_set_tcout'					: 'Use current position for end',
				'rp_save'						: 'Save changes',
				'rp_select_document'			: 'Select a document to add',
				'rp_play_video'					: 'Watch video',
				'rp_capture_image'				: 'Capture image',
				'rp_loose_changes'				: 'Loose all changes ?',
				'rp_remove_all'					: 'Remove/Recover all'
			}

	 		if (params['videoLength']) 		this.videoLength=params['videoLength'];
	 		if (params['selectPanier']) 	this.mySelect=document.getElementById(params['selectPanier']);

	 		if (params['msgTitreDefaut']) this.messages['titreDefaut']=params['msgTitreDefaut'];
			if (params['formName']) 		this.formName=params['formName'];
			if (params['mode']) 		this.mode=params['mode'];
			if (params['defaultTCIN']) 		this.defaultTCIN=params['defaultTCIN'];
			if (typeof(params['displayBar'])!='undefined') this.displayBar=params['displayBar'];
			if (params['imgDir']) this.imgDir=params['imgDir'];
			if (typeof(params['selectAllButton'])!='undefined') this.selectAllButton=params['selectAllButton'];
			if (typeof(params['addButton'])!='undefined') this.addButton=params['addButton'];
			if (typeof(params['TCButton'])!='undefined') this.TCButton=params['TCButton'];
			if (typeof(params['playButton'])!='undefined') this.playButton=params['playButton'];
			if (typeof(params['selectButton'])!='undefined') this.selectButton=params['selectButton'];
			if (typeof(params['captureButton'])!='undefined') this.captureButton=params['captureButton'];
			if (typeof(params['removeAllButton'])!='undefined') this.removeAllButton=params['removeAllButton'];
			if (params['language']) this.language=params['language'];
            this.content_id_lang=this.language;
			if (params['content_id_lang']) this.content_id_lang=params['language'];
			//update VG 08/09/2010 : ajout de cette ligne, pour éviter que ce soit tout le temps en français
			if (params['nbLignes']) this.nbLignes=params['nbLignes'];
			if (params['xslForm']) this.xslForm=params['xslForm'];
			//if (!document.getElementById('sidecommande')) alert('no sidecommande !');

		if (this.language == 'fr')
			this.tooltips = tooltips_fr;
		else
			this.tooltips = tooltips_en;
	}

	rightPanel.prototype.dspBar = function () {

			if (this.displayBar==true) {

				myBar=document.createElement('div');
				myBar.className='icon_bar';
				myBar.id='icon_bar';

				document.getElementById('sidecommande').appendChild(myBar);

				if (this.selectAllButton) {
				_btn=document.createElement('img');
				_btn.id='barAllMovie';
				_btn.src=this.imgDir+'b_film_entier_petit.gif';
				_btn.title=this.tooltips['rp_select_movie'];
				_btn.alt=this.tooltips['rp_select_movie'];
				myBar.appendChild(_btn);
				//by ld 10/11/08 remplacÃˆ -1 par ''
				_btn.onclick=function () {myPanel.selectExtrait('');}
				}

				if (this.addButton){
				_btn2=document.createElement('img');
				_btn2.id='barNew';
				_btn2.src=this.imgDir+'b_nouv_chap_petit.gif';
				_btn2.title=this.tooltips['rp_add_new'];
				_btn2.alt=this.tooltips['rp_add_new'];
				myBar.appendChild(_btn2);
				_btn2.onclick=function () {myPanel.addExtrait();}
				}

				if (this.TCButton) {
				_btn3=document.createElement('img');
				_btn3.id='barTCIN';
				_btn3.src=this.imgDir+'b_definir_debut_petit.gif';
				_btn3.title=this.tooltips['rp_set_tcin'];
				_btn.alt=this.tooltips['rp_set_tcin'];
				myBar.appendChild(_btn3);
				_btn3.onclick=function () {myPanel.setTC('in');}

				_btn=document.createElement('img');
				_btn.id='barTCOUT';
				_btn.src=this.imgDir+'b_definir_fin_petit.gif';
				_btn.title=this.tooltips['rp_set_tcout'];
				_btn.alt=this.tooltips['rp_set_tcout'];
				myBar.appendChild(_btn);
				_btn.onclick=function () {myPanel.setTC('out');}
				}

				if (this.captureButton) {
				_btn=document.createElement('img');
				_btn.id='barRemoveAll';
				_btn.src=this.imgDir+'b_remove_all_petit.gif';
				_btn.title=this.tooltips['rp_remove_all'];
				_btn.alt=this.tooltips['rp_remove_all'];
				myBar.appendChild(_btn);
				_btn.onclick=function () {javascript:myPanel.removeAll();}
				}

				if (this.captureButton) {
				_btn=document.createElement('img');
				_btn.id='barCapture';
				_btn.src=this.imgDir+'b_capt_img_petit.gif';
				_btn.title=this.tooltips['rp_capture_image'];
				_btn.alt=this.tooltips['rp_capture_image'];
				myBar.appendChild(_btn);
				_btn.onclick=function () {javascript:capturePicture();}
				}

				_btn=document.createElement('img');
				_btn.id='barSave';
				_btn.src=this.imgDir+'b_disquette_petit.gif';
				_btn.title=this.tooltips['rp_save'];
				_btn.alt=this.tooltips['rp_save'];
				myBar.appendChild(_btn);
				_btn.onclick=function () {myPanel.save();}


				if (this.selectButton) {
				_btn=document.createElement('img');
				_btn.id='barSelect';
				_btn.src=this.imgDir+'b_select.gif';
				_btn.title=this.tooltips['rp_select_document'];
				_btn.alt=this.tooltips['rp_select_document'];
				myBar.appendChild(_btn);
				_btn.onclick=function () {javascript:choose(this,'titre_index=Document&id_lang='+this.language+'&valeur=&champ=DOC&rtn=addDoc');}
				}


				if (this.playButton) {
				_btn=document.createElement('img');
				_btn.id='barPlay';
				_btn.src=this.imgDir+'b_play_petit.gif';
				_btn.title=this.tooltips['rp_play_video'];
				_btn.alt=this.tooltips['rp_play_video'];
				myBar.appendChild(_btn);
				_btn.onclick=function () {loadVideo();}
				}

			}
			//if (document.getElementById('iframeSauve')) return;
			if (/msie 6.0/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) { //Special IE6 qui n'accepte pas de setAttribute name
			_fr= document.createElement("<iframe name='iframeSauve'></iframe>");
			} else {
			_fr = document.createElement("iframe");			}
			_fr.src='';
			_fr.id='iframeSauve';
			_fr.name='iframeSauve';
			_fr.style.width='0px';
			_fr.style.height='0px';
			_fr.style.visibility='hidden';
			//_fr.innerHTML='&#160;';
			document.getElementById('sidecommande').appendChild(_fr);

			myBar=document.createElement('div');
			myBar.id='zoneSaisie';
			document.getElementById('sidecommande').appendChild(myBar);
	}


	rightPanel.prototype.getTCOutFromVideo = function () {
		if (this.video) this.videoLength=this.video.GetCurrentSelectionEnd();
	}

	rightPanel.prototype.refreshContent = function () {
		if (this._hasChanged)
			if (!confirm(this.tooltips['rp_loose_changes'])){
				for (var id = 0; id < this.mySelect.options.length; id++)
					if (this.mySelect.options[id].value == idPanier)
						this.mySelect.selectedIndex = id;
				return;
			}
			if (document.getElementById('zoneSaisie')) document.getElementById('zoneSaisie').innerHTML="<center><img src='design/images/wait30trans.gif'></center>";

			if (this.mode=='extrait') {

				if (!this.mySelect) return;
				idPanier=this.mySelect.options[this.mySelect.selectedIndex].value;
				if (this.xslForm=='') this.xslForm='oraoweb_extrait';
				return !sendData('GET','blank.php','xmlhttp=1&urlaction=processPanier&id_panier='+idPanier+'&commande=view&xsl='+this.xslForm+'&items='+this.IDs,'myPanel.getCart');
			}
			if (this.mode=='sequence') {
				if (this.xslForm=='') this.xslForm='oraoweb_sequence';
				return !sendData('GET','blank.php','xmlhttp=1&urlaction=processSequence&id='+this.IDs+'&commande=view&xsl='+this.xslForm,'myPanel.getCart');
			}

			if (this.mode=='materiel') {
				if (this.xslForm=='') this.xslForm='oraoweb_document';
				return !sendData('GET','blank.php','xmlhttp=1&urlaction=processDocument&id='+this.IDs+'&commande=view&xsl='+this.xslForm,'myPanel.getCart');
			}

			if (this.mode.indexOf('storyboard')!=-1) {
				storymode=this.mode.substring(this.mode.indexOf(':')+1);
				if (this.xslForm=='') this.xslForm='oraoweb_storyboard';

				return !sendData('GET','blank.php','xmlhttp=1&urlaction=processStoryboard&id='+this.IDs+'&commande=view&xsl='+this.xslForm+'&from='+storymode+'&page='+this.page+'&nbLignes='+this.nbLignes+'&id_lang='+this.content_id_lang,'myPanel.getCart');
			}

	}

	rightPanel.prototype.getCart = function (xml) {
		document.getElementById('zoneSaisie').innerHTML=xml;
	}

	rightPanel.prototype.resetContent= function () {
		document.getElementById('sidecommande').innerHTML='';
	}

	rightPanel.prototype.hasChanged= function (row) {
		document.getElementById('barSave').src=this.imgDir+'b_disquette_petit_anim.gif';
		row.style.border='1px solid #66FF66';
		this._hasChanged=true;

	}

	rightPanel.prototype.checkLine = function (row) {
		_tcin=getChildById(row,'tcin$');
		_tcout=getChildById(row,'tcout$');
		_titre=getChildById(row,'ext_titre$');

		if (_tcin.value=='' || _tcin.value<this.defaultTCIN ) {
			new Effect.Pulsate(_tcin);_tcin.value=this.defaultTCIN;}
		if (_tcout.value=='' || _tcout.value>this.videoLength || _tcout.value<_tcin.value) {
			new Effect.Pulsate(_tcout);_tcout.value=this.videoLength;}
		if (_titre.value.Trim()=='') {new Effect.Pulsate(_titre);_titre.value=this.messages['titreDefaut'];}
	}

	rightPanel.prototype.save =function () {
		document.getElementById('barSave').src=this.imgDir+'b_disquette_petit.gif';
		this.selectExtrait('');
		
		if(typeof(document.forms[this.formName])!='undefined')
			document.forms[this.formName].submit();
		
		this._hasChanged=false;
	}

	rightPanel.prototype.showResultInParent=function (elt) {
		//GÃ‹re le retour de la sauvegarde depuis l iframe / processPanier
		//Attention, on utilise une astuce pour contourner un bug FF
		//Explications : refreshContent va dÃˆtruire et recrÃˆer l iframe depuis laquelle cette fonction est lancÃˆe
		//Or FF ne permet pas l appel d une fonction (a fortiori AJAX) depuis un object en cours de destruction
		//Donc on effectue un lancement indirect de la fonction via un "faux" timeout

		//alert(elt.innerHTML);
		showAlert(elt.innerHTML,'alertBox','',0,190); //affiche le rÃˆsultat + dÃˆcalage vertical pour afficher sous la vidÃˆo

   		window.setTimeout(function () {myPanel.refreshContent();}, 10); // VP 25/11/11 : ajout 10 millisecondes
	}


	rightPanel.prototype.selectExtrait=function(thisrow) {
		if (this.selectedRow!='' && this.selectedRow==thisrow) { //toggle selected/off
			this.selectExtrait('');
			return;
		}
		this.selectedRow=thisrow;
		alldiv=document.getElementById('zoneSaisie').getElementsByTagName('div');
		for (i=0;i<alldiv.length;i++) { //raz styles
			if (alldiv[i].id.indexOf('row$')==0) alldiv[i].className='row_extrait';
			if (alldiv[i].id.indexOf('handle$')==0)  alldiv[i].className='ext_handler';
		}
		if (thisrow!='') { //highlight sur ligne sÃˆlectionnÃˆe
			_n=getChildById(thisrow,'action$');
			if (!_n || _n.value=='suppr') return; //on n active pas une ligne marquÃˆe pour suppr
			thisrow.className='row_extrait_selected';
			_n=getChildById(thisrow,'handle$')
			if (_n) _n.className='ext_handler_selected';
			_n=getChildById(thisrow,'tcin$');
			if (_n) _tcin=_n.value;
			_n=getChildById(thisrow,'tcout$');
			if (_n) _tcout=_n.value;
			if (this.video) this.video.SetSelection(_tcin,_tcout);
		} else { //rewind au dÃˆbut
			if (this.video) {
				//by ld 10/11/08 : on ne retourne plus au dÃˆbut
				//this.video.GoToBegSelection();
				this.video.UnSetSelection();}

		}
	}

	rightPanel.prototype.addExtrait= function() {

	 	blankDiv=document.getElementById('row$blank');
	 	myNewRow=blankDiv.cloneNode(true);
	 	myNewRow.id='row$cloned'; //chgt id car il ne faut qu'un seul row$blank
	 	//21/10/08 : clone rattachÃˆ au formulaire et non au row$blank.parentNode
	 	document.getElementById(this.formName).appendChild(myNewRow);
	 	myNewRow.style.display='block'; //on rend visible le clone

		// VP 31/08/10 : positionnement tcin et tcout en fct de la sÃ©lection utilisateur
	 	if (this.video) {
			_tcin=this.video.GetCurrentSelectionBeginning();
			_tcout=this.video.GetCurrentSelectionEnd();
			_tc=this.video.GetCurrentLongTimeCode();
			//alert(_tcin + " < "+ _tc +" > "+ _tcout);
			//VP 9/09/10 : ajout test sur this.video.flag_sub_selection_set propriŽtŽ spŽcifique ˆ OraoWeb
			if(_tc < _tcin || _tc >= _tcout || this.video.flag_sub_selection_set!=undefined){
				_tcin=_tc;
				_tcout=(this.videoLength!=0?this.videoLength:'00:00:00:00');
			}
		}else{
			_tcin=this.defaultTCIN;
			_tcout=(this.videoLength!=0?this.videoLength:'00:00:00:00');
		}
	 	//if (this.video) _tcin=this.video.GetCurrentLongTimeCode(); else _tcin=this.defaultTCIN;
		//videoLength est maj par le load video mais parfois il est â€¡ 0 car la video n'est pas chargÃˆe complÃ‹tement
		//if (this.videoLength==0 && this.video) Video ok mais TC out=0 ? on retente de rÃˆcup le tc out
		// VP 12/12/09 : quid de ce TC ?
		//_tcout=(this.videoLength!=0?this.videoLength:TC);
		_n=getChildById(myNewRow,'tcin$');
		if (_n) _n.value=_tcin;
		_n=getChildById(myNewRow,'tcout$');
		if (_n) _n.value=_tcout;
		_n=getChildById(myNewRow,'ext_titre$');
		if (_n) _n.value=this.messages['titreDefaut'];
		this.hasChanged(myNewRow);
	 	if (this.mode.indexOf('storyboard')==-1) this.selectExtrait(myNewRow); //pas de selection auto en mode sb
		 // VP 10/09/09 : Calcul de la durÃ©e
		_n=getChildById(myNewRow,'duration$');
		if (_n){
			_duration=diffTC(_tcout,_tcin);
			_n.value=_duration;
		}
	 	// VP 10/09/09 : Scroll div zoneSaisie
		if (document.getElementById('zoneSaisie')) {
			document.getElementById('zoneSaisie').scrollTop=document.getElementById('zoneSaisie').scrollHeight;
		}
		return myNewRow;
	}

	rightPanel.prototype.removeExtrait = function(row) {

		new Effect.Opacity(row,{from:1,to:0.4,duration:0.3});

		_n=getChildById(row,'trash$');
		if (_n) {
			_n.onclick=function(){myPanel.reactivateRow(row);};
			_n.src=this.imgDir+'button_drop_restore.gif';
		}
		_n=getChildById(row,'action$');
		if (_n) _n.value='suppr';
		this.hasChanged(row);

		if (row==this.selectedRow) {this.selectExtrait('');}

	}
	rightPanel.prototype.removeAll = function() {
		alldiv=document.getElementById('zoneSaisie').getElementsByTagName('div');


		for (idx=0;idx<alldiv.length;idx++) {
			if (alldiv[idx].id=='row$') {
				if (this.toggleAllDeleted) this.reactivateRow(alldiv[idx]); else this.removeExtrait(alldiv[idx]);
			}
		}
		this.toggleAllDeleted=!this.toggleAllDeleted;

		/*
		_n=getChildById(row,'trash$');
		if (_n) {
			_n.onclick=function(){myPanel.reactivateRow(row);};
			_n.src=this.imgDir+'button_drop_restore.gif';
		}
		_n=getChildById(row,'action$');
		if (_n) _n.value='suppr';
		this.hasChanged(row);

		if (row==this.selectedRow) {this.selectExtrait('');}*/

	}


	rightPanel.prototype.reactivateRow=function(row) {

		new Effect.Opacity(row,{from:0.4,to:1,duration:0.3});

		_n=getChildById(row,'trash$');
		if (_n) {
			_n.onclick=function(){myPanel.removeExtrait(row);};
			_n.src=this.imgDir+'button_drop.gif';
		}
		_n=getChildById(row,'action$');
		if (_n) _n.value='edit';
	}

	rightPanel.prototype.positionCursor=function(tc) {
		if (!tc || !this.video) return;
			//t = this.video.LongTimeCodeToQTTime(tc);
			//this.video.theVideo.SetTime(t);
			this.video.GoToLongTimeCode(tc);
	}

	rightPanel.prototype.setTC=function (inout) {
		if (typeof(this.selectedRow)=='undefined' || this.selectedRow=='') return;
		if (this.video)
		{
			//by ld 03 12 08 : on stoppe la video quand on place un tcout
			if (inout=='out') this.video.StopTheVideo();
			TC=this.video.GetCurrentLongTimeCode();

			// VP 31/08/10 : ajout contrÃ´le des bornes
			_tcin=this.video.GetCurrentSelectionBeginning();
			_tcout=this.video.GetCurrentSelectionEnd();
			if(inout=='out' && TC<_tcin) inout='in';
			else if(inout=='in' && TC>_tcout) inout='out';

			_n=getChildById(this.selectedRow,'tc'+inout+'$');
			if (_n) _n.value=TC;

		}
		this.hasChanged(this.selectedRow);

		_n=getChildById(this.selectedRow,'tcin$');
		if (_n) _tcin=_n.value;
		_n=getChildById(this.selectedRow,'tcout$');
		if (_n) _tcout=_n.value;
		if(_tcin > _tcout){
			_tc=_tcin;
			_tcin=_tcout;
			_tcout=_tc;
			_n=getChildById(this.selectedRow,'tcin$');
			if (_n) _n.value=_tcin;
			_n=getChildById(this.selectedRow,'tcout$');
			if (_n) _n.value=_tcout;
		}
		_n=getChildById(this.selectedRow,'duration$');
		if (_n){
			_duration=diffTC(_tcout,_tcin);
			_n.value=_duration;
		}

		if (this.video) this.video.SetSelection(_tcin,_tcout);
	}


	rightPanel.prototype.updateSelection=function () {
		if (typeof(this.selectedRow)=='undefined' || this.selectedRow=='') return;
		if (this.video)
		{
			_tcin=this.video.GetCurrentSelectionBeginning();
			_tcout=this.video.GetCurrentSelectionEnd();
			_n=getChildById(this.selectedRow,'tcin$');
			if (_n) _n.value=_tcin;
			_n=getChildById(this.selectedRow,'tcout$');
			if (_n) _n.value=_tcout;
			this.hasChanged(this.selectedRow);
			_n=getChildById(this.selectedRow,'duration$');
			if (_n){
				_duration=diffTC(_tcout,_tcin);
				_n.value=_duration;
			}
		}
	}

	rightPanel.prototype.debug=function () {

	}




