<?php
include("postget.php");
include_once("common.php");

if (isset($_SESSION['hd_accesslvl'])) {
	include("head_template.php");
}else{
	include("head_template_guest.php");
}

if ($config[82][1]==1) {
	selectthemecookie($theme);

	echo '
<div class="container">
	<div class="row">


<table width="98%" class="table table-bordered">
		<tr>
		<td align="center" width="100%">
';
	print '<b>'.ucfirst(_SELECT_THEME).'</b>';
echo '
		</td>
		</tr>
';	
echo '
			<tr valign="top">
				<td>

';

	
	if (substr($license,0,4)=='FREE') {
		echo messagetopinthispage(lang('_AVAILABLE_ONLY_IN_THE_PREMIUM_VERSION'),'',2);
	}
	
	echo $content;
echo '
		</td>
		</tr>
		</table>
</div>
</div>
';
	include("foot_template.php");
}


echo "</tr></table>";

function selectthemecookie() {
	$pagefrom = 'changetheme.php' ;

	global $theme, $content, $serverurl;

	$content = "";
	$handle=opendir('themes');
	while ($file = readdir($handle)) {
		if ( (!preg_match("/[.]/",$file)) ) {
			$themeslist .= "$file ";
		}
	}
	closedir($handle);
	$themeslist = explode(" ", $themeslist);
	sort($themeslist);
	$content .= "<br><table width='100%' border='0' align='center'><tr>";
	$conta=0;
	$images4line=6;
	for ($i=0; $i < sizeof($themeslist); $i++) {
		if($themeslist[$i]!="") {
			if ($conta==$images4line) {$content .= "<tr>"; $conta=0;}
			$content .= "<td align='center'>";
			$content .= "<a href='".$serverurl."/cookietheme.php?theme=$themeslist[$i]&file=$pagefrom'><img src=".$serverurl."/themes/".$themeslist[$i]."/thumbnail.jpg title='".$themeslist[$i]."' hspace='2' ";
			if($themeslist[$i]==$theme) {$content .= " border='5'";}else{$content .= " border='0'";};
			$content .= "></a>";
			$content .= "</td>";
			if ($conta==$images4line) {$content .= "</tr>"; $conta=0;}
			$conta++;
		}
	}
	$content .= "</tr></table>";
	return $content;
}


?>