var seconds_to_bring_up, seconds_to_hide;

var SecondsBringUp = new Array();
var SecondsHide = new Array();
var Popups = new Array();
var TotalPopups = 0, PopupIndex = 0;

var W = 500;
var H = 628;

var Browser;
var timer;
var timer_for_scroll;
var w = window.screen.width;
var h = window.screen.height;
var X = Math.ceil((w-W)/2);
var Y = Math.ceil((h-H)/2);

if (navigator.appName == "Netscape") Browser = "Netscape";
else if  (navigator.appName == "Microsoft Internet Explorer") Browser = "Explorer";
else Browser = "Netscape";

document.write('<style>p { margin: 10px 0px 0px 0px; padding: 0px 30px 0px 30px; font-family: Arial, Helvetica, sans-serif; font-size: 12px; }</style>');

function blink(sElementID) {
   eval('document.all.getElementById("' + sElementID + '").style.visibility = (document.all.getElementById("' + sElementID + '").style.visibility == \"visible\") ? \"hidden\" : \"visible\";');
} 

function ScrollPopup(divName)
{
	eval(divName).style.top = document.body.scrollTop + Y - 90;
	// eval(divName).style.left = document.body.scrollLeft + X;
}

function delay_to_bring_up(divName)
{
   seconds_to_bring_up--;
   
   if (seconds_to_bring_up == 0)
    {
    window.clearInterval(timer);
    
	if ( GetCookie(divName) == null )
     {
	 SetCookie( divName, divName, 14 );
	
	 eval(divName).style.top = document.body.scrollTop + Y - 90;
	 eval(divName).style.left = document.body.scrollLeft + X;

	 
	 timer = setInterval('delay_to_hide("'+divName+'")', 1000);
	 timer_for_scroll = setInterval('ScrollPopup("'+divName+'")', 10);
	
	 Effect.toggle(divName, "slide");
	 }
	else {
		 /*alert("Cookie for \""+divName+"\" was placed already! It is being deleted!"); 
	     DeleteCookie(divName);
		 /**/
		 seconds_to_hide = SecondsHide[PopupIndex];
		 PopupIndex++;
		 seconds_to_bring_up = 1;
		 if (PopupIndex <= TotalPopups) delay_to_bring_up(Popups[PopupIndex - 1]);
		 }

    }
}

function delay_to_hide(divName)
{
   seconds_to_hide--;

   if (Browser == "Explorer") blink(divName + "BlinkWarning");
   document.forms[divName + "Form"].elements[divName + "TimerInput"].value = seconds_to_hide;
         
   if (seconds_to_hide == 0)
    {
 	window.clearInterval(timer);
	window.clearInterval(timer_for_scroll);
	ClosePopup(divName);
	}
}

function ShowPopups()
{
var argv    = ShowPopups.arguments;
var argc    = ShowPopups.arguments.length;

if (argc == 0 || argc%3 != 0) { alert("'ShowPopup(...)' must have at least 3 arguments - Popup Name, Seconds To Bring Up, Seconds To Hide - or 6 or 9 and etc...! Check the function!"); return; }

for (var i = 0; i < argc; i += 3)
  {
  Popups[TotalPopups]    = argv[i];
  SecondsBringUp[TotalPopups]  = argv[(i+1)];
  SecondsHide[TotalPopups]  = argv[(i+2)];
  TotalPopups++;
  }

if (TotalPopups > 1) PopupIndex++;

seconds_to_bring_up = SecondsBringUp[0];
seconds_to_hide = SecondsHide[0];
timer = setInterval('delay_to_bring_up("'+Popups[0]+'")', 1000);	
}

function ClosePopup(divName)
{
Effect.toggle(divName, "appear");

if (PopupIndex > 0 && PopupIndex <= TotalPopups-1)
 {
 seconds_to_bring_up = SecondsBringUp[PopupIndex];
 seconds_to_hide = SecondsHide[PopupIndex];
 timer = setInterval('delay_to_bring_up("'+Popups[PopupIndex]+'")', 1000);	
 if (PopupIndex <= TotalPopups-1) PopupIndex++;
 }
}

