# COMMON HTML BLOCKS USED PUBLIC PAGES

#start smile_list
if (!exists $vars_graemlins->{'graems'}) {
	require "$vars_config{VariablesPath}/vars_graemlins.cgi";
}

$smile_list = "";

my $count = 1;
foreach my $item (sort keys %{$vars_graemlins->{'origs'}}) {
	my $short  = %$vars_graemlins->{'origs'}->{$item};
	my $break  = "<br />" if (($count / 6) == int($count / 6));
	my $before = "";                                              # &nbsp\;" if($count == 1);
	my $after  = " &nbsp\;";
	$smilie_list .= qq($before <a href="javascript: x()" onClick="DoSmilie(' $short->{'trigger'} ');"><img src="$vars_config{NonCGIURL}/$short->{'image'}" border="0" alt="$short->{'text'}"></a> $after $break\n);
	$count++;
}    #endforeach

foreach my $item (sort keys %{$vars_graemlins->{'graems'}}) {
	my $short  = %$vars_graemlins->{'graems'}->{$item};
	my $break  = "<br />" if (($count / 6) == int($count / 6));
	my $before = "";                                              # &nbsp\;" if($count == 1);
	my $after  = " &nbsp\;";
	$smilie_list .= qq($before <a href="javascript: x()" onClick="DoSmilie(' :$short->{'trigger'}: ');"><img src="$vars_config{NonCGIURL}/graemlins/$short->{'image'}" border="0" alt="$short->{'text'}"></a> $after $break\n);
	$count++;
}    #endforeach
     #end smile_list


$instant_jscript = qq~
<script language="JavaScript">
<!--
function x () {
return;
}

function DoSmilie(addSmilie) {
	var revisedMessage;
	var currentMessage = document.REPLIER.message.value;
	revisedMessage = currentMessage+addSmilie;
	document.REPLIER.message.value=revisedMessage;
	document.REPLIER.message.focus();
	return;
}

function DoPrompt(action) {
	var revisedMessage;
	var currentMessage = document.REPLIER.message.value;


	if (action == "url") {
	var thisURL = prompt("$vars_wordlets{enter_url}", "http://");
	var thisTitle = prompt("$vars_wordlets{enter_title}", "web page");
var urlUBBCode = "[URL="+thisURL+"]"+thisTitle+"[/URL]";
	revisedMessage = currentMessage+urlUBBCode;
	document.REPLIER.message.value=revisedMessage;
	document.REPLIER.message.focus();
	return;
	}

	if (action == "email") {
	var thisEmail = prompt("$vars_wordlets{enter_email}", "");
	var emailUBBCode = "[EMAIL]"+thisEmail+"[/EMAIL]";
	revisedMessage = currentMessage+emailUBBCode;
	document.REPLIER.message.value=revisedMessage;
	document.REPLIER.message.focus();
	return;
	}

	if (action == "bold") {
	var thisBold = prompt("$vars_wordlets{enter_bold}", "");
	var boldUBBCode = "[B]"+thisBold+"[/B]";
	revisedMessage = currentMessage+boldUBBCode;
	document.REPLIER.message.value=revisedMessage;
	document.REPLIER.message.focus();
	return;
	}

	if (action == "italics") {
	var thisItal = prompt("$vars_wordlets{enter_italics}", "");
	var italUBBCode = "[I]"+thisItal+"[/I]";
	revisedMessage = currentMessage+italUBBCode;
	document.REPLIER.message.value=revisedMessage;
	document.REPLIER.message.focus();
	return;
	}

	if (action == "image") {
	var thisImage = prompt("$vars_wordlets{enter_image}", "http://");
	var imageUBBCode = "[IMG]"+thisImage+"[/IMG]";
	revisedMessage = currentMessage+imageUBBCode;
	document.REPLIER.message.value=revisedMessage;
	document.REPLIER.message.focus();
	return;
	}

	if (action == "quote") {
	var quoteUBBCode = "[QUOTE]  [/QUOTE]";
	revisedMessage = currentMessage+quoteUBBCode;
	document.REPLIER.message.value=revisedMessage;
	document.REPLIER.message.focus();
	return;
	}

	if (action == "code") {
	var codeUBBCode = "[CODE]  [/CODE]";
	revisedMessage = currentMessage+codeUBBCode;
	document.REPLIER.message.value=revisedMessage;
	document.REPLIER.message.focus();
	return;
	}

	if (action == "liststart") {
	var liststartUBBCode = "[LIST]";
	revisedMessage = currentMessage+liststartUBBCode;
	document.REPLIER.message.value=revisedMessage;
	document.REPLIER.message.focus();
	return;
	}

	if (action == "listend") {
	var listendUBBCode = "[/LIST]";
	revisedMessage = currentMessage+listendUBBCode;
	document.REPLIER.message.value=revisedMessage;
	document.REPLIER.message.focus();
	return;
	}
	if (action == "listitem") {
	var thisItem = prompt("$vars_wordlets{enter_list_item2}", "");
	var itemUBBCode = "[*]"+thisItem;
	revisedMessage = currentMessage+itemUBBCode;
	document.REPLIER.message.value=revisedMessage;
	document.REPLIER.message.focus();
	return;
	}

	}
