////////////////////////////////////////////////////////////
//                      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','sub.html','us.html','faq.html','contact.html','bio.html');

var TheLinkNames = new Array( 'HOME','AFFILIATES','ORDER','FREQUENT QUESTIONS','CONTACT US','ABOUT US'); 


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 2007','Lose 10 Pounds in 2 Weeks.com');

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


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

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

TheBackGroundColor = "#FFFFFF";

// 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 = "#000000";


////////////////////////////////////////////////////////////
//                        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 = 4320

// Display the Subscribe Pop for Non-Subscribers

var DoThePop = 2

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

var HowOftenPop = 0

// 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 = 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 = 5

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


var TimeMinutes = "0"
var TimeSeconds = "5"

// Width and Height of the Sub Pop

var SubPopWidth = 230
var SubPopHeight = 150

// Starting and Ending Position of Sub Pop

var StartPosX = 300
var StartPosY = -300
var EndPosX = 250
var EndPosY = 100

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

var PopSpeed = 1
var PopSteps = 50

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

var KeepItAround = 30

// Delay before Subscribe Pop-up displays

var DelayforSubscribe = 5






////////////////////////////////////////////////////////////
// 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]= "197";
DiscountPrice[0] = "147";
Reason4Discount[0] = "<i><b><font color=\"#ff0000\">This is the offer for the first 24 hours\: not $197, $147, 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');

VisitTime();

// Show pop-up if required
if (DoThePop!=1) {
return;
};
var PopItUp = 0
var TheSecond = IsCookieHere( "Visit");
var TheThird = IsCookieHere( "subscribed");
if ((TheSecond==null)&&(TheThird==null)) { 
PopItUp = 1;
};
if (PopItUp==1) { 
WiggleSub();
};

// 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( "td.html","PopUp3","directories=no,height=600,width=500,location=no,menubar=no,scrollbars=yes,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="td.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="ds.html"}
	}

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

if((PopURL=="td.html")&&(ShowTimeOffer!=2)){ PopURL="ds.html"};

// If the URL is the Down Sell, but it is NOT enabled,
// change the URL to the Why Not
if((PopURL=="ds.html")&&(DoTheDown!=1)){ PopURL="wn.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=="ds.html")&&(IsIt)){ PopURL="wn.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=="wn.html")&&(IsIt)){ return};

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

if((PopURL=="wn.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")
if(x){ return};
var TheDateNow = new Date();
var VisitTime = TheDateNow.getTime();
xx = WriteCookie( "1stVisit",VisitTime,4320);
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;
};


////////////////////////////////////////////////////////////
//   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)
}
}
