<!-- 
/****************************************************
*			    	General Routines
*             ==================
*            Please edit with care...
*****************************************************/

// creates banner on top of page
function createBanner(text) {
	top.head.document.getElementById("pageheader").innerHTML=text;
}

function getObject(name) {return (document.getElementById?document.getElementById(name):document.all?document.all[name]:document.layers?eval("document.layers[\"" + name + "\"]"):null);}

function doChange(um) {
	getObject("pwdBox").style.display=(um)?"block":"none";
	getObject("pwdMsg").innerHTML='';
}
function doCheck() {
	pw1=getObject("pw1").value;
	pw2=getObject("pw2").value;
	pwN=getObject("pwdNew");
	msg="";
	if((pw1.length<6) && !msg)   msg='Passwords must be at least 6 characters.';
	if((pw1!=pw2) && !msg)       msg='Passwords do not match.';
	if((pw1==pwN.value) && !msg) msg='New password same as old.';
	if(!msg) {
		msg='&radic; Password OK.';
		pwN.value=pw1;		// change the password
		getObject("pwdBox").style.display="none";
	}
	getObject("pwdMsg").innerHTML=msg;
}

// 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);
}

function goto(loc) { window.location=loc;}

function doToggle(objid) { obj=getObject(objid);obj.style.display = (obj.style.display == "block")?"none":"block";}

// "within-page" navigation; one DIV (of id "objid") is displayed while making previous element invisible.
var objPage = null;										// old (or previous) object
function doShow(objid) {
	if (objPage) objPage.style.display="none";	// blank any that are displayed
	objPage=getObject(objid);							// get referenced object
	objPage.style.display = "block";					// display it
}

function doCopy() {
var r=new Date(),y=r.getFullYear();
	document.write('<p class="copy">Copyright &copy; 1984 - '+y+' Ottawa Independent Writers<br /><span class="copy2">(<a href="webtext.php" target="main">Site</a> optimized for 1024x768)</span></p>');
}


/*******************************************************************
*               M E N U   I M A G E   R O U T I N E S
********************************************************************/

var iOne,iTwo,tOne,tTwo;
function menuImg() {	
	iOne = getObject("i1");iOne.src=rroot+"loading.gif";
	tOne = getObject("t1");tOne.innerHTML="";
	iTwo = getObject("i2");iTwo.src=rroot+book[count][image];
	tTwo = getObject("t2");tTwo.innerHTML='<strong>'+book[count][name]+'</strong><br />' + book[count][author];
	var fIn=0;odd=true;
	doChImg();
}


/* Change image has two routines... fading, and changing image.
		ODD: 	fade up back image, fade down front image
				change (faded) front image 
		EVEN:	fade up front image, fade down back image
				change (faded) back image
				start again
*/

function doChImg() {
	if (odd) {									// if odd, fade down i1, t1 and fade up i2, t2
		setOp(iOne,1-(fIn/100));setOp(tOne,1-(fIn/100));
		setOp(iTwo,fIn/100);		setOp(tTwo,fIn/100);
	}
	else {										// if even, fade up i1, t1 and fade down i2, t2
		setOp(iTwo,1-(fIn/100));setOp(tTwo,1-(fIn/100));
		setOp(iOne,fIn/100);		setOp(tOne,fIn/100);
	}
	fIn=fIn+5;									// fading step size
	if(fIn<=100) {
		setTimeout("doChImg()",50);				// speed for changing step (ms)
	} else {
		if (odd) {								// if odd, change i1, t1
			iOne.src=rroot+book[iNext][image];
 			tOne.innerHTML='<strong>'+book[iNext][name]+'</strong><br />' + book[iNext][author]+'';
 		} else {								// if even, change i2, t2
 			iTwo.src=rroot+book[iNext][image];
 			tTwo.innerHTML='<strong>'+book[iNext][name]+'</strong><br />' + book[iNext][author]+'';
 		}
 		do {									// do this loop until next book has non-empty reference
			iNext=(iNext-1<=0)?iNext=count:iNext-1;
 		}
		while (book[iNext][ref]==="") 
		fIn=0;odd=!odd;							// restart image fade; toggle odd/even flag
		setTimeout("doChImg()",5000);			// time before changing to next image (ms)
	}
}

