<?

class template {

function template($public = "") {
	$this->public = $public;
}


function btn($value, $onclick, $width="", $forJS=false, $extra="", $return=false) {

if ($forJS) {
	global $str;
	ob_start();
}
?>
<table border="0" cellspacing="0" cellpadding="0" class="button" <?echo $width?"style=\"width:$width\"":"";?> <?echo $onclick?"onclick=\"javascript:$onclick\"":"";?> onkeydown="this.onclick()"><tr><td align="center" <?echo $extra;?>><?echo $value;?></td></tr></table>
<?
	if ($forJS) {
	$buff = ob_get_contents();
	ob_end_clean();
	if (!$return) {
	echo $str->HTMLforSafeJS($buff);
	} else {
	return $str->HTMLforSafeJS($buff);
	}
	}
}



function startMenu($id, $title, $width, $height="80") {

if ($width < 1) {
	$width="220";
}

if ($height < 1) {
	$height="80";
}

?>
<div id="<?echo $id?>" style="position:absolute;top:0px;left:0px;visibility:hidden;width:<?echo $width?>px;height:<?echo $height?>px;z-index:120">
<!-- dialogbox-->
<table border="0" cellpadding="0" cellspacing="0"  style="width:<?echo $width?>px;height:<?echo $height?>px">
<tr><td style="height:22px;">

<div id="<?echo $id?>_menu_title_bar">
<table border="0" cellpadding="0" cellspacing="0" class="dialogboxTitle">
<tr><td width="6"><img src="<?if($this->public){echo "../";}?>images/interface/a-left.gif" border="0"></td>
<!-- dialogbox TITLE TEXT-->
<td class="dialogboxTitleText">
<?echo strtoupper($title)?>
</td>
<!-- END dialogbox TITLE TEXT-->
<td style="vertical-align:middle;padding-right:3px;padding-top:3px;"><a href="javascript:hideMenu('<?echo $id?>')" onfocus="javascript:blur()" onclick="javascript:if(Afian.hasIcons){afianOnSelect();}"><img src="<?if($this->public){echo "../";}?>images/interface/menutitleright.gif" border="0" alt="Close menu"></a></td>
<td width="3"><img src="<?if($this->public){echo "../";}?>images/interface/a-right.gif" border="0"></td>
</tr></table>
</div>

</td>

<tr><td class="dialogboxMargins">

<table border="0" cellpadding="0" cellspacing="0" style="background-color:white;width:100%;height:100%;"><tr><td class="dialogboxInterior" align="center">

<?
}
function endMenu() {
?>
</td></tr></table>
</td></tr></table>
<!-- END dialogbox -->
</div>
<?
}


function startFormBlock($width="300", $height="160") {
?>
<div style="
border-right:1px solid white;
border-bottom: 1px solid white;
width:<?echo $width;?>px;
height:<?echo $height;?>px;
margin:5px;
float:left;
">

<div style="
border:1px solid gray;
width:<?echo $width-1;?>px;
height:<?echo $height-1;?>px;
background-color:#F2F2F2;">

<div style="
border-top:1px solid white;
border-left: 1px solid white;
float:left;
width:<?echo $width-2;?>px;
height:<?echo $height-2;?>px;
">

<?
}

function endFormBlock() {
?>
</div>
</div>
</div>
<?
}


function status2Popup($statusBarMessage, $baseURL = "") {
	if (is_array($statusBarMessage)) {
?>
<div style="position:absolute;top:0;left:0;visibility:hidden" id="popmenu-notice">
<table cellspacing="0" cellpadding="0" border="0" width="260" height="120">
<tr id="popmenu-titlebar-notice">
    <td width="9" height="21"><img src="<?echo $baseURL?>images/interface/popmenu/sp-titlebar-top-left.gif" width="9" height="21" alt="" border="0"></td>
    <td background="<?echo $baseURL?>images/interface/popmenu/sp-titlebar-top-bg.gif" style="background-repeat:repeat-x;font-weight:bold" align="center">Notice</td>
    <td width="11" height="21"><img src="<?echo $baseURL?>images/interface/popmenu/sp-titlebar-top-right.gif" width="11" height="21" alt="" border="0"></td>
</tr>
<tr>
    <td width="9" height="5"><img src="<?echo $baseURL?>images/interface/popmenu/sp-titlebar2-top-left.gif" width="9" height="5" alt="" border="0"></td>
    <td height="5" background="<?echo $baseURL?>images/interface/popmenu/sp-titlebar2-top-bg.gif" style="background-repeat:repeat-x"><img src="<?echo $baseURL?>images/interface/pixel.gif" width="1" height="5" border="0" alt=""></td>
    <td width="11" height="5"><img src="<?echo $baseURL?>images/interface/popmenu/sp-titlebar2-top-right.gif" width="11" height="5" alt="" border="0"></td>
</tr>
<tr>
    <td width="9" background="<?echo $baseURL?>images/interface/popmenu/sp-left.gif" style="background-repeat:repeat-y"><img src="<?echo $baseURL?>images/interface/pixel.gif" width="9" height="1" border="0" alt=""></td>
    <td style="background-color:#E4E4E4;padding-left:20px;padding-right:20px;padding-top:10px" align="center">

<?
for ($i = 0 ; $i < sizeof($statusBarMessage) ; $i++) {
	if($statusBarMessage[$i][1]){?>
	<span style="color:red;">
	<?echo $statusBarMessage[$i][0];?>
	</span>
	<?
	}else{
		echo $statusBarMessage[$i][0];
	}
	if ($i < sizeof($statusBarMessage)-1) {echo "<br>";}
}
?>

</td>
    <td width="11" background="<?echo $baseURL?>images/interface/popmenu/sp-right.gif" style="background-repeat:repeat-y"><img src="<?echo $baseURL?>images/interface/pixel.gif" width="9" height="1" border="0" alt=""></td>
</tr>
<tr>
    <td width="9" height="44"><img src="<?echo $baseURL?>images/interface/popmenu/sp-bottom-left.gif" width="9" height="44" alt="" border="0"></td>
    <td height="44" background="<?echo $baseURL?>images/interface/popmenu/sp-bottom-bg.gif" style="background-repeat:repeat-x" align="center">

<?
$this->btn(
$value="   OK   ", 
$onclick="hideMenu('popmenu-notice');"
)
?>

</td>
    <td width="11" height="44"><img src="<?echo $baseURL?>images/interface/popmenu/sp-bottom-right.gif" width="11" height="44" alt="" border="0"></td>
</tr>
</table>
</div>


<script language="JavaScript1.2" type="text/javascript">
titleDrag('notice');
centeredMenu('popmenu-notice');
</script>

<?
	}
}





	function startPopup($title) {
		$title = strtoupper($title);
?>
<table cellspacing="0" cellpadding="0" border="0" class="popupContents">
<tr>
    <td class="popupTitleArea" style="padding:7px;">&nbsp;
<span class="popupTitleTextNormal"><?echo $title;?></span>
<span class="popupTitleTextShadow"><?echo $title;?></span>
</td>
</tr>

<!-- POPUP CONTENTS -->
<tr>
<td style="border-top:1px solid white;padding-left:12px;padding-right:12px">
<?
	}

	function endPopup() {
?>
<!-- POPUP CONTENTS -->
</td></tr></table>
<?
	}

	function displayMessages($messages) {
		global $str;
	$s = "";
	for ($i = 0 ; $i < sizeof($messages) ; $i++) {
		if($messages[$i][1]){
			$s .= "<span style=\"color:red;\">";
			$s .= $messages[$i][0];
			$s .= "</span>";
		
		}else{
			$s .= $messages[$i][0];
		}
			if ($i < sizeof($messages)-1) {
			$s .=  "<br>";
			}
		}
		echo "parent.AfianAlert('".$str->safeJS($s)."');";
	}



}
?>