
$(document).ready(function() {
	
racine_image = '../include/img/';


/*
 *
 *
 *
 *
 *
 *Opérations sur le background
 */
insertBg(numBg);
$(window).resize(function() {
  insertBg(numBg);
});


/*
 *
 *
 *
 *
 *
 * Opération sur le menu haut
 */
//Menu Haut - Mise en évidence page actuelle
if(numBg == 1 || numBg == 2 || numBg == 3 || numBg == 4){
    $('#header_'+numBg+' .bulle').css({ "margin-top" : "0px", "height" : "90px" });
}

//Effets sur le menu haut
//$('#header_menu').mouseenter(function() {  $('#header_menu').animate({"right": "+=20px"}, { "duration": "slow", "easing": "easeOutElastic" }); });
//$('#header_menu').mouseleave(function() {  $('#header_menu').animate({"right": "-=20px"}, "slow");});

$('#header_1').mouseover(function() {  $('#header_2, #header_3, #header_4').css({ opacity: 0.7 }); $('#picto_1').css({ "background-image" : "url("+racine_image+"structure/menu_haut/picto_1_black.png)" }); });
$('#header_2').mouseover(function() {  $('#header_1, #header_3, #header_4').css({ opacity: 0.7 }); $('#picto_2').css({ "background-image" : "url("+racine_image+"structure/menu_haut/picto_2_black.png)" }); });
$('#header_3').mouseover(function() {  $('#header_1, #header_2, #header_4').css({ opacity: 0.7 }); $('#picto_3').css({ "background-image" : "url("+racine_image+"structure/menu_haut/picto_3_black.png)" }); });
$('#header_4').mouseover(function() {  $('#header_1, #header_2, #header_3').css({ opacity: 0.7 }); $('#picto_4').css({ "background-image" : "url("+racine_image+"structure/menu_haut/picto_4_black.png)" }); });

$('#header_1').mouseout(function() {  $('#header_2, #header_3, #header_4').css({ opacity: 1 }); $('#picto_1').css({ "background-image" : "url("+racine_image+"structure/menu_haut/picto_1.png)" }); });
$('#header_2').mouseout(function() {  $('#header_1, #header_3, #header_4').css({ opacity: 1 }); $('#picto_2').css({ "background-image" : "url("+racine_image+"structure/menu_haut/picto_2.png)" }); });
$('#header_3').mouseout(function() {  $('#header_1, #header_2, #header_4').css({ opacity: 1 }); $('#picto_3').css({ "background-image" : "url("+racine_image+"structure/menu_haut/picto_3.png)" }); });
$('#header_4').mouseout(function() {  $('#header_1, #header_2, #header_3').css({ opacity: 1 }); $('#picto_4').css({ "background-image" : "url("+racine_image+"structure/menu_haut/picto_4.png)" }); });


/*
 *
 *
 *
 *
 *
 * Opacité des blocs
 */
$("#page").css({ opacity: 0.2 });
$("#contenu_page").css({ opacity: 1 });
$("#bandeau_gauche").css({ opacity: 0.5 });
$("#bgFooter").css({ opacity: 0.5 });
$(".post").css({ opacity: 0.7 });
$(".cadre").css({ opacity: 0.7 });
$('#content form').css({opacity: 0.7});


/*
 *
 *
 *
 *
 *
 * Redimensionnement des hauteurs des blocs
 */
redim();
setTimeout(function(){checkRedim();}, 2000);//Reredimensionne si une partie du contenu se charge après


/*
 *
 *
 *
 *
 *
 * Effets sur le menu gauche
 */
$('#menu_gauche').mouseenter(function() {  
        //$('#menu_gauche').animate({"top": "-=10px"}, "slow");
	$('#header_1, #header_2, #header_3, #header_4').css({ opacity: 0.7 });
	});
$('#menu_gauche').mouseleave(function() {  
        //$('#menu_gauche').animate({"top": "+=10px"}, "slow");
	$('#header_1, #header_2, #header_3, #header_4').css({ opacity: 1 });
	});

/*
 *
 *
 *
 *
 *
 *
 * Effets d'arrivée
 */
$('#menu_gauche').animate({"top": "-=370px"}, 3000);
//$('#header_menu').animate({"bottom" : "-=210px"}, 1000, "linear");



/*
 *
 *
 *
 *
 *
 * Quelques corrections pour ie6
 */
if($.browser.msie && $.browser.version=="6.0")
{
	//Message d'information
	$("#information").html('Pour une vision optimale du site nous vous conseillons l\'utilisation d\'un navigateur plus r&eacute;cent.');
	$("#information").show();
	
	//Menu sans transparence
	$("#menu_gauche2").css({ "background-image" : "url("+racine_image+"structure/menu_gauche_2_ie.png)" });
		
	//Puce
	$("h1").css({ "background-image" : "url("+racine_image+"structure/puceh1ie6.png)" });
	$("h2").css({ "background-image" : "url("+racine_image+"structure/puceie6.png)" });
	
	//Image contact
	$('.contact').attr("src", racine_image+"structure/nouscontacterie6.png");
}

/*
 *
 *
 *
 *Petites résolutions
 */
if($(window).width()<1025)
{
   $("#central_content").css({ "right" : "5%" });
   $("#right_content").css({ "right" : "-15%" });
}


/*
 *
 *
 *
 * Ajout d'effets sur le h1
 * Bordure bas h1
 */
$('h1').after('<div class="h1_underline"></div>');

/*
 *
 *
 *
 * Ajout des quotes dans les cadres
 */
$('.cadre').prepend('<img class="alignleft size-full wp-image-588" height="19" width="30" title="Cédric Caria Consultant Stratégie d\'entreprise et Internet" alt="Conseil en Communication et Internet" src="http://www.cedric-caria.fr/wordpress/wp-content/uploads/2010/08/quotedepart3.png">');
$('.cadre').append('<img height="19" width="30" class="alignright size-full wp-image-590" title="Caria Consultant Stratégie Internet" alt="Caria Consultant Stratégie Internet" src="http://www.cedric-caria.fr/wordpress/wp-content/uploads/2010/08/quotedarrivee.png">');




});


