////////////////////////////////////////////////////////////
//                      Visitor tracking statistics       //
////////////////////////////////////////////////////////////




////////////////////////////////////////////////////////////
//                      Legal Windows pop-ups             //
////////////////////////////////////////////////////////////

function extraWindow()
{
  win=window.open("poverty.html","baby","width=435,height=450,resizable=0,left=10,top=10");
}    function privacy()
{
  win=window.open("privacy.html","priv","width=600,height=540,resizable=1,scrollbars=1,right=10,top=10");
}
function terms()
{
  win=window.open("termsofuse.html","terms","width=600,height=540,resizable=1,scrollbars=1,right=10,top=10");
}  
var win=null;
function NewWindow(mypage,myname,w,h,pos,infocus){
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();}

////////////////////////////////////////////////////////////
//                      Navigation                        //
////////////////////////////////////////////////////////////
//  Insert the links you wish to display in the blanks below
//  You can use RELATIVE links for pages in the Sales 
//  Trapper site, use ABSOLUTE links for pages outside the
//  site (see documentation for details.)

function WriteNavigation() {


var TheLinks = new Array( 'index.html','http://www.7stepstofreedom.com/affiliates/index.html','javascript:NewWindow("termsofuse.html","terms","640","480","center","front");','javascript:NewWindow("contact.html","terms","640","480","center","front");','javascript:NewWindow("privacy.html","terms","640","480","center","front");');


var TheLinkNames = new Array( 'HOME','AFFILIATES','TERMS OF USE','CONTACT US','PRIVACY POLICY'); 



for (x=0; x<(TheLinks.length-1); x++) {
document.write( "<a href='"+TheLinks[x]+"' onclick='exit=false;'>"+TheLinkNames[x]+"</a> | ");
}
document.write( "<a href='"+TheLinks[x]+"' onclick='exit=false;'>"+TheLinkNames[x]+"</a>");
return;
};

////////////////////////////////////////////////////////////
//                  Copyright and Address                 //
////////////////////////////////////////////////////////////
//  Insert the information you wish to appear at the bottom
//  of the pages.  Usually this would be your contact info
//  as well as your copywrite information

function WriteAddress() {

var TheAddress = new Array ('Copyright 2004, ','Virtual Web Marketing Inc., ','50 South Shore Drive, ','Brooks, AB T1R 1M4, ','Canada ');

for (x=0; x<TheAddress.length; x++) {
document.write( TheAddress[x]);
}
return;
};


////////////////////////////////////////////////////////////
//                          Colors                        //
////////////////////////////////////////////////////////////

// The Color of the Background the Page "FLOATS" In

TheBackGroundColor = "#000080";

// The Color of the Background for the Sales Page

TheSalesPageBackground = "#ffffff";

// The Color of the TEXT For the Sales Page

TheSalesPageText = "#000000";

// The Color of the TEXT for the Address

TheAddressColor = "#888888";


////////////////////////////////////////////////////////////
//                        Features                        //
////////////////////////////////////////////////////////////

// Display the Downsell Page when Person Leaves without
// purchasing 1=yes
// NOTE: If you have the time delayed offer set to hit
// when the person leaves without buying, the downsell will
// NOT be shown on the initial visit.  Instead, the time
// sensitive offer will be shown.

var DoTheDown = 0

//  How long, in hours, between each viewing of the downsell

var DownDelay = 0
		// 4320

// Display the Subscribe Pop for Non-Subscribers
	var PopItUp = 0   //ignore this - don't change it
var DoThePop = 0

// How often would you like the pop displayed?
// 0 = every visit else it is the number of hours between
// pops

var HowOftenPop = 1

// Display the WHY NOT page when they pass on the Downsell?
// 1=yes

var DoTheWhyNot = 0

// Number of hours between showing the Why Not

var WhyNotDelay = 0   
			//   4320

// Display the COUNTDOWN Offer upon...
// 1=arriving 
// 2=leaving without buying 
// 0=not at all

var ShowTimeOffer = 0

// If the Time Delayed Offer appears when the person
// arrives, how many seconds before it pops?

var HowSoon = 15

// How much time in minutes and seconds does
// the time offer count down from?


var TimeMinutes = "10"
var TimeSeconds = "0"

// Width and Height of the Sub Pop

var SubPopWidth = 300
var SubPopHeight = 350

// Starting and Ending Position of Sub Pop

  if (navigator.appName == "Netscape") {
    winWidth = window.innerWidth;
    }
else {
    winWidth=document.documentElement.offsetWidth;
    } 


  ScrnCentre = winWidth/2



