/*
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright © 2003 by Gary Johnson
Copyright (&copy;) 2003 by Gary Johnson

COPYRIGHT

The information contained on this site is protected by Canadian, United States of America and international copyright laws.

All website materials, including, without limitation, design, text, graphics, photos, files, the Fast Track! logo, and 
the selection and arrangement thereof are © 2004 Gary Johnson ALL RIGHTS RESERVED.
 
Permission is granted to electronically copy and print to hard copy portions of this website for the sole purpose of 
using materials it contains for informational and non-commercial personal use only.
 
Any other use of materials in this website, including any commercial use, reproduction for purposes other than those noted above, 
modification, distribution or republication, without the prior written consent of Gary Johnson is strictly prohibited.


The Full Copyright statement is

	http://mywebpages.comcast.net/adgj/XXSoftwareTools/Copyright.html

  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/

/*

  Venkman wants a straight path to source
	This does not cut it ../XXSoftwareTools/js/gjcore.js


	Mozilla and Popups
	see 	pref("dom.disable_open_during_load",              true);


  Javascript HTML naming conventions

	Naming conventions. 
	Properties of the HTML-specific interfaces begin with lowercase letters. 
	If the property name consists of multiple words, the first letters of the second and subsequent words are capitalized.
	Thus, the maxlength attribute of the <input> tag translates into the maxLength property of HTMLInputElement.

	When an HTML attribute name conflicts with a JavaScript keyword, it is prefixed with the string "html" to avoid 
	the conflict. Thus, the for attribute of the <label> tag translates to the htmlFor property of the HTMLLabelElement. 
	An exception to this rule is the class attribute (which can be specified for any HTML element); 
	it translates to the className property of HTMLElement.
	
	false,  0, "0", "", null, undefined;
		Anything else is "true".
		
	need to check for value = "" before doing a calculation

	GLITCH Watch for name and id collsion
	GLITCH Watch for position:absolute on DOM and moving the DIV type things

  I may need to set up my own layered system
	and then switch between them

  the layers could fill the entier screen
	need disolve, fade, wipe etc
	need to rethink units

 I need to do more checks on what my Javascript code is to do.

	events and function calls have to make sense

	I prefer to sniff for browsers and handle their differences explicitly 
			
		example if(isGecko())

	rather than hoping for the best
  hopefully we will be able to keep isGecko() up to date


Changelog
Sep 2006
getElement - removed try catch

	 
*/


//  Globals
var	toggleId;
var px	= 'px';
//	var EOL = "\n";
var EOL = '<br>';
var debugOnce=false;
var vtoggleTop=200;

// need a reliable error reporter 
// using the displayDivError only works for the really simple stuff
function gjonerror(ex, msg) 
{
/*  I have to fix the height display before I can use this ?
		Put displayDivError in Garytest and see what the DOM puts up
*/

	try
	{
		if(isGecko())
		{
			dump("gjonerror " + msg + " " + ex.name + " " + ex.message + "\n");	
			var wintxt = "\n" + " - - -  " +  "\n" + "\n" + " " + " - - -  "  + msg + " - - -  " +  "\n" +  " " + " - - -  "  + ex.name + " - - -  " + " " +  ex.message + " - - -  " +  "\n" + "\n" + " - - -  " +  ex.fileName  + " - - -  " + " line: " + ex.lineNumber + " - - -  " + "\n" + "\n" + " - - -  " + " UA " + navigator.userAgent + " - - -  " + "\n" + "\n" + "\n" + " - - -  ";
			alert(wintxt);
		}
		else
		{
			var wintxt = "\n" + " - - -  " +  "\n" + "\n" + " " + " - - -  "  + msg + " - - -  " +  "\n" + " " + " - - -  "  + ex.name + " - - -  " + " " +  ex.message + " - - -  " + "\n" + "\n" + " - - -  " + " UA " + navigator.userAgent + " - - -  " + "\n" + "\n" + " - - -  ";
			alert(wintxt);
		}		
//  needs a total rewrite	displayDivError(ex,msg);
	}
	catch(error)
	{
	  	alert("Error in Error" + msg + "1: " + ex.name + "1: " + ex.message  + "2: " + error.name +  "2: " + error.name);	
	}

return false;
}