//-->
</script>
~;

sub set_page_elements {
	local ($rn, $rn2, @table_borders, $page_background);
	if (($vars_style{Header} ne '') || ($vars_style{Footer} ne '')) {

		#create random numbers for headers/footers
		$rn  = &make_random_number;
		$rn2 = $rn + 823;

		if ($vars_style{Header} ne '') {
			$vars_style{Header} =~ s/UBBrandomX/$rn/isg;
			$vars_style{Header} =~ s/UBBrandomY/$rn2/isg;
		}
		if ($vars_style{Footer} ne '') {
			$vars_style{Footer} =~ s/UBBrandomX/$rn/isg;
			$vars_style{Footer} =~ s/UBBrandomY/$rn2/isg;
		}
	}

	if ($vars_style{PageBackground} ne '') {
		$page_background = qq!background="$vars_config{NonCGIURL}/$vars_style{PageBackground}"!;
	} else {
		$page_background = '';
	}


	$standard_title_table = qq~
<TABLE border="0" width="$vars_style{TableWidth}">
<TR>
<TD align="center" colspan="2">
<B>
<FONT size="5" face="$vars_style{FontFace}" color="blue">$vars_config{BBName}</FONT></B>
<br>
<FONT size="2" face="$vars_style{FontFace}">
$MainButtonsLine
</FONT>
</TD></TR></TABLE>
~;


	$search_standard_title_table = qq~
<TABLE border="0" width="$vars_style{TableWidth}">
<TR>
<TD align="center" colspan="2">
<B>
<FONT size="5" face="$vars_style{FontFace}" color="blue">$vars_config{BBName} - поиск</FONT></B>
<br>
<FONT size="2" face="$vars_style{FontFace}">
$MainButtonsLine
</FONT>
</TD></TR></TABLE>
~;

	$show_logout = qq~
<script language="JavaScript">
<!--
var user_cookie = getCookie('ubber$vars_config{Cookie_Number}');
if(''==user_cookie ||  null==user_cookie) {
document.writeln('$vars_wordlets{not_logged_in}' , ' <a href="$vars_config{CGIURL}/ultimatebb.cgi?ubb=login">$vars_wordlets{login_now}</a> $vars_wordlets{or} <a href="$vars_config{CGIURL}/ultimatebb.cgi?ubb=agree">$vars_wordlets{register_link}</a>')
} else {

var user_array=user_cookie.split("&");
user_array[2] = unescape(user_array[2]);
realusername=converter(user_array[2]);
document.writeln('$vars_wordlets{hello}  ',realusername, '</U>')// for [192-255] delta=+848;
function converter( strSource ){  var c;  strDestination='';
  ie = (document.all)? true : false;
  if (ie) {    for (i=0;i<strSource.length;i++)    {     c=strSource.charCodeAt(i);
       if (c>=192 && c<=255) { c+=848; }      strDestination+=String.fromCharCode(c);
    }  } else strDestination=strSource;
  return strDestination;}



document.writeln('[ <a href="$vars_config{CGIURL}/ultimatebb.cgi?ubb=logoff">'
,'<acronym title="$vars_wordlets{logout_acronym}">'
,'$vars_wordlets{logout}</acronym></a> ]');

}
//-->
</script>
~ unless ($vars_registration{DisplayRegistration} ne "YES");


	$show_logout_noreg = qq~
<script language="JavaScript">
<!--
var user_cookie = getCookie('ubber$vars_config{Cookie_Number}');
if(''==user_cookie ||  null==user_cookie) {
document.writeln('$vars_wordlets{not_logged_in}');
} else {

var user_array=user_cookie.split("&");
user_array[2] = unescape(user_array[2]);
document.writeln('$vars_wordlets{hello} ', user_array[2]);
document.writeln('[ <a href="$vars_config{CGIURL}/ultimatebb.cgi?ubb=logoff">'
,'<acronym title="$vars_wordlets{logout_acronym}">'
,'$vars_wordlets{logout}</acronym></a> ]');

}
//-->
</script>
~ unless ($vars_registration{DisplayRegistration} ne "YES");


	my $charsetmeta = "";
	if ($masterCharset) {
		$charsetmeta = qq(<meta http-equiv="Content-Type" content="text/html; charset=$masterCharset">);
	}    #endif

	#stupid unintialized values....
	my $htmltag;
	if (exists $vars_style{html_extra}) {
		$htmltag = "<html $vars_style{html_extra}>";
	} else {
		$htmltag = "<html>";
	}

	if ($title_wording) {
		$title_wording = ": $title_wording ";
	} else {
		$title_wording = "";
	}

	unless ($direct_to) {
		$direct_to = "";
	}

	unless ($vars_style{HeaderInsert}) {
		$vars_style{HeaderInsert} = "";
	}


	$Header = qq~
$htmltag
<HEAD>

$charsetmeta

<script language="JavaScript1.1">
<!--

var session_cookie = getCookie('session$vars_config{Cookie_Number}');
if (session_cookie == null) {
	var session_dt = "0";
	var session_j = "0";
}  else {
	var session_array = session_cookie.split("&");
	var session_dt = session_array[0];
	var session_j = session_array[1];
}

function getCookie(name) {
     var cname = name + "=";
        var dc = document.cookie;

        if (dc.length > 0) {

             begin = dc.indexOf(cname);

        	 if (begin != -1) {
                begin += cname.length;
        		end = dc.indexOf(";", begin);

                    if (end == -1) end = dc.length;

                    return (dc.substring(begin, end));
             }
        }
        return null;
    }

//-->
</script>

<TITLE>$vars_config{BBName}$title_wording</TITLE>

<META HTTP-EQUIV="Pragma" CONTENT="no-cache" />

	$direct_to

	$vars_style{HeaderInsert}

</HEAD>

<BODY $page_background BGCOLOR="$vars_style{BGColor}" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" text="$vars_style{TextColor}" link="$vars_style{LinkColor}" vlink="$vars_style{VisitedLinkColor}" alink = "$vars_style{ActiveLinkColor}" marginwidth="0" marginheight="0"  $vars_style{body_extra}>


$vars_style{Header}

~;

	local ($contact_url);

	if ($vars_display{ContactLinkType} ne 'Email') {
		$contact_url = qq!$vars_display{ContactURL}!;
	} else {
		$contact_url = qq!mailto:$vars_display{BBEmail}!;
	}

	my $ContactLine = qq!<A HREF="$contact_url">$vars_wordlets{contact_us}</A> | <A HREF="$vars_display{HomePageURL}">$vars_display{MyHomePage}</A> !;

	if ($vars_display{ShowPrivacyLink} eq "ON") {
		$ContactLine .= qq!| <A HREF="$vars_display{PrivacyURL}">$vars_wordlets{privacy_statement_link}</A>!;
	}

	$Footer = qq~

$vars_style{Footer}

</BODY>
</HTML>
~;

	# simplified header for emails...
	$EmailHeader = qq~
<HTML>
<HEAD>
	<TITLE>$vars_config{BBName} : powered by Infopop</TITLE>

</HEAD>

<BODY $page_background BGCOLOR="$vars_style{BGColor}" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" text="$vars_style{TextColor}" link="$vars_style{LinkColor}" vlink="$vars_style{VisitedLinkColor}" alink = "$vars_style{ActiveLinkColor}" marginwidth="0" marginheight="0">

$vars_style{Header}

~;


	# set table border display
	if ($vars_style{table_border_display} eq '3') {

		$table_borders[0] = '2';
		$table_borders[1] = '0';
		$table_borders[2] = '4';
		$table_borders[3] = '1';

	} elsif ($vars_style{table_border_display} eq '2') {
		$table_borders[0] = '0';
		$table_borders[1] = '1';
		$table_borders[2] = '4';
		$table_borders[3] = '1';
	} else {

		$table_borders[0] = '1';
		$table_borders[1] = '1';
		$table_borders[2] = '3';
		$table_borders[3] = '0';

	}

	$TBT = qq(
<center>
<table border="0" cellpadding="$table_borders[0]" cellspacing="$table_borders[1]" width="$vars_style{TableWidth}">
<tr bgcolor="$vars_style{TableBorderColor}"><td>
<table border="0" width="100%" cellpadding="$table_borders[2]" cellspacing="$table_borders[3]">
);

	$TBB = qq(
</table></td></tr></table>
</center>
);

}    #end Set Page Elements


