<!--
/****************************************************
*			    	General Routines
*             ==================
*            Please edit with care...
*****************************************************/

// creates banner on top of page
function createBanner(text) {top.head.document.getElementById("pageheader").innerHTML = text;}

var curPage="";
function changeNav(pID) {
	for (i=1;i<8;i++) { pageID = "p"+i+"";	var cname = (pageID == pID)?"pbutton":"mbutton";
		top.head.document.getElementById(pageID).className=cname;}
		curPage=pID;
}

/*****************************************************************************************************************/
// "within-page" navigation; one book <DIV> (of id "objid") is displayed while making previous book invisible.
var objBook = null;										// old (or previous) book
function doShowBook(objid) {
	if (objBook) objBook.style.display="none";	// blank any book that is displayed
	objBook=getObject(objid);							// get referenced object
	objBook.style.display = "block";					// display it
}

// returns the "name" Object
function getObject(name) {
	return (document.getElementById?document.getElementById(name):document.all?document.all[name]:document.layers?eval("document.layers[\"" + name + "\"]"):null);
}

/*****************************************************************************************************************/
// HINTS.  Used on main page to introduce page subject matter and contents

// NOTE: first element not used... it just shows the order of text for hints
// hintarray items may contain any valid HTML; for quotes rememver to use ' NOT "  !

var hintarray = new Array("0-menu, 1-home, 2-books, 3-motivation,4-reviews, 5-talks, 6-contact, 7-biography, 8-previews",
"<h1>welcome</h1>",
"<h1>My published books</h1><p>Read the synopses, excerpts and availability information for my books. See my latest book <a href='books.html#molly'><em>Molly's Story: Aftermath of War and Love</em></a></p>",
"<h1>Motivation</h1><p>Why I write and what inspires me...</p>",
"<h1>Reviews</h1><p>Please take a look at what people have said about my published work... Enjoy!</p>",
"<h1>Talks &amp; Readings</h1><p>I'd love to visit your school to discuss writing and my books!<br />Please call or email me to discuss.</p>",
"<h1>Contact Information</h1><p>How to reach me by email, phone and post...</p>",
"<h1>Biography</h1><p>Just a few details about me...</p>",
"<h1>Previews</h1><p>Just that...</p>");

// display hint when link is rolled over...
function doHint(linkNum) {
	objPage=getObject("hint");							// get referenced object
 	objPage.innerHTML = hintarray[linkNum];		// write the appropriate text
  	objPage.style.display = "block";					// display it
}

var stickyHint = true;	// sticky determines whether hints stay on or are reset following roll-over

// returns hint to default
function noHint() {
	objPage=getObject("hint");							// get referenced object
	if (!stickyHint) objPage.innerHTML = hintarray[1];				// display the Index Page text
}

// returns hint to default
function doHomeText() {
	objPage=getObject("hint");							// get referenced object
	objPage.innerHTML = hintarray[1];				// display the Index Page text
}
/******************************************** end hints ***********************************************/


// used in body as <... onLoad="MM_preloadImages('/images/xxx.jpg','/images/yyy.jpg',...">

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// used in <... onMouseOut="MM_swapImgRestore()">

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// used in <... onMouseOver="MM_swapImage('image_name_and_ID','','swap_image_source',1)">

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Used to fade between one colour (rgb_start) and another (rgb_final).
// To create an effect of a link changing between colours, use: <a href="...". id="unique_id" onMouseOver="KW_fade(r_start,g_start,b_start,r_final,g_final,b_final,speed,this.id)" onMouseOut="KW_fade(r_final,g_final,b_final,r_start,g_start,b_start,speed,this.id)"
// speed is ~20?  don't know the units.

function KW_s(r, g, b, el) {
// changes colour of element (el) to hex value of rgb
    d=document;hr=r.toString(16);hg=g.toString(16);hb=b.toString(16);
	hr=(hr.length==1)?"0"+hr:hr;hg=(hg.length==1)?"0"+hg:hg;hb=(hb.length==1)?"0"+hb:hb;
	if (d.getElementById) d.getElementById(el).style.color="#"+hr+hg+hb;
}

function KW_c(a,b,s,i) { return Math.floor(a*((s-i)/s)+b*(i/s)); }

function KW_fade(r,g,b,e,n,l,s,o){
// fades colour (rgb) of object (o) to (enl) at speed (s)

    for(i=0;i<=s;i++)setTimeout("KW_s("+KW_c(r,e,s,i)+","+KW_c(g,n,s,i)+","+KW_c(b,l,s,i)+",'"+o+"');",i*s);
}

// writes the copyright information on page
function doCopy() {
	document.write('<div id="copy"> Copyright © Jennifer Cook, 2009<br />(site by <a target="_blank" href="http://www.woodsgood.ca/fwebdesign.htm"><span class="woodsgood">WoodsGood</span></a>)</div>');
}

/***********************************************
* Carousel Slideshow II- By Harry Armadillo (http://www.codingforums.com/showthread.php?t=58814)
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
* Please keep this notice intact
***********************************************/