/*
 *
 *
 *
 *
 *
 *Opérations sur le background
 */
 function insertBg(numBg)
 {
     ex = $(window).width();
     ey = $(window).height();

     ix = 2000;
     iy = 1435;

     iyr = ey;
     ixr = (ix * iyr)/iy;

     if(ixr<ex)//=>pas ok
     {
       ixr = ex;
       iyr = (iy * ixr)/ix
     }

     ixr = Math.ceil(ixr);
     iyr = Math.ceil(iyr);

     if(numBg == 0)displayBg = 1;
     else displayBg = numBg;
     $('#background_bloc').html('<img src="'+racine_image+'/structure/bg/bg'+displayBg+'.jpg" width="'+ixr+'" height="'+iyr+'" >');
 }


/*
 *
 *
 *
 *
 *
 * Redimensionnement des hauteurs des blocs (fonctions)
 */
//Content
function redim()
{
content_height = 600;
height_menu_gauche = $("#menu_gauche").height() + $("#addMenuGauche").height() + 110;
if($("#contenu_page").height()>content_height && $("#contenu_page").height()>$("#bandeau_gauche").height()) content_height = $("#contenu_page").height();
if(height_menu_gauche>content_height && height_menu_gauche>$("#contenu_page").height()) content_height = height_menu_gauche;
$("#page").height(content_height + 30);
$("#bandeau_gauche").height($("#page").height());
$("#content").height($("#page").height());

//Footer
if( $('#footer_1_1').height()>$('#footer_1_2').height() && $('#footer_1_1').height()>$('#footer_1_3').height() ){
    $('#footer_1_2').height( $('#footer_1_1').height() );
    $('#footer_1_3').height( $('#footer_1_1').height() );
}
if( $('#footer_1_2').height()>$('#footer_1_1').height() && $('#footer_1_2').height()>$('#footer_1_3').height() ){
    $('#footer_1_1').height( $('#footer_1_2').height() );
    $('#footer_1_3').height( $('#footer_1_2').height() );   
}
if( $('#footer_1_3').height()>$('#footer_1_1').height() && $('#footer_1_3').height()>$('#footer_1_1').height() ){
    $('#footer_1_1').height( $('#footer_1_3').height() );
    $('#footer_1_2').height( $('#footer_1_3').height() );
}
$('#bgFooter').height( $('#contentFooter').height() );

}
//Vérification du redimensionnement
function checkRedim()
{
    if($("#contenu_page").height()>$("#bandeau_gauche").height())
    {
         $("#page").height($("#contenu_page").height() + 30);
         $("#bandeau_gauche").height($("#page").height());
         $("#content").height($("#page").height());
    }
}