function mkunique() 
{
	//	<script type="text/javascript" src="js/md4.js"></script>
	//	return hex_md4(stringIn);

    return (new Date()).getTime();
}




function noOP()
{
return;
}

/*

	EvalError - raised when the eval() functions is used in an incorrect manner;

	RangeError - raised when a numeric variable exceeds its allowed range;

	ReferenceError - raised when an invalid reference is used;

	SyntaxError - raised when a syntax error occurs while parsing JavaScript code;

	TypeError - raised when the type of a variable is not as expected;

	URIError - raised when the encodeURI() or decodeURI() functions are used in an incorrect manner;

	You can trap more than one exception, and handle each one in a different way, by using multiple "if" constructs within a single "catch" block.


JavaScript also allows you to add a "finally" block to the "try-catch" block discussed previously. The "finally" block contains statements that are executed regardless of whether an exception is generated or not in the "try-catch" block.


	try 
	{
		execute this block
	} 
	catch (error) 
	{
		execute this block if error
	}
	 finally 
	{
		execute this block after the try block
	}

  http://www.ecma-international.org/publications/standards/ecma-262.htm

*/


/*
  may want to set toggleHighLight('o', id) in the script that is called by onFocus or use the onmouse

  document.onmouseover = myMouseOver; and global event handling.  I want KISS for now

  I could get and save the current background-color and then change the value to the H and F positions

  it did not like goldNbutton, but buttonNgold was okay

*/

function setToggleTop(eventin)
{
	if(isGecko())
	{
		vtoggleTop = getEventY(eventin) + 10;
	}
	else
	{
		//cannot get zindex to go in front of java object
		vtoggleTop = getEventY(eventin) +30;
	}
}


function getToggleBottom()
{
	return 1;
}


function getElement(idin)
{
// SEP 2006, removed try catch because of Timer.html and FF throwing error
  
//	try
//	{
		if(document.all)
		{
			return document.all[idin];
		}
		else
		{
			return document.getElementById(idin);
		}
//	}
// 	catch (error)
//	{
//		gjonerror( error, " getElement for " + idin);
//	}
}

function setVisible(idin)
{
	try
	{
		getElement(idin).style.visibility = 'visible';
	}
 	catch (error)
	{
		gjonerror( error, " setVisible ");
	}
}

function setHidden(idin)
{
	try
	{
		getElement(idin).style.visibility = 'hidden';
	}
 	catch (error)
	{
		gjonerror( error, " setHidden ");
	}
}

function setGone(idin)
{
	try
	{

		getElement(idin).style.visibility = 'hidden';

//		setTop(idin,0);
//		setWidth(idin,0);
//		setHeight(idin,0);

	}
 	catch (error)
	{
		gjonerror( error, " setGone ");
	}
}

/* diplay none is better */
function isVisible(idin)
{
		var myE= getElement(idin);
		if(myE.style.visibility=='hidden')
		{
			return false;
		}
		else
		{
			return true;
		}
}

function toggleVisibility(idin)
{
	try
	{
		if(isVisible(idin))
		{
			setHidden(idin);
		}
		else
		{
			setVisible(idin);
		}
	}
	catch (error)
	{
		gjonerror( error, " toggleVisibility ");
	}
}

/* display:none might be a better way to do this */

function toggleDivVisibility(idin, width, height)
{
	try
	{
		if(isVisible(idin))
		{
			setHeight(idin,10);
			setWidth(idin,10);
			setHidden(idin);
		}
		else
		{
			if(width)
			{
				setWidth(idin,width);
				//should throw error here if width is bad
			}
			if(height)
			{
				setHeight(idin,height);
			}
			setVisible(idin);
		}
	}
	catch (error)
	{
		gjonerror( error, " toggleDivVisibility ");
	}
}