sub Transition {

	# requires three parameters:
	# $_[0] : URL we are forwarding user to
	# $_[1] : Thank you wording
	# $_[2] : URL Link Wording

	$_[0] =~ s/\&/\&amp\;/g;
	$direct_to = qq!<meta http-equiv="refresh" content="3; URL=$_[0]">!;

	&set_page_elements;

	print <<THIS;

$Header
<center>
$standard_title_table
</center>
<P>

$TBT

<TR bgcolor="$vars_style{AltColumnColor1}">
<TD valign="bottom" align="left">
<FONT size="1" face="$vars_style{FontFace}">
<B>&#187;
$show_logout
 </B>
</font>
</TD>
<TD valign="bottom" align="right">
<FONT size="1" face="$vars_style{FontFace}"><B>
<a href="$vars_config{CGIURL}/ultimatebb.cgi">$vars_config{BBName}</a> &raquo; $vars_wordlets{transition}</B>
</font>
</TD>
</TR>

$TBB

<P>

$TBT

<TR bgcolor="$vars_style{TableColorStrip}">
<TD>
<FONT COLOR="$vars_style{TableStripTextColor}" SIZE="$vars_style{TextSize}" FACE="$vars_style{FontFace}"><B>
$vars_wordlets{transition}
</B></FONT>
</TD>
</TR>

<TR bgcolor="$vars_style{AltColumnColor1}"><TD>
<FONT SIZE="$vars_style{TextSize}" FACE="$vars_style{FontFace}"><B>
$_[1]
<P><BR>
$vars_wordlets{transition_wording}
<A HREF="$_[0]">$_[2]</A>
</B></FONT>
</TD></TR>

$TBB
<P>

$Footer

THIS

}    #end Transition

