var TAFthisPageDir = 'regalstuff';
var SendToPage = 'http://tellafriend.regalbuilt.com/link.php?page=receive&PageDir=' + TAFthisPageDir;
// 2007.04.28 KJD: File Created for TellAFriend Service
var TellAFriendBoxID = "RegalBuilt_TellAFriend_LinkDiv";
var TAFDisplayBox = "RegalBuilt_TAF_DisplayBox";
var TAFthisPage = document.location;
var TAFThankYou = "Thank you. A link to this page has been sent to your friend";
// 2007.04.28 KJD: Populate the Link
function LoadTAF()
{
var detectBox = DetectTAFBox();
if( detectBox )
{
// 2007.04.30 KJD: Load the CSS
TAFinclude_css( TAFStyle );
WriteTAFBox( TAFLinkHTML );
}
}
// 2007.04.28 KJD: Check for box
function DetectTAFBox()
{
if( document.getElementById( TellAFriendBoxID ) )
{
return true;
}
else
{
return false;
}
}
// 2007.04.28 KJD: Place into TAF Box
function WriteTAFBox( thisString )
{
thisString = thisString
+ "
"
+ "";
document.getElementById( TellAFriendBoxID ).innerHTML = thisString;
SetSizesAndPositions();
}
// 2007.05.08 KJD: Set the sizes and positions
function SetSizesAndPositions()
{
// 2007.05.08 KJD: Required for Opacity
document.getElementById( "TAFOuterBox" ).style.width = document.body.clientWidth + "px";
document.getElementById( "TAFOuterBox" ).style.height = document.body.clientHeight + "px";
document.getElementById( TAFDisplayBox ).style.left = parseInt( ( document.body.clientWidth / 2 ) - 100 ) + "px";
document.getElementById( TAFDisplayBox ).style.top = parseInt( ( document.body.clientHeight / 2 ) - 150 ) + "px";
}
// 2007.04.30 KJD: Validate form
function TAFValidate()
{
var sendit = 1;
if( !( document.TAFform.TAF_name.value ) || ( document.TAFform.TAF_name.value == " " ) ){ sendit = 0; }
if( !( document.TAFform.TAF_email.value ) || ( document.TAFform.TAF_email.value == " " ) ){ sendit = 0; }
if( document.TAFform.TAF_email.value.indexOf("@") == -1 || document.TAFform.TAF_email.value.indexOf(".") == -1 ){ sendit = 0; }
if( !( document.TAFform.TAF_friendname.value ) || ( document.TAFform.TAF_friendname.value == " " ) ){ sendit = 0; }
if( !( document.TAFform.TAF_friendemail.value ) || ( document.TAFform.TAF_friendemail.value == " " ) ){ sendit = 0; }
if( document.TAFform.TAF_friendemail.value.indexOf("@") == -1 || document.TAFform.TAF_friendemail.value.indexOf(".") == -1 ){ sendit = 0; }
if( sendit )
{
TAFSend();
}
else
{
alert( "All fields are required to send this page." );
}
}
// 2007.04.28 KJD: Send the link
function TAFSend()
{
var sendVars = TAFEncode();
TAFinclude_js( SendToPage + "&vars=" + sendVars );
// alert( SendToPage + "&vars=" + sendVars );
document.getElementById( 'TAFInfo' ).innerHTML = ""
+ TAFThankYou + "
"
+ "
";
}
// 2007.04.28 KJD: Encode the vars
function TAFEncode()
{
var thisSeparator = "####";
var thisString = ""
+ TAFthisPage + thisSeparator
+ document.TAFform.TAF_name.value + thisSeparator
+ document.TAFform.TAF_email.value + thisSeparator
+ document.TAFform.TAF_friendname.value + thisSeparator
+ document.TAFform.TAF_friendemail.value + thisSeparator
+ document.TAFform.TAF_notes.value + thisSeparator
+ document.TAFform.TAF_subject.value + thisSeparator
"";
thisString = thisString.replace( "\r", "" );
thisString = thisString.replace( "\n", " " );
thisString = escape( encode64( thisString ) );
return thisString;
}
// 2007.04.28 KJD: Display TAF box
function displayTAFbox()
{
WriteTAFBox( TAFLinkHTML );
document.getElementById( TAFDisplayBox ).style.visibility = "visible";
document.getElementById( 'TAFOuterBox' ).style.visibility = "visible";
}
// 2007.04.28 KJD: Hide the TAF box
function hideTAFbox()
{
document.getElementById( TAFDisplayBox ).style.visibility = "hidden";
document.getElementById( 'TAFOuterBox' ).style.visibility = "hidden";
}
// 2007.04.28 KJD: Include another JS file
function TAFinclude_js( thisFile )
{
var html_doc = document.getElementsByTagName('head').item(0);
var js = document.createElement( 'script' );
js.setAttribute( 'language', 'javascript' );
js.setAttribute( 'type', 'text/javascript' );
js.setAttribute( 'src', thisFile );
html_doc.appendChild( js );
return false;
}
// 2007.04.30 KJD: Include another CSS file
function TAFinclude_css( thisFile )
{
var html_doc = document.getElementsByTagName('head').item(0);
var file = document.createElement( 'link' );
file.setAttribute( 'rel', 'stylesheet' );
file.setAttribute( 'type', 'text/css' );
file.setAttribute( 'href', thisFile );
html_doc.appendChild( file );
return false;
}
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function encode64(input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
do {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
keyStr.charAt(enc3) + keyStr.charAt(enc4);
} while (i < input.length);
return output;
}
var TAFStyle = "http://tellafriend.regalbuilt.com/style1.css";
var LinkText = "Email this page to a friend"
var TAFLinkHTML = "";
var SendSubject = "Check out this page";
LoadTAF();