function toggleDivVisibilityZ(idin, width, height, myZ)
{

try
	{
		if(isVisible(idin))
		{
			setHeight(idin,10);
			setWidth(idin,10);
            setZ(idin, --myZ);
			setHidden(idin);
		}
		else
		{
			if(width)
			{
				setWidth(idin,width);
				//should throw error here if width is bad
			}
			if(height)
			{
				setHeight(idin,height);
			}
            setZ(idin,++myZ);
			setVisible(idin);
		}
	}
	catch (error)
	{
		gjonerror( error, " toggleDivVisibility ");
	}
return myZ;
}

// <input class="closeit" type="button" id="sSSssazy" value="-" onClick="toggleDisplayButton('CMEB1','sSSssazy' );">
// <p id ="CMEB1" class="note">

function toggleDisplayButton(idin,buttonid)
{
	try
		{
				var aDiv = getElement(idin);

				if(aDiv.style.display == 'none')
				{
					aDiv.style.display = 'block';
					getElement(buttonid).value="-"; 
				}
				else
				{
					aDiv.style.display = 'none';
					getElement(buttonid).value="+"; 
				}
		}
 		catch (error)
		{
			gjonerror( error, " toggleDisplayButton");
		}
}



//get the integer of the top
//changed before this save
function getTop(idin)
{
	var top=-1;

	var myE= getElement(idin);

	try
	{
		if(isGecko())
		{
			top = parseInt(myE.style.top);
		}
		else if(isIE())
		{
			if(myE.style)
			{
				top = myE.style.posTop;
			}
		}
		else
		{
			alert('unkown browser in getTop');
		}
	}
 	catch (error)
	{
		gjonerror( error, " getTop ");
	}
return top;
}

function mygetTop(idin)
{
var mtop

	try
	{
		mtop = getTop(idin); 
		if((!mtop) || (mtop == -1))
		{
			mtop = parseInt(getCompStyle(idin, 'top'));
			if(isNaN(mtop))
			{
				mtop = -1;
			}
		}
	}
 	catch (error)
	{
		gjonerror( error, " mygetTop ");
	}
return mtop;
}


//get the integer of the left
//I probably need to make all of these act like this one

function getLeft(idin)
{
	var left=-1;
	
	var myE= getElement(idin);

	try
	{
		if(isGecko())
		{
			if(myE.style.left)
			{
				left = parseInt(myE.style.left);
			}
		}
		else if(isIE())
		{
			if(myE.style.pixelLeft)
			{
				left = myE.style.pixelLeft;
			}
		}
		else
		{
			alert('unkown browser in getLeft');
		}
	}	
 	catch (error)
	{
		gjonerror( error, " getLeft ");
	}
return left;
}
//			if(!mleft == NaN) if (typeof yourvar == "undefined"
function mygetLeft(idin)
{
var mleft;

	try
	{
		mleft = getLeft(idin); 
		if((!mleft) || (mleft == -1))
		{
			mleft = parseInt(getCompStyle(idin, 'left'));
			if(isNaN(mleft))
			{
				mleft = -1;
			}
		}
	}
 	catch (error)
	{
		gjonerror( error, " mygetLeft ");
	}
return mleft;
}


function getWidth(idin)
{

	var myE= getElement(idin);

	var width =-1;
	try
	{
		if(isGecko())
		{
			width = parseInt(myE.style.width);
		}
		else if(isIE())
		{
			if(myE.style)
			{
				width = myE.style.pixelWidth;
			}
		}
		else
		{
			alert('unkown browser in getWidth');
		}
	}	
//		isGecko() ? (width = parseInt(myE.style.width )) : ( width = myE.style.pixelWidth); 
 	catch (error)
	{
		gjonerror( error, " getWidth ");
	}
return width;
}