sub StandardHTML {

	print header(
		-charset => "$masterCharset",
		-type    => "text/html",
	);

	local ($goback);
	&set_page_elements;

	if (($in{refer}) && ($in{refer} !~ /logoff$/)) {
		$goback = qq!<A HREF="$in{refer}">$in{refer}</A>!;
	} else {
		$goback = "$vars_wordlets_err{use_back_button}";
	}

	print <<THIS_PAGE;

$Header

<center>
<TABLE border="0" width="$vars_style{TableWidth}">
<TR>
<TD align="center" colspan="2">
<B><FONT size="5" face="$vars_style{FontFace}" color="blue">$vars_config{BBName}</FONT></B>
<br>
<FONT size="2" face="$vars_style{FontFace}" >
$MainButtonsLine
</FONT>
</TD></TR></TABLE>
</center>
<P>
$TBT

<TR bgcolor="$vars_style{AltColumnColor1}">
<TD valign="bottom" align="left">
<FONT size="1" face="$vars_style{FontFace}">
<B>
&#187; $show_logout
</B>
</font>
</TD>
<TD valign="bottom" align="right">
<FONT size="1" face="$vars_style{FontFace}"><B>
<a href="$vars_config{CGIURL}/ultimatebb.cgi">$vars_config{BBName}</a> &raquo; $vars_wordlets{fyi}</B>
</font>
</TD>
</TR>
$TBB
<P>

$TBT

<TR bgcolor="$vars_style{TableColorStrip}">
<TD>
<FONT COLOR="$vars_style{TableStripTextColor}" SIZE="$vars_style{TextSize}" FACE="$vars_style{FontFace}"><B>
$vars_wordlets{fyi}
</B></FONT>
</TD>
</TR>

<TR bgcolor="$vars_style{AltColumnColor1}"><TD>
<FONT SIZE="$vars_style{TextSize}" FACE="$vars_style{FontFace}">
<B>$_[0]</B>
<P>
&#187; $goback
</FONT>
</TD></TR>

$TBB
<P>

$Footer

THIS_PAGE

	exit(0);
}    #end StandardHTML



