// test for browser and platform

	var isNscape = '';

	if (navigator.appName == 'Netscape') {var isNscape = 'N';}
	var isMac = (navigator.userAgent.indexOf('Mac') != -1) ? 'mac': '';

// window status

window.defaultStatus = '';

var descr = '';

function show(descr) {
     window.status = descr;
     document.returnValue = true;
}

// clouds south navigation rollover

function tocnav_on(img_name,descr) {
     document[img_name].src='images/toc/' + img_name + 'hi.gif';
     show(descr)
}

function tocnav_off(img_name,descr) {
     document[img_name].src='images/toc/' + img_name + 'lo.gif';
     show(descr)
}

// clouds edge navigation rollover

function edgetocnav_on(img_name,descr) {
     document[img_name].src='images/toc/' + img_name + 'on.gif';
     show(descr)
}

function edgetocnav_off(img_name,descr) {
     document[img_name].src='images/toc/' + img_name + 'off.gif';
     show(descr)
}

// clouds south chapter navigation rollover

function leftnav_on(loc,img_name,descr) {
   	if (document.layers) {
   		document.layers[loc].document[img_name].src='../../images/leftnav/' + img_name + 'hi.gif';
   		show(descr)
    } else {
   		document[img_name].src='../../images/leftnav/' + img_name + 'hi.gif';
   		show(descr)
	}
}

function leftnav_off(loc,img_name,descr) {
   	if (document.layers) {
	    document.layers[loc].document[img_name].src='../../images/leftnav/' + img_name + 'lo.gif';
    	show(descr)
    } else {
   		document[img_name].src='../../images/leftnav/' + img_name + 'lo.gif';
   		show(descr)
	}
}

// function to open specific chapter in 'content' frame on chapter.html

function chapter(num)
{
	var loc = 'chapter.html?' + num;
//	alert(loc);
	window.location = loc;
}

// function for pop-up windows

function photoWin(photoLoc,photoName,Width,Height,XPos,YPos)
{
     var Params = 'width=' + Width + ',height=' + Height + ',resizable=0,status=0,menubar=0,scrollbars=1,left=' + XPos + ',top=' + YPos + ',screenX=' + XPos + ',screenY=' + YPos;
     pop = window.open(photoLoc, photoName, Params);
}

// function for textbox scroller in chapters

var Scroller = 'text';

function moveIt(Scroller,stepSize)
	{
		if ((Scroller!="") && (running==true))
		{
			stepper=stepSize;
			if (document.all)
			{
				whereNow=parseInt(document.all[Scroller].style.top);
				divHeight=parseInt(document.all[Scroller].clientHeight);
// alert('top=' + document.all[Scroller].style.top + 'height=' + document.all[Scroller].clientHeight);
// if div placement absolute, use: 85; 434
// if div placement relative, use: 0; 350
				if (((whereNow+stepSize)<=0) && ((whereNow+divHeight+stepSize)>=350)) 
				{
					document.all[Scroller].style.top=(whereNow+stepSize);
					setTimeout("moveIt(Scroller,stepper)",10)
				}
			}
			else if(document.layers)
			{
				whereNow=parseInt(document.layers[Scroller].top);
				divHeight=parseInt(document.layers[Scroller].clip.height);
// alert('top=' + document.layers[Scroller].top + 'height=' + document.layers[Scroller].clip.height);
// if div placement absolute, use: 85; 434
// if div placement relative, use: 0; 350
				if (((whereNow+stepSize)<=0) && ((whereNow+divHeight+stepSize)>=350)) 
				{
					document.layers[Scroller].top=(whereNow+stepSize);
					setTimeout("moveIt(Scroller,stepper)",10)
				}
			}
			else
			{
//alert("Browser Detection Error")
			}
		}
	}

function stopThat() 
	{
		window.scrollTo(0,0);
	}

window.onscroll = stopThat;

// function for photos scroller in chapters

var ScrollerP = 'photos';
var whichPhoto = 1;