function mygetWidth(idin)
{
var mwidth

	try
	{
		mwidth = getWidth(idin); 
		if((!mwidth) || (mwidth == -1))
		{
			mwidth = parseInt(getCompStyle(idin, 'width'));
			if(isNaN(mwidth))
			{
				mwidth = -1;
			}
		}
	}
 	catch (error)
	{
		gjonerror( error, " mygetWidth ");
	}
return mwidth;
}

function getHeight(idin)
{
	var myE= getElement(idin);
	var height=-1;

	try
	{
		if(isGecko())
		{
			height = parseInt(myE.style.height);
		}
		else if(isIE())
		{
			if(myE.style)
			{
				height = myE.style.posHeight;
			}
		}
		else
		{
			alert('unkown browser in getHeight');
		}
	}	
//		isGecko() ? (height = parseInt(myE.style.height)) : (height = myE.style.posHeight); 
 	catch (error)
	{
		gjonerror( error, " getHeight ");
	}
return height;
}

function mygetHeight(idin)
{
var mheight;

	try
	{
		mheight = getHeight(idin);
		if((!mheight) || (mheight == -1))
		{
			mheight = parseInt(getCompStyle(idin, 'height'));
			if(isNaN(mheight))
			{
				mheight = -1;
			}
		}
	}
 	catch (error)
	{
		gjonerror( error, " mygetHeight ");
	}
return mheight;
}



function setWidth(idin, newWidth)
{

	var myE= getElement(idin);

	try
	{
		isGecko() ? (myE.style.width = newWidth + px) : ( myE.style.pixelWidth = newWidth); 
	}
 	catch (error)
	{
		gjonerror( error, " setWidth ");
	}
}

//may need to fix the others like this

function setHeight(idin, newHeight)
{
	var myE= getElement(idin);
	var ret = -1;
	try
	{
		if(isGecko())
		{ 
			myE.style.height = newHeight + px;
			ret = myE.style.height;
		}
		else if(isIE())
		{
			myE.style.posHeight = newHeight; 
			ret = myE.style.posHeight;
		}
//		isGecko() ? (myE.style.height = newHeight + px) : (myE.style.posHeight = newHeight); 
//		getElement(idin).style.height = newHeight + px; 
	}
 	catch (error)
	{
		gjonerror( error, " setHeight " + idin);
	}
return ret;
}

	// x oordinates CSS style is always T R B L - need to have T and L to set Postion
	// Mickey has left as read only

function setTop(idin,y)
{
	var myE= getElement(idin);

	try
	{
		isGecko() ? myE.style.top = y + px : myE.style.pixelTop = y; 
	}
 	catch (error)
	{
		gjonerror( error, " setTop for " + idin);
	}
}


function setLeft(idin, x)
{
	var myE= getElement(idin);
	try
	{
		isGecko() ? myE.style.left = x + px : myE.style.pixelLeft = x; 
	}
 	catch (error)
	{
		gjonerror( error, " setLeft for " + idin );
	}
}

// Have to set clip on style of DIV beforehand clip:rect(0 320 0 0) 
// as usual absolute or relative
// IE does not use the px
// T = 0, Right = Width, Bottom = height, Left = 0
// vary the top and you should be able to shrink the element
// did not like DOCTYPE. ml4/strict.dtd">
// The 'clip' property applies only to absolutely positioned elements
//
// Mozilla won't set clip if HTML strict
// Looks like IE wants it in an inline style 
// style='position:absolute;clip:rect(0 300 300 0);'> 
//
function setClip(idin, t,r,b,l)
{

// I should set a check debug type thing here
	if(checkDebug())
	{
		var myE= getElement(idin);
		if(myE.style.clip == undefined  || myE.style.clip == "" || myE.style.clip == "0")
		{
			alert('setClip clip not set in css');
			return; 
		}
		if(myE.style.position != 'absolute')
		{
			alert('setClip position not absolute');
			return;
		}
	}
	else
	{
		var myE= getElement(idin);
	}

	try
	{
//		var myRect = 'rect(' + t + px + ' ' + r + px + ' ' + b + px + ' ' + l + px + ')';
//		myE.style.clip = 'rect(' + t + px + ',' + r + px + ',' + b + px + ',' + l + px + ')';

		var myclip = 'rect(' + t + ',' + r + ',' + b + ',' + l + ')';
//		alert(" " + myclip);
		myE.style.clip = myclip; 
//		alert("clip is : " + myE.style.clip);
	}
 	catch (error)
	{
		gjonerror( error, " setClip ");
	}
}