function CreateFitnessNewsletterWithBonusesPopup(divName)
{
document.write('<div id="'+divName+'" style="display: none; top:0px; left:0px; position: absolute; width:' + W + 'px; height:' + H + 'px;"><div>');
document.write('<form name="'+divName+'Form" action="https://m286.infusionsoft.com/AddForms/processForm.jsp" method="POST">');
document.write('<table border="0" width="100%" height="' + H + '" background="images/postnote3.gif" style="background-repeat: no-repeat; cursor: move;" align="center" cellpadding="0" cellspacing="0">');
document.write('<tr valign="top"><td width="63" rowspan="3"></td><td height="20"></td><td width="55" rowspan="3"><img hspace="14" vspace="38" alt="Close" title="Close" src="images/cross.gif" onClick="javascript: window.clearInterval(timer); window.clearInterval(timer_for_scroll); ClosePopup('+divName+');" style="cursor: pointer;"></td></tr>');
document.write('<tr align="center" valign="middle"><td>');
document.write('<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td align="center" valign="top">');
// <!---      BEGIN   Content      --->
document.write('<p><font size="4" face="arial" color="#0000FF"><b>Learn How to Lose Fat and Gain Muscle...AUTOMATICALLY</b></font>');
document.write('<p align="justify"><font face="arial" size="2">Subscribe to <B>The Health and Fitness channel Newsletter</B> and learn specific tips and tricks on losing fat, gaining lean muscle, getting into your best shape in record time, increasing your health, looking younger, and more...I even provide you tips straight out of the Ultimate Results Manual - for FREE.</font>');
document.write('<p style="padding-bottom: 0px; "><font face="arial" size="2" color="#C60000"><B><i>"....I lost 12 1/2 pounds in the first 5 days!...Thank you for putting this program together, it\'s given me hope again."</i></B></font><font face="arial" size="1" color="#000000">- Merrie Price, Addison, Texas</font>');
document.write('<p align="justify" style="font-family:Arial, Helvetica, sans-serif;">Plus you\'ll receive:</p>');
document.write('<ol style="text-align: justify; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; padding-right: 25px; margin-top:5px; margin-bottom:5px;">');
document.write('<li>"How To Get Maximum Weight Loss & Fitness Results In Minimum Time" - 16 Secrets - <font color="#FF0000">FREE Report</font></li>');
document.write('<li>"The Five Biggest Weight Loss & Fitness Myths" - <font color="#FF0000">FREE Report</font></li>');
document.write('<li>"Four Secrets To Finally Achieving The Weight Loss, Health & Fitness Results You Want" - <font color="#FF0000">FREE Report</font></li>');
document.write('</ol>');
document.write('<table width="80%" align="center" style=" font-size: 12px; margin-bottom:10px; font-family:Arial, Helvetica, sans-serif;" cellpadding="2" cellspacing="0">');
document.write('<tr align="center"><td colspan="2"><b>Join Our Newsletter!</b></td></tr>');
document.write('<tr align="center"><td><b>First Name: </b></td><td><input type="text" name="FirstName" value="" size="27"></td></tr>');
document.write('<tr align="center"><td><b>Enter Your Email: </b></td><td><input type="text" name="Email" value="" size="27"></td></tr>');
document.write('<tr align="center"><td colspan="2"><input title="" type="submit" name="Submit" id="Submit" value="Join Newsletter"  class="button"></td></tr>');
document.write('</table>');
document.write('<table cellspacing="0" border="1" align="center" width="80%" style="font-family: Arial, Helvetica, sans-serif; font-size:10px; border:1px solid red; font-weight:bold;">');
document.write('<tr><td align="center" style="color:#FFFFFF; background-color:#FF0000; border:0px; font-size:12px; ">Free Reports Clock Count-Down</td></tr>');
document.write('<tr><td valign="middle" align="center" style="border:0px; background-color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:9px; ">You Must Claim Your Free Reports Within <input type="text" name="'+divName+'TimerInput" size="1" value=""> Seconds</td></tr>');
document.write('</table>');
document.write('<p style="font-family: Arial, Helvetica, sans-serif; font-size:10px; color:#FF0000; font-weight:bold;"><span style="font-family:Arial, Helvetica, sans-serif; color:#FF0000; font-weight: bold; font-size: 12px;" id="'+divName+'BlinkWarning"><blink>WARNING!</blink></span> These FREE Reports are ONLY available until the clock-timer counts down to zero! Refreshing the screen or coming back in the future will not allow this page to reappear!</p>');
// <!---      END  Content         --->
document.write('</td></tr></table>');
document.write('</td></tr><tr><td height="40"></td></tr></table>');
document.write('<input type="hidden" id="formid" name="formid" value="25"><input type="hidden" id="type" name="type" value="CustomFormWeb">');
document.write('</form>');
document.write('</div></div>');

new Draggable(divName, { revert: false });
}