function setOp(obj, opacity) { 
	obj.style.filter = 'alpha(opacity='+(100*opacity)+')'; 
	obj.style.KHTMLOpacity = opacity; 
	obj.style.MozOpacity = opacity; 
	obj.style.opacity = opacity;
}

/*******************************************************************
*              E V E N T S   M A N A G E M E N T
********************************************************************/

function doDates() { 
 	var d=new Date();
 	var yy=d.getFullYear()-2000;yy=(yy<10)?yy="0"+yy+"":""+yy+"";
 	var mm=d.getMonth()+1;mm=(mm<10)?mm="0"+mm+"":""+mm+"";
 	var dd=d.getDate();dd=(dd<10)?dd="0"+dd+"":""+dd+"";
 	var dT=yy+mm+dd;
 	var fTags=document.getElementsByTagName("fieldset");
 	for(x=0;x<fTags.length;x++) {
 		eID=fTags[x].id;					// get all <fieldset> tags
 		if(eID.substr(0,1)=="e") {			// if event id number starts with an "e"
			eDate=eID.substr(1,6);			// next 6 characters is date in format yymmdd
			if(Number(eDate)<Number(dT)) document.getElementById(eID).style.display="none";
		}
 	}
}

//******************************************************************
// Cookie expiration information...

function doCookie(num) {
	var expdate = new Date (); // get current date //
	FixCookieDate (expdate);  // Correct for Mac date bug - call only once for given Date object! //
	expdate.setTime (expdate.getTime() + (7 * 24 * 60 * 60 * 1000)); // im ms, 7 days from now //
	SetCookie("dialup",num,expdate); // set the cookie
}
function markRead () {
	sCookie(book.length);
}

function sCookie(num) {
	var expdate = new Date (); // get current date //
	FixCookieDate (expdate);  // Correct for Mac date bug - call only once for given Date object! //
	expdate.setTime (expdate.getTime() + (30 * 24 * 60 * 60 * 1000)); // im ms, 30 days from now //
	SetCookie("lastNum",num,expdate); // set the cookie
}

//******************************************************************
//
//  Cookie Functions -- "Night of the Living Cookie" Version (25-Jul-96)
//
//  Written by:  Bill Dortch, hIdaho Design <bdortch@hidaho.com>
//  The following functions are released to the public domain.
//
//******************************************************************
//
// "Internal" function to return the decoded value of a cookie
//
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
//
//  Function to correct for 2.x Mac date bug.  Call this function to
//  fix a date object prior to passing it to SetCookie.
//  IMPORTANT:  This function should only be called *once* for
//  any given date object!
//
function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}
//
//  Function to return the value of the cookie specified by "name".
//    name - String object containing the cookie name.
//    returns - String object containing the cookie value, or null if
//      the cookie does not exist.
//
function GetCookie (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 getCookieVal (j);
	i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
return null;
}

//
//  Function to create or update a cookie.
//    name - String object containing the cookie name.
//    value - String object containing the cookie value.  May contain
//      any valid string characters.
//    [expires] - Date object containing the expiration data of the cookie.  If
//      omitted or null, expires the cookie at the end of the current session.
//    [path] - String object indicating the path for which the cookie is valid.
//      If omitted or null, uses the path of the calling document.
//    [domain] - String object indicating the domain for which the cookie is
//      valid. If omitted or null, uses the domain of the calling document.
//    [secure] - Boolean (true/false) value indicating whether cookie transmission
//      requires a secure channel (HTTPS).
//
//  To set a secure cookie for path "/myPath", that expires after the
//  current session, you might code:
//
//      SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
//
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

//  Function to delete a cookie. (Sets expiration date to start of epoch)
//    name -   String object containing the cookie name
//    path -   String object containing the path of the cookie to delete.  This MUST
//             be the same as the path used to create the cookie, or null/omitted if
//             no path was specified when creating the cookie.
//    domain - String object containing the domain of the cookie to delete.  This MUST
//             be the same as the domain used to create the cookie, or null/omitted if
//             no domain was specified when creating the cookie.
//
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}


////////////////////////////// Sliding Menus ////////////////////////////////////////////

