function writePlayerShowreel(source,name,image){
document.write('	<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"\n');
document.write('		width="320"\n');
document.write('		height="196"\n');
document.write('		id="qtPlayer'+name+'"\n');
document.write('		type="video/quicktime"\n');
document.write('		codebase="http://www.apple.com/qtactivex/qtplugin.cab">\n');		
document.write('			<param name="src" value="'+image+'"/>\n');			
document.write('			<param name="href" value="<'+source+'> T<myself> E<autoplay=true scale=aspect>"/>\n');	
document.write('			<param name="qtnext1" value="<'+source+'> T<myself> E<autoplay=true scale=aspect>"/>\n');
document.write('			<param name="qtnext2" value="goto0"/>\n');
document.write('			<param name="target" value="myself"/>\n');		
document.write('			<param name="targetcache" value="true"/>\n');		
document.write('			<param name="qtsrcchokespeed" value="800000"/>\n');
document.write('			<param name="autoplay" value="false" />\n');
document.write('			<param name="controller" value="true" />\n');
document.write('			<param name="bgcolor" value="#000000" />\n');
document.write('			<param name="kioskmode" value="false"/>\n');
document.write('			<param name="scale" value="aspect"/> \n');
document.write('			<param name="cache" value="true"/> \n');
document.write('		<embed\n');
document.write('			width="320"\n');
document.write('			height="196"\n');
document.write('			name="qtPlayer'+name+'"\n');
document.write('			enablejavascript="true"\n');
document.write('			target="myself"\n');
document.write('			targetcache="true"\n');
document.write('			src="'+image+'"\n');
document.write('			qtnext1="<'+source+'> T<myself> E<autoplay=true scale=aspect>"\n');
document.write('			qtnext2="goto0"\n');
document.write('			href="<'+source+'> T<myself> E<autoplay=true scale=aspect>"\n');
document.write('			qtsrcchokespeed="800000"\n');
document.write('			scale="aspect"\n');
document.write('			kioskmode="false"\n');
document.write('			bgcolor="#000000"\n');
document.write('			controller="true"\n');
document.write('			cache="true"\n');
document.write('			type="video/quicktime"\n');
document.write('			autoplay="false"\n');
document.write('			pluginspage="http://www.apple.com/quicktime/download/">\n');
document.write('		</embed>\n');
document.write('	</object>\n');
}