function setClass(idin, cname)
{
	var myE= getElement(idin);
	 myE.className=cname; 
}

function setZ(idin,z)
{
	var myE= getElement(idin);
	
	try
	{
		myE.style.zIndex = z;
	}
 	catch (error)
	{
		gjonerror( error, " setZ ");
	}
}

function setTopLeft(idin, x, y) 
{
	setTop(idin,y);
	setLeft(idin,x)
}


function setBackGroundColor(idin, mycolor)
{
	var myE= getElement(idin);

	try
	{
		myE.style.backgroundColor = mycolor; 
	}
 	catch (error)
	{
		gjonerror( error, " setBackGroundColor ");
	}
	

}

function getInterCap(cstyle)
{
//go from margin-left to MarginLeft
// background-color to backgroundColor
//this does not fix this kinda thing
//	top or  posTop 
//	left or pixelLeft
//	width or  pixelWidth
//	height or posHeight

	try
	{
		var converted = new String(cstyle);
		var re = "-";
		var where = converted.indexOf(re);

		
		if(where > 0)
		{
			var part1 = converted.substr(0, where);
			var capit = converted.substr(where + 1, 1);
			capit = capit.toUpperCase();
			var part2 = converted.substr(where +2, converted.length);
			return part1 + capit + part2;
		}
		else
		{
			delete converted;
			return cstyle;
		}
	}
 	catch (error)
	{
		gjonerror( error, " getInterCap ");
	}
}


/*
For IE
Both innerText and innerHTML represent what's contained inside the element, 
though the later includes its HTML makeup as well. The outer 
properties operate in the same manner, except that their range covers the element itself..

innerHTML   The complete content (including HTML tags, if any) of an element.  
outerHTML   The complete content of an element, including the element itself. 

For Moz
innerHTML only

*/

function changeInnerHTML(idin, myHTML)
{

	try
	{
		var myE= getElement(idin);
		myE.innerHTML = myHTML;
	}
 	catch (error)
	{
		gjonerror( error, " changeInnerHTML " + idin + " " + myHTML);
	}
}

function returnInnerHTML(idin)
{

	try
	{
		var myE= getElement(idin);
	}
 	catch (error)
	{
		gjonerror( error, " returnInnerHTML id" + idin);
	}

return myE.innerHTML;
}

function changeBorder(idin, which)
{
	//borderWidth
	if(which)
	{
		getElement(idin).style.borderStyle	=	'dotted';
		getElement(idin).style.borderSize	=	'2px';
		getElement(idin).style.borderColor	=	'black';
	}
	else
	{
		getElement(idin).style.borderStyle	=	'solid';
		getElement(idin).style.borderSize	=	'2px';
		getElement(idin).style.borderColor	=	'black';
	}
}

function myHighlight(idto, idfrom, mygoto)
{

	if(isIE())
	{
		var temp = getElement(idto);
//		if(getElement(idto).style.borderStyle	==	'dotted')
		if(temp.style.borderStyle	==	'dotted')
		{
			myHighlightundo(idto);
			myHighlightundo(idfrom);
		}
		else
		{
			myHighlightdo(idto);
			myHighlightdo(idfrom);

			if(mygoto)
			{
				window.location = mygoto;
			}
		}
	}
	else 
	if(isGecko())
	{
//kludge see note in getCompStyle		
		var testit = getCompStyle(idto,'border-left-style');

		if( (testit == 'dotted') || (getElement(idto).style.borderStyle	==	'dotted') )
		{
			myHighlightundo(idto);
			myHighlightundo(idfrom);
		}
		else
		{
			myHighlightdo(idto);
			myHighlightdo(idfrom);

			if(mygoto)
			{
				window.location = mygoto;
			}
		}

	}

}