var hp=26;
function doMenus() {
//     ypSlideOutMenu(   id      dir    left  top   width   items)  //
 	new ypSlideOutMenu("menu0", "right",  20,  366,    130,     6);		// Books
 	new ypSlideOutMenu("menu1", "right",  20,  326,    130,     4);		// Events
 	new ypSlideOutMenu("menu2", "right",  20,  346,    130,     4);		// Services
}

// Home Menu
function doMenu0() {
	var msg = "";
	msg += '<div id="menu0Container"><div id="menu0Content">';
    msg += '<a class="rollmenut" onmouseover="ypSlideOutMenu.showMenu(\'menu0\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu0\')" href="latestbooks.html" target="main">Latest Additions &raquo;</a>';
    msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu0\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu0\')" href="bookstext.html" target="main">Book Authors &raquo;</a>';
    msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu0\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu0\')" href="synopesestxt.html" target="main">Book Synopses &raquo;</a>';
    msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu0\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu0\')" href="bookcategories.html" target="main">Book Categories &raquo;</a>';
    msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu0\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu0\')" href="bookseries.html" target="main">Book Series &raquo;</a>';
    msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu0\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu0\')" href="bookcatalogue.html" target="_blank" >Book Catalogue &raquo;</a>';
//    msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu0\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu0\')" href="javascript:markRead();">Mark books as read</a>';
	msg += '</div></div>';
	document.write (msg);
}

function doMenu1() {
	var msg = "";
	msg += '<div id="menu1Container"><div id="menu1Content">';
    msg += '<a class="rollmenut" onmouseover="ypSlideOutMenu.showMenu(\'menu1\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu1\')" href="eventstext.html#next" target="main">Next Meeting &raquo;</a>';
    msg += '<a class="rollmenut" onmouseover="ypSlideOutMenu.showMenu(\'menu1\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu1\')" href="eventstext.html#meetings" target="main">Meeting Schedule &raquo;</a>';
//    msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu1\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu1\')" href="news.html" target="main">NEWS &raquo;</a>';
    msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu1\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu1\')" href="eventstext.html#interest" target="main">Events of Interest &raquo;</a>';
    msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu1\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu1\')" href="contests.html" target="main">Writing Contests &raquo;</a>';
    msg += '</div></div>';
   document.write (msg);
}

function doMenu2() {
	var msg = "";
	msg += '<div id="menu2Container"><div id="menu2Content">';
    msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu2\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu2\')" href="bentext.html" target="main">Member Benefits &raquo;</a>';
    msg += '<a class="rollmenut" onmouseover="ypSlideOutMenu.showMenu(\'menu2\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu2\')" href="writerstext.html" target="main">Need A Writer? &raquo;</a>';
    msg += '<a class="rollmenut" onmouseover="ypSlideOutMenu.showMenu(\'menu2\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu2\')" href="writerstext.html" target="main">Need A Editor? &raquo;</a>';
    msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu2\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu2\')" href="speaker.html#interest" target="main">Need A Speaker? &raquo;</a>';
    msg += '</div></div>';
   document.write (msg);
}



////////////////////////////// Slide Out Menus //////////////////////////////////

ypSlideOutMenu.Registry = [];
ypSlideOutMenu.aniLen = 650;
ypSlideOutMenu.hideDelay = 325;
ypSlideOutMenu.minCPUResolution = 10;

// constructor
function ypSlideOutMenu(id, dir, left, top, width, h) {
	this.ie  = document.all ? 1 : 0;
	this.ns4 = document.layers ? 1 : 0;
	this.dom = document.getElementById ? 1 : 0;

	var height=parseInt(h,10)*hp;
	if (this.ie || this.ns4 || this.dom) {
		this.id			 = id;
		this.dir		 = dir;
		this.orientation = dir == "left" || dir == "right" ? "h" : "v";
		this.dirType	 = dir == "right" || dir == "down" ? "-" : "+";
		this.dim		 = this.orientation == "h" ? width : height;
		this.hideTimer	 = false;
		this.aniTimer	 = false;
		this.open		 = false;
		this.over		 = false;
		this.startTime	 = 0;

		// global reference to this object
		this.gRef = "ypSlideOutMenu_"+id;
		eval(this.gRef+"=this");

		// add this menu object to an internal list of all menus
		ypSlideOutMenu.Registry[id] = this;

		var d = document;
		d.write('<style type="text/css">');
		d.write('#' + this.id + 'Container { visibility:hidden; ');
		d.write('left:' + left + 'px; ');
		d.write('top:' + top + 'px; ');
		d.write('overflow:hidden; }');
		d.write('#' + this.id + 'Container, #' + this.id + 'Content { position:absolute;z-index:1000; ');
		d.write('width:' + width + 'px; ');
		d.write('height:' + height + 'px; ');
//		d.write('clip:rect(0px, ' + width + 'px, ' + height + 'px, 0px); ');		// AJ: added "px" to declaration	
		d.write('}');
		d.write('</style>');

		this.load();
	}
}

