/* 
** Custom js
*/
function getVar(name)
{
	get_string = document.location.search;         
	return_value = '';     
	do { 
		name_index = get_string.indexOf(name + '=');    
		if(name_index != -1)
		{
			get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);  
			end_of_value = get_string.indexOf('&');
			if(end_of_value != -1)                
				value = get_string.substr(0, end_of_value);                
			else                
				value = get_string;
			if(return_value == '' || value == '')
				return_value += value;
			else
				return_value += ', ' + value;
		}
	} while(name_index != -1)        
	space = return_value.indexOf('+');
	while(space != -1)
	{ 
        return_value = return_value.substr(0, space) + ' ' + 
        return_value.substr(space + 1, return_value.length);
		space = return_value.indexOf('+');
	}      
	return(return_value);        
}
    
$(document).ready(function(){
	
	/*
	** Init prettyPhoto - mentions legales
	*/
	$("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'light_square'
	});
	
	/*
	** HoverSubMenuFrame - pages offers 
	** approche
	** offre
	** references
	** post-entry-approche
	** post-entry-offre
	** post-entry-references
	*/
	/* hide ref & approche divs when DOM is rdy */
	$("#post-entry-references").hide();
	$("#post-entry-offer").hide();
	$("#approche").css('font-weight', 'bold');
	/* show & hide div depending on sub menu click */
	$("#approche").click(function (){
		$("#post-entry-offer").hide();
		$("#post-entry-references").hide();
		$("#post-entry-approche").show();
		$("#approche").css('font-weight', 'bold');
		$("#offre").css('font-weight', 'normal');
		$("#references").css('font-weight', 'normal');
	});
	$("#offre").click(function (){
		$("#post-entry-approche").hide();
		$("#post-entry-references").hide();
		$("#post-entry-offer").show();
		$("#offre").css('font-weight', 'bold');
		$("#approche").css('font-weight', 'normal');
		$("#references").css('font-weight', 'normal');
	});
	$("#references").click(function (){
		$("#post-entry-approche").hide();
		$("#post-entry-offer").hide();
		$("#post-entry-references").show();
		$("#references").css('font-weight', 'bold');
		$("#offre").css('font-weight', 'normal');
		$("#approche").css('font-weight', 'normal');
	});
	
	/*
	** HoverSubMenuFrame - page nous connaitre
	** lagence
	** faits-chiffres
	** les-gens
	** post-entry-lagence
	** post-entry-faits-chiffres
	** post-entry-les-gens
	*/
	/* hide ref & approche divs when DOM is rdy */
	$("#post-entry-faits-chiffres").hide();
	$("#post-entry-les-gens").hide();
	$("#lagence").css('font-weight', 'bold');
	/* show & hide div depending on sub menu click */
	$("#lagence").click(function (){
		$("#post-entry-faits-chiffres").hide();
		$("#post-entry-les-gens").hide();
		$("#post-entry-lagence").show();
		$("#lagence").css('font-weight', 'bold');
		$("#faits-chiffres").css('font-weight', 'normal');
		$("#les-gens").css('font-weight', 'normal');
	});
	$("#faits-chiffres").click(function (){
		$("#post-entry-lagence").hide();
		$("#post-entry-les-gens").hide();
		$("#post-entry-faits-chiffres").show();
		$("#faits-chiffres").css('font-weight', 'bold');
		$("#lagence").css('font-weight', 'normal');
		$("#les-gens").css('font-weight', 'normal');
	});
	$("#les-gens").click(function (){
		$("#post-entry-lagence").hide();
		$("#post-entry-faits-chiffres").hide();
		$("#post-entry-les-gens").show();
		$("#les-gens").css('font-weight', 'bold');
		$("#faits-chiffres").css('font-weight', 'normal');
		$("#lagence").css('font-weight', 'normal');
	});
	
	
	var refresh = getVar('refresh');
	if (refresh != '') {
		$("#post-entry-lagence").hide();
		$("#post-entry-faits-chiffres").hide();
		$("#post-entry-les-gens").show();		
		$("#les-gens").css('font-weight', 'bold');
		$("#faits-chiffres").css('font-weight', 'normal');
		$("#lagence").css('font-weight', 'normal');
	}
	/*
	** Refresh button gallery 
	*/
	/*
	var curPage = document.location.toString();
	if (curPage.match('#les-gens')) {
		$("#post-entry-lagence").hide();
		$("#post-entry-faits-chiffres").hide();
		$("#post-entry-les-gens").show();
	}
	*/
	
	/*
	** HoverImageText - home page offers 
	*/
	/* box reputation */
	$(".reputation").mouseover(function(){document.getElementById('reputation-text').style.visibility = "visible";});
	$(".reputation").mouseout(function(){document.getElementById('reputation-text').style.visibility = "hidden";});
	/* box relations */
	$(".relationspubliques").mouseover(function(){document.getElementById('relationspubliques-text').style.visibility = "visible";});
	$(".relationspubliques").mouseout(function(){document.getElementById('relationspubliques-text').style.visibility = "hidden";});
	/* box change */
	$(".change").mouseover(function(){document.getElementById('change-text').style.visibility = "visible";});
	$(".change").mouseout(function(){document.getElementById('change-text').style.visibility = "hidden";});
	/* box brands */
	$(".brands").mouseover(function(){document.getElementById('brands-text').style.visibility = "visible";});
	$(".brands").mouseout(function(){document.getElementById('brands-text').style.visibility = "hidden";});
	/* box clients */
	$(".clients").mouseover(function(){document.getElementById('clients-text').style.visibility = "visible";});
	$(".clients").mouseout(function(){document.getElementById('clients-text').style.visibility = "hidden";});
	/* box creations */
	$(".creations").mouseover(function(){document.getElementById('creations-text').style.visibility = "visible";});
	$(".creations").mouseout(function(){document.getElementById('creations-text').style.visibility = "hidden";});
	/* box digital */
	$(".digital").mouseover(function(){document.getElementById('digital-text').style.visibility = "visible";});
	$(".digital").mouseout(function(){document.getElementById('digital-text').style.visibility = "hidden";});
	/* box intelligences */
	$(".intelligences").mouseover(function(){document.getElementById('intelligences-text').style.visibility = "visible";});
	$(".intelligences").mouseout(function(){document.getElementById('intelligences-text').style.visibility = "hidden";});
	/* box mediatisations */
	$(".mediatisations").mouseover(function(){document.getElementById('mediatisations-text').style.visibility = "visible";});
	$(".mediatisations").mouseout(function(){document.getElementById('mediatisations-text').style.visibility = "hidden";});

	/* box mediacoverage */
	$(".media-relations").mouseover(function(){document.getElementById('media-relations-text').style.visibility = "visible";});
	$(".media-relations").mouseout(function(){document.getElementById('media-relations-text').style.visibility = "hidden";});
	/* box intelligenceuk */
	$(".intelligence-en").mouseover(function(){document.getElementById('intelligence-en-text').style.visibility = "visible";});
	$(".intelligence-en").mouseout(function(){document.getElementById('intelligence-en-text').style.visibility = "hidden";});
	/* box design */
	$(".design").mouseover(function(){document.getElementById('design-text').style.visibility = "visible";});
	$(".design").mouseout(function(){document.getElementById('design-text').style.visibility = "hidden";});
	/* box reputationuk */
	$(".reputation-en").mouseover(function(){document.getElementById('reputation-en-text').style.visibility = "visible";});
	$(".reputation-en").mouseout(function(){document.getElementById('reputation-en-text').style.visibility = "hidden";});
	/* box publicrelations */
	$(".public-relations").mouseover(function(){document.getElementById('public-relations-text').style.visibility = "visible";});
	$(".public-relations").mouseout(function(){document.getElementById('public-relations-text').style.visibility = "hidden";});
});

