function nrelate_related_ads_do_page()
{
    $options = get_option('nrelate_related_options');
    $style_options = get_option('nrelate_related_options_styles');
    ?>
	
	<?php 
    nrelate_related_settings_header();
    ?>
    <script type="text/javascript">
		//<![CDATA[
		var nr_plugin_settings_url = '<?php 
    echo NRELATE_RELATED_SETTINGS_URL;
    ?>
';
		var nr_plugin_domain = '<?php 
    echo NRELATE_BLOG_ROOT;
    ?>
';
		var nr_plugin_version = '<?php 
    echo NRELATE_RELATED_PLUGIN_VERSION;
    ?>
';
		//]]>
    </script>
		<form name="settings" action="options.php" method="post" enctype="multipart/form-action">
			<?php 
    settings_fields('nrelate_related_options_ads');
    ?>
			<?php 
    do_settings_sections(__FILE__);
    ?>
			
			<div class="nrelate-hidden">
		      <input type="hidden" id="related_number_of_posts" value="<?php 
    echo isset($options['related_number_of_posts']) ? $options['related_number_of_posts'] : '';
    ?>
" />
		      <input type="hidden" id="related_number_of_posts_ext" value="<?php 
    echo isset($options['related_number_of_posts_ext']) ? $options['related_number_of_posts_ext'] : '';
    ?>
" />
		      <input type="hidden" id="related_title" value="<?php 
    echo isset($options['related_title']) ? $options['related_title'] : '';
    ?>
" />
		      <input type="checkbox" id="related_show_post_title" <?php 
    echo empty($options['related_show_post_title']) ? '' : 'checked="checked"';
    ?>
 value="on" />
		      <input type="hidden" id="related_max_chars_per_line" value="<?php 
    echo isset($options['related_max_chars_per_line']) ? $options['related_max_chars_per_line'] : '';
    ?>
" />
		      <input type="checkbox" id="related_show_post_excerpt" <?php 
    echo empty($options['related_show_post_excerpt']) ? '' : 'checked="checked"';
    ?>
 value="on" />
		      <input type="hidden" id="related_max_chars_post_excerpt" value="<?php 
    echo isset($options['related_max_chars_post_excerpt']) ? $options['related_max_chars_post_excerpt'] : '';
    ?>
" />
		      <input type="checkbox" id="show_logo" <?php 
    echo empty($options['related_display_logo']) ? '' : 'checked="checked"';
    ?>
 value="on" />
		      <input type="hidden" id="related_thumbnail" value="<?php 
    echo isset($options['related_thumbnail']) ? $options['related_thumbnail'] : '';
    ?>
" />
		      <input type="hidden" id="related_textstyle" value="<?php 
    echo empty($style_options['related_text_style']) ? 'default' : $style_options['related_text_style'];
    ?>
" />
		      <input type="hidden" id="related_imagestyle" value="<?php 
    echo empty($style_options['related_thumbnails_style']) ? 'default' : $style_options['related_thumbnails_style'];
    ?>
" />
		      <input type="hidden" id="related_default_image" value="<?php 
    echo $options['related_default_image'];
    ?>
" />
		      <input type="hidden" id="related_max_age_num" value="<?php 
    echo $options['related_max_age_num'];
    ?>
" />
		      <input type="hidden" id="related_max_age_frame" value="<?php 
    echo $options['related_max_age_frame'];
    ?>
" />
		      <input type="hidden" id="related_blogoption" value="<?php 
    echo is_array($options['related_blogoption']) && count($options['related_blogoption'] > 0) ? 1 : 0;
    ?>
" />
		      <input type="hidden" id="related_thumbnail_size" value="<?php 
    echo $options['related_thumbnail_size'];
    ?>
" />
		      <input type="hidden" id="related_imagestyle" value="<?php 
    echo $style_options['related_thumbnails_style'];
    ?>
" />
		      <input type="hidden" id="related_textstyle" value="<?php 
    echo $style_options['related_text_style'];
    ?>
" />
			  <input type="hidden" id="related_blogoption" value="<?php 
    echo is_array($options['related_blogoption']) && count($options['related_blogoption'] > 0) ? 1 : 0;
    ?>
" />
		    </div>
		</form>

	</div>
<?php 
    update_nrelate_data_rc_adv();
}
function nrelate_related_do_page()
{
    // nrelated option loaded from wp db
    $options = get_option('nrelate_related_options');
    $ad_options = get_option('nrelate_related_options_ads');
    $style_options = get_option('nrelate_related_options_styles');
    ?>
	
	<?php 
    nrelate_related_settings_header();
    ?>
    <script type="text/javascript">
		//<![CDATA[
		var nr_plugin_settings_url = '<?php 
    echo NRELATE_RELATED_SETTINGS_URL;
    ?>
';
		var nr_plugin_domain = '<?php 
    echo NRELATE_BLOG_ROOT;
    ?>
';
		var nr_plugin_version = '<?php 
    echo NRELATE_RELATED_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['related_display_ad']) ? '' : 'checked="checked"';
    ?>
 value="on" />
      <input type="hidden" id="related_number_of_ads" value="<?php 
    echo isset($ad_options['related_number_of_ads']) ? $ad_options['related_number_of_ads'] : '';
    ?>
" />
      <input type="hidden" id="related_ad_placement" value="<?php 
    echo isset($ad_options['related_ad_placement']) ? $ad_options['related_ad_placement'] : '';
    ?>
" />
      <input type="hidden" id="related_ad_title" value="<?php 
    echo isset($ad_options['related_ad_title']) ? $ad_options['related_ad_title'] : '';
    ?>
" />
      <input type="checkbox" id="ad_animation" value="on" <?php 
    echo empty($ad_options['related_ad_animation']) ? '' : ' checked="checked" ';
    ?>
 />
      <input type="hidden" id="related_imagestyle" value="<?php 
    echo $style_options['related_thumbnails_style'];
    ?>
" />
      <input type="hidden" id="related_textstyle" value="<?php 
    echo $style_options['related_text_style'];
    ?>
" />
	  <input type="hidden" id="related_blogoption" value="<?php 
    echo is_array($options['related_blogoption']) && count($options['related_blogoption'] > 0) ? 1 : 0;
    ?>
" />
      </div>
     
			<?php 
    settings_fields('nrelate_related_options');
    ?>
			<?php 
    do_settings_sections(__FILE__);
    ?>
		</form>
    <script type="text/javascript">
		//<![CDATA[
		jQuery(document).ready(function($){
			$('.nrelate_preview_button').click(function(event){
				event.preventDefault();
				$(this).parents('form:first').find('.nrelate_disabled_preview span').hide();
				
				if ($('#related_thumbnail').val()=='Thumbnails') {
					if ($('#related_imagestyle').val()=='none') { $(this).parents('td:first').find('.thumbnails_message:first').show(); return; }
				} else {
					if ($('#related_textstyle').val()=='none') { $(this).parents('td:first').find('.text_message:first').show(); return; }
				}
				
				if ($('#related_thumbnail').val()=='Text') {
					if (!$('#related_show_post_title').is(':checked') && !$('#related_show_post_excerpt').is(':checked')) {
						$(this).parents('td:first').find('.text-warning-message:first').show();
						setTimeout('tb_remove()', 50);
						return;
					}
				}
			});
			
			$('#related_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 ($('#related_thumbnail').val()=='Thumbnails') return;
				if ($('#related_show_post_title').is(':checked')) return;
				if ($('#related_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_rc();
}