function writePlayerInis(count,locale){
var clips= new Array();
var images= new Array();
if(locale=='fr'){
	clips[0]='http://helix.nfb.ca/archives/INIS/Action_de_grace_final.mp4';
	clips[1]='http://helix.nfb.ca/archives/INIS/Alea_final.mp4';
	clips[2]='http://helix.nfb.ca/archives/INIS/Fin_de_Regne.mp4';
	clips[3]='http://helix.nfb.ca/archives/INIS/Grandir_d_elle.mp4';
	clips[4]='http://helix.nfb.ca/archives/INIS/Hadji_baba.mp4';
	clips[5]='http://helix.nfb.ca/archives/INIS/L_appel.mp4';
	clips[6]='http://helix.nfb.ca/archives/INIS/L_esprit_de_Jack.mp4';
	clips[7]='http://helix.nfb.ca/archives/INIS/Le_depart.mp4';
	clips[8]='http://helix.nfb.ca/archives/INIS/Le_manege_f.mp4';
	clips[9]='http://helix.nfb.ca/archives/INIS/Nous_avions_20_ans.mp4';
	clips[10]='http://helix.nfb.ca/archives/INIS/Ode_a_la_terre.mp4';
	clips[11]='http://helix.nfb.ca/archives/INIS/Profession_de_foi.mp4';
	images[0]='/images/pages/fr/medias/images/Action_de_grace.jpg';
	images[1]='/images/pages/fr/medias/images/Alea.jpg';
	images[2]='/images/pages/fr/medias/images/Fin_de_regne_.jpg';
	images[3]='/images/pages/fr/medias/images/Grandir_d_elle.jpg';
	images[4]='/images/pages/fr/medias/images/Hadji_Baba.jpg';
	images[5]='/images/pages/fr/medias/images/L_appel.jpg';
	images[6]='/images/pages/fr/medias/images/L_esprit_de_Jack.jpg';
	images[7]='/images/pages/fr/medias/images/Le_depart.jpg';
	images[8]='/images/pages/fr/medias/images/Le_manege_f.jpg';
	images[9]='/images/pages/fr/medias/images/Nous_avions_20_ans.jpg';
	images[10]='/images/pages/fr/medias/images/Ode_a_la_terre.jpg';
	images[11]='/images/pages/fr/medias/images/Profession_de_foi.jpg';

}else{
	clips[0]='http://helix.nfb.ca/archives/INIS/Demo_onf.mp4';
	images[0]='/images/pages/fr/medias/images/mere-16-9.jpg';
}
var source=clips[count%clips.length];
var image=images[count%clips.length];

document.write('	<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"\n');
document.write('		width="240"\n');
document.write('		height="196"\n');
document.write('		id="playerINIS"\n');
document.write('		type="video/quicktime"\n');
document.write('		codebase="http://www.apple.com/qtactivex/qtplugin.cab">\n');		
document.write('			<param name="src" value="'+image+'"/>\n');			
document.write('			<param name="href" value="<'+source+'> T<myself> E<autoplay=true scale=aspect>"/>\n');	
document.write('			<param name="qtnext1" value="<'+source+'> T<myself> E<autoplay=true scale=aspect>"/>\n');
document.write('			<param name="qtnext2" value="goto0"/>\n');
document.write('			<param name="target" value="myself"/>\n');		
document.write('			<param name="targetcache" value="true"/>\n');		
document.write('			<param name="qtsrcchokespeed" value="800000"/>\n');
document.write('			<param name="autoplay" value="false" />\n');
document.write('			<param name="controller" value="true" />\n');
document.write('			<param name="bgcolor" value="#000000" />\n');
document.write('			<param name="kioskmode" value="false"/>\n');
document.write('			<param name="scale" value="aspect"/> \n');
document.write('			<param name="cache" value="true"/> \n');
document.write('			<param name="loop" value="false"/> \n');
document.write('		<embed\n');
document.write('			width="240"\n');
document.write('			height="196"\n');
document.write('			name="playerINIS"\n');
document.write('			enablejavascript="true"\n');
document.write('			src="'+image+'"\n');
document.write('			target="myself"\n');
document.write('			targetcache="true"\n');
document.write('			qtnext1="<'+source+'> T<myself> E<autoplay=true scale=aspect>"\n');
document.write('			qtnext2="goto0"\n');
document.write('			href="<'+source+'> T<myself> E<autoplay=true scale=aspect>"\n');
document.write('			qtsrcchokespeed="800000"\n');
document.write('			scale="aspect"\n');
document.write('			kioskmode="false"\n');
document.write('			bgcolor="#000000"\n');
document.write('			controller="true"\n');
document.write('			cache="true"\n');
document.write('			type="video/quicktime"\n');
document.write('			autoplay="false"\n');
document.write('			loop="false"\n');
document.write('			pluginspage="http://www.apple.com/quicktime/download/">\n');
document.write('		</embed>\n');
document.write('	</object>\n');
}

function writePlayer(source,width,height,starttime,endtime,background){
document.write('	<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"\n');
document.write('		width="'+width+'"\n');
document.write('		height="'+height+'"\n');
document.write('		id="qtPlayer"\n');
document.write('		type="video/quicktime"\n');
document.write('		codebase="http://www.apple.com/qtactivex/qtplugin.cab">\n');		
document.write('			<param name="src" value="'+source+'"/>\n');			
document.write('			<param name="qtsrcchokespeed" value="800000"/>\n');
document.write('			<param name="autoplay" value="false" />\n');
document.write('			<param name="controller" value="true" />\n');
document.write('			<param name="bgcolor" value="'+background+'" />\n');
document.write('			<param name="kioskmode" value="false"/>\n');
document.write('			<param name="scale" value="aspect"/> \n');
document.write('			<param name="cache" value="true"/> \n');
if(starttime!='00:00:00:00'){
document.write('			<param name="starttime" value="'+starttime+'"/>\n');
}
if(endtime!='00:00:00:00'){
document.write('			<param name="endtime" value="'+endtime+'"/>\n');
}
document.write('		<embed\n');
document.write('			width="'+width+'"\n');
document.write('			height="'+height+'"\n');
document.write('			name="qtPlayer"\n');
document.write('			enablejavascript="true"\n');
document.write('			src="'+source+'"\n');
document.write('			qtsrcchokespeed="800000"\n');
document.write('			scale="aspect"\n');
document.write('			kioskmode="false"\n');
document.write('			bgcolor="'+background+'"\n');
document.write('			controller="true"\n');
document.write('			cache="true"\n');
document.write('			type="video/quicktime"\n');
document.write('			starttime="'+starttime+'"\n');
document.write('			endtime="'+endtime+'"\n');
document.write('			autoplay="false"\n');
document.write('			pluginspage="http://www.apple.com/quicktime/download/">\n');
document.write('		</embed>\n');
document.write('	</object>\n');
}