//  End -->
var StartPosX = 250
var StartPosY = -300
var EndPosX =  ScrnCentre-240
var EndPosY = 200

// Number of Steps to Get From Start to Finish
// as well as speed

var PopSpeed = 10
var PopSteps = 50

// Number of seconds pop hangs around before disappearing
// 0 means it DOESN'T disappear

var KeepItAround = 0

// Delay before Subscribe Pop-up displays

var DelayforSubscribe = 15






////////////////////////////////////////////////////////////
// Create the Default Settings 5 the Limited Time Offers  //
////////////////////////////////////////////////////////////

var RegularPrice = new Array();
var DiscountPrice = new Array();
var Reason4Discount = new Array();
var PercentOff = new Array();


// The number of hours since the initial visit before the
// first offer expires

var Offer1 = 24

RegularPrice[0]= "37";
DiscountPrice[0] = "27";
Reason4Discount[0] = "<i><b><font color=\"#ff0000\">This is the offer for the first 24 hours\: not $37, just $27, more than <u>25% off</u></i></b>";
PercentOff[0] = "25"


// The number of hours since the initial visit before the
// second offer expires

var Offer2 = 72

RegularPrice[1]= "197";
DiscountPrice[1] = "147";
Reason4Discount[1] = "<i><b><font color=\"#ff0000\">This is the offer for the 48 hours hours\: not $197, $147, more than <u>25% off</u></i></b>";
PercentOff[1] = "25"

// The number of hours since the initial visit before the
// third offer expires

var Offer3 = 720

RegularPrice[2]= "197";
DiscountPrice[2] = "147";
Reason4Discount[2] = "<i><b><font color=\"#ff0000\">This is the offer for the next 30 days\: not $197, $147, more than <u>25% off</u></i></b>";
PercentOff[2] = "25"

// The number of hours since the initial visit before the
// fourth offer expires

var Offer4 = 792

RegularPrice[3]= "197";
DiscountPrice[3] = "147";
Reason4Discount[3] = "<i><b><font color=\"#ff0000\">This is the offer for a 3-day sale\: not $197, $147, more than <u>25% off</u></i></b>";
PercentOff[3] = "25"

// The number of hours since the initial visit before the
// fifth offer expires

var Offer5 = 4320

RegularPrice[4]= "197";
DiscountPrice[4] = "147";
Reason4Discount[4] = "<i><b><font color=\"#ff0000\">This is the offer rounds out the first six months\: not $197, $147, more than <u>25% off</u></i></b>";
PercentOff[4] = "25"



////////////////////////////////////////////////////////////
//             What to Do on First Visit                  //
////////////////////////////////////////////////////////////

function ImHere() {

disappear('subpop');

// Show pop-up if required
if (DoThePop==1) {

	var TheSecond = IsCookieHere( "1stVisit");
	var TheThird = IsCookieHere( "subscribed");
	if (TheThird!="here"){ 
		if (TheSecond=="here") {
			TimePassed=timeElapsed();
			if (TimePassed>(HowOftenPop*3600000)) {PopItUp = 1};
//			alert(TimePassed+"howoften"+HowOftenPop*3600000+"pop"+PopItUp);
		};
		if (TheSecond!="here") {PopItUp = 1};
		if (PopItUp==1){
			WiggleSub();    
		};
	};
};

VisitTime() ;


// Display the Time Sensitive Offer if
// the code is correct

var SeenTimeSensitive = IsCookieHere( "TimeOffer");
if(SeenTimeSensitive) {return;}
if(ShowTimeOffer==1) {
setTimeout( "ArriveTimeDelay()", HowSoon*1000);
}
return;
};


function ArriveTimeDelay() {
var ThePopUp3 = window.open( "timedelay.html","PopUp3","directories=no,height=370,width=580,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=yes");
ThePopUp3.moveTo(20,20);
return;
};
////////////////////////////////////////////////////////////
//                What to Do on Leaving                   //
////////////////////////////////////////////////////////////
var exit=true;

