//Copyright 2006,2007 Bontrager Connection, LLC
// http://bontragerconnection.com/ and http://www.willmaster.com/
// Version: July 28, 2007
var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(d) {
if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}
d.style.left = (cX-150) + "px";//centred
d.style.top = (cY+10) + "px";
}
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
dd.style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = "block"; }
else { dd.style.display = "none"; }
}

//This bit NOT Copyright 2006,2007 Bontrager Connection

//onMouseover information boxes add as many as needed. 
//Must be called by reference and must had div defined in mouseover.css
var numTabs=9; //number of unique divs used in total called on website

function doMouseOverDivs(calledDivs){
//list all divs  each unique each requiring mouseover.css definition REQUIRED
//convenience of not having to change on all pages and also it is hidden completely
var	tab1="<div id='tab1'>Click for some history about the company and what we have to offer currently.</div>"	;
var	tab2="<div id='tab2'>Click for detailed information to help you self-publish including frequently asked questions.</div>";
var	tab3="<div id='tab3'>Click for pricing information and for our online price enquiry form.</div>";
var	tab4="<div id='tab4'>Click to read what some of our clients say about us and to see samples.</div>";
var	tab5="<div id='tab5'>Click to visit Authors&#8217; Pages and MyLiveBook sample pages of published books.</div>";
var	tab6="<div id='tab6'>Click for telephone, email and file upload information.</div>";
var	tab7="<div id='tab7'>Click to go to the last page visited.</div>";
var	tab8="<div id='tab8'>Click to go through the website in order.</div>";
var	tab9="<div id='tab9'>Click to find out more to help you promote your book once it is printed - for free.</div>";

var callTheDiv='';//initialise

for (i=1;i<=numTabs;i++){
	if (calledDivs.indexOf('tab'+i)>=0){
		callTheDiv=callTheDiv+eval('tab'+i);//only set active on page if called through function and create string for document.write
	}
}
		return callTheDiv;
}

//var thisCookie = 'balloonState'; // This is the name of the cookie that is used.  
var toggleWord='off';//initialise
var SPBcookieName='SPBhelp';

function doHelpboxToggle () {
var tabId='';//init
	for (i=1;i<=numTabs;i++) {
			tabId='tab'+ i.toString();
			tabId = document.getElementById(tabId);	
			tabId.style.visibility = (tabId.style.visibility == 'hidden') ? 'visible' : 'hidden';	
		}
	toggleWord = (toggleWord == 'on') ? 'off' : 'on';
	drawTxt('toggleWord',toggleWord);
	createCookie (SPBcookieName, toggleWord, '9999');
}

function getToggleState(){
	var tabId='';//init
	var theBalloons='visible';//init
	toggleWord=readCookie(SPBcookieName);
	if(toggleWord=='on'){
		theBalloons='hidden';
	}
	else{
			theBalloons='visible';
			toggleWord='off';
	}
	for (i=1;i<=numTabs;i++) {
			tabId='tab'+ i.toString();
			tabId = document.getElementById(tabId);	
			tabId.style.visibility = theBalloons;	
		}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