function writePlayerHome(source){
document.write('	<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"\n');
document.write('		width="512"\n');
document.write('		height="288"\n');
document.write('		id="qtPlayer"\n');
document.write('		type="video/quicktime"\n');
document.write('		codebase="http://www.apple.com/qtactivex/qtplugin.cab">\n');		
document.write('			<param name="src" value="'+source+'"/>\n');			
document.write('			<param name="qtsrcchokespeed" value="800000"/>\n');
document.write('			<param name="autoplay" value="true" />\n');
document.write('			<param name="controller" value="false" />\n');
document.write('			<param name="bgcolor" value="#000000" />\n');
document.write('			<param name="volume" value="0" />\n');
document.write('			<param name="kioskmode" value="false"/>\n');
document.write('			<param name="scale" value="aspect"/> \n');
document.write('			<param name="cache" value="true"/> \n');
document.write('			<param name="loop" value="true"/> \n');
document.write('		<embed\n');
document.write('			width="512"\n');
document.write('			height="288"\n');
document.write('			name="qtPlayer"\n');
document.write('			enablejavascript="true"\n');
document.write('			src="'+source+'"\n');
document.write('			qtsrcchokespeed="800000"\n');
document.write('			scale="aspect"\n');
document.write('			kioskmode="false"\n');
document.write('			bgcolor="#000000"\n');
document.write('			volume="0"\n');
document.write('			controller="false"\n');
document.write('			cache="true"\n');
document.write('			type="video/quicktime"\n');
document.write('			autoplay="true"\n');
document.write('			loop="true"\n');
document.write('			pluginspage="http://www.apple.com/quicktime/download/">\n');
document.write('		</embed>\n');
document.write('	</object>\n');
}

function writePlayerFull(source,width,height,starttime,endtime){
document.write('	<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"\n');
document.write('		width="'+width+'"\n');
document.write('		height="'+height+'"\n');
document.write('		id="qtPlayerFull"\n');
document.write('		type="video/quicktime"\n');
document.write('		codebase="http://www.apple.com/qtactivex/qtplugin.cab">\n');		
document.write('			<param name="src" value="'+source+'"/>\n');			
document.write('			<param name="qtsrcchokespeed" value="800000"/>\n');
document.write('			<param name="autoplay" value="false" />\n');
document.write('			<param name="controller" value="false" />\n');
document.write('			<param name="bgcolor" value="#D2D2D2" />\n');
document.write('			<param name="kioskmode" value="false"/>\n');
document.write('			<param name="scale" value="aspect"/> \n');
document.write('			<param name="cache" value="true"/> \n');
if(starttime!='00:00:00:00'){
document.write('			<param name="starttime" value="'+starttime+'"/>\n');
}
if(endtime!='00:00:00:00'){
document.write('			<param name="endtime" value="'+endtime+'"/>\n');
}
document.write('		<embed\n');
document.write('			width="'+width+'"\n');
document.write('			height="'+height+'"\n');
document.write('			name="qtPlayerFull"\n');
document.write('			enablejavascript="true"\n');
document.write('			src="'+source+'"\n');
document.write('			qtsrcchokespeed="800000"\n');
document.write('			scale="aspect"\n');
document.write('			kioskmode="false"\n');
document.write('			bgcolor="#D2D2D2"\n');
document.write('			controller="false"\n');
document.write('			cache="true"\n');
document.write('			type="video/quicktime"\n');
document.write('			starttime="'+starttime+'"\n');
document.write('			endtime="'+endtime+'"\n');
document.write('			autoplay="false"\n');
document.write('			pluginspage="http://www.apple.com/quicktime/download/">\n');
document.write('		</embed>\n');
document.write('	</object>\n');
}


