<?
function get_props($dir,$type)
{
	$file = get_file($dir,"style.inc");
	if (!empty($file))
	{
		include($file);
	}
	if (empty($tb_cs))
		$tb_cs="4";
	if (empty($tb_cp))
		$tb_cp="2";
	if (empty($tb_bd))
		$tb_bd="2";
	if (empty($bd_bg))
		$bd_bg="white";
	$body = "";
	if (!empty($bd_bg))			# next line overrides this
		$body = "background=$bd_bg";
	if (!empty($bd_cl))
		$body .= " bgcolor=$bd_cl";
	if (!empty($bd_tx))
		$body .= " text=$bd_tx";
	if (!empty($bd_lk))
		$body .= " link=$bd_lk";
	if (!empty($bd_vk))
		$body .= " vlink=$bd_vk";
	if (!empty($bd_ak))
		$body .= " alink=$bd_ak";
	$tb_props = "CELLSPACING=$tb_cs CELLPADDING=$tb_cp BORDER=$tb_bd " . $tb_props;
	if ($type == "T")
		return $tb_props;
	else
		return $body;
}
/******************************************************
*	this builds a head and surrounds
*	There are two style
*	If head.inc exists it is assumed to include body style
*	Else side.inc and style.inc are used
*******************************************************/
#try to get table propertities
#If $localpage set then assume called from add or viewcart.htm in cart
function standard($dir,$sub)
{
	global	$localpage,$tb_props,$head_set;
	global	$domain,$HTTPS,$SSL_BASE;
	global	$HTTP_REFERER;

	if (!empty($domain))
	{
		if ($HTTPS == "on")
			$ref="https://$domain/";
		else
			$ref="http://$domain/";
		$SSL_BASE=$ref;
	}
	$body=get_props($dir,"B");

	if (empty($localpage))
		return;
	form_head($dir,$sub);
	echo "<body $body>";
	echo "<A NAME=_top></A>";
				#Output client name if not using his own page

	$res=ms_query("select name from client where id = '$dir'");
	$name=@db_result($res,0,"name");
	echo "\n<TABLE CELLPADDING=0 CELLSPACING=5 BORDER=0 WIDTH=100%>";
	echo "\n<TR ALIGN=CENTER>";
	echo "\n<TD ALIGN=CENTER VALIGN=TOP>\n";
	echo "<A HREF=$HTTP_REFERER><BIG><BIG>$name</BIG></BIG></A>";
	echo "\n</TD></TR></TABLE>\n";
}
function get_file($dir,$file)
{
	global	$DBS,$AP;

	if (file_exists("$DBS/$dir/$file"))
		return "$DBS/$dir/$file";
	elseif (file_exists("$AP/stores/client/$dir/$file"))
		return "$AP/stores/client/$dir/$file";
	elseif (file_exists("/usr/local/stronghold/htdocs/stores/client/$dir/$file"))
		return "/usr/local/stronghold/htdocs/stores/client/$dir/$file";
	else
		return "";
}
function form_head($dir,$sub)
{
	global	$control,$head_set;

	if ($head_set == 'Y') return;
	$head_set = "Y";
	echo "<HTML>";
	echo "<HEAD>";
	echo "<META NAME=Author Content=jawjb@bullnet.co.uk>\n";

	$titl = "A1 Printer Supplies from Pinkjets";

	if (!empty($dir))
	{
		$res = @ms_query("select * from $control where id = '$dir'");
		$num = @db_numrows($res);
		if ($num > 0)
		{
			$titl = db_result($res,0,"description");
			$titl .= $sub;
			$keys .= db_result($res,0,"keywords");
		}
	}
	echo "<META NAME=KEYWORDS CONTENT='$keys'>\n";
	echo "<META HTTP-EQUIV=KEYWORDS CONTENT='$keys'>\n";
	echo "<META NAME=DESCRIPTION CONTENT='$titl'>\n";
	echo "<TITLE>$titl</TITLE>\n";
	echo "</HEAD>\n";
}
function h_coltop($dir)
{
	global	$domain,$HTTPS,$dbname;

	$file = get_file($dir,"head.inc");

	if (!empty($file))
	{
		include($file);
	}
	echo "<CENTER>";
	if (!empty($dir))
	{
		echo "<A HREF=http://$domain>Return to Home page</A></BR>";
	}
	else
		echo "<A HREF=http://www.bullnet.co.uk>Check our services</A></BR>";
	echo "</CENTER>";

}
function foot($dir)
{
	global $foot_set,$localpage,$side_set,$WCAR;

	if (empty($localpage)) return;
	if ($foot_set == "Y") return;
	$foot_set="Y";
	echo	"</BODY>";
	echo	"</HTML>";
}
?>
