// <!--
// Prepared for Brian Kuehn Design and Illustration by Mental Models, Inc.
// Copyright (c) 2001 Mental Models, Inc. All rights reserved.
// If there are any questions please contact Aaron Simkin;
// http://www.mentalmodels.com
// -->


// Since netscape does not support having mouseovers on plain <img>
// objects we have to do some more work to fake it. What we do is wrap
// the <img> in an <a> and then use the callbacks on the <a> object.
// This means that we have to have an association between the <img> and
// the <a> in another table that we maintain.

var activeGlyphTable = new Array()


function helpWindow() {
 helpwindow_var=window.open("regHelp.html","_help","location=no,toolbar=no,menubar=yes,scrollbars=yes,status=yes,resizable=yes,width=550,height=400 left=15, top=15")

}
function quickHelp( fileName ) {
 quickhelp_var=window.open(fileName,"_help","location=no,toolbar=no,menubar=yes,scrollbars=yes,status=yes,resizable=yes,width=550,height=225, left=15, top=15")
}

function openLink( link ) {
  openlink_var = window.open(link, "_blank")
}

function assocEntry( imageOn, imageOff, toUrl )
{
	this.imageOn = new Image()
	this.imageOn.src = imageOn
	this.imageOff = new Image()
	this.imageOff.src = imageOff
	this.toUrl = toUrl
}

function generateActiveGlyph( imageName, width, height, text, toUrl, anchorClass, imgClass )
{
	var x = ''
	var i = activeGlyphTable.length
	activeGlyphTable[i] = new assocEntry( '../images/' + imageName + '-on.gif', '../images/' + imageName + '-off.gif', toUrl )
	activeGlyphTable[i].anchorName = 'ag_' + i
	x += '<a name="' + activeGlyphTable[i].anchorName + '"'
	//x += ' href="javascript:void(0)"'
	x += ' href="'+toUrl+'"'
	x += ' onclick="activeGlyphClick('+i+');return false;"'
	x += ' onmouseover="activeGlyphMouseOver('+i+');"'
	x += ' onmouseout="activeGlyphMouseOut('+i+');"'
	if( anchorClass != null && anchorClass != "" )
	{
		x += ' class="'+anchorClass+'"'
	}
	x += '><img name="image_'+i+'" src="../images/' + imageName + '-off.gif" border=0'
	if( imgClass != null && imgClass != "" )
	{
		x += ' class="'+imgClass+'"'
	}
	x += ' width='+width+' height='+height+'>'
	if( text != null && text != "" )
	{
		x += '<br>' + text
	}
	x += '</a>'

	//alert(x)
	//document.writeln(x)
	//if( document.layers == null )
	//{
		document.write(x)
	//}
	//else
	//{
	//	document.layers["mainLayer"].document.writeln(x)
	//}
}

function generateActiveGlyphWithAlt( imageName, width, height, alt, text, toUrl, anchorClass, imgClass )
{
	var x = ''
	var i = activeGlyphTable.length
	activeGlyphTable[i] = new assocEntry( '../images/' + imageName + '-on.gif', '../images/' + imageName + '-off.gif', toUrl )
	activeGlyphTable[i].anchorName = 'ag_' + i
	x += '<a name="' + activeGlyphTable[i].anchorName + '"'
	//x += ' href="javascript:void(0)"'
	x += ' href="'+toUrl+'"'
	x += ' onclick="activeGlyphClick('+i+');return false;"'
	x += ' onmouseover="activeGlyphMouseOver('+i+');"'
	x += ' onmouseout="activeGlyphMouseOut('+i+');"'
	if( anchorClass != null && anchorClass != "" )
	{
		x += ' class="'+anchorClass+'"'
	}
	x += '><img name="image_'+i+'" src="../images/' + imageName + '-off.gif" border=0'
	if( imgClass != null && imgClass != "" )
	{
		x += ' class="'+imgClass+'"'
	}
	x += ' width='+width+' height='+height+' alt=' +alt +'>'
	if( text != null && text != "" )
	{
		x += '<br>' + text
	}
	x += '</a>'

	//alert(x)
	//document.writeln(x)
	//if( document.layers == null )
	//{
		document.write(x)
	//}
	//else
	//{
	//	document.layers["mainLayer"].document.writeln(x)
	//}
}