function doStop(){
	document.qtPlayer.Stop();
	document.playpausebutton.src='../styles/imgs/btn-ico-play.gif';
	//document.getElementById('playButton').innerHTML='<a href="#" onclick="javascript:doPlay();">Play</a>';
}

function setStartToEnd(insec,outsec){
		var inInt=Math.floor(insec*document.qtPlayer.GetTimeScale());
		var outInt=Math.ceil(outsec*document.qtPlayer.GetTimeScale());
		document.qtPlayer.SetStartTime(inInt);
		document.qtPlayer.SetTime(inInt);
		document.qtPlayer.SetEndTime(outInt);
}

function playStartToEnd(insec,outsec){
	if(document.qtPlayer.GetRate()==0){
		//doPlay
		var inInt=Math.floor(insec*document.qtPlayer.GetTimeScale());
		var outInt=Math.ceil(outsec*document.qtPlayer.GetTimeScale());
		document.qtPlayer.SetStartTime(inInt);
		var currentTime=document.qtPlayer.GetTime();
		if(currentTime<inInt||currentTime>outInt){
			document.qtPlayer.SetTime(inInt);
		}
		document.qtPlayer.SetEndTime(outInt);
		document.qtPlayer.Play();
		document.playpausebutton.src='../styles/imgs/btn-ico-pause.gif';
		//document.getElementById('playButton').innerHTML='<a href="#" onclick="javascript:doStop();">Stop</a>';
	}else{
		//doStop
		document.qtPlayer.Stop();
		document.playpausebutton.src='../styles/imgs/btn-ico-play.gif';
		//document.getElementById('playButton').innerHTML='<a href="#" onclick="javascript:doPlay();">Play</a>';
	}
}

