<!--//
//
// Détermination du navigateur
//
var agt			= navigator.userAgent.toLowerCase();
var appVer		= navigator.appVersion.toLowerCase();
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);
var is_opera	= (agt.indexOf("opera") != -1);
var iePos		= appVer.indexOf('msie');
if (iePos !=-1) {
	is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
	is_major = parseInt(is_minor);}
var kqPos		= agt.indexOf('konqueror');
var is_safari	= ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
var is_khtml	= (is_safari || (kqPos != -1));
var is_ie		= ((iePos!=-1) && (!is_opera) && (!is_khtml));
var is_ie6up	= (is_ie && is_minor >= 6);



function dw(txt)
{
	document.write(txt);
}
//
// Fonction d'affichage des liens pour l'ouverture de la popup
//
function pop_link(id_test)
{
	dw('<a href="#" ');
	dw('onclick="pop_test(' + id_test + '); return false;">');
	dw('Commencer ce test');
	dw('</a>');
}

//
// Fonction d'ouverture de la popup des tests
//
function pop_test(id_test, is_save)
{
	if (is_save)
		url = '/tests/popup.php?save=' + id_test;
	else
		url = '/tests/popup.php?t=' + id_test;
	height = 487;
	width = 665;
	if(is_ie)
	{
		opt = "dialogHeight:" + (height+25) + "px;dialogWidth:" + width + "px;resizable:no;help:no;status:no;scroll:no;center:yes;";
		val = window.showModalDialog(url, 0, opt);
		return val;
	}
	else
	{
		window.open(url, 'Test', 'width='+width+',height='+height+',toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no');
	}
}

//
// Fonction d'ouverture de la popup des tests
//
function pop_edit_test(id_test)
{
	if (id_test)
		url = '/membres/tests_popup.php?t=' + id_test;
	else
		url = '/membres/tests_popup.php';
	height = 550;
	width = 750;
	if(is_ie)
	{
		opt = "dialogHeight:" + (height+25) + "px;dialogWidth:" + width + "px;resizable:yes;help:no;status:no;scroll:no;center:yes;";
		val = window.showModalDialog(url, 0, opt);
		return val;
	}
	else
	{
		window.open(url, 'Test_edit', 'width='+width+',height='+height+',toolbar=no,menubar=no,status=no,scrollbars=no,resizable=yes');
	}
}


//
// Exemple de résultats
//
function popup_preview()
{
	window.open('/tests-qi/preview.jpg', 'ExempleRes', 'width='+475+',height='+540+',toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no');
}

//
// Fonction d'ouverture de la popup des tests
//
function pop_reponses(id_test)
{
	url = '/tests/reponses.php?t=' + id_test;
	height = 487;
	width = 665;
	if(is_ie)
	{
		opt = "dialogHeight:" + (height+25) + "px;dialogWidth:" + width + "px;resizable:no;help:no;status:no;scroll:yes;center:yes;";
		val = window.showModalDialog(url, 0, opt);
		return val;
	}
	else
	{
		window.open(url, 'Test_reponses', 'width='+width+',height='+height+',toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no');
	}
}

//
// Fonctions nécessaires ŕ l'affichage de la progression du test
//
function progress_init()
{
	inner = '<table cellpadding="0" cellspacing="0" align="left" style="margin-left: 5px;">';
	inner += '<tr>';
	inner += '<td style="background: url(\'/pics/progress_bg.gif\');"><img src="/pics/progress_left.gif"></td>';
	inner += '<td style="background: url(\'/pics/progress_bg.gif\');">';
	for (a = 0; a != 10; a++)
		inner += '<img id="progress_' + a + '" src="/pics/px.gif" style="margin-right: 2px" width="8px" height="11px">';
	inner += '</td>';
	inner += '<td style="background: url(\'/pics/progress_bg.gif\');"><img src="/pics/progress_right.gif"></td>';
	inner += '<td style="font-weight: bold; color: white; font-size: 9px;"><div id="progress"></td>';
	inner += '</tr>';
	inner += '</table>';
	document.write(inner);
}

function progress_update(p, str)
{
	for (a = 0; a != 10; a++)
		if (a < p)
			document.getElementById('progress_' + a).src = '/pics/progress.gif';
		else
			document.getElementById('progress_' + a).src = '/pics/px.gif';

	document.getElementById('progress').innerHTML = '&nbsp;' + str;
}






