$(document).ready(function(){
	$("#next1").click(function(){nextequipe();})
	$("#prev1").click(function(){prevequipe();})
	$("#texteofflien").click(function(){visible_invisible();});
	$("#texteonlien").click(function(){visible_invisible();});
	$("#image_1").click(function(){afficheimage(1);})
	$("#image_2").click(function(){afficheimage(2);})
	$("#image_3").click(function(){afficheimage(3);})
	$("#image_4").click(function(){afficheimage(4);})
	$("#image_5").click(function(){afficheimage(5);})
	$("#image_6").click(function(){afficheimage(6);})
	$("a[@id*=photocv]").click(function(){ affichecv($(this).attr("id"));})

});

function affichecv(idcv){
var newid=idcv;
newid=newid.replace('photocv','');
$(document).ready(function(){
$.get("functiona.php",
   {
   affichage:$("#affichage").val(),
   page: $("#next").val(),
   valeur: newid
   }, 
   function(data){
	$("#letexte").attr({ innerHTML:data });
   }
 )});

}

function afficheimage(image){

var newimg=$("#image_"+image).attr('src');
newimg=newimg.replace('thumb/','');
newimg=newimg.replace('v.jpg','.jpg');
$("#imagefond").css("background-image",'url('+newimg+')');

for (i=1; i<=6; i++){
   if(image==i){
	$("#image_"+i).css("opacity", "0.20");
	$("#image_"+i).css("filter", "alpha(opacity=20)");
	$("#image_"+i).css("cursor","default");   
   $("#legendeimg").html($("#image_"+i).attr("rel"));
   }
   else{
	$("#image_"+i).css("cursor","pointer");
   $("#image_"+i).css("opacity", "1");
   $("#image_"+i).css("filter", "alpha(opacity=100)");
	}
	}
	if (image>1){
		$("#texteonlien").css({display:""});
		$("#texteofflien").css({display:"none"});
		$("#tableaudetexte").fadeOut("slow");
		$("#letexte").fadeOut("slow");
	}
}


function visible_invisible(){
if ($("#letexte").is(':visible'))
			{
			$("#texteonlien").css({display:""});
			$("#texteofflien").css({display:"none"});
			$("#tableaudetexte").fadeOut("slow");
			$("#letexte").fadeOut("slow");
		} 
			else 
			{
			$("#texteonlien").css({display:"none"});
			$("#texteofflien").css({display:""});
			$("#tableaudetexte").fadeIn("slow");
			$("#letexte").fadeIn("slow");
			}
}

function nextequipe(){
//~ alert("ok");
$(document).ready(function(){
//~ $("#letexte1").css("visibility", "hidden");
//~ $("#letexte1").css("display", "none");  
$.get("functiona.php",
   {
   affichage:$("#affichage").val(),
   sens: 'next',
   page: $("#next").val(),
   valeur: $("#valeur").val()
   }, 
   function(data){
	$("#letexte").attr({ innerHTML:data });
   }
 )});
 }
//~ $("#prev").val()
function prevequipe(){
$(document).ready(function(){
//~ $("#letexte1").css("visibility", "hidden");
//~ $("#letexte1").css("display", "none");
$.post("functiona.php",
   {
	affichage:$("#affichage").val(),
	sens: 'prev',
	page: $("#prev").val(),
	valeur: $("#valeur").val()
   },
   function(data){
		$("#letexte").attr({ innerHTML:data });
   }
 )});
 }
 
 $(document).ready(function() {
	//Select all anchor tag with rel set to tooltip
	$('a[rel=tooltip]').mouseover(function(e) {
		//Grab the title attribute's value and assign it to a variable
		var tip = $(this).attr('title');	
		//Remove the title attribute's to avoid the native tooltip from the browser
		$(this).attr('title','');
		//Append the tooltip template and its value
		$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');		
		//Show the tooltip with faceIn effect
		$('#tooltip').fadeIn('500');
		$('#tooltip').fadeTo('10',0.9);
	}).mousemove(function(e) {
		//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
		$('#tooltip').css('top', e.pageY + 10 );
		$('#tooltip').css('left', e.pageX + 20 );
	}).mouseout(function() {
		//Put back the title attribute's value
		$(this).attr('title',$('.tipBody').html());
		//Remove the appended tooltip template
		$(this).children('div#tooltip').remove();
	});
});