function ImLeaving() {

if(exit==false) {return}

// If none of the exit pops are enabled, return
if((ShowTimeOffer!=2)&&(DoTheDown!=1)&&(DoTheWhyNot!=1)) {return};
var PopURL="timedelay.html";

// Check to see if the Time Offer is Enabled for Leaving
// and not seen yet.  If it is enabled but already seen,
// change the URL to the DownSell.

if(ShowTimeOffer==2) {
	var IsIt = IsCookieHere( "TimeOffer");
	if(IsIt){ PopURL="downsell.html"}
	}

// If the URL is still Time Delay, but it is not disabled,
// set the URL to Downsell

if((PopURL=="timedelay.html")&&(ShowTimeOffer!=2)){ PopURL="downsell.html"};

// If the URL is the Down Sell, but it is NOT enabled,
// change the URL to the Why Not
if((PopURL=="downsell.html")&&(DoTheDown!=1)){ PopURL="whynot.html"};

// If the URL is the Down Sell but the downsell has already
// been shown, change the URL to the Why Not
IsIt = IsCookieHere( "downsell");
if((PopURL=="downsell.html")&&(IsIt)){ PopURL="whynot.html"};

// If the URL has (finally) been changed to the Why Not
// but the Why Not has already been shown, return

IsIt = IsCookieHere( "whynot");
if((PopURL=="whynot.html")&&(IsIt)){ return};

// If the URL is the Why Not but it is not enabled,
// return

if((PopURL=="whynot.html")&&(DoTheWhyNot!=1)){ return};

// If you're still here, pop the window to the proper
// URL

var ThePopUp = window.open( PopURL,"PopUp","directories=no,height=600,width=500,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes");
ThePopUp.moveTo(20,20);
};


////////////////////////////////////////////////////////////
//              Show the Wiggle-Image Pop                 //
////////////////////////////////////////////////////////////

function WiggleSub() {

setTimeout("floatDiv('subpop',StartPosX,StartPosY,EndPosX,EndPosY,PopSteps,PopSpeed,KeepItAround);",(DelayforSubscribe*1000));

};



////////////////////////////////////////////////////////////
//         Searches to see if a cookie is present         //
////////////////////////////////////////////////////////////

function IsCookieHere(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 "here";
i=document.cookie.indexOf(" ",i)+1;
if (i==0) {break;}
}
return null;
}


////////////////////////////////////////////////////////////
//         Write Cookie with #Hours Expire Time           //
////////////////////////////////////////////////////////////

function WriteCookie(name,value,hours) {
var expire=new Date();
var HowLong = hours*3600000
expire=new Date(expire.getTime()+HowLong);
document.cookie= name+"="+value+"; path=/; expires="+expire;
return;
}

////////////////////////////////////////////////////////////
//       Write Visit Cookie IF Not Already There          //
////////////////////////////////////////////////////////////




function VisitTime() {
var x = IsCookieHere("1stVisit");
//var y = IsCookieHere("ThisVisit");

if (x==null){ 
	var TheDateNow = new Date();
	var VisitTime = TheDateNow.getTime();
	WriteCookie( "1stVisit",VisitTime,4320);
    };
//
//if (y==null){ 
//	var TheDateNow = new Date();
//	var VisitTime = TheDateNow.getTime();
//	WriteCookie( "ThisVisit",VisitTime,HowOftenPop);
//    };
//

return;
};



////////////////////////////////////////////////////////////
//     This routine takes a "normal" date and creates     //
//     a "printable" version                              //
////////////////////////////////////////////////////////////

function WriteDate( MyDate) {

DaysofWeek = new Array()
DaysofWeek[0]="Sunday"
DaysofWeek[1]="Monday"
DaysofWeek[2]="Tuesday"
DaysofWeek[3]="Wednesday"
DaysofWeek[4]="Thursday"
DaysofWeek[5]="Friday"
DaysofWeek[6]="Saturday"

Months = new Array()
Months[0]="January"
Months[1]="February"
Months[2]="March"
Months[3]="April"
Months[4]="May"
Months[5]="June"
Months[6]="July"
Months[7]="August"
Months[8]="September"
Months[9]="October"
Months[10]="November"
Months[11]="December"

var day = DaysofWeek[MyDate.getDay()]
var date = MyDate.getDate()
var Month = Months[MyDate.getMonth()]
var Year = MyDate.getFullYear()

if (date == 1 || date == 21 || date == 31)
{ender = "<SUP>st</SUP>"}

else
if (date == 2 || date == 22)
{ender = "<SUP>nd</SUP>"}

else
if (date == 3 || date == 23)
{ender = "<SUP>rd</SUP>"}

else
{ender = "<SUP>th</SUP>"}

var TextDate = day+", "+Month+" "+date+", "+Year 

return TextDate;

};

////////////////////////////////////////////////////////////
//         Creates the Time as a String                   //
////////////////////////////////////////////////////////////

