<!-- Standard ToolBookDeveloper.com JavaScript file  -->

var greeting;
function getGreeting(){
datetoday = new Date();
timenow=datetoday.getTime();
datetoday.setTime(timenow);
thehour = datetoday.getHours();
if (thehour > 18) display = "Evening";
else if (thehour >11) display = "Afternoon";
else display = "Morning";
greeting = ("Good " + display + "!");
}
getGreeting();

// Get today's current date.
var today;
function getToday(){
var now = new Date();
// Array list of days.
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
// Array list of months.
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "" : "")+ now.getDate();
// Join it all together
today =  months[now.getMonth()] + " " +
               date + ", " +
                (fourdigits(now.getYear()));
}

// Calculate four digit year.
function fourdigits(number)	{
	return (number < 1000) ? number + 1900 : number;
}

getToday();

var winPopupObj;
var winPopupURL;
function popupBlockerChecker(winObj, winURL){
winPopupObj = winObj;
winPopupURL = winURL;
setTimeout('popupBlockerChecker2()',100);
}

function popupBlockerChecker2(){
if (winPopupObj && winPopupObj.closed){
alert("Your computer is blocking POP-UP's from this site. You will not be able to view the requested page.  You must disable the pop-up blocker or allow pop-ups from this site in order to view the page.");
}
}

function doPopUpPre_order(){
var winURL = "http://www.toolbookdeveloper.com/forms/preorder.mv";
var winWidth = 750;
var winHeight = 550;
doPopUpWin(winURL,winWidth,winHeight);
}

function doPopUpDevEx(){
// Developers Exchange popup
var winURL = 'http://www.toolbookdeveloper.com/freebees/devextools.htm';
var winName = 'DevEx';
var winLeft;
var winTop;
var winWidth=700;
var winHeight=500;
if (!winLeft){
	if (!winWidth){
		winLeft=0;
		winWidth=screen.width-10;
	}else{
		winLeft=(screen.width-winWidth-10)/2;
	}
}
if (!winTop){
	if (!winHeight){
		winTop=0;
		winHeight=screen.height-37;
	}else{
		winTop=(screen.height-winHeight-37)/2;
	}
}
if (!winWidth) winWidth=screen.width-(winLeft*2)-10;
if (!winHeight) winHeight = screen.height-(winTop*2)-37;
var winPosn = 'left=' + winLeft + ',top=' + winTop;
var winFeatures = ',menubar=no,toolbar=no,location=no,scrollbars=yes,status=no,resizable=no,';
var winSize = 'width=' + winWidth + ',height=' + winHeight;
winFeatures = winPosn + winFeatures + winSize;
var winObj = window.open(winURL,winName,winFeatures);
//sets focus to popup window if already open this will bring it to the front
winObj.focus();
}

function doPopUpProductTerms(productTitle){
// Standard EULA Popup
var winURL = 'http://www.toolbookdeveloper.com/products/eula/terms.htm?product='+escape(productTitle);
var winName = 'EULA';
var winLeft;
var winTop;
var winWidth=670;
var winHeight=500;
if (!winLeft){
	if (!winWidth){
		winLeft=0;
		winWidth=screen.width-10;
	}else{
		winLeft=(screen.width-winWidth-10)/2;
	}
}
if (!winTop){
	if (!winHeight){
		winTop=0;
		winHeight=screen.height-37;
	}else{
		winTop=(screen.height-winHeight-37)/2;
	}
}
if (!winWidth) winWidth=screen.width-(winLeft*2)-10;
if (!winHeight) winHeight = screen.height-(winTop*2)-37;
var winPosn = 'left=' + winLeft + ',top=' + winTop;
var winFeatures = ',menubar=no,toolbar=no,location=no,scrollbars=yes,status=no,resizable=no,';
var winSize = 'width=' + winWidth + ',height=' + winHeight;
winFeatures = winPosn + winFeatures + winSize;
var winObj = window.open(winURL,winName,winFeatures);
//sets focus to popup window if already open this will bring it to the front
winObj.focus();
}

