/*
This Javascript file manages the rotation of the phone pictures on the right side.
It is called by "common.php".
*/


var pictures_speed = 18000// the pictures' rotation speed
var j; // "j" will be equal to the number of pictures.
var b; // "b" will be between 0 and "j-1"
var imgPath_pictures = new Array(); // to stock the phone picture's files, under "/pictures"
var text_pictures = new Array(); // to stock the compulsory information joined to the pictures
var link_pictures = new Array(); // to stock the addresses reached by clicking on the information texts
var version_pictures = navigator.appVersion.substring(0,1);


// The function opens the page according to the value of the address "link_pictures[b]".
function pic_description(x) {
	if (link_pictures[x]!="")
		window.open(link_pictures[x], "popup7", "width=640,top=40,left=40,scrollbars=yes,resizable=yes");
}


function randomInt_pictures(mini, maxi)
	{
		var nb = mini + (maxi+1-mini)*Math.random();
		return Math.floor(nb);
	}


function StartAnim_pictures(b, j)
	{
		if (version_pictures >= 3)	{ // If the version of the browser is recent, we will lauch the turns
			// The id "pic" is very important. It will allow to change the content of the <div> tag.
			document.write(			
			"<div id='pic' style='text-align: center; height: 160px;'>" + 
				"<a class='links' href='mobile_phone_quiz.php' alt='mobile phone quiz'>" + 
					"<img src='" + imgPath_pictures[b] + "' border=0/>" + 
				"</a>" + 
				"<div id='prop'>" + 
					"<span class='links' onclick=pic_description(" + b + ")>" + text_pictures[b] + "</span>" + 
				"</div>" +	
			"</div>"	
			);
			defil_pictures(j); // We lauch the turns.					
		}
		else	{
			document.write(			
			"<div id='pic' style='text-align: center; height: 160px;'>" + 
				"<a class='links' href='mobile_phone_quiz.php' alt='mobile phone quiz'>" + 
					"<img src='" + imgPath_pictures[b] + "' border=0/>" + 
				"</a>" + 
				"<div id='prop'>" + 
					"<span class='links' onclick=pic_description(" + b + ")>" + text_pictures[b] + "</span>" + 
				"</div>" +	
			"</div>"
			);
		}
	}


function defil_pictures(j)
	{
		if (b == j)	{
			b = 0;
		}
		if (version_pictures >= 3)	{
			// We change the content of the tag whose id is "pic".
			// Automatically, it will change the picture and the corresponding information...
			document.getElementById('pic').innerHTML = 
			"<a class='links' href='mobile_phone_quiz.php' alt='mobile phone quiz'>" + 
				"<img src='" + imgPath_pictures[b] + "' border=0/>" + 
			"</a>" + 
			"<div id='prop'>" + 
				"<span class='links' onclick=pic_description(" + b + ")>" + text_pictures[b] + "</span>" + 
			"</div>";
			tempo3_pictures = setTimeout("defil_pictures(j)", pictures_speed);
			b++;
		}
	}