function myHighlightdo(idin)
{

			getElement(idin).style.borderStyle	=	'dotted';
			getElement(idin).style.borderWidth	=	'2px';
			getElement(idin).style.borderColor	=	'black';
}

function myHighlightundo(idin)
{

			getElement(idin).style.borderStyle	=	'none';
			getElement(idin).style.borderWidth	=	'0';
}



function hideStatus()
{
	try
	{
//		if(isGecko())
//		{
//			netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
//		}
		if(window.statusbar.visible=='visible')
		{
			window.statusbar.visible=!window.statusbar.visible;
		}
	}
 	catch (error)
	{
		gjonerror( error, " hide Status error ");
	}
}


/*
returns and element that you can use 
document.body.appendChild(image)
createChild etc
*/

function createIMG(theid, thesrc, thestyle, thealt)
{
	try
	{
//		netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
		
		image = document.createElement("img");
		image.setAttribute("id",theid);
		image.setAttribute("src",thesrc);
		
		if(thestyle !='null')
		{
			image.setAttribute("alt",thestyle);
		}
		
		if(thealt !='null')
		{
			image.setAttribute("style",thealt);
		}
	}
	catch (error)
	{
		gjonerror( error, " createIMG");
	}
	return image;
}

// C:\SavedWebPagesMozilla\IEdhtmlpos.gif

function getCW()
{

var clientWidth	= -1;
	
		if(isIE())
		{
			if( document.body ) 
			{
				//IE 4, 5 & 6 (in non-standards compliant mode)
				clientWidth				=	document.body.clientWidth; //document.body.clientWidth;
			} 
			else if( document.documentElement ) 
			{
				//IE 6 (in standards compliant mode)
				clientWidth				=	document.documentElement.clientWidth; // 0 in some case document.body.clientWidth;
			}
			//try body.offsetWidth or body.clientWidth + body.clientLeft + widht of scrollbars
		}
		else if(isGecko())
		{
//				clientWidth				=	window.screen.width;   document width client width - scroll bars - margins ?
					clientWidth				=	document.width; 
		}

/*
		if(checkDebug() && !(debugOnce))
		{
			debugOnce = true;
			//be nice to query screen state here
			//getting strange values
			sanityCheck = screen.width - 10; //for scroll bars
			
			if(clientWidth > sanityCheck)
			{
				alert('client width > screen width : clientWidth = ' + clientWidth + ' screen width = ' + sanityCheck);
//				dumpAll();
			}
			else if(clientWidth < 200)
			{
				alert('client width < 200 : clientWidth = ' + clientWidth);
//				dumpAll();
			}

			if(isGecko())
			{
				if(document.body.scrollWidth > clientWidth)
				{
					alert('body.ScrollWidth > clientWidth - probably means we are scrolled horizontally');
//					dumpAll();
				}
			}
		}
*/

return clientWidth;
}

function getCH()
{
var clientHeight = -1;

/*

  The height of the client
  if(document.compatMode && document.compatMode=='CSS1Compat')docRoot='document.documentElement';


*/

		
	//document.compatMode = 'CSS1Compat' -strict || 'BackCompat'
		if(isIE())
		{
			if( document.documentElement && ( document.documentElement.clientHeight )) 
			{
				//IE 6 (in standards compliant mode)
				clientHeight				=	document.documentElement.clientHeight; 
			}
			else if( document.body ) 
			{
				//IE 4, 5 & 6 (in non-standards compliant mode)
				clientHeight				=	document.body.clientHeight; 
			} 
			//body.clientHeight + body.style.border + body.clientTop
		}
		else if(isGecko())
		{
// 			var clientHeight			=	window.innerHeight;
//			if(window.scrollY > 0)
//			{
 //				clientHeight			=	window.scrollY;
//			}
//			else
//			{
 				clientHeight			=	window.innerHeight;
//			}
		}

/*
		if(checkDebug() && !(debugOnce))
		{
			debugOnce=true;
			if(isGecko())
			{
				if(clientHeight < window.scrollY) // body.scrollTop
				{
					alert('clientHeight < body.scrollTop means we are scrolled down');
				}
			}
		}

*/

return clientHeight;
}