function doPopUpImportCategory(productName,productCategory){
// Standard EULA Popup
var winURL = 'http://www.toolbookdeveloper.com/products/customcatalog/index.htm?product=' + escape(productName) + '&category=' + escape(productCategory);
var winName = 'ImportCategory';
var winLeft;
var winTop;
var winWidth=670;
var winHeight=500;
if (!winLeft){
	if (!winWidth){
		winLeft=0;
		winWidth=screen.width-10;
	}else{
		winLeft=(screen.width-winWidth-10)/2;
	}
}
if (!winTop){
	if (!winHeight){
		winTop=0;
		winHeight=screen.height-37;
	}else{
		winTop=(screen.height-winHeight-37)/2;
	}
}
if (!winWidth) winWidth=screen.width-(winLeft*2)-10;
if (!winHeight) winHeight = screen.height-(winTop*2)-37;
var winPosn = 'left=' + winLeft + ',top=' + winTop;
var winFeatures = ',menubar=no,toolbar=no,location=no,scrollbars=yes,status=no,resizable=no,';
var winSize = 'width=' + winWidth + ',height=' + winHeight;
winFeatures = winPosn + winFeatures + winSize;
var winObj = window.open(winURL,winName,winFeatures);
//sets focus to popup window if already open this will bring it to the front
winObj.focus();
}

var productName = 'Default Product';
var productCategory = 'Default Category.wbk';
function getCategoryDetails(){
	productName = getParam('product');
	productCategory = getParam('category');
}

function downloadProduct(fileName){
//	if(!agree_eula()) return;
	var dlFile = "download_prod.php?Store_Code="+store_id+"&ID="+secCode+"&file="+fileName+"&sgc="+sgc;
	window.location = dlFile;
}

function doDownloadProduct(product){
// Standard Popup Download product function
var winURL = 'http://www.toolbookdeveloper.com/downloads/products/' + product + '/index.htm';
var winWidth=670;
var winHeight=500;
doPopUpWin(winURL,winWidth,winHeight);
}

function doDownloadFreeBee(freebee){
// Standard Popup Download freebee function
var winURL = 'http://www.toolbookdeveloper.com/downloads/freebees/' + freebee + '/license.htm';
//var winWidth=670;
var winWidth=500;
var winHeight=500;
doPopUpWin(winURL,winWidth,winHeight);
}

function doPopUpmulti_form(){
var winURL = 'http://www.toolbookdeveloper.com/forms/multi_form.mv';
var winWidth=650;
var winHeight=450;
doPopUpWin(winURL,winWidth,winHeight);
}

function doPopUpfreebee_sub(){
var winURL = 'http://www.toolbookdeveloper.com/forms/freebee_sub.mv';
var winWidth=700;
var winHeight=575;
doPopUpWin(winURL,winWidth,winHeight);
}

function doPopUppbbconv(){
var winURL = 'http://www.toolbookdeveloper.com/forms/pbb_conv_app.mv';
var winWidth=700;
var winHeight=575;
doPopUpWin(winURL,winWidth,winHeight);
}

function doPopUpfeedback(){
//var winURL = 'http://www.toolbookdeveloper.com/freebees/feedback.htm';
//var winWidth=650;
//var winHeight=450;
//doPopUpWin(winURL,winWidth,winHeight);
}

function doPopUppbbnewfeat(){
var winURL = 'http://www.toolbookdeveloper.com/products/pbb/pbbnewfeat.htm';
var winWidth=650;
var winHeight=450;
doPopUpWin(winURL,winWidth,winHeight);
}

function doAboutOrder(){
var winURL = "http://www.toolbookdeveloper.com/products/about_order.htm";
var winName = 'about_order';
var winWidth = 750;
var winHeight = 350;
doPopUpWinName(winURL,winName,winWidth,winHeight);
}

function doHowMethods(){
var winURL = "http://www.toolbookdeveloper.com/products/userguides/how_methods.htm";
var winName = 'how_methods';
var winWidth = 750;
var winHeight = 550;
doPopUpWinName(winURL,winName,winWidth,winHeight);
}