function carousel(params){
  if(!(params.width>0 && isFinite(params.width)))params.width=100;
  if(!(params.height>0 && isFinite(params.height)))params.height=100;
  if(!(params.sides>2 && isFinite(params.sides)))params.sides=4;
  if(!(params.steps>0 && params.steps<100 && isFinite(params.steps)))params.steps=20;
  if(!(params.speed>0 && isFinite(params.speed)))params.speed=8;
  if(!(params.image_border_width>=0 && isFinite(params.image_border_width)))params.image_border_width=0;
  if(isFinite(params.id)||!params.id)params.id='bad_id_given_'+Math.random();

  document.write("<div class='caroselItself' id='"+params.id.replace(/[^a-zA-Z0-9]+/g,'_')+"'></div>");
  var cdiv=document.getElementById(params.id.replace(/[^a-zA-Z0-9]+/g,'_'));
  cdiv.style.width=params.width+'px';
  cdiv.style.height=params.height+'px';
  cdiv.style.border=params.border;
  cdiv.style.position='relative';
  cdiv.style.overflow='hidden';
  cdiv.title=params.id;

  var counter=0,spinning=true,interval=Math.floor(60000/params.sides/params.steps/params.speed)-5;
  interval=isNaN(interval)?200:interval;
  var img_position=[],images=[],img_dimension=[];
  var img_index=params.images.length+1,img_index_cap=2*params.images.length;
  var faces=Math.ceil(params.sides/2), dimension, direction, targ, attr, faraway;

  function init(){
    if(params.direction=="left" || params.direction=="right"){
      direction=params.direction;
      dimension="width";
      }
    else if(params.direction=="top" || params.direction=="bottom"){
      direction=params.direction;
      dimension="height";
      }
    else {
      direction="left";
      dimension="width";
      }
    faraway=(direction=="left"||direction=="top")?'-20000px':'20000px';
    cdiv.style[dimension]=params[dimension]/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)+'px';
    var img=new Image();
    img.style.position='absolute';
    img.style[direction]=faraway;
    img.style.width=params.width-2*params.image_border_width+'px';
    img.style.height=params.height-2*params.image_border_width+'px';
    img.style.border=(params.image_border_width||0)+'px solid '+params.image_border_color;

    for(var i=0;i<params.images.length;i++){
      images[i]=img.cloneNode(true);
      images[i].src=params.images[i];
      if(params.links && params.links[i] && params.links[i]!=''){
			images[i].onclick=new Function("location='" + params.links[i] + "'");  // Adrian's edit
		}
//      if(params.links && params.links[i] && params.links[i]!=''){
//        targ=params.lnk_targets && params.lnk_targets[i]||params.lnk_base||'new';
//        if(targ=="_blank"){
//          attr=(params.lnk_attr && params.lnk_attr[i])?",'"+params.lnk_attr[i]+"'":"";
//          images[i].onclick=new Function("window.open('"+params.links[i]+"','"+targ+"'"+attr+")");
//          }
//        else if(targ.substr(0,1)=="_"){
//          images[i].onclick=new Function(targ.substr(1)+".location='"+params.links[i]+"'");
//          }
//        else{
//          attr=(params.lnk_attr && params.lnk_attr[i])?",'"+params.lnk_attr[i]+"'":"";
//          images[i].onclick=new Function("var t='"+targ+"';if(window[t]){try{window[t].close()}catch(z){}}window[t]=window.open('"+params.links[i]+"',t"+attr+");window[t].focus()");
//          }
//        images[i].style.cursor=document.all?'hand':'pointer';
//        }

      if(params.titles && params.titles[i] && params.titles[i]!='')
        images[i].title=params.titles[i];
      if(document.all)
        images[i].alt=images[i].title;
      images[i+params.images.length]=images[i];
      if(params.images.length==faces)
        images[i+2*params.images.length]=images[i];
      cdiv.appendChild(images[i]);
      }

    var face_size=params.size_mode=='image'?params[dimension]:params[dimension]*Math.sin(Math.PI/params.sides);
    var face_offset=params[dimension]*Math.cos(Math.PI/params.sides)/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)/2-0.5;
    var pi_piece=2*Math.PI/params.steps/params.sides;
    for(i=0;i<=params.steps*faces;i++){
      img_dimension[i]=face_size*Math.sin(pi_piece*i);
      img_position[i]=(i<params.steps*params.sides/2)?Math.floor(params[dimension]/2/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)-face_offset*Math.cos(pi_piece*i)-img_dimension[i]/2)+'px':faraway;
      img_dimension[i]=img_dimension[i]-2*params.image_border_width>1?Math.ceil(img_dimension[i])-2*params.image_border_width+'px':'1px';
      }
    }
  init();

  cdiv.rotate = function(){
    setTimeout('document.getElementById("'+cdiv.id+'").rotate()',interval);
    if(!spinning) return;
    if(++counter>=params.steps){
      counter=0;
      if(++img_index>=img_index_cap)
        img_index=params.images.length;
      }
    images[img_index-faces].style[direction]=faraway;
    for(var i=faces-1;i>=0;i--){
      images[img_index-i].style[direction]=img_position[counter+i*params.steps];
      images[img_index-i].style[dimension]=img_dimension[counter+i*params.steps];
      }
    }
  cdiv.onmouseover=function(){
    spinning=false;
    }
  cdiv.onmouseout=function(){
    spinning=true;
    }
  setTimeout('document.getElementById("'+cdiv.id+'").rotate()',100);
  }

-->