ypSlideOutMenu.prototype.load = function() {
	var d = document;
	var lyrId1 = this.id + "Container";
	var lyrId2 = this.id + "Content";
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1];
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2);
	var temp;

	if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100);
	else {
		this.container	= obj1;
		this.menu		= obj2;
		this.style		= this.ns4 ? this.menu : this.menu.style;
		this.homePos	= eval("0" + this.dirType + this.dim);
		this.outPos		= 0;
		this.accelConst	= (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen;

		// set event handlers.
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
//		this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')")
//		this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')")

		//set initial state
		this.endSlide();
	}
}

ypSlideOutMenu.showMenu = function(id) {
	var reg = ypSlideOutMenu.Registry;
	var obj = ypSlideOutMenu.Registry[id];

	if (obj.container) {
		obj.over = true;

		// if this menu is scheduled to close, cancel it.
		if (obj.hideTimer) { 
			reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer);
		}

		// if this menu is closed, open it.
		if (!obj.open && !obj.aniTimer) reg[id].startSlide(true);
	}
}

ypSlideOutMenu.hideMenu = function(id) {
	// schedules the menu to close after <hideDelay> ms, which
	// gives the user time to cancel the action if they accidentally moused out
	var obj = ypSlideOutMenu.Registry[id];
	   if (obj.container) {
		   if (obj.hideTimer) window.clearTimeout(obj.hideTimer);
		   obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
	   }
}

ypSlideOutMenu.hide = function(id) {
	var obj = ypSlideOutMenu.Registry[id];
	obj.over = false;

	if (obj.hideTimer) window.clearTimeout(obj.hideTimer);

	// flag that this scheduled event has occured.
	obj.hideTimer = 0;

	// if this menu is open, close it.
	if (obj.open && !obj.aniTimer) obj.startSlide(false);
}

ypSlideOutMenu.prototype.startSlide = function(open) {
	this[open ? "onactivate" : "ondeactivate"]();
	this.open = open;
	if (open) this.setVisibility(true);
	this.startTime = (new Date()).getTime();
	this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution);
}

ypSlideOutMenu.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime;
	if (elapsed > ypSlideOutMenu.aniLen) this.endSlide();
	else {
		var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst);
		if (this.open && this.dirType == "-")		d = -d;
		else if (this.open && this.dirType == "+")	d = -d;
		else if (!this.open && this.dirType == "-")	d = -this.dim + d;
		else										d = this.dim + d;

		this.moveTo(d);
	}
}

ypSlideOutMenu.prototype.endSlide = function() {
	this.aniTimer = window.clearTimeout(this.aniTimer);
	this.moveTo(this.open ? this.outPos : this.homePos);
	if (!this.open) this.setVisibility(false);
	if ((this.open && !this.over) || (!this.open && this.over)) {
		this.startSlide(this.over);
	}
}

ypSlideOutMenu.prototype.setVisibility = function(bShow) {
	var s = this.ns4 ? this.container : this.container.style;
	s.visibility = bShow ? "visible" : "hidden";
}
ypSlideOutMenu.prototype.moveTo = function(p) {
	this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : (p) + "px";
}
ypSlideOutMenu.prototype.getPos = function(c) {
	return parseInt(this.style[c],10);
}

// events
ypSlideOutMenu.prototype.onactivate		= function() { }
ypSlideOutMenu.prototype.ondeactivate	= function() { }
// ******************************* end of routines *************************** //
-->