function doAddToCart(product){

}


function doPopUpWin(winURL,winWidth,winHeight){
// General purpose PopUp window maker
var winName = 'TBDPopUp';
var winLeft;
var winTop;
if (!winLeft){
	if (!winWidth){
		winLeft=0;
		winWidth=screen.width-10;
	}else{
		winLeft=(screen.width-winWidth-10)/2;
	}
}
if (!winTop){
	if (!winHeight){
		winTop=0;
		winHeight=screen.height-37;
	}else{
		winTop=(screen.height-winHeight-37)/2;
	}
}
if (!winWidth) winWidth=screen.width-(winLeft*2)-10;
if (!winHeight) winHeight = screen.height-(winTop*2)-37;
var winPosn = 'left=' + winLeft + ',top=' + winTop;
var winFeatures = ',menubar=no,toolbar=no,location=no,scrollbars=yes,status=no,resizable=no,';
var winSize = 'width=' + winWidth + ',height=' + winHeight;
winFeatures = winPosn + winFeatures + winSize;
var winObj = window.open(winURL,winName,winFeatures);
//sets focus to popup window if already open this will bring it to the front
winObj.focus();
}

function doPopUpWinName(winURL,winName,winWidth,winHeight){
// General purpose PopUp window maker, this is the same a doPopUpWin except we pass the window name
var winLeft;
var winTop;
if (!winLeft){
	if (!winWidth){
		winLeft=0;
		winWidth=screen.width-10;
	}else{
		winLeft=(screen.width-winWidth-10)/2;
	}
}
if (!winTop){
	if (!winHeight){
		winTop=0;
		winHeight=screen.height-37;
	}else{
		winTop=(screen.height-winHeight-37)/2;
	}
}
if (!winWidth) winWidth=screen.width-(winLeft*2)-10;
if (!winHeight) winHeight = screen.height-(winTop*2)-37;
var winPosn = 'left=' + winLeft + ',top=' + winTop;
var winFeatures = ',menubar=no,toolbar=no,location=no,scrollbars=yes,status=no,resizable=no,';
var winSize = 'width=' + winWidth + ',height=' + winHeight;
winFeatures = winPosn + winFeatures + winSize;
var winObj = window.open(winURL,winName,winFeatures);
//sets focus to popup window if already open this will bring it to the front
winObj.focus();
}

IE4 = document.all;

function ASYM_Request(title,mess,icon,mods) {
   (IE4) ? makeMsgBox(title,mess,icon,0,0,mods) : alert(mess);
}

function ASYM_Confirm(title,mess,icon,defbut,mods) {
   if (IE4) {
      icon = (icon==0) ? 0 : 2;
      defbut = (defbut==0) ? 0 : 1;
      retVal = makeMsgBox(title,mess,icon,4,defbut,mods);
      retVal = (retVal==6);
   }
   else {
      retVal = confirm(mess);
   }
   return retVal;
}

function ASYM_Ask(title,mess,def) {
   retVal = (IE4) ? makeInputBox(title,mess,def) : prompt(mess,def);
   return retVal;
}

function doPopUpppt_survey(){
var winURL = 'http://www.toolbookdeveloper.com/forms/survey.mv';
var winWidth=650;
var winHeight=450;
doPopUpWin(winURL,winWidth,winHeight);
}
var searchDets = window.location.search;
searchDets = searchDets.substring(1,searchDets.length).split('&');
function getParam(paramName){
	for(i=0;i<searchDets.length;i++){
		var passValue = searchDets[i].split('=');
		if (passValue[0]==paramName) return unescape(passValue[1]);
	}
	return null;
}

function agree_eula(){
	var Msg = 'You should have read the Nirvana Bound terms and conditions before downloading this PRODUCT.\r\n';
	Msg = Msg + 'Downloading the PRODUCT indicates your acceptance of the license agreement and warranty.';
	alert(Msg);
	return true;
}