
function affiche_metier(id_metier){
	$(".sous_menu li").each( function() {
		$(this).removeClass('selected');
	});
	
	$(".sous_menu #id_sr_"+id_metier).addClass("selected");
	
	$(".reference").each( function() {
		$(this).addClass('hover');
	});
	
	$(".references .metier_"+id_metier).removeClass("hover");
	
}






function slide_show_preload() { 


	tmp_img_loaded = new Array();
	tmp_img = new Array();
	tmp_img_loaded_count = 0
	
	for(a = 0; a < diaporama_array.length; a++){
		array_img =diaporama_array[a].split('|');
		
		tmp_img[a] = new Image(); 
		tmp_img[a].src  = array_img[0];
		tmp_img_loaded[a] = false
	}										  
	slide_show_checkload()

}




function slide_show_checkload() {
	if (tmp_img_loaded_count == diaporama_array.length) { 
		slide_show(0);
		return false;
	}
	for (i = 0; i <= diaporama_array.length; i++) {
		if (tmp_img_loaded[i] == false && tmp_img[i].complete) {
			tmp_img_loaded[i] = true;
			tmp_img_loaded_count++;
		}
	}
	timerID = setTimeout("slide_show_checkload()",10) 
}


function slide_show(id){
		clearTimeout(MyTimout)
	array_img = diaporama_array[id].split('|');
	
	
	
	Details = array_img[0].split('.');
	
	Extension = Details[Details.length - 1];
	
	if(Extension == 'flv'){
		$("#slide_show_flv").show();
		$("#slide_show_img").hide();
		
            var so = new SWFObject(CFG_HTTP_ROOT+'img/player_flv.swf', 'slide_show_flv', '550', '355', '8', '#FFFFFF');
            so.useExpressInstall(CFG_HTTP_ROOT+'lib_common/js/expressinstall.swf');
            so.addParam('menu', 'false');
            so.addParam('allowFullScreen', 'true');
            so.addParam('wmode', 'transparent');
			
			so.addVariable('CFG_HTTP_ROOT', CFG_HTTP_ROOT);
			so.addVariable('video', array_img[0]);
			
            so.write('slide_show_flv');
		
		
	}else{
		$("#slide_show_flv").hide();
		$("#slide_show_img").show();
		$("#slide_show").attr('src', array_img[0]);
		$("#slide_show").attr('alt', array_img[1]);
		$("#slide_show").parent().attr('href', array_img[2]);
	}

	$(".puces img").each( function() {
		$(this).attr('src', CFG_HTTP_ROOT+'img/reference-puce.gif');
	});
	$(".puces #image_"+id+"").attr('src', CFG_HTTP_ROOT+'img/reference-puce-selected.gif');
	
      $("#slide_show").fadeTo(500,1, function () {
			new_id = (current_id == diaporama_array.length - 1) ? 0 : current_id+1;
			if((diaporama_vitesse > 0) &&(Extension != 'flv')){
				MyTimout = setTimeout("slide_show_fade_out("+new_id+")",diaporama_vitesse);
			}
			
      });

	

	
}	


function slide_show_fade_out(id){
      $("#slide_show").fadeTo(500,0, function () {
			current_id = id;
			slide_show_timout(id)
      });
}

function slide_show_timout(id){
	slide_show(id);
}





function slide_show_next(){
	if(diaporama_vitesse > 0){
		clearTimeout(MyTimout)
	}
	id  = current_id;
	id = (id == diaporama_array.length - 1) ? 0 : id+1;
	slide_show_fade_out(id);
}
function slide_show_previous(){
	if(diaporama_vitesse > 0){
		clearTimeout(MyTimout)
	}
	id  = current_id;
	id = (id == 0) ? diaporama_array.length - 1 : id-1;
	slide_show_fade_out(id);
}


function slide_show_id(id){
	if(diaporama_vitesse > 0){
		clearTimeout(MyTimout)
	}
	slide_show_fade_out(id);
}


















function open_popup(file, largeur, hauteur){
	if(largeur == undefined){
		largeur = 650;
	}
	
	if(hauteur == undefined){
		hauteur = 650;
	}
	window.open(file, "_blank", "menubar=no, status=no, scrollbars=yes, menubar=no, width="+largeur+", height="+hauteur+",location=no");
}








function carrousel(id_name){
	$("#caroussel ul.boutons li").removeClass("selected");
	$("#caroussel ul.boutons li."+id_name).addClass("selected");

	$("#caroussel .carrousel.block ").hide("slide", 750, function() {
		$(this).removeClass("block")
		$("#"+id_name).addClass("block");
		$("#"+id_name).show('slide', 750);	
		}

	);
}






function valid_sondage(){
	id_sondage = $("#id_sondage").val();
	id = $("#question_selected").val();
	
	
	if(id > 0){
		$.ajax({
			type: "POST",
			url: CFG_HTTP_ROOT + "include/ajax.inc.php",
			data: "action=valid_sondage&id_sondage=" + id_sondage + "&id=" + id +"" ,
			success: function(msg){
				if(msg){
					$("#sondage_questions").css("display", "none");
					$("#sondage_resultats").css("display", "block");
				}else{
					$("#sondage_erreur").html('Une erreur s\'est produite, merci de valider &agrave; nouveau le formulaire.')
				}
			}
		});		
	}else{
		$("#sondage_erreur").html('Merci de s&eacute;lectionner une r&eacute;ponse.')
	}
}



function resultats_sondage(){
	$("#sondage_questions").css("display", "none");
	$("#sondage_resultats").css("display", "block");
}

