// Fonctions JavaScript pour les exercices 
 
 function calculer(formname){
	 	var exercice = formname;
		 
		var popupname = 'profil.htm';
		
		 if(exercice == "frmpoints"){
			var titre = 'Strengths';
			exemples = document.forms[0].exemples.value;
		 }else{
			 var titre = 'Fields that interest you';
		 }
 		points = " ";
			for(i=0;i<document.forms[0].length;i++){	
				if(document.forms[0].elements[i].checked){
					points += '<li>' + document.forms[0].elements[i].value + '</li>';
				}
			}

		ouvrirPopup(popupname,titre,exercice,400,600);
	}
 
function soumettre(info) {
	
		var exercice = 'ex1';
		var popupname = 'profil.htm';
		var titre = 'job situation';
		

    	section = new Array();
			section[0] = new Array();
   				section[0][0] = 'Type of work';
				 					
			if(document.forms[0].rbexperience[0].checked){
				section[0][1] = document.forms[0].rbexperience[0].value;
			}else{
				section[0][1] = document.forms[0].rbexperience[1].value;
			}
			
				section[0][2] = document.forms[0].precisionst.value;
				section[0][3] = " ";
				for(var z=0; z < document.forms[0].secteurs.length; z++){
					if(document.forms[0].secteurs[z].checked){
						section[0][3] += '<li>' + document.forms[0].secteurs[z].value;
					}
				}
				
			if(document.forms[0].rbinteret[0].checked){
				section[0][4] = document.forms[0].rbinteret[0].value;
			}else{
				section[0][4] = document.forms[0].rbinteret[1].value;
			}
			
			section[0][5] = " ";
			for (var z=0;z<document.forms[0].points.length; z++){
				if(document.forms[0].points[z].checked){
					section[0][5] += '<li>'+ document.forms[0].points[z].value;
				}
				}
						
			if(document.forms[0].rbformation[0].checked){
				section[0][6] = document.forms[0].rbformation[0].value;
				
			}else{
				section[0][6] = document.forms[0].rbformation[1].value;
			}
			section[0][7] = document.forms[0].laquelleformation.value;
			
			
			section[1] = new Array();
   				section[1][0] = 'Mobility';
			if(document.forms[0].rbville[0].checked){
				section[1][1] = document.forms[0].rbville[0].value;
			}else{
				section[1][1] = document.forms[0].rbville[1].value;
			}

			if(document.forms[0].rapprocher[0].checked){
				section[1][4] = document.forms[0].rapprocher[0].value;
			}else{
				section[1][4] = document.forms[0].rapprocher[1].value;
			}
				section[1][2] = document.forms[0].precisionsm.value;
				section[1][3] = document.forms[0].moyentransport.value;
				
			if(document.forms[0].rbregion[0].checked){
				section[1][5] = document.forms[0].rbregion[0].value;
			}else{
				section[1][5] = document.forms[0].rbregion[1].value;
			}
				
   		section[2] = new Array();
		section[2][0] = 'Availability';
			if(document.forms[0].contraintes[0].checked){
				section[2][1] = document.forms[0].contraintes[0].value;
			}else{
				section[2][1] = document.forms[0].contraintes[1].value;
			}
			section[2][2] = " ";
			for (var z=0;z<document.forms[0].temps.length;z++){
				if(document.forms[0].temps[z].checked){
					section[2][2] += '<li>'+ document.forms[0].temps[z].value;
				}
				}
			if(document.forms[0].heuressup[0].checked){
				section[2][3] = document.forms[0].heuressup[0].value;
			}else{
				section[2][3] = document.forms[0].heuressup[1].value;
			}
			section[2][4] = " ";
			for (var z=0;z<document.forms[0].travailler.length;z++){
				if(document.forms[0].travailler[z].checked){
					section[2][4] += '<li>'+ document.forms[0].travailler[z].value;
				}
				}
			if(document.forms[0].horaire[0].checked){	 
				section[2][5] = document.forms[0].horaire[0].value;
			}else{
				section[2][5] = document.forms[0].horaire[1].value;
			}
			if(document.forms[0].voyage[0].checked){	 
				section[2][6] = document.forms[0].voyage[0].value;
			}else{
				section[2][6] = document.forms[0].voyage[1].value;
			}
			section[2][7] = document.forms[0].precisionsd.value;
			
   		section[3] = new Array();
		section[3][0] = 'Financial needs';
		section[3][1] = document.forms[0].salairebrut.value;
		section[3][2] = " ";
			for (var z=0;z<document.forms[0].salaire.length;z++){
				if(document.forms[0].salaire[z].checked){
					section[3][2] = document.forms[0].salaire[z].value;
				}
				}
		section[3][3] = document.forms[0].precisionsf.value;
		
	ouvrirPopup(popupname,titre,exercice,400,600);
	
}

  function openWin(url, name, props){
    var w = window.open(url, name, props);
	w.focus();
	return w;	//important de retourner les valeurs!
}

