<?php
	global $mainframe;
	$document		=& JFactory::getDocument();
	$db 			=& JFactory::getDBO();
	$id				= JRequest::getVar( 'id', 0, '', 'int' );
	$option			= JRequest::getCmd( 'option' );

	// Get the current default template
	$query = 'SELECT template' .
			' FROM #__templates_menu' .
			' WHERE client_id = 0' .
			' AND menuid = 0';
	$db->setQuery($query);
	$template = $db->loadResult();

	// check if template editor stylesheet exists
	if (!file_exists( JPATH_SITE.DS.'templates'.DS.$template.DS.'css'.DS.'editor.css' )) {
		$template = 'system';
	}

	// Set page title
	$document->setTitle(JText::_('Article Preview'));
	$document->addStyleSheet(JURI::root() . 'templates/'.$template.'/css/editor.css');
	$document->setBase(JUri::root());

	$editor		=& JFactory::getEditor();
	$document	=& JFactory::getDocument();
	$document->setLink(JURI::root());
	JHTML::_('behavior.caption');
?>
	<script>
	var form = window.top.document.adminForm
	var title = form.name.value;
	var alltext = window.top.<?php echo $editor->getContent('body') ?>;
	alltext = alltext.replace(/<hr\s+id=(\"|')system-readmore(\"|')\s*\/*>/i, '');
	</script>
	<table align="center" width="90%" cellspacing="2" cellpadding="2" border="0">
		<tr>
			<td class="contentheading" colspan="2"><script>document.write(title);</script></td>
		</tr>
	<tr>
		<script>document.write("<td valign=\"top\" height=\"90%\" colspan=\"2\">" + alltext + "</td>");</script>
	</tr>
	</table>



