var secs
var timerID = null
var timerRunning = false
var delay = 1000

var path="http://www.orten.fr/images/exp/"

var textTroncInBed_FR = new Array(3);
var textTronc_FR = new Array(3);
var textLeg_FR = new Array(3);
var textBK_FR = new Array(3);
var textMorph_FR = new Array(3);
var textPreCorrec_FR = new Array(3);
var textSeat_FR = new Array(3);

var textTroncInBed_EN = new Array(3);
var textTronc_EN = new Array(3);
var textLeg_EN = new Array(3);
var textBK_EN = new Array(3);
var textMorph_EN = new Array(3);
var textPreCorrec_EN = new Array(3);
var textSeat_EN = new Array(3);

/* Ce qui s'affiche sous l'image lorsqu'on passe la souris sur le lien */
/*textTroncInBed_FR[0]='La nouvelle version d\'OrtenPIX vous permet désormais de photographier un patient dans n\'importe quelles conditions, y compris dans son lit !'
textTronc_FR[0]='Le logiciel calcule automatiquement une <a href="javascript: LoadExample(\'tronc360.gif\',\'trunk\',4); SetTextRelated2TheImage(\'fr\');">forme 3D</a> qui s\'ajuste  sur la silhouette du patient tracée dans les images. Ce strict respect de la morphologie facilite la conception d\'un corset parfaitement adapté.'
textLeg_FR[0]='L\'acquisition d\'une jambe se fait également très simplement avec 2 images. La <a href="javascript: LoadExample(\'leg360.gif\',\'leg\',4); SetTextRelated2TheImage(\'fr\');">mod&eacute;lisation 3D</a> obtenue peut alors servir à la conception d\'une orthèse. Une autre application est la réalisation d\'une <a href="esthetique.html">mousse esthétique</a> à partir de la jambe saine.'
textBK_FR[0]='L\'utilisation des mires de calibrage garantit une mesure fiable et reproductible à partir des images, indispensable pour la <a href="javascript: LoadExample(\'bk360.gif\',\'bk\',4); SetTextRelated2TheImage(\'fr\');">mod&eacute;lisation 3D</a> d\'un moignon.'
textMorph_FR[0]='Le modèle épouse parfaitement la silhouette du patient.'
textPreCorrec_FR[0]='En agissant directement sur la silhouette du patient, la modélisation 3D est automatiquement modifiée.'

textTroncInBed_EN[0]='The new version of OrtenPIX allows to take pictures of patient in any conditions, included when lying down!'
textTronc_EN[0]='Take two pictures from a patient: frontal and profile. The software finds automatically his silhouette and calculates his 3D modeling.'
textLeg_EN[0]='Take two pictures from a patient\'s leg: frontal and profile. The software finds automatically his silhouette and calculates his 3D modeling.'
textBK_EN[0]='Take two pictures from a patient\'s stump: frontal and profile. The software finds automatically his silhouette and calculates his 3D modeling.'
textMorph_EN[0]='The resulting model fits perfectly the patient\'s contour.'
textPreCorrec_EN[0]='By acting directly on the patient\'s contour, his 3D modeling is automatically modified.'*/

/* Ce qui s'affche sous l'image d'exemple (non 360), lorsque la souris n'est plus sur aucun lien */
textTroncInBed_FR[1]='<span class="ortenpix">OrtenPIX</span> vous permet de photographier un patient dans n\'importe quelles conditions, y compris dans son lit ! Vous bénéficiez ainsi d’une souplesse de travail évidente, autant appréciée par l’orthoprothésiste  que par l’équipe médicale et votre patient.'
textTronc_FR[1]='Le logiciel calcule automatiquement une forme 3D qui s\'ajuste sur la silhouette du patient. <span class="activcurve">ActivCurve</span> acquiert ensuite la véritable topographie de la surface recouverte par le réseau de lignes. Des points de repère quelconques indiqués sur le patient peuvent par ailleurs être enregistrés. Ce strict respect de la morphologie garantit la conception d\'un corset parfaitement adapté.'
textLeg_FR[1]='L\'acquisition d\'une jambe se fait également très simplement avec 2 images. La <a href="javascript: LoadExample(\'leg360.gif\',\'leg\',4); SetTextRelated2TheImage(\'fr\');">mod&eacute;lisation 3D</a> obtenue peut alors servir à la conception d\'une orthèse. Une autre application est la réalisation d\'une mousse esthétique à partir de la jambe saine.'
textBK_FR[1]='La technologie <span class="activcurve">ActivCurve</span> et ses courbes, associées aux mires de calibrage, garantissent une mesure fiable et reproductible, indispensable pour la modélisation 3D d\'un moignon. Tout repère anatomique peut être noté sur le moignon et enregistré dans le but de créer les corrections nécessaires.'
textSeat_FR[1]='<span class="ortenpix">OrtenPIX</span> et <span class="activcurve">ActivCurve</span> simplifient la conception des corsets sièges délicats. Pour obtenir le positif à rectifier, il suffit de tracer des lignes sur le moulage plâtré ou le matelas à dépression et de le prendre en photo.'
/*textMorph_FR[1]='Le modèle épouse parfaitement la silhouette du patient.'
textPreCorrec_FR[1]='En agissant directement sur la silhouette du patient, la modélisation 3D est automatiquement modifiée.'*/

