jQuery(document).ready(function () {
    var $ = jQuery;
    
	$('#ads_space_header').append(createFrame('http://www.jta.org/ads/space/header', 728, 90));
	$('#ads_home_subheadlines_left').append(createFrame('http://www.jta.org/ads/space/home-subheadlines-left', 180, 150));
	$('#ads_home_subheadlines_right').append(createFrame('http://www.jta.org/ads/space/home-subheadlines-right', 180, 150));
	$('#ads_home_single').append(createFrame('http://www.jta.org/ads/space/home-single', 180, 150));
	$('#ads_sidebar_1').append(createFrame('http://www.jta.org/ads/space/sidebar-1-ad', 300, 75));
	$('#ads_sidebar_2').append(createFrame('http://www.jta.org/ads/space/sidebar-2-ad', 300, 250));
	$('#ads_sidebar_3').append(createFrame('http://www.jta.org/ads/space/sidebar-3-ad', 300, 250));
	$('#ads_sidebar_4').append(createFrame('http://www.jta.org/ads/space/sidebar-4-ad', 300, 250));
	
	function createFrame(src, width, height)
	{
	    var iframe = $('<iframe src="' + src + '" width="' + width + '" height="' + height + '" ' +
                'frameborder="0" scrolling="no" allowtransparency="true" hspace="0" ' + 
                'vspace="0" marginheight="0" marginwidth="0" style="float: left"></iframe>');
	    
	    
	    iframe.load(function() {
            if ($(this).contents().find('a').length > 0)
            {
                if ($(this).contents().find('a').attr('target') == '_self')
                {
                    $(this).contents().find('a').attr('target', '_parent');
                }
            }
	    });
	    
		return iframe;
	}
});

