function ResizeGC() {
    var pos = $("#links_right").position();
    if ($("#links_left").width()+30 > pos.left && $("#links").hasClass("links_large")) {
        $("#links_right").removeClass("links_right_large").addClass("links_right_small");
        $("#links").removeClass("links_large").addClass("links_small");
    } else if ($("#links_left").width()+30 <= pos.left && $("#links").hasClass("links_small")) {
        $("#links_right").addClass("links_right_large").removeClass("links_right_small");
        $("#links").addClass("links_large").removeClass("links_small");
    }
    
    if ($("#sections").height() > $("#sections strong:first").height() && $("#sections").hasClass("sections_large")) {
        $("#sections").removeClass("sections_large").addClass("sections_small");
    }
    
    if ($("#sites").height() > $("#partenaires").height() && $("#sites").height() > $("#cercle").height()) {
        $("#gcfooter").height($("#sites").height()+$("#description").height());
    } else if ($("#partenaires").height() > $("#sites").height() && $("#partenaires").height() > $("#cercle").height()) {
        $("#gcfooter").height($("#partenaires").height()+$("#description").height());
    } else if ($("#cercle").height() > $("#sites").height() && $("#cercle").height() > $("#partenaires").height()) {
        $("#gcfooter").height($("#cercle").height()+$("#description").height());
    }
    
    $("#content .subcontent").each(function (i) {
        var pos_parent = $(this).position();
        var height_parent = $(this).height();
        var width_parent = $(this).width();

        $(this).find("img").each(function (i) {
            var pos_img = $(this).position();
            
            if ($(this).height() + pos_img.top + 20 > height_parent + pos_parent.top && $(this).css("float") != "none") {
                $(this).css("float", "none");
            }

            var pos_img = $(this).position();

            if ($(this).width() + pos_img.left + 30 > width_parent + pos_parent.left) {
                if ($(this).width() + 50 > width_parent) {
                    $(this).css("width", $(this).width()/2);
                    $(this).css("height", $(this).height()/2);
                } else {
                    $(this).css("float", "none");
                }
            }
        });
    });
}

$(document).ready(ResizeGC);
$(window).resize(ResizeGC);