textTroncInBed_EN[1]='<span class="ortenpix">OrtenPIX</span> allows you to "scan" a patient laying down and demanding situations including their own bed. Everyone (patient, CPO and medical staff included) benefit from a quicker, more flexible approach. '
textTronc_EN[1]='<span class="ortenpix">OrtenPIX</span> software calculates a 3D shape which matches the patient\'s contours. <span class="activcurve">ActivCurve</span> acquires the shape\'s surface reconciling the lines drawn on the patient\'s jersey. Anatomical landmarks can be added.  Together, they enable perfect fitting TLSO braces.'
textBK_EN[1]='<span class="activcurve">ActivCurve</span> technology, along with Orten\'s calibration cards lock in all measures and shapes needed for modeling a 3D socket. All anatomical landmark can be singled out for further necessary modification.'
textSeat_EN[1]='<span class="ortenpix">OrtenPIX</span> and  <span class="activcurve">ActivCurve</span> simplify  the conception of delicate seating systems. In order to obtain the positive model to rectify, lines are drawn on the negative model before digital pictures are taken.'
/*textMorph_EN[1]='The resulting shape fits perfectly the patient\'s contour.'
textPreCorrec_EN[1]='By acting directly on the patient\'s contour, his 3D modeling is automatically modified.'*/

/* Ce qui s'affche sous l'image d'exemple (360), lorsque la souris n'est plus sur aucun lien */
textTroncInBed_FR[2]='La nouvelle version d\'OrtenPIX vous permet désormais de <a href="javascript: LoadExample(\'TrunkInBed2.gif\',\'trunk_bed\',4); SetTextRelated2TheImage(\'fr\');">photographier</a> un patient dans n\'importe quelles conditions, y compris dans son lit ! Vous bénéficiez ainsi dans tous les cas d\'une mod&eacute;lisation 3D fidèle.'
textTronc_FR[2]='Le logiciel calcule automatiquement une forme 3D qui s\'ajuste  sur la silhouette du patient tracée dans les <a href="javascript: LoadExample(\'tronc.gif\',\'trunk\',4); SetTextRelated2TheImage(\'fr\');">images</a>. Ce strict respect de la morphologie facilite la conception d\'un corset parfaitement adapté.'
textLeg_FR[2]='L\'acquisition d\'une jambe se fait également très simplement avec 2 <a href="javascript: LoadExample(\'leg.gif\',\'leg\',4); SetTextRelated2TheImage(\'fr\');">images</a>. La mod&eacute;lisation 3D</a> obtenue peut alors servir à la conception d\'une orthèse. Une autre application est la réalisation d\'une mousse esthétique à partir de la jambe saine.'
textBK_FR[2]='L\'utilisation des mires de calibrage garantit une mesure fiable et reproductible à partir des <a href="javascript: LoadExample(\'bk.gif\',\'bk\',4); SetTextRelated2TheImage(\'fr\');">images</a>, indispensable pour la mod&eacute;lisation 3D d\'un moignon.'
/*textMorph_FR[0]='Le modèle épouse parfaitement la silhouette du patient.'
textMorph_FR[2]='Le modèle épouse parfaitement la silhouette du patient.'
textPreCorrec_FR[2]='En agissant directement sur la silhouette du patient, la modélisation 3D est automatiquement modifiée.'*/