function WriteTime( MyDate) {
var yyy = MyDate.getHours();
NightorDay = "am";
if(yyy > 12){ 
yyy=yyy-12;
NightorDay="pm"
};
var xxx=MyDate.getMinutes();
if(xxx<10) {xxx="0"+xxx;}
TextHours = yyy+":"+xxx+" "+NightorDay;
return TextHours;
};

////////////////////////////////////////////////////////////
//      Look for and get a value for a cookie             //
////////////////////////////////////////////////////////////

function DecodeCookie( name) {
TheCookie = document.cookie;
var Answer = "";
var List1 = new Array();
var List2 = new Array();
List1 = TheCookie.split( ";");
for (a=0; a<List1.length; a++) {
List2 = List1[a].split("=");
if((List2[0]==name)||(List2[0]==(" "+name))) {
Answer = List2[1];
}
}
return Answer;
};


////////////////////////////////////////////////////////////
//   Checks time passed since 1st Visit                   //
////////////////////////////////////////////////////////////

// NOTE:Each of the "Periods" below is in hours 
// since the first visit

function timeElapsed() {
var xyz2 = DecodeCookie( "1stVisit");
if(xyz2==null) { return 0;}
var TheDateNow2 = new Date();
var x2 = TheDateNow2.getTime();
var TimePassed = x2-xyz2;

return TimePassed;
}



////////////////////////////////////////////////////////////
//   Chooses the Proper Offer Based on the Visit Time     //
////////////////////////////////////////////////////////////

// NOTE:Each of the "Periods" below is in hours 
// since the first visit

function SetPrice( Period1,Period2,Period3,Period4,Period5) {
var xyz2 = DecodeCookie( "1stVisit");
if(xyz2==null) { return 0;}
var TheDateNow2 = new Date();
var x2 = TheDateNow2.getTime();
var TimePassed = x2-xyz2;
if((TimePassed>=(Period1*3600000))&&(TimePassed<(Period2*3600000))) {return 1;}
if((TimePassed>=(Period2*3600000))&&(TimePassed<(Period3*3600000))) {return 2;}
if((TimePassed>=(Period3*3600000))&&(TimePassed<(Period4*3600000))) {return 3;}
if((TimePassed>=(Period4*3600000))&&(TimePassed<(Period5*3600000))) {return 4;}
if(TimePassed>=(Period5*3600000)) {return 4;}
return 0;
}

var TheOfferNumber = SetPrice(Offer1,Offer2,Offer3,Offer4,Offer5);


////////////////////////////////////////////////////////////
//            Moving Layer Pop-Over Functions             //
////////////////////////////////////////////////////////////

function getObj(name)
{
  if (document.getElementById) {
    this.obj = document.getElementById(name);
    this.style = document.getElementById(name).style;
  }
  else if (document.all) {
    this.obj = document.all[name];
    this.style = document.all[name].style;
  }
  else if (document.layers) {
    this.obj = document.layers[name];
    this.style = document.layers[name];
  }
}
function disappear(which)
{
  var x = new getObj(which);
  x.style.visibility = 'hidden';
}
function appear(which)
{
  var xxx = new getObj(which);
  xxx.style.visibility = 'visible';

}
function moveDiv(which, startx, starty, finishx, finishy, steps, speed)
{
  var x = new getObj(which);
  if (steps) {
    stepx = (finishx - startx)/steps;
    stepy = (finishy - starty)/steps;
    steps -= 1;
    x.style.top = starty;
    x.style.left = startx;
    startx=startx+stepx;
    starty=starty+stepy;
    setTimeout("moveDiv('"+which+"',"+startx+","+starty+","+finishx+","+finishy+","+steps+","+speed+")",speed);
  }
}
function floatDiv(which, startx, starty, finishx, finishy, steps, speed, hangtime)
{
  var x = new getObj(which);
  x.style.visibility = 'visible';
  moveDiv(which, startx, starty, finishx, finishy, steps, speed);
  if (hangtime != 0) {
    setTimeout("disappear('"+which+"')",hangtime*1000);
  }

}

////////////////////////////////////////////////////////////
//                Countdown Timer Script                  //
////////////////////////////////////////////////////////////

var limit=TimeMinutes+":"+TimeSeconds;
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function begintimer(){
if (!document.images) {return};

if (parselimit==1) { window.close()}
else{ 
parselimit-=1;
curmin=Math.floor(parselimit/60);
cursec=parselimit%60;
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left"
else
curtime=cursec+" seconds left"
window.status=curtime
window.timer.MinRemain.value=curmin
window.timer.SecRemain.value=cursec
setTimeout("begintimer()",1000)
}
}