function ouvrirPopup(url,titre,exnum,w,h){

	  	//On ouvre  le pop-up:
    var URL = url;
	var title = titre;
    var windowName = "profil";
    var features =
        'width='        + w +
        ',height='      + h +
        ',left='      	+ 100 +
        ',top='      	+ 100 +
        ',directories=' + (0) +
        ',location='    + (0) +
        ',menubar='     + (0) +
        ',scrollbars='  + (1) +
        ',status='      + (0) +
        ',toolbar='     + (0) +
        ',resizable='   + (1);

  	//fenProfil = window.open (URL, windowName, features);
	fenProfil = openWin(URL, windowName, features);
   	//fenProfil.focus();
   	
   if(exnum != "popup"){
	fenProfil.document.open(); //pour que la page generée automatiquement pourrait être imprimée
	
   	fenProfil.document.write('<html>'+'<head>'+'<link rel=\'shortcut icon\' href=\'../favicon.ico\' />'+'<title>'+ title+'</title>');
	fenProfil.document.write('<link rel=\'stylesheet\' href=\'../css/exemples.css\' type=\'text/css\' />');
	fenProfil.document.write('<link rel=\'stylesheet\' href=\'../css/guide_print.css\' type=\'text/css\' media=\'print\' />');
	fenProfil.document.write('</head>'+'<body>');

		if (window.print) fenProfil.document.write('<div id=\'imprimer\'>' + 
										'<a href=\'javascript:window.print()\'>'+
										'print this page'+
										'</a>' +
										'<\/div>');
		
	ecrire(exnum, title);
	fenProfil.document.close();
   }
}
function ecrire(exnum, title){
	 
	if(exnum == 'ex1'){	//situation
	fenProfil.document.write('<h3>'+'Your ' + title +'</h3>' +
							'<h4>'+ section[0][0] +'</h4>' +
							'I would like to work in one of the following fields:' + 
							'<ol>'+ section[0][3] +'</ol>' +
							section[0][1] +'<br>'+	//expérience
	 						section[0][4] +'<br>' +	//intérêt
							section[0][6] +	//formation
							'<em>'  + section[0][7]  + '</em>' + '<br>' +
							'The skills that describe me best are: ' + '<ol>' + section[0][5] +'</ol>' +
							'<b>'+ 'Specify: ' +'</b>'+ section[0][2] +'<br>' +
	
	 						'<h4>'+ section[1][0] +'</h4>' +
							'To get to work, I will use: '+ section[1][3] +'<br>' +
							section[1][1] +'<br>' +	//ext ville
							section[1][5] +'<br>' +	//ext région
							section[1][4] +'<br>' +	//déménager
	 						'<b>'+ 'Specify: ' +'</b>'+ section[1][2] +'.<br>' +
	
	 						'<h4>'+ section[2][0] +'</h4>' +	//Dispo
	 						section[2][1]  +		//Contraintes
							'<ul>'+ section[2][2] +'</ul>' +	//temps plein, le soir, la nuit
							section[2][3] +
	 						'<ul>'+ section[2][4] +'</ul>' +
	 						section[2][5] + '<br>' +	//horaire
	 						section[2][6] + '<br>' +	//voyager
							'<b>' + 'Specify: ' + '</b>' + section[2][7] +
	
	 						'<h4>'+ section[3][0] +'</h4>' +	//Besoins fin
	 						'I would accept a salary of $ ' + section[3][1]  +
	 						' (' + section[3][2] +')' + '<br>' +
	 						'<b>' + 'Specify: ' + '</b>' + section[3][3] +

	 						'</body>'+'</html>');
	}else{	//exercices Secteurs ou Points
	
			fenProfil.document.write('<h3>'+ title +'</h3>' +
	 						'<ul>'+ points +'</ul>');
		if(exnum =="frmpoints"){fenProfil.document.write ('<p>' + '<em>' + exemples +'</em>' + '</p>');}
							 
	 		fenProfil.document.write('</body>'+'</html>');
	}
}
function checkNumeric(arg){ 	//envoyé par onchange() dans le champ de texte 'salairebrut'
	var n = parseFloat(arg.value);
	if (isNaN(n)){
		alert('You\'d better choose something else as your salary');
		arg.value=" ";
		arg.focus();
	}
}
/* -------- fonction pour afficher/cacher les éléments -- */
	function controlAffichDOM(objectID)
	{
	if(isAll||isID)	//si le navigateur comprend DOM All ou ID
	{
		domStyle = findDOM(objectID,1);
		if(domStyle.display == 'block') domStyle.display='none';
		else domStyle.display='block';
	}
	else	//si le navigateur n'est pas compatible avec DOM, la fonction charge une nouvelle page
	{
		alert('Votre navigateur est désuet');
		//destination=objectID + '.htm';
		//self.location='riasec_NN4.htm';
	}
	return;
	}
/* imprimer page */
function printpage(){
			if (window.print) document.write('<div id=\'imprimer\'>' + 
										'<a href=\'javascript:window.print()\'>'+
										'print this page'+
										'</a>' +
										'<\/div>');
	
}