function generateActiveGlyphWithAlt2( imageName, width, height, alt, text, toUrl, anchorClass, imgClass )
{
	var x = ''
	var i = activeGlyphTable.length
	activeGlyphTable[i] = new assocEntry( './images/' + imageName + '-on.gif', './images/' + imageName + '-off.gif', toUrl )
	activeGlyphTable[i].anchorName = 'ag_' + i
	x += '<a name="' + activeGlyphTable[i].anchorName + '"'
	//x += ' href="javascript:void(0)"'
	x += ' href="'+toUrl+'"'
	x += ' onclick="activeGlyphClick('+i+');return false;"'
	x += ' onmouseover="activeGlyphMouseOver('+i+');"'
	x += ' onmouseout="activeGlyphMouseOut('+i+');"'
	if( anchorClass != null && anchorClass != "" )
	{
		x += ' class="'+anchorClass+'"'
	}
	x += '><img name="image_'+i+'" src="./images/' + imageName + '-off.gif" border=0'
	if( imgClass != null && imgClass != "" )
	{
		x += ' class="'+imgClass+'"'
	}
	x += ' width='+width+' height='+height+' alt=' +alt +'>'
	if( text != null && text != "" )
	{
		x += '<br>' + text
	}
	x += '</a>'

	//alert(x)
	//document.writeln(x)
	//if( document.layers == null )
	//{
		document.write(x)
	//}
	//else
	//{
	//	document.layers["mainLayer"].document.writeln(x)
	//}
}

function activeGlyphClick(i)
{
    glyph = activeGlyphTable[i]
	if( glyph == null )
	{
		alert('can not find glyph')
		return
	}
	if( glyph.toUrl != null && glyph.toUrl != "" )
	{
		//alert('to URL = "' + glyph.toUrl + '" first char is "' + glyph.toUrl.substr(0,1) + '"')
		if( glyph.toUrl.substr(0,1) != '!' )
		{
			//alert('branching')
			location = glyph.toUrl
		}
		else
		{
			//alert('eval-ing')
			eval( glyph.toUrl.substr(1) )
		}
	}
}

function activeGlyphMouseOver(i)
{
	glyph = activeGlyphTable[i]
	//if( document.layers == null )
	//{
		image = document.images['image_' + i]
	//}
	//else
	//{
	//	image = document.layers["mainLayer"].document.images['image_' + i]
	//}
	if(glyph == null || image == null)
	{
		alert('can not find active glyph or image')
		return
	}
	image.src = glyph.imageOn.src

	// add code to change text color as well for netscrape
/*
	if( document.layers != null )
	{
		atext = document.layers["mainLayer"].document.anchors['ag_' + i]
		atext.style.color = 'red'
	}
*/
}

function activeGlyphMouseOut(i)
{
	glyph = activeGlyphTable[i]
	//if( document.layers == null )
	//{
		image = document.images['image_' + i]
	//}
	//else
	//{
	//	image = document.layers["mainLayer"].document.images['image_' + i]
	//}
	if(glyph == null || image == null)
	{
		alert('can not find active glyph or image')
		return
	}
	image.src = glyph.imageOff.src

	// add code to change text color as well for netscrape
/*
	if( document.layers != null )
	{
		atext = document.layers["mainLayer"].document.anchors['ag_' + i]
		atext.style.color = 'green'
	}
*/
}

function dumpObject( object )
{
	var x = ''
	var n
	for(n in object)
	{
		x += n + ' ' + object[n] + '\n'
	}
	alert(x)
}
