$(document).ready(function(){
/********************IMAGE POPUP   PART 1**********************************/	
if($(".imagePop").length>0)
{
	if($(".imagePop").children("img").length>0)
	{
		$(".imagePop").each(function(){
			
			limage = $(".imagePop").children("img").attr("src")
			limageTab = limage.split("/");
			nbrLien = limageTab.length
			nomImage = limageTab[nbrLien-1]
			lienImage="";
			for(i=0; i<nbrLien-1;i++)
			{
				lienImage += limageTab[i]+"/";
			}
			
			tabNomImage = nomImage.split(".");
			slExtension = tabNomImage[1];
			slNomImage = tabNomImage[0];	
			$(this).append('<div style="display:none;"><img src="'+lienImage+slNomImage+"-gr."+slExtension+'" /></div>');
	
			
		})
	}
		 
}

	
/*********************TOGGLE***************************************/

var pathname = window.location.pathname;
var slFermer = "Fermer"


if((pathname.search("eng") == 1) ||(pathname.search("ENG") == 1) || (pathname.search("en") == 1) || (pathname.search("EN")==1))
{
	slFermer = "Close"
}

$(".showhide").append("<div class='fermer'>" + slFermer + "</div>");
$(".fermer").click(function() {
  if( $(this).parent(".showhide").prev().attr("class")=="bullet-prod bullet-prod-bas" ||  $(this).parent(".showhide").prev().attr("class")=="bullet-prod" )
  {
 	 $(this).parent(".showhide").prev().attr("class","bullet-prod")	
	 $(this).parent(".showhide").prev().children(".bullet-img").attr("src",'../images/layout/bulletprod.gif')
  }
 
 $(this).parent(".showhide").slideUp("fast",function(){$(this).removeAttr("style")}).attr("class","showhide hideme");
  


});


$(".showhide").prev().css("cursor","pointer").click(function() {
  
 
  if($(this).next(".showhide").attr("class")=="showhide" || $(this).next(".showhide").attr("class")=="showhide hideme")
  {
  		$(this).next(".showhide").removeAttr("style").slideDown("fast").attr("class","showhide showme");
		
		$(this).children(".bullet-img").attr("src",'../images/layout/bulletprod-o.gif')
		
  }
  else{
	  if($(this).next(".showhide").attr("class")=="showhide" || $(this).next(".showhide").attr("class")=="showhide showme")
	  {
		   $(this).next(".showhide").slideUp("fast",function(){$(this).removeAttr("style")}).attr("class","showhide hideme");
		   $(this).children(".bullet-img").attr("src",'../images/layout/bulletprod.gif')
		    
	  }
  }
  
  if($(this).attr("class")=="bullet-prod bullet-prod-bas" || $(this).attr("class")=="bullet-prod" )
  {
 	 $(this).toggleClass("bullet-prod-bas")
	 
  }
  
});
	
$(".bullet-prod").prepend("<img src='../images/layout/bulletprod.gif' class='bullet-img'/> ")

/********************IMAGE POPUP   PART 2**********************************/

$(".imagePop").bind("click", function() {
limage = $(this).children("img").attr("src");
texteImage = $(this).children("img").attr("alt");
eval(benbox(limage,getHTMLEncode(texteImage)))
});


$(".temoignageAcc").children("p").children("a").click(function()
{
	
	longDescr =$(this).attr("rel")
	compagnie = $(".compagnieTem").html();
	ville =  $(".villeTem").html();
	auteur =  $(".auteurTem").html();
	if(auteur == "")
	{
		auteur=""	
	}
	else
	{
		auteur =  $(".auteurTem").html()+"<br />"
	}
	
	Temoignage = "<div class='intLongDesc'><span class=\"ouvertGuillemet\">&laquo;&nbsp;</span><div class=\"textIntTem\">"+longDescr+"</div></div><div style='text-align:right;padding-right:20px; font-size:10px;'><br />"+compagnie+" <br/>"+auteur +""+ville+"</div>";
	$("#longDescription").html(Temoignage);
	hauteurTem = $("#longDescription").height()/2;
	$("#longDescription").css("top","-"+hauteurTem+"px");
	
	//$("#longDescription").css("filter", 'progid:DXImageTransform.Microsoft.Blur(makeShadow=true, pixelradius=3, shadowOpacity=0.5)');   
	//$("#longDescription").css("zoom","1");  
	$("#longDescription").show(300)

	
	phrase = $(".textIntTem").children("p:last").html()
	newPhrase = phrase+" <span style=\"font-size:15px;\">&raquo;</span>"
	$(".textIntTem").children("p:last").html(newPhrase)
}
)

$("#longDescription").hover(function()
{
	$("#longDescription").show();
},
function(){
	$("#longDescription").hide("fast")
	}
)

});



function getHTMLEncode(t) {
    return t.toString().replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&rsquo;");
}

