<!--

/*
#########################################
# Add2it Mailman Pro V2.63	   04/11/03 #
# add-optin.js - One-click optin pop-up #
#########################################
# Copyright 2000-2003 by Frank Bauer	#
# Add2it.com - All Rights Reserved.		#
#########################################

3-Step Setup Instructions:
--------------------------

1. Please call this Java Script file from within the header area of a web page with:
   <script language="JavaScript" src="add2it-optin.js"></script>
   <script language="JavaScript"><!--
   var buttonText = "Click here to subscribe to the FREE More4you Newsletter";
   var email = "subscribe-m4u@add2it.com";
   var emailSubject = "subscribe";
   var buttonBgColor = "#003399";
   var buttonBgColorOver = "#FFFF99";
   var buttonTextColor = "#FFFF99";
   var buttonTextColorOver = "#003399";
   var displayText = "Subscribe to the FREE More4you Newsletter and get:\n\n -> More tips, training and tutorials for webmasters and entrepreneurs...\n     everything you need to make your website and business a success!\n\nThis is all completely automatic - just hit the button below!\n\nComplete privacy: Your email address will not be revealed to third parties\n\nBTW: As a gifts for subscribing to the More4you Newsletter you get\n         your FREE copy of the Add2it PostIt Free software tool.\n\n         It's a cool tool to jot down your notes, just like the yellow paper\n         version.  Plus it has a bunch of features, that the original version\n         doesn't have... :)  It works on Windows 95/98/ME/NT & XP.";
   var forwardURL = "";
   //--></script>

   If the add2it-optin.js file is not in the same directory as the web page, please use:
   <script language="JavaScript" src="http://www.yourdomain.com/mmp/add2it-optin.js"></script>

2. Add this Java Script code in the position of a web page where the on-click subscribe button should appear:
   <script language="JavaScript"><!--
   showButton(buttonText, email, emailSubject, buttonBgColor, buttonBgColorOver, buttonTextColor, buttonTextColorOver);
   //--></script>

   To make the it invisible, please use this Java Script code instead:
   <script language="JavaScript"><!--
   showButton(buttonText, email, emailSubject, "invisible");
   //--></script>
   
   If you prefer not to use this button and just want to forward the visitor to a web page, don't use this code.
   
   Instead, enter an URL in the forwardURL variable of step 1:
   var forwardURL = "http://www.yourdomain.com/mmp/sub.pl?<list>=!FLM";
   
3. And add this Java Script code in a web page before the </BODY> tag:
   <script language="JavaScript"><!--
   Go(displayText);
   //--></script>

   or add the following command parameter to your <BODY> tag:
   onload='Go(displayText)'

... if you like, you can edit also the following 4 variables:
*/

var delaytime = "8";
var loadonsecondpage = "1";
var cookie = "add2itmmpoptin";
var tcookie = "add2itmmpoptintest";

// Don't edit anything past this point!

function showButton(buttonText, email, emailSubject, buttonBgColor, buttonBgColorOver, buttonTextColor, buttonTextColorOver) {
	document.write("<form name=mailer id=mailer enctype=text/plain method=post action='mailto:"+email);
	document.write((emailSubject!="")?"?subject="+emailSubject+"&body="+emailSubject:"");
	document.write("'><input type='submit' onclick='setPermanentCookie();'");
	document.write((buttonBgColor=="invisible")?" STYLE='width:1px;height:1px;' value='Yes'":" STYLE='cursor:hand;background:"+buttonBgColor+";COLOR:"+buttonTextColor+";FONT-WEIGHT:bold' onMouseOver=\"this.style.backgroundColor='"+buttonBgColorOver+"'; this.style.color='"+buttonTextColorOver+"'\" onMouseOut=\"this.style.backgroundColor='"+buttonBgColor+"'; this.style.color='"+buttonTextColor+"'\" value='"+buttonText+"'");
	document.write(" name=subscribe id=subscribe></form>");
}

function Go(displayText) {
	if (displayText != "") {
		if (loadonsecondpage == "0") {
			setTestCookie ();
		}
		if (getTestCookie(tcookie) != "") {
			if (getOptinCookie(cookie) == "") {
				setTimeout("optin(displayText);",delaytime * 1000);
			}
		}
		if (loadonsecondpage == "1") {
			setTestCookie ();
		}
	}
}

function getOptinCookie(cookieName) {
	var id = cookieName + "=";
	var cookievalue = "";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(id);
		if (offset != -1) {
			cookievalue = "x";
		}
	}
	return cookievalue;
}

function getTestCookie(tcookieName) {
	var id = tcookieName + "=";
	var cookievalue = "";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(id);
		if (offset != -1) {
			cookievalue = "x";
		}
	} 
	return cookievalue;
}

function optin(text) {
	setOptinCookie();
	if(confirm(text)) {
		if (forwardURL != "") {
			window.location.href = forwardURL;
			setPermanentCookie();
		} else {
			document.mailer.subscribe.click();
		}
	}
}

function setTestCookie () {
	var today = new Date();
	var expdate = new Date(today.getTime() + 1 * 24 * 60 * 60 * 1000); // 1 day
	document.cookie = tcookie + "=done;expires=" + expdate.toGMTString();
}

function setOptinCookie () {
	var today = new Date();
	var expdate = new Date(today.getTime() + 1 * 24 * 60 * 60 * 1000); // 1 day
	document.cookie = cookie + "=done;expires=" + expdate.toGMTString();
}

function setPermanentCookie () {
	var today = new Date();
	var expdate = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000); // 1 year
	document.cookie = cookie + "=done;expires=" + expdate.toGMTString();
}

//-->
