<!-- Copyright 2004 Bontrager Connection, LLC
// See the "It Kicks In When Visitors Leave Your Site" 
//      article for more information. It's linked from
//      http://willmaster.com/possibilities/archives/
//
// Six places can be customized.
//


// Customization place 1:
// Here, specify whether the Kick In code shall be turned 
//    on or off. Use "off" to turn it off. Otherwise, use 
//    "on" or anything else. (The code looks for "off". If 
//    anything else is specified, the Kick In code runs.)

var TheKickInCodeRunSwitch = "on";



// Customization place 2:
// Specify the domain name where the web pages containing 
//    this JavaScript code are at. Do not specify the 
//    "www." part of the domain name. (The code will 
//    automatically look for www and other third level 
//    names.) This domain name is also used when setting 
//    the cookie so the cookie can be read from various 
//    third level names -- if you use any with your 
//    domain. Example of use: "willmaster.com";

var DoNotKickInForThisDomain = "fountainofhealth.com";



// Customization place 3:
// Specify a cookie name. Give it a name different than 
//    any other cookies that your web site sets. The name 
//    may contain only alphabetical characters.

var KickInCookieName = 'FountainOfHealth';



// Customization place 4:
// Specify how many days shall elapse before the Kick In 
//    code may kick in again after it has kicked in once. 
//    (Zero (0) means the cookie will last only until the 
//    browser is closed. Any other number will cause the 
//    cookie to last that many days, with a maximum of 
//    10 years.)

var HowManyDaysTheCookieWillLast = 180;



// Customization place 5:
// When a subscription comes through, a purchase is made, 
//    or other specific action is completed, the length 
//    of time the cookie lasts can be a multiplication of 
//    the time it lasts when the Kick In code kicks in.
//    To have it last the same length of time, specify the 
//    digit 1. For twice as long, the digit 2. To have no 
//    cookie set under this circumstance, use the digit 0
//    A decimal number is allowed.

var CookieLastsHowManyTimesLonger = 1;



// Customization place 6:
// Below, specify what the JavaScript shall do when the 
//    Kick In code kicks in. The instructions can be any 
//    JavaScript code. Put the code between the first and 
//    last lines of the WhatToDo() function.

function WhatToDo() { // This is the first line of the WhatToDo() function
if (confirm("\nWe hope you enjoyed the Fountain of Health website.\n Before you leave, would you like to subscribe to our newsletter?\n Press OK to be take to the newsletter subscription page\n"))	{
		alert("\nThank you!\n");
		window.open("http://www.fountainofhealth.com/newsletter.php");
		}
else {
alert("\nThank you for visiting!\n");
return false;
} // This is the last line of the WhatToDo() function
}


////////////////////////////////////////////
//
// No additional customization is necessary.
//
////////////////////////////////////////////

var OkayToKickIn = true;
TheKickInCodeRunSwitch = TheKickInCodeRunSwitch.toLowerCase();
DoNotKickInForThisDomain = DoNotKickInForThisDomain.toLowerCase();
HowManyDaysTheCookieWillLast = Math.abs(parseInt(HowManyDaysTheCookieWillLast));
CookieLastsHowManyTimesLonger = Math.abs(parseInt(CookieLastsHowManyTimesLonger));

function KickItIn() {
if(TheKickInCodeRunSwitch == 'off') { return; }
if(OkayToKickIn == false) { return; }
var host = String(location.host);
host = host.toLowerCase();
if(host == 'undefined' || host == 'null' || host.length < 1) { return; }
var hasCookie = DoesItHaveACookie();
if(hasCookie == true) { return; }
SetTheCookie();
WhatToDo();
} // function KickItIn()


function DoesItHaveACookie() {
var cookiecontent = '';
if(document.cookie.length > 0) {
	var cookiename = KickInCookieName + '=';
	var cookiebegin = document.cookie.indexOf(cookiename);
	var cookieend = 0;
	if(cookiebegin > -1) {
		cookiebegin += cookiename.length;
		cookieend = document.cookie.indexOf(";",cookiebegin);
		if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
		cookiecontent = document.cookie.substring(cookiebegin,cookieend);
		}
	}
if(cookiecontent.length > 0) { return true; }
return false;
} // function DoesItHaveACookie()


function SetTheCookie() {
if(HowManyDaysTheCookieWillLast > 3562) { HowManyDaysTheCookieWillLast = 3562; }
var exp = '';
if(HowManyDaysTheCookieWillLast > 0) {
	var now = new Date();
	then = now.getTime() + (HowManyDaysTheCookieWillLast * 24 * 60 * 60 * 1000);
	now.setTime(then);
	exp = '; expires=' + now.toGMTString();
	}
var firstperiod = location.host.indexOf('.');
var lastperiod = location.host.lastIndexOf('.');
var domain = '';
if((firstperiod > -1) && (lastperiod > -1) && (firstperiod != lastperiod)) { domain = '; domain=.' + DoNotKickInForThisDomain; }
document.cookie = KickInCookieName + '=set; path=/' + domain + exp;
} // function SetTheCookie()


function CancelKickIn() {
HowManyDaysTheCookieWillLast *= CookieLastsHowManyTimesLonger;
if(CookieLastsHowManyTimesLonger > 0) { SetTheCookie(); }
OkayToKickIn = false;
} // function CancelKickIn()


function DoNotKickInThisTime(url) {
OkayToKickIn = false;
window.location = url; 
} // function DoNotKickInThisTime()


function FixLinks() {
var numlinks = document.links.length - 1;
for(var i = 0; i <= numlinks; i++) {
	var doChange = false;
	var host = String(document.links[i].host);
	var hostname = String(document.links[i].hostname);
	host = host.toLowerCase();
	hostname = hostname.toLowerCase();
	if((host == 'undefined' && hostname == 'undefined') || (host == 'null' && hostname == 'null')) {
		document.links[i].href = "javascript:DoNotKickInThisTime('" + document.links[i].href + "')";
		continue;
		}
	if(host.length > DoNotKickInForThisDomain.length) {
		host = host.substr(-(DoNotKickInForThisDomain.length+1));
		if(host.indexOf('.') == 0) { host = host.substr(1); }
		}
	if(hostname.length > DoNotKickInForThisDomain.length) {
		hostname = hostname.substr(-(DoNotKickInForThisDomain.length+1));
		if(hostname.indexOf('.') == 0) { hostname = hostname.substr(1); }
		}
	if(host == DoNotKickInForThisDomain || hostname == DoNotKickInForThisDomain) {
		document.links[i].href = "javascript:DoNotKickInThisTime('" + document.links[i].href + "')";
		continue;
		}
	}
} // function FixLinks()

setTimeout('FixLinks()',1000);
//-->

