/**********
what day is it?
**********/


function MakeArray(n) {
this.length = n
return this
}
monthNames = new MakeArray(12)
monthNames[1] = "January"
monthNames[2] = "February"
monthNames[3] = "March"
monthNames[4] = "April"
monthNames[5] = "May"
monthNames[6] = "June"
monthNames[7] = "July"
monthNames[8] = "August"
monthNames[9] = "September"
monthNames[10] = "October"
monthNames[11] = "November"
monthNames[12] = "December"
dayNames = new MakeArray(7)
dayNames[1] = "Sunday"
dayNames[2] = "Monday"
dayNames[3] = "Tuesday"
dayNames[4] = "Wednesday"
dayNames[5] = "Thursday"
dayNames[6] = "Friday"
dayNames[7] = "Saturday"


function customDateString(oneDate) {
var theDay = dayNames[oneDate.getDay() + 1]
var theMonth = monthNames[oneDate.getMonth() + 1]
var theYear = oneDate.getFullYear()
return theDay + ", " + theMonth + " " + oneDate.getDate() + ", " + theYear
 }


function writeDate(){
document.write("<font face='arial' size='2'>Nerdy Books Tip-of-Day for " + customDateString(new Date()) + " (&copy; 2008 Nerdy Books)</font>")
}

// for internal use only -- we don't need the words "Nerdy Books"
function writeDateInternal(){
document.write("<font face='arial' size='2'>Tip-of-Day: " + customDateString(new Date()) + " (&copy; 2008 Nerdy Books).</font>")
}

 

/**********
what software is today's tip for?
**********/

time = new Date ();
todayIs = time.getTime();
startCount = new Date("March 8, 2009")
startDate = startCount.getTime()
daysPassed = parseInt((todayIs-startDate)/(24*60*60*1000))
origDaysPassed = parseInt((todayIs-startDate)/(24*60*60*1000))





// The displayTip function displays the tip in the current window
function displayTip() {
document.write("<br><img alt='Tip-of-Day' border='2' bordercolor='black' src='http://www.nerdybooks.com/tips2003/" + daysPassed + ".gif'></b></font>")
document.write("<font face='arial' size='2'><br>See more tips at <a href='http://www.nerdybooks.com' target='_blank'>www.nerdybooks.com</a>.")
}



// The displayTipInternal function is for our use only
function displayTipInternal() {
writeDateInternal()
document.write("<br><img alt='Tip-of-Day' border='2' bordercolor='black' src='http://www.nerdybooks.com/tips2003/" + daysPassed + ".gif'></b></font>")
}




/*The displayTipAffiliate function displays the tip in the current window. It's just like the displayTip function, except it eliminates the lines below the graphic, so affiliates can write their own links.
*/
function displayTipAffiliate() {
document.write("<br><img alt='Tip-of-Day' border='2' bordercolor='black' src='http://www.nerdybooks.com/tips2003/" + daysPassed + ".gif'></b></font>")
}


// The displayTipSize function displays the tip in the current window
// and allows the user to specify width and height.
// It's for tips in a page with content, not a popup window
function displayTipSize(imgWidth, imgHeight) {
theWindow = "<br><img alt='Tip-of-Day' border='2' bordercolor='black' width='" + imgWidth + "' height='" + imgHeight + "' src='http://www.nerdybooks.com/tips2003/" + daysPassed + ".gif'></b></font>"
document.write(theWindow)
document.write("<font face='arial' size='2'><br>See more tips at <a href='http://www.nerdybooks.com' target='_blank'>www.nerdybooks.com</a>.")
}


/* The displayTipSizeAffiliate function displays the tip in the current window and allows the user to specify width and height. It's for tips in a page with content, not a popup window. It's just like the displayTipSize function, except it eliminates the lines below the graphic, so affiliates can write their own links.
*/
function displayTipSizeAffiliate(imgWidth, imgHeight) {
theWindow = "<br><img alt='Tip-of-Day' border='2' bordercolor='black' width='" + imgWidth + "' height='" + imgHeight + "' src='http://www.nerdybooks.com/tips2003/" + daysPassed + ".gif'></b></font>"
document.write(theWindow)
}