//
// Fonctions du timer
//

timer_seconds	= 0;
timer_started	= 0;
timer_mask		= 0;
timer_min = '00';
timer_sec = '00';
function timer_init()
{
	inner = '<table cellpadding="0" cellspacing="0" align="right" style="margin-right: 5px;">';
	inner += '<tr>';
	inner += '<td>';
		inner += '<img id="timer_pic" alt="Masquer le compteur" title="Masquer le compteur" style="cursor: pointer;" src="/pics/timer_on.gif" onclick="if (timer_mask == 0) {timer_mask = 1; this.title = \'Afficher le compteur\'; document.getElementById(\'timer\').innerHTML = \'XX:XX\'; this.alt = \'Afficher le compteur\'; this.src = \'/pics/timer_off.gif\';} else {timer_mask = 0; document.getElementById(\'timer\').innerHTML = timer_min + \':\' + timer_sec; this.title = \'Masquer le compteur\'; this.alt = \'Masquer le compteur\'; this.src = \'/pics/timer_on.gif\';}">';
	inner += '</td>';
	inner += '<td style="background: url(\'/pics/progress_bg.gif\');"><img src="/pics/progress_left.gif"></td>';
	inner += '<td style="background: url(\'/pics/progress_bg.gif\');  font-weight: bold; color: #525252;">';
		inner += '<div id="timer">00:00</div>';
	inner += '</td>';
	inner += '<td style="background: url(\'/pics/progress_bg.gif\');"><img src="/pics/progress_right.gif"></td>';
	inner += '<td style="font-weight: bold; color: white; font-size: 9px;"><div id="progress"></td>';
	inner += '</tr>';
	inner += '</table>';
	document.write(inner);
}

function timer_update()
{
	if (timer_started == 1)
		setTimeout("timer_update()", 1000);

	timer_min = Math.round(timer_seconds/60);
	timer_sec = timer_seconds%60;
	if (timer_min < 10)
		timer_min = '0' + timer_min;
	if (timer_sec < 10)
		timer_sec = '0' + timer_sec;

	if (timer_mask == 1)
	{
		if (document.getElementById('timer').innerHTML != 'XX:XX')
			document.getElementById('timer').innerHTML = 'XX:XX';
	}
	else
		document.getElementById('timer').innerHTML = timer_min + ':' + timer_sec;
	timer_seconds++;
}

function timer_start()
{
	if (timer_started != 1)
	{
		timer_started = 1;
		timer_update();
	}
}

function timer_stop()
{
	if (timer_started == 1)
		timer_started = 0;
}




//
// Fonctions pour l'enregistrement d'un test
//
save_ok = 0;
save_get = 0;

function save(id_test, id_save)
{
	if (save_ok == 0)
	{
		alert('Vous ne pouvez pas encore enregistrer ce test car vous ne l\'avez pas commencé');
	}
	else if (save_ok == -1)
	{
		alert('Le test est terminé... Pourquoi voudriez vous l\'enregistrer pour finir plus tard ? :)');
	}
	else
	{
		timer_stop();
		window.frames['if'].document.location.href = '/tests/save.php?t=' + id_test + '&timer=' + timer_seconds + '&get=' + save_get + '&id_save=' + (id_save ? id_save : '');
	}
}

function save_set(val)
{
	save_ok = val;
}

function save_set_get(val)
{
	save_get = val;
}

function sx()
{
	/*
	html = '<div style="text-align: center; padding: 2px; margin: 2px; background-color: #FFF5EC; border: 1px solid #FFE3CA;">';
	html += '<a target="_blank" href="http://www.10000jeux.com/?id=games3000&w=2" style="color: red; font-weight: bold;">10000jeux.com</a> : Le plus grand portail de jeux en téléchargement.';
	html += '</div>';
	*/
	html = '<div style="" class="sx">';
	html += '<a href="/rencontres.php">Services de rencontres</a>';
	html += '<a href="http://www.cibleclick.com/cibles/clicks/symp.cfm?site_id=63325145&friend_id=624929759" target="_blank">Astrologie, Tarots, Voyance</a>';
	html += '<a href="http://www.10000jeux.com/?id=games3000&w=2" target="_blank">Jeux en ligne</a>';
	html += '(pub)</div>';
	document.write(html);
}
//-->