#version used when die() is called
#minor changes, uses vars_wordlets_err{error} rather than fyi, etc
sub StandardHTML2 {

	print header(
		-charset => "$masterCharset",
		-type    => "text/html",
	);

	local ($goback);
	&set_page_elements;

	print <<THIS_PAGE;

$Header

<center>
<TABLE border="0" width="$vars_style{TableWidth}">
<TR>
<TD align="center" colspan="2">
<B><FONT size="5" face="$vars_style{FontFace}" color="blue">$vars_config{BBName}</FONT></B>
<br>
<FONT size="2" face="$vars_style{FontFace}" >
$MainButtonsLine
</FONT>
</TD></TR></TABLE>
</center>
<P>
$TBT

<TR bgcolor="$vars_style{AltColumnColor1}">
<TD valign="bottom" align="left">
<FONT size="1" face="$vars_style{FontFace}">
<B>
&#187; $show_logout
</B>
</font>
</TD>
<TD valign="bottom" align="right">
<FONT size="1" face="$vars_style{FontFace}"><B>
<a href="$vars_config{CGIURL}/ultimatebb.cgi">$vars_config{BBName}</a> &raquo; $vars_wordlets_err{error}</B>
</font>
</TD>
</TR>
$TBB
<P>

$TBT

<TR bgcolor="$vars_style{TableColorStrip}">
<TD>
<FONT COLOR="$vars_style{TableStripTextColor}" SIZE="$vars_style{TextSize}" FACE="$vars_style{FontFace}"><B>
$vars_wordlets_err{error}
</B></FONT>
</TD>
</TR>

<TR bgcolor="$vars_style{AltColumnColor1}"><TD>
<FONT SIZE="$vars_style{TextSize}" FACE="$vars_style{FontFace}">
<p>$vars_wordlets_err{error_has_occured} <br />
</font><B><pre>$_[0]</pre></B><FONT SIZE="$vars_style{TextSize}" FACE="$vars_style{FontFace}">
</p><p>$vars_wordlets_err{error_contact_admin}</p>
</FONT>
</TD></TR>

$TBB
<P>

$Footer

THIS_PAGE

	exit(0);
}    #end StandardHTML2



sub instant_ubb_code {

	my $ubb_code_buttons = qq~
<a href="javascript: x()" onClick="DoPrompt('url');"><img src="$vars_config{NonCGIURL}/url.gif" width="72" height="16" border="0" alt="$vars_wordlets_img{ubb_code_url}"></a>
 &nbsp;
 <a href="javascript: x()" onClick="DoPrompt('email');"><img src="$vars_config{NonCGIURL}/email_url.gif" width="72" height="16" border="0" alt="$vars_wordlets_img{ubb_code_email}"></a>
<br>
<a href="javascript: x()" onClick="DoPrompt('bold');"><img src="$vars_config{NonCGIURL}/bold.gif" width="72" height="16" border="0" alt="$vars_wordlets_img{ubb_code_bold}"></a>
  &nbsp;
  <a href="javascript: x()" onClick="DoPrompt('italics');"><img src="$vars_config{NonCGIURL}/italics.gif" width="72" height="16" border="0" alt="$vars_wordlets_img{ubb_code_italics}"></a>
<br>
<a href="javascript: x()" onClick="DoPrompt('quote');"><img src="$vars_config{NonCGIURL}/ubb_quote.gif" width="72" height="16" border="0" alt="$vars_wordlets_img{ubb_code_quote}"></a>
  &nbsp;
  <a href="javascript: x()" onClick="DoPrompt('code');"><img src="$vars_config{NonCGIURL}/code.gif" width="72" height="16" border="0" alt="$vars_wordlets_img{ubb_code_code}"></a>
<br>
<a href="javascript: x()" onClick="DoPrompt('liststart');"><img src="$vars_config{NonCGIURL}/list-start.gif" width="72" height="16" border="0" alt="$vars_wordlets_img{ubb_code_list_start}"></a>
 &nbsp;
  <a href="javascript: x()" onClick="DoPrompt('listitem');"><img src="$vars_config{NonCGIURL}/list-item.gif" width="72" height="16" border="0" alt="$vars_wordlets_img{ubb_code_list_item}"></a>
<br>
<a href="javascript: x()" onClick="DoPrompt('listend');"><img src="$vars_config{NonCGIURL}/list-end.gif" width="72" height="16" border="0" alt="$vars_wordlets_img{ubb_code_list_end}"></a>
 &nbsp;
 ~;

	if ($ubb_images_wording eq '') {
		$ubb_code_buttons .= qq~
<a href="javascript: x()" onClick="DoPrompt('image');"><img src="$vars_config{NonCGIURL}/image.gif" width="72" height="16" border="0" alt="$vars_wordlets_img{ubb_code_image}"></a>
~;
	}

	$ubb_code_buttons .= qq~
<p></p>
<a href="$vars_config{CGIURL}/ultimatebb.cgi?ubb=ubb_code_page" target="_new">$vars_wordlets{ubb_code_explained}</a>
~;

	return ($ubb_code_buttons);
}


# DANGER: DO NOT REMOVE THE FOLLOWING LINE!
1;