//if pageX/Y is supplied, pageX/Y is relative to the whole page (Netscape compatible) - also used by Opera 7+ 
//if clientX/Y is supplied, clientX/Y should be relative to displayed portion of page (Internet Explorer compatible) 
// http://www.howtocreate.co.uk/tutorials/index.php?tut=0&part=17

function getEventX(event)
{
	var eventX;
	
	if(isIE())
	{
		//			eventX						=	event.offsetX;
		//			eventX						=	event.clientX + event.offsetX;
		if( typeof( event.clientX ) == 'number' ) 
		{
			eventX = event.clientX;
			
			// add it if its not 0
			if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
			{
				//IE 4, 5 & 6 (in non-standards compliant mode)
				eventX += document.body.scrollLeft;
			} 
			else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
			{
				//IE 6 (in standards compliant mode)
				eventX += document.documentElement.scrollLeft;
			}
		}
		else
		{
			alert('we are hosed in getEventX Not number');
		}
	}
	else if(isGecko())
	{
		eventX						=	event.pageX;
	}
	return eventX;
}

function getEventY(event)
{
	var eventY;
	if(isIE())
	{
		//			var eventY					=	event.offsetY;
		//			eventY						=	event.clientY + event.offsetY;
		if( typeof( event.clientY ) == 'number' ) 
		{
			eventY = event.clientY;
			
			// add it if its not 0
			if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
			{
				eventY += document.body.scrollTop;
			} 
			else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
			{
				eventY += document.documentElement.scrollTop;
			}
		}
		else
		{
			alert('we are hosed in getEventY not number');
		}
	}
	else if(isGecko())
	{
		eventY						=	event.pageY;
	}
	else
	{
			alert('unsupported browser');
	}
return eventY;
}


function showMousePosition()
{
  if (document.addEventListener) 
	{ 
	// DOM Level 2 Event Model
	// Register capturing event handlers
		document.addEventListener("mousemove", showMousePostionE, true);
  }
  else if (document.attachEvent) 
	{  
	// IE 5+ Event Model
	// In the IE Event model, we can't capture events, so these handlers
	// are triggered when only if the event bubbles up to them.
	// This assumes that there aren't any intervening elements that
	// handle the events and stop them from bubbling.
		document.attachEvent("onmousemove", showMousePostionE);
  }
  else
	{
		alert('we are hosed in showMousePosition');
	} 
}
function showMousePostionE(event)
{


	if(isGecko())
	{
		var w = window; 

		window.status = "eventX,Y: " + event.pageX + "," + event.pageY + 
						" w.page X,YOffset: " + window.pageXOffset + "," + window.pageYOffset +  
						" w.inner W,H: "   	+ window.innerWidth +  "," + window.innerHeight +
						" w.scroll X,Y: "     + window.scrollX +  "," + window.scrollY;
	}
	else if(isIE())
	{

		var w = window; 

		if(document.compatMode == 'CSS1Compat')
//		if(document.documentElement)
		{
			var d = document.documentElement;
		}
		else if(document.body)
		{
			var d = document.body;
		}
		else
		{
			alert('we are hosed in showMousePostionE');
		}

		window.status = "w.event.clientX,Y: " + w.event.clientX + "," + w.event.clientY +
					  " w.eventx,y: " + w.event.x + "," + w.event.y +
					  " d.scrollL,T: " + d.scrollLeft + "," + d.scrollTop;
	}
	else
	{
		alert('we are hosed in showMousePostionE');
	}

}

