id = $id;
	}
	
	function note($n,$s) {
		$id=$this->id;
		$this->refs = true;
	
		return
			'
'.trim($s).
			" ^top". 
			'';
	}
	function footnotes($matches) {
	
		$str = '';
		return $str;
		
	}
	
	function references($matches) {
	
		$n = $matches[1];
		
		$id = $this->id;
		
		$href_rel = "{$id}-rel-{$n}";
		$href_note = "{$id}-fn-{$n}";
		
		return "{$n}";
	}
	
	function headings($matches) {
		$i = 7-strlen($matches[1]);
		return "{$matches[2]}";
		
	}
	
	
}
	
function plugin_footnotes_filter($text) {
	
	
	global $smarty;
	
	$footnotes_obj = new footnotes_class($id = $smarty->get_template_vars('id'));
		
	// *STRONG* emphasis
	$text = preg_replace('|(?\w)|xs', '$1', $text);
	// _emphasis_ (italic)
	$text = preg_replace('|(?\w)|xs', '$1', $text);
	
	// heading
	/*
	$text = preg_replace_callback(
					'(?\w)|xs'
					//'/\n(#{1,6})([^#]+)# * /', 
					array(&$footnotes_obj, 'headings'), 
					$text);
					
	*/
	
	
	
	$text = preg_replace_callback('|\n'. preg_quote(FOOTNOTES_START) .'\s*(.*)|sm', 
									array(&$footnotes_obj, 'footnotes'), 
									$text);
		
	// no [footnotes] references at the bottom of the page: stops							
	if (!$footnotes_obj->refs)
		return $text;
									
	$text = preg_replace_callback('|\[([0-9]+)\]|', 
									array(&$footnotes_obj, 'references'), 
									$text);
	
	
	return $text;
	
}
add_filter('the_content', 'plugin_footnotes_filter', 0);
?>