﻿$(function () {
    // thanks: http://www.google.com/support/forum/p/Google+Ad+Manager/thread?tid=7bcfaa482259cc28&hl=en
    $('#hiddenAds div').each(function () {
        var id = this.id.replace(/-hidden/, '');
        var pos = $('#' + id).position();

        if (pos) {
            // Show the ad container directly over the placeholder
            $(this).css({
                'left': pos.left + 'px',
                'top': pos.top + 'px'
            });

            // resize the placeholder to match the size of the ad container
            $('#' + id).height($(this).height() + 5);
            $('#' + id).width($(this).width());
        }
    });

    // re-place ads when the window scrolls, or when content containers are resized.
    $(window).scroll(WCH.RepositionAds);
    $('#main, #flash').resize(WCH.RepositionAds);

    WCH.RepositionAds();
});