function CreateBlueprintsPopup(divName)
{
document.write('<div id="'+divName+'" style="display: none; top:0px; left:0px; position: absolute; width:' + W + 'px; height:' + H + 'px;"><div>');
document.write('<form name="'+divName+'Form" action="https://m286.infusionsoft.com/AddForms/processForm.jsp" method="POST">');
document.write('<table border="0" width="100%" height="' + H + '" background="images/postnoteblue.gif" style="background-repeat: no-repeat; cursor: move;" align="center" cellpadding="0" cellspacing="0">');
document.write('<tr valign="top"><td width="63" rowspan="3"></td><td height="20"></td><td width="55" rowspan="3"><img hspace="5" vspace="45" alt="Close" title="Close" src="images/cross2.gif" onClick="javascript: window.clearInterval(timer); window.clearInterval(timer_for_scroll); ClosePopup('+divName+');" style="cursor: pointer;"></td></tr>');
document.write('<tr align="center" valign="middle"><td>');
document.write('<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td align="center" valign="top">');
// <!---      BEGIN   Content      --->
document.write('<p align="center"><font face="Verdana" size="3" color="white"><font color="#ff0000" size="4"><b>FREE </b></font><b>"Blueprints" to Quicker, Easier, More Effective Fat Loss</b></font></p>');
document.write('<p align="center"><font face="Verdana" size="2" color="#A2DEF9">These are the "Blueprints" I used to get into the best shape of my life at 42 years of age.<br><br>  <font color="#ff0000" size="4"><b>PLUS</b></font>, I\'ll also show you what I did to go from 12% to 7.3% bodyfat...in only 2 weeks!</font></p>');
document.write('<p align="center"><font face="Verdana" size="2"><b><font color="white">!BONUS!<font color="white"> By signing up for the course you\'ll receive a chance to win free supplements.<br> (Full Details when you click Submit below)</font></font></b></font></p>');
document.write('<p align="justify" style="padding-bottom: 5px;"><font face="Verdana" size="0" color="#A2DEF9">(Entering your information below will subscribe you to an 8-Day course featuring 7 of the "blueprints" from the highly acclaimed book "20 Blueprints To Physical Excellence". At no time will your information be given or sold to others. Your privacy is guaranteed.)</font></p>');
document.write('<table width="80%" align="center" style=" font-size: 12px; margin-bottom:10px; font-family:Arial, Helvetica, sans-serif; color: white;" cellpadding="2" cellspacing="0">');
document.write('<tr align="center"><td colspan="2"><b>Get Blueprints!</b></td></tr>');
document.write('<tr align="center"><td><b>First Name: </b></td><td><input type="text" name="FirstName" value="" size="27"></td></tr>');
document.write('<tr align="center"><td><b>Enter Your Email: </b></td><td><input type="text" name="Email" value="" size="27"></td></tr>');
document.write('<tr align="center"><td colspan="2"><input title="" type="submit" name="Submit" id="Submit" value="Get Blueprints"  class="button"></td></tr>');
document.write('</table>');
document.write('<table cellspacing="0" border="1" align="center" width="80%" style="font-family: Arial, Helvetica, sans-serif; font-size:10px; border:2px solid yellow; font-weight:bold;">');
document.write('<tr><td align="center" style="color:blue; background-color:#FFFF00; border:0px; font-size:12px; ">Blueprints Clock Count-Down</td></tr>');
document.write('<tr><td valign="middle" align="center" style="border:0px; background-color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:9px; ">You Must Claim Your Blueprints Within <input type="text" name="'+divName+'TimerInput" size="1" value=""> Seconds</td></tr>');
document.write('</table>');
document.write('<p style="font-family: Arial, Helvetica, sans-serif; font-size:10px; color:#FFFF00; font-weight:bold;"><span style="font-family:Arial, Helvetica, sans-serif; color:#FF0000; font-weight: bold; font-size: 12px;" id="'+divName+'BlinkWarning"><blink>WARNING!</blink></span> These Blueprints are ONLY available until the clock-timer counts down to zero! Refreshing the screen or coming back in the future will not allow this page to reappear!</p>');
// <!---      END  Content         --->
document.write('</td></tr></table>');
document.write('</td></tr><tr><td height="40"></td></tr></table>');
document.write('<input type="hidden" id="formid" name="formid" value="29"><input type="hidden" id="type" name="type" value="CustomFormWeb">');
document.write('</form>');
document.write('</div></div>');

new Draggable(divName, { revert: false });
}

function EndPopup()
{
//alert("you are leaving!");
}

//---------------------------------------------------------------------
// Function to return the value of the cookie specified by "name".

// Parameter:
//     name     String object containing the cookie name.

// Return:      String object containing the cookie value, or null if
//              the cookie does not exist.
//---------------------------------------------------------------------
function GetCookie (name)
{
    var arg  = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i    = 0;

    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
          return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}
//---------------------------------------------------------------------
// Function to get a cookie.
//---------------------------------------------------------------------
function getCookieVal( offset )
{
    var endstr = document.cookie.indexOf (";", offset);

    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}
//---------------------------------------------------------------------
// Function to set a cookie.
//---------------------------------------------------------------------
function SetCookie( name, value )
{
    var argv    = SetCookie.arguments;
    var argc    = SetCookie.arguments.length;
    var expiredays = (argc > 2) ? argv[2] : null;
    var path    = (argc > 3) ? argv[3] : null;
    var domain  = (argc > 4) ? argv[4] : null;
    var secure  = (argc > 5) ? argv[5] : false;
    
	
	var ExpDate = new Date();
        ExpDate.setDate(ExpDate.getDate() + expiredays);
	
    document.cookie =
        name + "=" + escape (value) +
        ((expiredays == null) ? "" : ("; expires=" + ExpDate.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}
//---------------------------------------------------------------------
// Function to delete a cookie. (Sets expiration date)
//    name - String object containing the cookie name
//---------------------------------------------------------------------
function DeleteCookie (name)
{
    var exp  = new Date();
    var cval = GetCookie (name);

    exp.setTime (exp.getTime() - 1);  // This cookie is history
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function PreLoad()
{
 if(document.images)
  {
  var argLen = arguments.length;
  for(var i = 0; i < argLen; i++)
    {
    var arg = arguments[i];
    self[arg] = new Image();
    self[arg].src = arg;
    }
  
  }
}

//*******************************************************************************************************//

