<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

if( $this->params->get( 'checkbot' ) &&
	( !isset($GLOBALS['pdabot']['version']) || $GLOBALS['pdabot']['version']!='J100' ) )
	die('Inconsistency between versions of PDA-plugin and PDA-template.');

$contenttype='text/html';
switch( $this->params->get( 'content' ) )
{
case 1:
	$contenttype='application/vnd.wap.xhtml+xml';
	break;
case 2:
	$contenttype='application/xhtml+xml';
	break;
case 3:
	$contenttype='text/xhtml';
	break;
}
header('Content-type: '.$contenttype.'; charset=utf-8');

if( $this->params->get( 'xmlhead' ) )
        echo '<?xml version="1.0" encoding="utf-8" ?>',"\n";

switch( $this->params->get( 'doctype' ) )
{
case 1:
	echo '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">',"\n";
	break;
case 2:
	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',"\n";
	break;
case 3:
	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',"\n";
	break;
}

if( $this->params->get( 'xmlhead' ) )
	echo '<html xmlns="http://www.w3.org/1999/xhtml">',"\n";
else
	echo '<html>',"\n";
?>
<head>
<!-- remove from normal head-->
<meta http-equiv="Content-Type" content="<?php echo $contenttype; ?>; charset=utf-8" />
<!-- remove from normal head-->
<?php
if( $this->params->get( 'head' ) )
{
	$document=&JFactory::getDocument();
	echo '<title>', $document->getTitle(), '</title>',"\n";
}
else
	echo '<jdoc:include type="head" />',"\n";

if( $this->params->get( 'embedcss' ) )
{
	echo '<style>',"\n";
	@readfile(JPATH_SITE.'/templates/'.$this->template.'/css/template.css');
	echo '</style>',"\n";
}
else
	echo '<link href="', JURI::root(), 'templates/', $this->template, '/css/template.css" rel="stylesheet" type="text/css" />',"\n";
?>
</head>
<body>
<?php
$modulepos=$this->params->get( 'header1' );
if( $modulepos && $this->countModules($modulepos)>0) {
	?><div id="<?php echo $modulepos; ?>"><jdoc:include type="modules" name="<?php echo $modulepos; ?>" style="xhtml" /></div><?php
}

$modulepos=$this->params->get( 'header2' );
if( $modulepos && $this->countModules($modulepos)>0) {
	?><div id="<?php echo $modulepos; ?>"><jdoc:include type="modules" name="<?php echo $modulepos; ?>" style="xhtml" /></div><?php
}

if( $this->params->get( 'pathway' ) )
	if( !isset($GLOBALS['pdabot']['home']) || $this->params->get( 'pathwayhome' ) )
		echo '<div id="pathway"><jdoc:include type="module" name="breadcrumbs" style="none" /></div>',"\n";

$modulepos=$this->params->get( 'middle1' );
if( $modulepos && $this->countModules($modulepos)>0) {
	?><div id="<?php echo $modulepos; ?>"><jdoc:include type="modules" name="<?php echo $modulepos; ?>" style="xhtml" /></div><?php
}

$modulepos=$this->params->get( 'middle2' );
if( $modulepos && $this->countModules($modulepos)>0) {
	?><div id="<?php echo $modulepos; ?>"><jdoc:include type="modules" name="<?php echo $modulepos; ?>" style="xhtml" /></div><?php
}

if( !isset($GLOBALS['pdabot']['home']) || $this->params->get( 'componentonhome' ) )
	echo '<jdoc:include type="component" />',"\n";

$modulepos=$this->params->get( 'footer1' );
if( $modulepos && $this->countModules($modulepos)>0) {
	?><div id="<?php echo $modulepos; ?>"><jdoc:include type="modules" name="<?php echo $modulepos; ?>" style="xhtml" /></div><?php
}

$modulepos=$this->params->get( 'footer2' );
if( $modulepos && $this->countModules($modulepos)>0) {
	?><div id="<?php echo $modulepos; ?>"><jdoc:include type="modules" name="<?php echo $modulepos; ?>" style="xhtml" /></div><?php
}

if( $this->params->get( 'jfooter' ) )
	echo '<div id="jfooter"><jdoc:include type="module" name="footer" style="none" /></div>',"\n";
?></body></html>