$(function(){
    tailleImageGrande = 400;
    grandPhoto = $('#photo_centrage img');
    $('.mignature img').mouseenter(function(){
        grandPhoto.attr('src',$(this).attr('src'));
        $('#photo_centrage a').attr('href',$(this).attr('src'));
    });
    $('img.centrer').bind("load",function(){
        tailleImage = parseInt($(this).parent().css('width'));
        var tmp_img = new Image();
        tmp_img.src=$(this).attr('src');
        real_width = tmp_img.width;
        real_height = tmp_img.height;
        //alert(real_width+" & "+real_height);
        
        if(real_width >real_height ){
            $(this).attr("width",tailleImage+"px");
            height =  Math.round(real_height*tailleImage/real_width);
            $(this).attr("height",height+'px');
            $(this).css('margin-left','0');
            $(this).css('margin-top',Math.round((tailleImage-height)/2)+'px');
        }else{
            $(this).attr("height",tailleImage+"px");
            width = Math.round(real_width*tailleImage/real_height);
            $(this).attr("width",width+'px');
            $(this).css('margin-top','0');
            $(this).css('margin-left',Math.round((tailleImage-width)/2)+'px');
        }
    });
    $('img.centrer1').bind("load",function(){
        tailleImage = parseInt($(this).parent().parent().css('width'));
        var tmp_img = new Image();
        tmp_img.src=$(this).attr('src');
        real_width = tmp_img.width;
        real_height = tmp_img.height;
        //alert(real_width+" & "+real_height);
        
        if(real_width >real_height ){
            $(this).attr("width",tailleImage+"px");
            height =  Math.round(real_height*tailleImage/real_width);
            $(this).attr("height",height+'px');
            $(this).css('margin-left','0');
            $(this).css('margin-top',Math.round((tailleImage-height)/2)+'px');
        }else{
            $(this).attr("height",tailleImage+"px");
            width = Math.round(real_width*tailleImage/real_height);
            $(this).attr("width",width+'px');
            $(this).css('margin-top','0');
            $(this).css('margin-left',Math.round((tailleImage-width)/2)+'px');
        }
    });   
});