textTroncInBed_EN[2]='The new version of OrtenPIX allows to take <a href="javascript: LoadExample(\'TrunkInBed2.gif\',\'trunk_bed\',4); SetTextRelated2TheImage(\'en\');">pictures</a> of patient in any conditions, included when lying down! Simple and reliable 3D modeling is therefore possible in every case.'
textTronc_EN[2]='The software automatically finds a 3D shape which fits the silhouette drawn in the <a href="javascript: LoadExample(\'tronc.gif\',\'trunk\',4); SetTextRelated2TheImage(\'en\');">images</a>. This rigorous respect of morphology ensures well fitted brace.'
textLeg_EN[2]='Leg\'s 3D capture is also done with 2 <a href="javascript: LoadExample(\'leg.gif\',\'leg\',4); SetTextRelated2TheImage(\'en\');">photographs</a>. The 3D file obtained can be used for the design of orthosis. Another application is manufacture of cosmetic cover from the unaffected leg.'
textBK_EN[2]='The use of calibration patterns enables reliable measurements from the <a href="javascript: LoadExample(\'bk.gif\',\'bk\',4); SetTextRelated2TheImage(\'en\');">images</a>, required for 3D modeling of stump.'

/*textMorph_EN[2]='The resulting shape fits perfectly the patient\'s contour.'
textPreCorrec_EN[2]='By acting directly on the patient\'s contour, his 3D modeling is automatically modified.'*/


function InitializeTimer(name,time)
{	
	// Set the length of the timer, in seconds
	secs = time;
	StopTheClock();
	if(name=='leg')
		StartTheTimer4Leg();
	else if(name=='tronc')
		StartTheTimer4Trunk();
}


function StopTheClock()
{
	if(timerRunning)
	clearTimeout(timerID)
	timerRunning = false
}


function StartTheTimer4Trunk()
{
	if (secs==0)
	{
		StopTheClock();
		//on force le raffichage
		im_elt=document.getElementById('exp');
		if(im_elt.src==(path+'tronc.gif'))
			im_elt.src='../images/exps/tronc360.gif';
	}
	else
	{
		self.status = secs
		secs = secs - 1
		timerRunning = true
		timerID = self.setTimeout("StartTheTimer4Trunk()", delay)
	}
}


function StartTheTimer4Leg()
{
	if (secs==0)
	{
		StopTheClock();
		//on force le raffichage
		im_elt=document.getElementById('exp');
		if(im_elt.src==(path+'leg.gif'))
			im_elt.src='../images/exps/leg360.gif';
	}
	else
	{
		self.status = secs
		secs = secs - 1
		timerRunning = true
		timerID = self.setTimeout("StartTheTimer4Leg()", delay)
	}
}


function LoadExample(name, cell, nbExps)
{
	im_elt=document.getElementById('exp');
	im_elt.src='../images/exps/'+name;
	tab_elt = document.getElementById('tabExps');
	for(i=0; i<nbExps; i++)
	{
		tab_elt.rows[0].cells[i].bgColor="#B0B0C0";
	}
	document.getElementById(cell).bgColor="#f8f8ff";
}


function SetTextArea(lang,type)
{
	text_elt=document.getElementById('myTable').rows[1].cells[1];
	if(type=="trunk")
	{
		if(lang=="fr")
			text_elt.innerHTML=textTronc_FR[0];
		else
			text_elt.innerHTML=textTronc_EN[0];
	}
	else if (type=="trunk_bed")
	{
        	if(lang=="fr")
			text_elt.innerHTML=textTroncInBed_FR[0];
		else
			text_elt.innerHTML=textTroncInBed_EN[0];
	}
	else if(type=="leg")
	{
		if(lang=="fr")
			text_elt.innerHTML=textLeg_FR[0];
		else
			text_elt.innerHTML=textLeg_EN[0];
	}
	else if(type=="bk")
	{
		if(lang=="fr")
			text_elt.innerHTML=textBK_FR[0];
		else
			text_elt.innerHTML=textBK_EN[0];
	}
	else if(type=="morph")
	{
		if(lang=="fr")
			text_elt.innerHTML=textMorph_FR[0];
		else
			text_elt.innerHTML=textMorph_EN[0];
	}
	else if(type=="precorrec")
	{
		if(lang=="fr")
			text_elt.innerHTML=textPreCorrec_FR[0];
		else
			text_elt.innerHTML=textPreCorrec_EN[0];
	}
	else
		text_elt.innerHTML="";
}