/*

*/

function getCenterY()
{
var center = -1;

	if(isGecko())
	{
		center = window.pageYOffset + (getCH() / 2);
	}
	else if(isIE())
	{
		if(document.compatMode == 'CSS1Compat')
		{
			center = document.documentElement.scrollTop + (getCH() / 2);
		}
		else
		{
			center = document.body.scrollTop + (getCH() / 2);
		}
	}
	else
	{
		alert('we are hosed in getCenterY');
	}
return center;
}

function getYoffset()
{
var yOff = -1;

	if(isGecko())
	{
		yOff = window.pageYOffset;
	}
	else if(isIE())
	{
		if(document.compatMode == 'CSS1Compat')
		{
			yOff = document.documentElement.scrollTop;
		}
		else
		{
			yOff = document.body.scrollTop;
		}
	}
	else
	{
		alert('we are hosed in getYOffset');
	}
return yOff;
}


function getCenterX()
{
var center = -1;

	if(isGecko())
	{
		center = window.pageXOffset + (getCW() / 2);
	}
	else if(isIE())
	{
		if(document.compatMode == 'CSS1Compat')
		{
			center = document.documentElement.scrollLeft + (getCH() / 2);
		}
		else
		{
			center = document.body.scrollLeft + (getCH() / 2);
		}
	}
	else
	{
		alert('we are hosed in getCenterX');
	}
return center;
}

function getXoffset()
{
var xOff = -1;

	if(isGecko())
	{
		xOff = window.pageXOffset;
	}
	else if(isIE())
	{
		if(document.compatMode == 'CSS1Compat')
		{
			xOff = document.documentElement.scrollLeft;
		}
		else
		{
			xOff = document.body.scrollLeft;
		}
	}
	else
	{
		alert('we are hosed in getXoffset');
	}
return xOff;
}

function setDisplayV(idin)
{
	try
	{
		getElement(idin).style.display = 'block';
	}
 	catch (error)
	{
		gjonerror( error, " setDisplayV ");
	}
}

function setDisplayH(idin)
{
	try
	{
		getElement(idin).style.display = 'none';
	}
 	catch (error)
	{
		gjonerror( error, " setDisplayH ");
	}
}

//no good unless I put it in an eval
//put the following type thing inline,  instead 
//myE.style.position = 'absolute'; 
function setStyle(idin, attrName, newData)
{
	var myE= getElement(idin);

	try
	{
		myE.style.attrName = newData; 
	}
 	catch (error)
	{
		gjonerror( error, " setStyle ");
	}
}


function assert(fact, msgin)
{
	if(!fact)
	{
		var msg = "Assert Failure " + msgin;
		if(arguments.callee.caller != null)
		{
			msg = msg + " in function " + arguments.callee.caller.toString().match(/function\s+(\w+)/)[1];
		}
		alert(msg);
	}
}
/* MSIE 7.0; Windows NT 6.0 */
function isIE()
{
	return (navigator.userAgent.toLowerCase().indexOf("msie") > -1)?true:false;
}


function isGecko()
{
    return ((navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
}

function isOpera()
{
	return (navigator.userAgent.toLowerCase().indexOf("opera") > -1)?true:false;
}


function whichBrowser()
{

	try
	{
		if (document.all) 
		{
			alert("Internet Explorer Detected");
		}
		else if (document.layers) 
		{
			alert("Netscape Navigator Detected");
		}
	}
 	catch (error)
	{
		gjonerror( error, " whichBrowser ");
	}

}


function LTrim(str) 
{ 
	for (var k=0; k<str.length && str.charAt(k)<=" " ; k++){} ;

return str.substring(k,str.length);
}

function RTrim(str) 
{
	for (var j=str.length-1; j>=0 && str.charAt(j)<=" " ; j--) {} ;

return str.substring(0,j+1);
}

function Trim(str) 
{
return LTrim(RTrim(str));
}   