// The displayTipWindow function originally did NOT open
// a new browser window, but that caused too many problems
// -- the displayTipWindow and displayTip functions
// are now identical
function displayTipWindow() {
document.write("<br><img alt='Tip-of-Day' border='2' bordercolor='black' src='http://www.nerdybooks.com/tips2003/" + daysPassed + ".gif'></b></font>")
document.write("<font face='arial' size='2'><br>See more tips at <a href='http://www.nerdybooks.com' target='_blank'>www.nerdybooks.com</a>.")
}


/*The displayTipWindowAffiliate function is just like the displayTipWindow function, except it eliminates the lines below the graphic, so affiliates can write their own links.
*/
function displayTipWindowAffiliate() {
document.write("<br><img alt='Tip-of-Day' border='2' bordercolor='black' src='http://www.nerdybooks.com/tips2003/" + daysPassed + ".gif'></b></font>")
}
 





/**********
this code generates the tip-of-day popup window
**********/

// find the screen size, then use the numbers
// to center the window on the screen
screenWidth = screen.availWidth;
screenHeight = screen.availHeight;
leftSide = (screenWidth - 559)/2;
topSide = (screenHeight - 550)/2;



// this one has absolute references for the rest of the world
function nbpopup() {
tipOfDayWindow = window.open("http://www.nerdybooks.com/friend/tipwindowxp.html", "tipwindow", "toolbar=no,directories=no,height=550,width=585,menubar=no,scrollbars=no,resizable=no");
tipOfDayWindow.focus()
// tipOfDayWindow.moveTo(leftSide,topSide)
return;
}







/**********
write out all functions
**********/



// This function uses the displayTip function to open the link in a new browser window
function tipofday() {
// alert("Original Days passed is " + origDaysPassed)
// alert("Days passed is " + daysPassed)
	writeDate()
	displayTip()
}


/* This function uses the displayTip function to open the link in a new browser window (just like the tipofday() function. It also eliminates the line below the tip graphic, so affiliates can post their custom links.
*/
function tipofdayAffiliate() {
// alert("Original Days passed is " + origDaysPassed)
// alert("Days passed is " + daysPassed)
	writeDate()
	displayTipAffiliate()
}


// If this function calls displayTipWindow instead of displayTip(), the link back to nerdybooks.com will open in the same window. Otherwise, the tipofdayWindow() and tipofday() functions are identical.


function tipofdayWindow() {
	writeDate()
	displayTip()
//	displayTipWindow()
}


/* The tipofdayWindowAffiliate is just like the tipofdayWindow function, except it eliminates the line under the graphic, so affiliates can write their own link.
*/

function tipofdayWindowAffiliate() {
	writeDate()
	displayTipAffiliate()
//	displayTipWindow()
}



function tipofdaySize(imgWidth, imgHeight) {
//	theWidth = imgWidth
//	theHeight = imgHeight
	writeDate()
	displayTipSize(imgWidth, imgHeight)


}


/* The tipofdaySizeAffiliate function is just like the tipofdaySize function, except it eliminates the line below the tip graphic, so affiliates can put their own links there.
*/
function tipofdaySizeAffiliate(imgWidth, imgHeight) {
//	theWidth = imgWidth
//	theHeight = imgHeight
	writeDate()
	displayTipSizeAffiliate(imgWidth, imgHeight)


}



/**********
This section is for custom functions for affiliates
**********/


// this one is for AMF Software (Andrew Freeman)
// Affiliate ID 111076, amf1@amfsoftware.com
function nbpopupAffiliateAMF() {
tipOfDayWindow = window.open("http://www.nerdybooks.com/1a/affiliates/tipwindowAMF.html", "tipwindow", "toolbar=no,directories=no,height=550,width=585,menubar=no,scrollbars=no,resizable=no");
tipOfDayWindow.focus()
// tipOfDayWindow.moveTo(leftSide,topSide)
return;
}