function SetTextRelated2TheImage(lang)
{
	im_elt=document.getElementById('exp');
	text_elt=document.getElementById('myTable').rows[1].cells[1];
	
	index1 = im_elt.src.lastIndexOf("/") + 1;
	index2 = im_elt.src.length;
	im_file = im_elt.src.substring(index1, index2);
	
	if(  im_file == 'leg.gif')
	{
  		if(lang=="fr")
			text_elt.innerHTML=textLeg_FR[1];
		else
			text_elt.innerHTML=textLeg_EN[1];
	}
	else if(  im_file == 'leg360.gif' )
	{
	        if(lang=="fr")
			text_elt.innerHTML=textLeg_FR[2];
		else
			text_elt.innerHTML=textLeg_EN[2];
	}
	else if( im_file == 'tronc.gif' )
	{
  		if(lang=="fr")
			text_elt.innerHTML=textTronc_FR[1];
		else
			text_elt.innerHTML=textTronc_EN[1];
	}
	else if( im_file == 'tronc360.gif' )
	{
	   if(lang=="fr")
			text_elt.innerHTML=textTronc_FR[2];
		else
			text_elt.innerHTML=textTronc_EN[2];
	}
	else if( im_file ==  'TrunkInBed2.gif')
	{
  		if(lang=="fr")
			text_elt.innerHTML=textTroncInBed_FR[1];
		else
			text_elt.innerHTML=textTroncInBed_EN[1];
	}
	else if( im_file == 'TrunkInBed2360.gif' )
	{
	         if(lang=="fr")
			text_elt.innerHTML=textTroncInBed_FR[2];
		else
			text_elt.innerHTML=textTroncInBed_EN[2];
	}
	else if( im_file ==  'bk.gif' )
	{
  		if(lang=="fr")
			text_elt.innerHTML=textBK_FR[1];
		else
			text_elt.innerHTML=textBK_EN[1];
	}
	else if( im_file ==  'bk360.gif' )
	{
	         if(lang=="fr")
			text_elt.innerHTML=textBK_FR[2];
		else
			text_elt.innerHTML=textBK_EN[2];
	}
	else if( im_file == 'morpho.gif' )
	{
  		if(lang=="fr")
			text_elt.innerHTML=textMorph_FR[1];
		else
			text_elt.innerHTML=textMorph_EN[1];
	}
	else if( im_file == 'precorrec.gif' )
	{
  		if(lang=="fr")
			text_elt.innerHTML=textPreCorrec_FR[1];
		else
			text_elt.innerHTML=textPreCorrec_EN[1];
	}
	else
		SetTextArea(lang,'');
}

function SetTextRelated2TheVideo(video, lang)
{
	im_elt=document.getElementById('exp');
	text_elt=document.getElementById('myTable').rows[1].cells[1];
	
	if(  video == 'seat')
	{
  		if(lang=="fr")
			text_elt.innerHTML=textSeat_FR[1];
		else
			text_elt.innerHTML=textSeat_EN[1];
	}
	else if( video == 'trunk' )
	{
  		if(lang=="fr")
			text_elt.innerHTML=textTronc_FR[1];
		else
			text_elt.innerHTML=textTronc_EN[1];
	}
	else if( video ==  'trunk_bed')
	{
  		if(lang=="fr")
			text_elt.innerHTML=textTroncInBed_FR[1];
		else
			text_elt.innerHTML=textTroncInBed_EN[1];
	}
	else if( video ==  'bk' )
	{
  		if(lang=="fr")
			text_elt.innerHTML=textBK_FR[1];
		else
			text_elt.innerHTML=textBK_EN[1];
	}
	else
		SetTextArea(lang,'');
}

function InsertVideo(file, id, size_x, size_y)
{
	var elt_id = document.getElementById(id);
	
	if(file != "")
	{
		elt_id.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+
			'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"'+
			'width="'+size_x+'" height="'+size_y+'" id="'+ file +'" align="">'+
			'<param name=movie value="../images/'+ file +'">'+
			'<param name=quality value=high>'+
			'<param name=bgcolor value=#ffffff>'+
			'<param name="loop" value="true">'+
			'<embed src="../images/'+ file +'" quality=high bgcolor=#137 width="'+size_x+'" height="'+size_y+'" name="'+ file +'" align="" 	type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">'+
			'</embed>'+
			'</object>';
	}
	else
	{
 		elt_app.innerHTML = "";
 	}
}

function LoadVideo(file, size_x, size_y, cell, nbExps)
{
	InsertVideo(file, 'app', size_x, size_y);
	
	tab_elt = document.getElementById('tabExps');
	for(i=0; i<nbExps; i++)
	{
		tab_elt.rows[0].cells[i].bgColor="#B0B0C0";
	}
	document.getElementById(cell).bgColor="#f8f8ff";
 }
 
 
function LoadAppercu(elt, file)
{
	var elt_app = document.getElementById(elt);
	if(file != "")
	{
		elt_app.innerHTML = "<img height=\"400px\" width=\"310px\" src=\"../images/"+file+"\"></img>";
	}
	else
	{
		elt_app.innerHTML = "";
	}
}

