package MasterFormV4DownloadLink;
###########################################################
#
# Master Form V4 Temporary Download Links
#   Version 1.0
#
#   Version 1.0 completed October 2, 2006
#
# This file MasterFormV4DownloadLink.pm is 
#   a plug-in for Master Form V4 version 4.5 or later
#
#    Note: This is a plug-in shell. When the functional 
#          plug-in is purchased, this file is to be 
#          replaced with the fully functional one.
#
# Copyright 2000,2001 by William Bontrager.
# Copyright 2002-2010 by Bontrager Connection, LLC
# Copyright 2012 by Will Bontrager Software, LLC
#
# Programmer: Will Bontrager
# Website: http://www.willmaster.com/
#
# This custom version downloaded
#   from: Willmaster.com
#    for: hobbyline.com
#     by: 208.117.46.253
#     at: 1397152772 -- Thursday, April 10, 2014 at 17:59:32 GMT.
#
###########################################################

use strict; # May be commented out after testing.
use vars qw( @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION );
require Exporter;
$VERSION = 1.00;
@ISA = qw( Exporter );
@EXPORT = qw( 
	@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION 
	VersionInfo 
	TemporaryDownloadLinkMenuItem 
	TemporaryDownloadLinkPreferences 
	ActualURL 
);


my $ThisVersion = '1.0';
my $ParentVersionRequired = '4.5';


sub VersionInfo
{
	my %versions = ();
	$versions{me} = $ThisVersion;
	$versions{parent} = $ParentVersionRequired;
	return %versions;
} # sub TemporaryDownloadLinkMenuItem


sub TemporaryDownloadLinkMenuItem
{
	return q`<div style="line-height:9px;margin:0px;padding:0px;font-size:12px;">Temporary Download Links</div><div style="line-height:8px;margin:0px;padding:0px;font-size:10px;">(plug-in required)</div>`;
} # sub TemporaryDownloadLinkMenuItem

sub TemporaryDownloadLinkPreferences
{
	my ($Gptr,$officialName,$formname) = @_;
	my $selfDomain = $ENV{SERVER_NAME};
	$selfDomain =~ s/^www\.//i;
	print <<PAGE;
<a name="piap"></a><p class="bold">If Plug-In Has Already Been Purchased &#151;</p>
<p class="italic">
Automatic Installation
</p>
<p>
If you have already purchased the Temporary Download Link Plug-In, 
you can ask $$officialName to install it for you automatically. See 
<a href="#ipi"><span style="text-decoration:underline;">the "Installing Plug-In" section,</span></a> below.
</p>
<p class="italic">
Manual Installation
</p>
<p>
If the auto-install fails, or you just prefer to do it 
manually, the "Tech Support" link on the Main Menu of 
this control panel contains instructions. 
In essence, it says to generate the lastest 
version of $$officialName. 
Then follow installation instructions included 
with the generated files.
</p>

<p class="bold top25">If Plug-In Has Not Yet Been Purchased &#151;</p>
<p>
The plug-in must be purchased before it can be installed.
</p>
<p>
To go directly to the payment page, 
<a href="http://willmaster.com/master/formV4/support/RelayToTDLpluginPaymentPage.cgi"><span style="text-decoration:underline;">click here</span>.</a>
</p>
<p>
To see a page with current pricing and other information, 
<a href="http://willmaster.com/master/formV4/support/RelayToTDLpluginInformationPage.cgi"><span style="text-decoration:underline;">click here</span>.</a>
</p>

<a name="ipi"></a>
<p class="bold top25">Installing Plug-In &#151;</p>

<script type="text/javascript" language="JavaScript"><!--
var CurrentMessage = 'Contacting remote server.';
var MonitorTrip = 40;
var CurrentMonitorStep = 0;
var CurrentProgressBarChunks = 0;
var NotDone = true;

function DisplayMessage(divid,message) { document.getElementById(divid).innerHTML = message; }

function ProgressBar(divid) {
var barchunksmax = 20;
var barincrements = 10;
CurrentMonitorStep++;
CurrentProgressBarChunks++;
var retval = CurrentMessage;
if(CurrentProgressBarChunks > barchunksmax) {
	var chunks = parseInt(CurrentProgressBarChunks / barchunksmax);
	for(var i = 1; i <= chunks; i++) { retval += '<div style="width:'+barchunksmax*10+';height:10;background-color:blue;font-size:1px;">&nbsp;</div>'; }
	var lastchunk = parseInt(CurrentProgressBarChunks % barchunksmax);
	if(lastchunk > 0) { retval += '<div style="width:'+lastchunk*10+';height:10;background-color:blue;font-size:1px;">&nbsp;</div>'; }
	}
else { retval += '<div style="width:'+CurrentProgressBarChunks*10+';height:10;background-color:blue;font-size:1px;">&nbsp;</div>' }
DisplayMessage(divid,retval);
} // function ProgressBar()


function MonitorDownload(divid,url) {
if(AJAXcontent.length > 0) { DisplayMessage(divid,AJAXcontent); }
else  { 
	ProgressBar(divid);
	if(CurrentMonitorStep >= MonitorTrip) { DisplayMessage(divid,'<br><br>Connection timed out.'); }
	else { setTimeout('MonitorDownload("'+divid+'","'+url+'")',2000); }
	}
} // function MonitorDownload()

function InstallPlugin(url) {
url += '?pi=TDL&tid=' + escape(document.$$formname.TransactionID.value);
url += '&d=' + escape(document.$$formname.domain.value);
GrabContent(url);
var divid = 'monitor';
setTimeout('MonitorDownload("'+divid+'","'+url+'")',2000);
document.getElementById(divid).style.display = 'block';
document.getElementById('monitorinit').style.display = 'none';
} // function InstallPlugin()
//--></script>



<p>
$$officialName can try to automatically install the plug-in for you.
</p>
<p>
<p>
Automatic installation will work with most servers.
</p>
<p>
If this is the first time the plug-in has been generated or installed, 
provide the purchase Transaction ID. Otherwise, that field can be left blank.
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="right">
Transaction ID: <input type="text" class="extra9top" name="TransactionID" size="33"><input type="hidden" name="domain" value="$selfDomain">
</td></tr></table>
</p>

<p align="center" id="monitorinit">
<input type="button" onclick="InstallPlugin('MasterFormV4PlugInInstall.cgi')" class="submitbutton" name="updateTDL" value="Install Plug-In">
</p>


<div 
	id="monitor" 
	style="display:none;width:200px;height:105px;
background-color:#DDF;padding:11px;border-style:solid;
border-width:1px;border-color:#66F;">
Contacting remote server.<br><br>
</div>


<p>
If automatic installation does not work 
on your server, information about how to proceed is 
at the "Tech Support" link on the Main Menu 
of this $$officialName control panel. 
In essence, it says to generate the lastest 
version of the software, 
then follow installation instructions included 
with the generated files.
</p>
<p>
<input type="submit" class="submitbutton" value="Return to Main Menu">
</p>
PAGE
} # sub TemporaryDownloadLinkPreferences

sub ActualURL { return; }




1;