function doPlay(){
	if(document.qtPlayer.GetRate()==0){
		//doPlay
		document.qtPlayer.SetStartTime(0);
		document.qtPlayer.SetEndTime(document.qtPlayer.GetDuration());
		document.qtPlayer.Play();
		document.playpausebutton.src='../styles/imgs/btn-ico-pause.gif';
		//document.getElementById('playButton').innerHTML='<a href="#" onclick="javascript:doStop();">Stop</a>';
	}else{
		//doStop
		document.qtPlayer.Stop();
		document.playpausebutton.src='../styles/imgs/btn-ico-play.gif';
		//document.getElementById('playButton').innerHTML='<a href="#" onclick="javascript:doPlay();">Play</a>';
	}
}
function doPlayFull(){
	if(document.qtPlayerFull.GetRate()==0){
		//doPlay
		document.qtPlayerFull.SetStartTime(0);
		document.qtPlayerFull.SetEndTime(document.qtPlayerFull.GetDuration());
		document.qtPlayerFull.Play();
		document.playpausebuttonFull.src='../styles/imgs/btn-ico-pause.gif';
		//document.getElementById('playButton').innerHTML='<a href="#" onclick="javascript:doStop();">Stop</a>';
	}else{
		//doStop
		document.qtPlayerFull.Stop();
		document.playpausebuttonFull.src='../styles/imgs/btn-ico-play.gif';
		//document.getElementById('playButton').innerHTML='<a href="#" onclick="javascript:doPlay();">Play</a>';
	}
}
function doPlayRate(rate){
	document.qtPlayer.SetStartTime(0);
	document.qtPlayer.SetEndTime(document.qtPlayer.GetDuration());
	document.qtPlayer.SetRate(rate);
	document.playpausebutton.src='../styles/imgs/btn-ico-pause.gif';
	//document.getElementById('playButton').innerHTML='<a href="#" onclick="javascript:doStop();">Stop</a>';
}
function doPlayRateFull(rate){
	document.qtPlayerFull.SetStartTime(0);
	document.qtPlayerFull.SetEndTime(document.qtPlayerFull.GetDuration());
	document.qtPlayerFull.SetRate(rate);
	document.playpausebuttonFull.src='../styles/imgs/btn-ico-pause.gif';
	//document.getElementById('playButton').innerHTML='<a href="#" onclick="javascript:doStop();">Stop</a>';
}
function doPlaySlow(){
	document.qtPlayer.SetStartTime(0);
	document.qtPlayer.SetEndTime(document.qtPlayer.GetDuration());
	document.qtPlayer.SetRate(0.20);
	document.playpausebutton.src='../styles/imgs/btn-ico-pause.gif';
	//document.getElementById('playButton').innerHTML='<a href="#" onclick="javascript:doStop();">Stop</a>';
}
function doPlayFast(){
	document.qtPlayer.SetStartTime(0);
	document.qtPlayer.SetEndTime(document.qtPlayer.GetDuration());
	document.qtPlayer.SetRate(4);
	document.playpausebutton.src='../styles/imgs/btn-ico-pause.gif';
	//document.getElementById('playButton').innerHTML='<a href="#" onclick="javascript:doStop();">Stop</a>';
}
function doStep(nbFrames){
	document.qtPlayer.SetStartTime(0);
	document.qtPlayer.SetEndTime(document.qtPlayer.GetDuration());
	document.qtPlayer.Step(nbFrames);
	document.playpausebutton.src='../styles/imgs/btn-ico-play.gif';
	//document.getElementById('playButton').innerHTML='<a href="#" onclick="javascript:doPlay();">Play</a>';
}
function pushStart(qtPlayer,stockShotEditForm){
var seconds=stockShotEditForm.start.value*qtPlayer.GetTimeScale();
document.qtPlayer.SetStartTime(seconds);
document.qtPlayer.SetTime(seconds);
}
function pushPreviousStart(qtPlayer,stockShotEditForm,previousStart){
var previousStartSeconds=previousStart*qtPlayer.GetTimeScale();
document.qtPlayer.SetStartTime(previousStartSeconds);
document.qtPlayer.SetTime(previousStartSeconds);
document.stockShotEditForm.start.value=previousStart;
}
function pushStop(qtPlayer,stockShotEditForm){
document.qtPlayer.SetEndTime(stockShotEditForm.end.value*qtPlayer.GetTimeScale());
}
function pushPreviousStop(qtPlayer,stockShotEditForm,previousEnd){
var previousEndSeconds=previousEnd*qtPlayer.GetTimeScale();
document.qtPlayer.SetEndTime(previousEndSeconds);
document.stockShotEditForm.end.value=previousEnd;
}

function qt2tc(time,framerate,framerateWeb,tcin,framePullDown,dropframe){
// Obtenir le framein a partir du TimeCodeIn
// convertir le framein en NDF si necessaire
// convertir le framein en framerate de la source (24) si necessaire
// Convertir le temps du QuickTime (de secondes vers frames NDF (vrai framerate))
// Obtenir le nombre total de frames
// Convertir le nombre total de frames en nombre de frames NDF selon le framerate framerateWeb
// Convertir le nombre total de frames NDF en DF si necessaire
// Convertir le nombre total de frames en TimeCode

	var framein=TCtoFrame(tcin,framerateWeb);//30fps

	var framerateApprox=Math.ceil(framerate); //24 if 23.976, 30 if 29.97
	var framerateWebApprox=Math.ceil(framerateWeb); //24 if 23.976, 30 if 29.97

	if(dropframe=='true'){
		//if drop frame, we need to calculate framein for Drop (get HH:00:00:00)
		var hours=Math.floor(framein/framerateWebApprox/3600);			
		var frameStartDrop=hours*framerateWebApprox*3600;		 		
		//CONVERT framein to NDF
		framein=convertToNDF(framein,frameStartDrop);// Non Drop (30fps or 24 fps)
	}
	if(framerateApprox==24&&framerateWebApprox==30){
		//if it is a 24fps in a 30 fps QuickTime, we need to get the framein in 24fps
		secondsIn=Math.floor(framein/framerateWebApprox);

		tcFramesIn=convertFrame30to24(framein,framePullDown);
		framein=secondsIn*framerateApprox+tcFramesIn; //24fps NonDrop

	}	
	
	var frames=Math.round(time*framerate); //convert QuickTime time into number of frames (always NDF, Real Frame Rate)

	var framesTotal=framein+frames;		

	if(framerateApprox==24&&framerateWebApprox==30){
		//if it is a 24fps in a 30 fps QuickTime, we need to convert framesTotal in 30 fps
		seconds=Math.floor(framesTotal/framerateApprox);		

		framesAlone=convertFrame24to30(framesTotal,framePullDown); //convert frame number to 30

		framesTotal=seconds*framerateWebApprox+framesAlone;	//get number total of frames in 30 fps		
	}
	if(dropframe=='true'){		

		//convert framesTotal to DF if needed
		framesTotal=convertToDF(framesTotal,frameStartDrop);	
	}	
	timeCodeConverted=frameToTimeCode(framesTotal,framerateWebApprox);
	return timeCodeConverted;
}