function moveItP(ScrollerP,stepSize)
	{
		if ((ScrollerP!="") && (running==true))
		{
			stepper=stepSize;
			if (document.all)
			{
				whereNow=parseInt(document.all[ScrollerP].style.left);
				divWidth=parseInt(document.all[ScrollerP].clientWidth);
				numPhotos=divWidth/430
// alert('left=' + document.all[ScrollerP].style.left + 'width=' + document.all[ScrollerP].clientWidth);
// if div placement absolute, use: 370; 790
// if div placement relative, use: 0; 415
				if (((whereNow+stepSize)<=0) && ((whereNow+divWidth+stepSize)>=415)) 
				{
					document.all[ScrollerP].style.left=(whereNow+stepSize);
					setTimeout("moveIt(ScrollerP,stepper)",10)
					if (stepSize<0)
					{
						whichPhoto = ++whichPhoto
					} else {
						whichPhoto = --whichPhoto
					}
					if (whichPhoto > 1)
					{
						document.all.horizscrollleft.style.visibility="visible";
					} else {
						document.all.horizscrollleft.style.visibility="hidden";
					}
					if (whichPhoto == numPhotos)
					{
						document.all.horizscrollright.style.visibility="hidden";
					} else {
						document.all.horizscrollright.style.visibility="visible";
					}
				}
			}
			else if(document.layers)
			{
// alert('left=' + document.layers[ScrollerP].left + 'width=' + document.layers[ScrollerP].clip.width);
				whereNow=parseInt(document.layers[ScrollerP].left);
				divWidth=parseInt(document.layers[ScrollerP].clip.width);
				numPhotos=Math.round(divWidth/430);
// if div placement absolute, use: 370; 790
// if div placement relative, use: 0; 415
				if (((whereNow+stepSize)<=0) && ((whereNow+divWidth+stepSize)>=415)) 
				{
					document.layers[ScrollerP].left=(whereNow+stepSize);
					setTimeout("moveIt(ScrollerP,stepper)",10)
					if (stepSize<0)
					{
						whichPhoto = ++whichPhoto
					} else {
						whichPhoto = --whichPhoto
					}
					if (whichPhoto > 1)
					{
						document.layers.horizscrollleft.visibility="show";
					} else {
						document.layers.horizscrollleft.visibility="hide";
					}
					if (whichPhoto == numPhotos)
					{
						document.layers.horizscrollright.visibility="hide";
					} else {
						document.layers.horizscrollright.visibility="show";
					}
				}
			}
			else
			{
//alert("Browser Detection Error")
			}
		}
	}

function stopThat()
	{
		window.scrollTo(0,0);
	}

window.onscroll = stopThat;

// function for desktop image scroller

var ScrollerD = 'desktop';
var whichImage = 1;

function moveItD(ScrollerD,stepSize)
	{
		if ((ScrollerD!="") && (running==true))
		{
			stepper=stepSize;
			if (document.all)
			{
				whereNow=parseInt(document.all[ScrollerD].style.left);
				divWidth=parseInt(document.all[ScrollerD].clientWidth);
				numImages=divWidth/760
// alert('left=' + document.all[ScrollerD].style.left + 'width=' + document.all[ScrollerD].clientWidth);
				if (((whereNow+stepSize)<=0) && ((whereNow+divWidth+stepSize)>=745)) 
				{
					document.all[ScrollerD].style.left=(whereNow+stepSize);
					setTimeout("moveIt(ScrollerD,stepper)",10)
					if (stepSize<0)
					{
						whichImage = ++whichImage
					} else {
						whichImage = --whichImage
					}
					if (whichImage > 1)
					{
						document.all.horizscrollleft.style.visibility="visible";
					} else {
						document.all.horizscrollleft.style.visibility="hidden";
					}
					if (whichImage == numImages)
					{
						document.all.horizscrollright.style.visibility="hidden";
					} else {
						document.all.horizscrollright.style.visibility="visible";
					}
				}
			}
			else if(document.layers)
			{
// alert('left=' + document.layers[ScrollerD].left + 'width=' + document.layers[ScrollerD].clip.width);
				whereNow=parseInt(document.layers[ScrollerD].left);
				divWidth=parseInt(document.layers[ScrollerD].clip.width);
				numImages=Math.round(divWidth/760);
				if (((whereNow+stepSize)<=0) && ((whereNow+divWidth+stepSize)>=745)) 
				{
					document.layers[ScrollerD].left=(whereNow+stepSize);
					setTimeout("moveIt(ScrollerD,stepper)",10)
					if (stepSize<0)
					{
						whichImage = ++whichImage
					} else {
						whichImage = --whichImage
					}
					if (whichImage > 1)
					{
						document.layers.horizscrollleft.visibility="show";
					} else {
						document.layers.horizscrollleft.visibility="hide";
					}
					if (whichImage == numImages)
					{
						document.layers.horizscrollright.visibility="hide";
					} else {
						document.layers.horizscrollright.visibility="show";
					}
				}
			}
			else
			{
//alert("Browser Detection Error")
			}
		}
	}

function stopThat()
	{
		window.scrollTo(0,0);
	}

window.onscroll = stopThat;

// function to return the chapter page to the appropriate frameset if discovered individually

function jumpIn()
	{
		if (top == self)
		{
			curloc = top.location.href;

// find the chapter definition within the individual url between the last '/' and '.html'
			locf = curloc.lastIndexOf('/');
			locf = locf + 1;
			locb = curloc.lastIndexOf('.');
			loc = curloc.substring(locf,locb);

			top.location.href = '../chapter.html?' + loc;
		}
	
	}
