function nrelate_popular_ads_do_page()
{
    $options = get_option('nrelate_popular_options');
    $style_options = get_option('nrelate_popular_options_styles');
    ?>
	
	<?php 
    nrelate_popular_settings_header();
    ?>
    <script type="text/javascript">
		//<![CDATA[
		var nr_mp_plugin_settings_url = '<?php 
    echo NRELATE_POPULAR_SETTINGS_URL;
    ?>
';
		var nr_plugin_domain = '<?php 
    echo NRELATE_BLOG_ROOT;
    ?>
';
		var nr_mp_plugin_version = '<?php 
    echo NRELATE_POPULAR_PLUGIN_VERSION;
    ?>
';
		//]]>
    </script>
		<form name="settings" action="options.php" method="post" enctype="multipart/form-action">
			<?php 
    settings_fields('nrelate_popular_options_ads');
    ?>
			<?php 
    do_settings_sections(__FILE__);
    ?>
			
			<div class="nrelate-hidden">
		      <input type="hidden" id="popular_number_of_posts" value="<?php 
    echo isset($options['popular_number_of_posts']) ? $options['popular_number_of_posts'] : '';
    ?>
" />
		      <input type="hidden" id="popular_number_of_posts_ext" value="<?php 
    echo isset($options['popular_number_of_posts_ext']) ? $options['popular_number_of_posts_ext'] : '';
    ?>
" />
		      <input type="hidden" id="popular_title" value="<?php 
    echo isset($options['popular_title']) ? $options['popular_title'] : '';
    ?>
" />
		      <input type="checkbox" id="popular_show_post_title" <?php 
    echo empty($options['popular_show_post_title']) ? '' : 'checked="checked"';
    ?>
 value="on" />
		      <input type="hidden" id="popular_max_chars_per_line" value="<?php 
    echo isset($options['popular_max_chars_per_line']) ? $options['popular_max_chars_per_line'] : '';
    ?>
" />
		      <input type="checkbox" id="popular_show_post_excerpt" <?php 
    echo empty($options['popular_show_post_excerpt']) ? '' : 'checked="checked"';
    ?>
 value="on" />
		      <input type="hidden" id="popular_max_chars_post_excerpt" value="<?php 
    echo isset($options['popular_max_chars_post_excerpt']) ? $options['popular_max_chars_post_excerpt'] : '';
    ?>
" />
		      <input type="checkbox" id="show_logo" <?php 
    echo empty($options['popular_display_logo']) ? '' : 'checked="checked"';
    ?>
 value="on" />
		      <input type="hidden" id="popular_thumbnail" value="<?php 
    echo $options['popular_thumbnail'];
    ?>
" />
		      <input type="hidden" id="popular_textstyle" value="<?php 
    echo empty($style_options['popular_text_style']) ? 'default' : $style_options['popular_text_style'];
    ?>
" />
		      <input type="hidden" id="popular_imagestyle" value="<?php 
    echo empty($style_options['popular_thumbnails_style']) ? 'default' : $style_options['popular_thumbnails_style'];
    ?>
" />
		      <input type="hidden" id="popular_default_image" value="<?php 
    echo $options['popular_default_image'];
    ?>
" />
		      <input type="hidden" id="popular_max_age_num" value="<?php 
    echo $options['popular_max_age_num'];
    ?>
" />
		      <input type="hidden" id="popular_max_age_frame" value="<?php 
    echo $options['popular_max_age_frame'];
    ?>
" />
		      <input type="hidden" id="popular_thumbnail_size" value="<?php 
    echo $options['popular_thumbnail_size'];
    ?>
" />
		      <input type="hidden" id="popular_imagestyle" value="<?php 
    echo $style_options['popular_thumbnails_style'];
    ?>
" />
		      <input type="hidden" id="popular_textstyle" value="<?php 
    echo $style_options['popular_text_style'];
    ?>
" />
		      <input type="hidden" id="popular_view" value="<?php 
    echo $options['popular_view'];
    ?>
" />
		       <input type="checkbox" id="popular_showviews" value="on" <?php 
    echo empty($options['popular_showviews']) ? '' : ' checked="checked" ';
    ?>
 />
		       <input type="checkbox" id="ad_animation" value="on" <?php 
    echo empty($options['popular_ad_animation']) ? '' : ' checked="checked" ';
    ?>
 />
		    </div>
		</form>

	</div>
<?php 
    update_nrelate_data_mp_adv();
}
function nrelate_popular_do_page()
{
    //Convert some visual option parameters for preview purposes
    $options = get_option('nrelate_popular_options');
    $ad_options = get_option('nrelate_popular_options_ads');
    $style_options = get_option('nrelate_popular_options_styles');
    ?>

		<?php 
    nrelate_popular_settings_header();
    ?>
		<script type="text/javascript">
			//<![CDATA[
			var nr_mp_plugin_settings_url = '<?php 
    echo NRELATE_POPULAR_SETTINGS_URL;
    ?>
';
			var nr_plugin_domain = '<?php 
    echo NRELATE_BLOG_ROOT;
    ?>
';
			var nr_mp_plugin_version = '<?php 
    echo NRELATE_POPULAR_PLUGIN_VERSION;
    ?>
';
			//]]>
		</script>
		<form name="settings" action="options.php" method="post" enctype="multipart/form-action">
	  <div class="nrelate-hidden">
	  <input type="checkbox" id="show_ad" <?php 
    echo empty($ad_options['popular_display_ad']) ? '' : 'checked="checked"';
    ?>
 value="on" />
      <input type="hidden" id="popular_number_of_ads" value="<?php 
    echo isset($ad_options['popular_number_of_ads']) ? $ad_options['popular_number_of_ads'] : '';
    ?>
" />
      <input type="hidden" id="popular_ad_placement" value="<?php 
    echo isset($ad_options['popular_ad_placement']) ? $ad_options['popular_ad_placement'] : '';
    ?>
" />
      <input type="hidden" id="popular_ad_title" value="<?php 
    echo isset($ad_options['popular_ad_title']) ? $ad_options['popular_ad_title'] : '';
    ?>
" />
      <input type="checkbox" id="ad_animation" value="on" <?php 
    echo empty($ad_options['popular_ad_animation']) ? '' : ' checked="checked" ';
    ?>
 />
      <input type="hidden" id="popular_imagestyle" value="<?php 
    echo $style_options['popular_thumbnails_style'];
    ?>
" />
      <input type="hidden" id="popular_textstyle" value="<?php 
    echo $style_options['popular_text_style'];
    ?>
" />
	</div>
			<?php 
    settings_fields('nrelate_popular_options');
    ?>
			<?php 
    do_settings_sections(__FILE__);
    ?>
		</form>
    	<script type="text/javascript">
		//<![CDATA[
		jQuery(document).ready(function($){
			$('.nrelate_mp_preview_button').click(function(event){
				event.preventDefault();
				$(this).parents('form:first').find('.nrelate_disabled_preview span').hide();
				
				if ($('#popular_thumbnail').val()=='Thumbnails') {
					if ($('#popular_imagestyle').val()=='none') { $(this).parents('td:first').find('.thumbnails_message:first').show(); return; }
				} else {
					if ($('#popular_textstyle').val()=='none') { $(this).parents('td:first').find('.text_message:first').show(); return; }
				}
				
				if ($('#popular_thumbnail').val()=='Text') {
					if (!$('#popular_show_post_title').is(':checked') && !$('#popular_show_post_excerpt').is(':checked')) {
						$(this).parents('td:first').find('.text-warning-message:first').show();
						setTimeout('tb_remove()', 50);
						return;
					}
				}
			});
			
			$('#popular_thumbnail').change(function(){
				$(this).parents('form:first').find('.nrelate_disabled_preview span').hide();
			});
			
			$('input.button-primary[name="Submit"]').click(function(event){
				$(this).parents('form:first').find('.nrelate_disabled_preview span').hide();
				
				if ($('#popular_thumbnail').val()=='Thumbnails') return;
				if ($('#popular_show_post_title').is(':checked')) return;
				if ($('#popular_show_post_excerpt').is(':checked')) return;
				event.preventDefault();
				event.stopPropagation();
				$(this).parents('td:first').find('.text-warning-message:first').show();
			});
		});
		//]]>
    </script>
	</div>
<?php 
    update_nrelate_data_mp();
}