function tc2qt(timecode,framerate,framerateWeb,tcin,framePullDown,dropframe){
//convertir les 2 timecodes en frames
//obtenir le vrai nombre de frames (convertir les 2 timecodes en NDF)
//obtenir la duree en frames
//diviser par nb frames par seconde
//conversion 30 a 24?
	//convert timecodes to frame (30DF)
	var framein=TCtoFrame(tcin,framerateWeb);
	var framecur=TCtoFrame(timecode,framerateWeb);	
	var framerateApprox=Math.ceil(framerate);
	var framerateWebApprox=Math.ceil(framerateWeb);
	if(dropframe=='true'){	
		//convert timecodes to NDF
		hours=Math.floor(framein/framerateWebApprox/3600);
		framehour=hours*3600*framerateWebApprox;//frame number of the hour before (startDrop)	
		framecur=convertToNDF(framecur,framehour);		
		framein=convertToNDF(framein,framehour);
	}	
	var nbFrames=framecur-framein; //Number of frames (30 fps)
	if(framerateApprox==24&&framerateWebApprox==30){
		//get number of frames (24fps) with special 30 to 24 conversion
		var secondsOnly=Math.floor(nbFrames/framerateWebApprox);		
		frameonlycur=convertFrame30to24(nbFrames,framePullDown);
		nbFrames=secondsOnly*framerateApprox+frameonlycur;				
	}		
	//get number of seconds (quicktime)
	var seconds=nbFrames/framerate;
	return seconds;	
}
function tc2qttime(timecode,framerate,framerateWeb,tcin,framePullDown,dropframe){
	//le starttime et le endtime du Quicktime prennent des timecode en 30e de seconde
	var seconds=tc2qt(timecode,framerate,framerateWeb,tcin,framePullDown,dropframe);
	var frames=30*seconds+1;
	var qttime=frameToTimeCode(frames,30);
	return qttime;
}
function convertToDF(frames,frameBegin){
        var framesFromBegin=frames-frameBegin;
        var nbMin=Math.floor(framesFromBegin/1800);
        var nb10Min=Math.floor(nbMin/10);
        var framesTemp=frames+2*nbMin-2*nb10Min;
        //conversion si termine a 0 ou 1 et n'existe pas     
        var isNewMin=framesTemp%1800==0?true:false;
        var isNew10Min=framesTemp%18000==0?true:false;
        var framesAloneTemp=framesTemp%30;
        if(framesAloneTemp<2&&isNewMin&&!isNew10Min){
            framesTemp=framesTemp-framesAloneTemp+2;
        }

        return framesTemp;
}
function convertToNDF(frames,frameBegin){
        var framesFromBegin=frames-frameBegin;
        var nbMin=Math.floor(framesFromBegin/1800);
        var nb10Min=Math.floor(nbMin/10);
        return frames-2*nbMin+2*nb10Min;
}
function frameToTimeCode(frames,fps){
        var tcHour=(Math.floor(frames/(3600*fps))).toString();
        var tcMin=(Math.floor(frames%(3600*fps)/(60*fps))).toString();
        var tcSec=(Math.floor(frames%(60*fps)/fps)).toString();
        var tcFrame=(Math.floor(frames%fps)).toString();
        //ajouter le 0 devant le nombre si plus petit que 10
        if(tcHour.length<2){
            tcHour="0"+tcHour;
        }
        if(tcMin.length<2){
            tcMin="0"+tcMin;
        }
        if(tcSec.length<2){
            tcSec="0"+tcSec;
        }
        if(tcFrame.length<2){
            tcFrame="0"+tcFrame;
        }
        return tcHour+":"+tcMin+":"+tcSec+":"+tcFrame;
    }
function TCtoFrame(tcin,framerate){
	//retourne le nombre de frames (ne fait aucune conversion)
		framerate=Math.ceil(framerate);
	    var frame=0;	    	    
        //obtenir hour min sec dans des strings differents
        timeCodeSplit=tcin.split(":");
        //si le split ne contient qu'un element, sous-entendre que c'est des heures et ajouter min sec frames
        if(timeCodeSplit.length<2){            
            timeCodeSplit=[timeCodeSplit[0],"00","00","00"];
        }
        //si le split ne contient que 2 elements, sous-entendre qu'il manque les secondes et les frames       
        if(timeCodeSplit.length<3){
            
            timeCodeSplit=[timeCodeSplit[0],timeCodeSplit[1],"00","00"];
        }
        //si le split ne contient que 3 elements, sous-entendre qu'il manque les frames       
        if(timeCodeSplit.length<4){            
            timeCodeSplit=[timeCodeSplit[0],timeCodeSplit[1],timeCodeSplit[2],"00"];
        }
        //convertir en frames        
        var tcHour=parseInt(timeCodeSplit[0],10);
        var tcMin=parseInt(timeCodeSplit[1],10);
        var tcSec=parseInt(timeCodeSplit[2],10);
        var tcFrames=parseInt(timeCodeSplit[3],10);              
        frame=tcHour*3600*framerate+tcMin*60*framerate+tcSec*framerate+tcFrames;
        return frame;
}	


	
function convertFrame24to30(frames24,firstFrameToSkip){
	//a optimiser?
	var frames24Only=parseInt(frames24%24);	
	var framesToAdd=0;
	if(frames24Only>=firstFrameToSkip&&frames24Only<firstFrameToSkip+4){
		framesToAdd=1;
	}else if(frames24Only>=firstFrameToSkip+4&&frames24Only<firstFrameToSkip+8){
		framesToAdd=2;
	}else if (frames24Only>=firstFrameToSkip+8&&frames24Only<firstFrameToSkip+12){
		framesToAdd=3;
	}else if (frames24Only>=firstFrameToSkip+12&&frames24Only<firstFrameToSkip+16){
		framesToAdd=4;
	}else if (frames24Only>=firstFrameToSkip+16&&frames24Only<firstFrameToSkip+20){
		framesToAdd=5;
	}else if (frames24Only>=firstFrameToSkip+20){
		framesToAdd=6;
	}
	return frames24Only+framesToAdd;
}

function convertFrame30to24(frames30,firstFrameToSkip){
	//a optimiser?
	var frames30Only=parseInt(frames30%30);		
	var framesToDel=0;
	if(frames30Only>=firstFrameToSkip&&frames30Only<firstFrameToSkip+5){
		framesToDel=1;
	}else if(frames30Only>=firstFrameToSkip+5&&frames30Only<firstFrameToSkip+10){
		framesToDel=2;
	}else if (frames30Only>=firstFrameToSkip+10&&frames30Only<firstFrameToSkip+15){		
		framesToDel=3;
	}else if (frames30Only>=firstFrameToSkip+15&&frames30Only<firstFrameToSkip+20){
		framesToDel=4;
	}else if (frames30Only>=firstFrameToSkip+20&&frames30Only<firstFrameToSkip+25){
		framesToDel=5;
	}else if (frames30Only>=firstFrameToSkip+25){
		framesToDel=6;
	}

	return frames30Only-framesToDel;
}