/*
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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/gjmisc.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

	look for metric to ounces 
	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

if(isIE) 
{
    document.write('<a style="text-decoration: none;" href="javascript:window.external.AddFavorite(url, title);"><font color="#0033FF" size="1" face="Verdana, Arial, Helvetica, sans-serif">BOOKMARK THIS PAGE</font></a>');
} 
else 
{
  document.write('<font color="#0033FF" size="1" face="Verdana, Arial, Helvetica, sans-serif">TO BOOKMARK THIS PAGE, PRESS CTRL+D</font>');
}

*/


//  Globals
var	toggleId;
var px	= 'px';
//	var EOL = "\n";
var EOL = '<br>';
var debugOnce=false;
var vtoggleTop=200;


function setDebug(which)
{
var expdate = new Date();

		expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); 
		setCookie("DebugCB", which, expdate, "/", null, false);
}

function checkDebugD()
{
    alert('debugging on');
 return true;
/*
    var debugCB;
    try
    {
        debugCD = getCookie("DebugCB");

        if( debugCD == undefined  || debugCD == "" || debugCD == "0")
        {
            alert('debugging off');
            return false;
        }
    else
        {
            alert('debugging on');
            return true;
        }
    }
    catch (error)
    {
        gjonerror( error, " checkDebugD ");
        return false;
    }
*/    
}

function checkDebug()
{
    
return true;    
    
/*    
    var debugCB;

    try
    {
        debugCD = getCookie("DebugCB");

        if( debugCD == undefined  || debugCD == "" || debugCD == "0")
        {
            return false;
        }
    else
        {
            return true;
        }
    }
    catch (error)
    {
        gjonerror( error, " checkDebug ");
        return false;
    }
*/    
}

function mkunique() 
{
	//	<script type="text/javascript" src="js/md4.js"></script>
	//	return hex_md4(stringIn);

    return (new Date()).getTime();
}


function testError(eventin, myCode)
{
	try 
	{
		alert(eval(myCode));
	}
	catch (error) 
	{
//		gjonerror2( error, " TestError ", eventin);
		gjonerror2( error, " TestError ");
	}
}

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

*/
//	Make sure ID is unique!
//	myClass.className = 'buttonH' + temp; does not work		getElement(myId).className = 'buttonH' + temp; does

//  Glitch if I have this on a button type element, I click on the button, do a script
//  the script executes
//  if I have the script make the button go away
//  Mozilla seems to still have an event for the button to execute.
//  when it excutes, than I throw an error with a try catch block
//
// removing the onblur event seems to make this okay.
//  I don't now wether to just trap an error or what.

function toggleHighLight(myEvent, myId)
{
 
		try
		{
			var myClass = getElement(myId).className;

			var temp = myClass.substr(7, 10);

			if(myEvent == "m")
			{
				getElement(myId).className = 'buttonH' + temp;
			}
			else if(myEvent == "f")
			{
				getElement(myId).className = 'buttonF' + temp;
			}
			else if(myEvent == "o")
			{
				getElement(myId).className = 'buttonN' + temp;
			}
		}
		catch (error)
		{
			if(checkDebug())
			{
					gjonerror( error, " toggleHighLight ");
			}
		}
return false;
}

  
function checkPosNumber(number)
{
//positive numbers
//  x - 0 to force conversion of text to number internally in place of a decent atoi, atof function
	try
	{
		for (var i = 0; i < number.length; i++) 
		{
			var oneChar = number.charAt(i);
			if ((oneChar >= "0" && oneChar <= "9") || (oneChar == ".")) 
			{
				continue;
			}
			else
			{
				DisplayNotNumber(number);
				return false;
			}
		}
	}
	catch (error)
	{
		gjonerror( error, " checkPosNumber ");
	}

return true;
}


function testInteger(number)
{
//positive numbers
//  x - 0 to force conversion of text to number internally in place of a decent atoi, atof function
//  if passed internally, it can be a number
//  so I will be REALLY lazy and convert it to a string here, for this test
	number = number.toString();

	try
	{
		for (var i = 0; i < number.length; i++) 
		{
			var oneChar = number.charAt(i);
			if(oneChar >= "0" && oneChar <= "9") 
			{
				continue;
			}
			else
			{
				return false;
			}
		}
	}
	catch (error)
	{
		gjonerror( error, " testInteger ");
	}

return true;
}


function checkAllNumber(number)
{
	//all numbers
	try
	{
		if(isNaN(number))
		{
				DisplayNotNumber(number);
				return false;
		}
	}
 	catch (error)
	{
		gjonerror( error, " checkAllNumber ");
	}

return true;
}

function frmtNumber(expression,NumDigitsAfterDecimal)
{
	try
	{
		var strNum = new String(expression);
		var re = ".";
		var intDec = strNum.indexOf(re);
		if(intDec > 0)
		{
			intDec = (parseInt(intDec)+(NumDigitsAfterDecimal+1));
			strNum = strNum.substr(0,intDec);
			return strNum;
		}
		else
		{
			return strNum;
		}
	}
 	catch (error)
	{
		gjonerror( error, " frmtNumber ");
	}

}

function frmtNumberFraction(expression,NumDigitsAfterDecimal)
{

	try
	{
		// I could add rounding instead of truncation
		var strNum = new String(expression);
		var re = ".";
		var intDec = strNum.indexOf(re);
		var whole = strNum.substring(0, intDec);
		if (whole == '0') {whole = "";}
		var frac = 	strNum.substring((intDec + 1), (intDec + 5));
	//	alert(" frac " + frac + " whole " + whole);

		if(intDec > 0)
		{
			intDec = (parseInt(intDec)+(NumDigitsAfterDecimal+1));
			strNum = strNum.substr(0,intDec);

			switch (frac)
			{
				case '0039':
					strNum += " (" + whole + " 1/256)";
					break;
				case '0052':
					strNum += " (" + whole + " 1/192)";
					break;
				case '0078':
					strNum += " (" + whole + " 1/128)";
					break;
				case '0104':
					strNum += " (" + whole + " 1/96)";
					break;
				case '0208':
					strNum += " (" + whole + " 1/48)";
					break;
				case '0312':
					strNum += " (" + whole + " 1/32)";
					break;
				case '0416':
					strNum += " (" + whole + " 1/24)";
					break;
				case '0625':
					strNum += " (" + whole + " 1/16)";
					break;
				case '0833':
					strNum += " (" + whole + " 1/12)";
					break;
				case '125':
					strNum += " (" + whole + " 1/8)";
					break;
				case '1666':
					strNum += " (" + whole + " 1/6)";
					break;
				case '25':
				case '250':
					strNum += " (" + whole + " 1/4)";
					break;
				case '3333':
					strNum += " (" + whole + " 1/3)";
					break;
				case '375':
					strNum += " (" + whole + " 3/8)";
					break;
				case '5':
				case '50':
				case '500':
					strNum += " (" + whole + " 1/2)";
					break;
				case '625':
					strNum += " (" + whole + " 5/8)";
					break;
				case '6666':
					strNum += " (" + whole + " 2/3)";
					break;
				case '75':
				case '750':
					strNum += " (" + whole + " 3/4)";
					break;
				case '875':
					strNum += " (" + whole + " 7/8)";
					break;
				default : strNum += " ";
			}			
			return strNum;
		}
		else
		{
			return strNum;
		}
	}
 	catch (error)
	{
		gjonerror( error, " frmtNumberFraction ");
	}

}

/*
	round any number to x decimal points 

1) Multiple the original number by 10^x (10 to the power of x)
2) Apply Math.round() to the result
3) Divide result by 10^x
*/

function Roundit(number, decimals) 
{
	try
	{
		var result1 = number * Math.pow(10, decimals);
		var result2 = Math.round(result1);
		var result3 = result2 / Math.pow(10, decimals);
	}
	catch (error)
	{
		gjonerror( error, " Roundit ");
	}

return (result3);
}


// intToHex converts 0-255 into hex 

function intToHex(n) 
{
  var result = n.toString(16);
  if (result.length==1) 
	  result = "0"+result;
return result;
}

// hexToInt converts hex to integer.
function hexToInt(hex) 
{
  return parseInt(hex, 16);
}


function fixFileUrl(u) 
{
	//	var loc,fileloc; 
	//	loc = document.location.href; 
	//	if (loc.length > 9 && loc.substr(0,8)=='file:') 

// JavaScript strict warning:
// gjmisc.js line 507: variable u hides argument
var windows
//var u; 
	windows = (navigator.platform.indexOf('Win') != -1);
	/* chop off file: slash slash slash, unescape each %hh, convert back slash to forward slash and | to : */  
	u = u.substr(windows ? 8 : 7); 
	u = unescape(u); 
	if(windows) 
	{ 
		u = u.replace(/\//g,'\\'); 
		u = u.replace(/\|/g,':'); 
	} 
return u; 
} 

function checkQuote(instr)
{
    //   var re1 = /[\"\']/; regular expressions has side effects in FireFox 1.03
    //
    
    if(instr.length == 0)
       return false;
          
    
    try
    {

        if(instr.indexOf("'") > 0)
        {
            return false;
        }
    else
        if(instr.indexOf('"') > 0)
        {
            return false;
        }
    }
    catch (error)
    {
        gjonerror( error, " checkQuote ");
    }

return true;
}

function checkWild(instr)
{
    //   var re1 = /[\"\']/; regular expressions has side effects in FireFox 1.03
    //
    
    if(instr.length == 0)
       return false;
          
    try
    {

        if(instr.indexOf("%") >= 0)
        {
            return true;
        }
    }
    catch (error)
    {
        gjonerror( error, " checkWild ");
    }

return false;
}


function aplusb(form) 
{
    try
    {
		if ( (checkAllNumber(form.a.value)) && (checkAllNumber(form.b.value)) ) 
		{
			   a=form.a.value - 0;
			   b=form.b.value - 0;
			   c=a+b;
			   form.ans.value = frmtNumberFraction(c,3);
		}
	}
	catch (error)
	{
		DisplayNotNumber(form.a.value + " " + form.b.value );
		return false;
	}
}

function aminusb(form) 
{
    try
    {
		if ( (checkAllNumber(form.a.value)) && (checkAllNumber(form.b.value)) ) 
		{
			   a=form.a.value - 0;
			   b=form.b.value - 0;
			   c=a-b;
			   form.ans.value=frmtNumberFraction(c,3);
		}
	}
	catch (error)
	{
		DisplayNotNumber(form.a.value + " " + form.b.value );
		return false;
	}
}
function atimesb(form) 
{
    try
    {
		if ( (checkAllNumber(form.a.value)) && (checkAllNumber(form.b.value)) ) 
		{
			   a=form.a.value - 0;
			   b=form.b.value - 0;
			   c=a*b;
			   form.ans.value=frmtNumberFraction(c,3);
		}
	}
	catch (error)
	{
		DisplayNotNumber(form.a.value + " " + form.b.value );
		return false;
	}
}
function adivb(form) 
{
    try
    {
		if ( (checkAllNumber(form.a.value)) && (checkAllNumber(form.b.value)) ) 
		{
			   a=form.a.value - 0;
			   b=form.b.value - 0;
			   c=a/b;
			   form.ans.value = frmtNumberFraction(c,3);
		}
	}
	catch (error)
	{
		DisplayNotNumber(form.a.value + " " + form.b.value );
		return false;
	}
}
function apowb(form) 
{
    try
    {
		if ( (checkAllNumber(form.a.value)) && (checkAllNumber(form.b.value)) ) 
		{
			a=form.a.value - 0;
			b=form.b.value - 0;
			if((a === 0) && (b === 0))
			{
				form.ans.value = "Not a Number";
			}
			else
			{
				c=Math.pow(a, b);
				form.ans.value = c;
			}
		}
	}
	catch (error)
	{
		DisplayNotNumber(form.a.value + " " + form.b.value );
		return false;
	}
}

function calc2(form) 
{
	try
    {
		var mynresult = eval(form.expr.value);
    }
    catch (error)
    {
		gjonerror( error, "Error Bad Data - Try Again  ");
		return;
    }

	 changeInnerHTML('myresult',mynresult);

/*				<p id="myresult" class="myresult" >&nbsp;</p>
*/

	setVisible('place');

	c1.appendChild(makerow(form.expr.value, mynresult ));
    c.appendChild( c1 );
    aa = document.getElementById('place');
    aa.replaceChild(c, aa.getElementsByTagName('TABLE')[0]);

}

function calc3(form) 
{
	try
    {
		var mynresult = eval(form.expr.value);
    }
    catch (error)
    {
		gjonerror( error, "Error Bad Data - Try Again  ");
		return;
    }

	 changeInnerHTML('myresult',mynresult);

}


function calc(form) 
{
    try
    {
		form.result.value=eval(form.expr.value);
    }
    catch(error)
    {
		gjonerror( error, "Error - Bad Data - Try Again ");
    }
}

function calcDisplayFrac(form) 
{
    try
    {
		var temp = eval(form.expr.value);
		form.result.value=	frmtNumberFraction(temp, 3);
    }
    catch (error)
    {
		gjonerror( error, "Conversion Calculator Error ");
    }
}

/* 

  I use pixels in these functions, yet I define the orginal top left in PTs
  <div id="TSSinfo" style="visibility:hidden; position:absolute; width:auto; height:auto; top:100pt; left:250pt; background-color:lightseagreen; border-left: 5px solid #000; padding-right:15pt; z-index:1">

  changing IE to go from left to right, since I cannot draw on top of 
  java applet

*/
function displayTSS(event)
{
	try
	{

		setToggleTop(event);
		if(isGecko()) 
		{
			self.statusbar.visible=false;
		}
		StartTSS();
	}
	catch (error)
	{
		gjonerror( error, " displayTSS ");
	}
}

function StartTSS()
{
var mytop;
var myleft;
	try
	{
		if(isGecko())
		{
			mytop =	parseInt(getElement("TSSinfo").style.top);
		}
		else if(isIE())
		{
			myleft = getElement("TSSinfo").style.posLeft;
		}
		else
		{
			alert('unkown browser')
			return;
		}

		if(isGecko())
		{
			if(mytop >= getToggleTop())
			{
				toggleId = window.setInterval("TSSUp()",1);
			}
			else
			{
				getElement("TSSinfo").style.visibility = "visible";
				toggleId = window.setInterval("TSSDown()",1);
			}
		}
		else if(isIE())
		{
			if(myleft >= getToggleTop())
			{
				toggleId = window.setInterval("TSSUp()",1);
			}
			else
			{
				getElement("TSSinfo").style.visibility = "visible";
				toggleId = window.setInterval("TSSDown()",1);
			}
		}
	}
	catch (error)
	{
		gjonerror( error, " StartTSS ");
	}
}

function TSSDown()
{
var top;
var left;	
	try
	{
		if(isGecko()) 
		{
			top = parseInt(getElement("TSSinfo").style.top);
			top +=25;
			var sztop = top + "px";
			getElement("TSSinfo").style.top = sztop;
			if (top >= getToggleTop()) 
			{
				window.clearInterval(toggleId);
			}
		}
		else if(isIE())
		{
			left = getElement("TSSinfo").style.posLeft;
			
			left +=7;
			
			getElement("TSSinfo").style.posLeft = left;
			
			if (left >= getToggleTop()) 
			{
				window.clearInterval(toggleId);
			}
		}
		else
		{
			alert('unkown browser');
		}
	}
	catch (error)
	{
		gjonerror( error, " TSSDown ");
		//		alert('e.msg ' + e.message + '\n e.name ' + e.name + '\n e.desc ' + e.description + '\n e.line ' + e.line);	
	}
}

function TSSUp()
{
var top;
var left; 
	try
	{
		if(isGecko()) 
		{
			top = parseInt(getElement("TSSinfo").style.top);
			top -=25;
			var sztop = top + "px";
			getElement("TSSinfo").style.top = sztop;
			if (top <= getToggleBottom()) 
			{
				getElement("TSSinfo").style.visibility = "hidden";
				window.clearInterval(toggleId);
			}
			
		}
		else
		{
			left = getElement("TSSinfo").style.posLeft;
			
			left -=7;
			
			getElement("TSSinfo").style.posLeft = left;
			
			if(left <= getToggleBottom()) 
			{
				getElement("TSSinfo").style.visibility = "hidden";
				window.clearInterval(toggleId);
			}
		}
	}
	catch (error)
	{
		gjonerror( error, " TSSUp ");
	}
}

function getToggleTop()
{

	return vtoggleTop;

}

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(id)
{
//var element;
//	try
//	{
//		if(isIE())
//		{
//			element	=  document.all[id];
//		}
//		else
//		{
//			element	= document.getElementById(id);
//		}
//	}
 //	catch (error)
//	{
//		gjonerror( error, " getElement ");
//	}
//
//	if (!element) 
//	{
//		alert('!test worked') 
//		element = null;
//	} 
//
//return element;

	try
	{
		if(document.all)
		{
			return document.all[id];
		}
		else
		{
			return document.getElementById(id);
		}
	}
 	catch (error)
	{
		gjonerror( error, " getElement ");
	}
}

function setVisible(id)
{
	try
	{
		getElement(id).style.visibility = 'visible';
	}
 	catch (error)
	{
		gjonerror( error, " setVisible ");
	}
}

function setHidden(id)
{
	try
	{
		getElement(id).style.visibility = 'hidden';
	}
 	catch (error)
	{
		gjonerror( error, " setHidden ");
	}
}

function setGone(id)
{
	try
	{

		getElement(id).style.visibility = 'hidden';

//		setTop(id,0);
//		setWidth(id,0);
//		setHeight(id,0);

	}
 	catch (error)
	{
		gjonerror( error, " setGone ");
	}
}

function isVisible(id)
{
		var myE= getElement(id);
		if(myE.style.visibility=='hidden')
		{
			return false;
		}
		else
		{
			return true;
		}
}

function toggleVisibility(id)
{
	try
	{
		if(isVisible(id))
		{
			setHidden(id);
		}
		else
		{
			setVisible(id);
		}
	}
	catch (error)
	{
		gjonerror( error, " toggleVisibility ");
	}
}

function toggleDivVisibility(id, width, height)
{
	try
	{
		if(isVisible(id))
		{
			setHeight(id,10);
			setWidth(id,10);
			setHidden(id);
		}
		else
		{
			if(width)
			{
				setWidth(id,width);
				//should throw error here if width is bad
			}
			if(height)
			{
				setHeight(id,height);
			}
			setVisible(id);
		}
	}
	catch (error)
	{
		gjonerror( error, " toggleDivVisibility ");
	}
}

//get the integer of the top
//changed before this save
function getTop(id)
{
	var top=-1;

	var myE= getElement(id);

	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(id)
{
var mtop

	try
	{
		mtop = getTop(id); 
		if((!mtop) || (mtop == -1))
		{
			mtop = parseInt(getCompStyle(id, 'top'));
		}
	}
 	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(id)
{
	var left=-1;
	
	var myE= getElement(id);

	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;
}

function mygetLeft(id)
{
var mleft;

	try
	{
		mleft = getLeft(id); 
		if((!mleft) || (mleft == -1))
		{
			mleft = parseInt(getCompStyle(id, 'left'));
			if(!mleft == NaN)
			{
				mleft = -1;
			}
		}
	}
 	catch (error)
	{
		gjonerror( error, " mygetLeft ");
	}
return mleft;
}


function getWidth(id)
{

	var myE= getElement(id);

	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(id)
{
var mwidth

	try
	{
		mwidth = getWidth(id); 
		if((!mwidth) || (mwidth == -1))
		{
			mwidth = parseInt(getCompStyle(id, 'width'));
		}
	}
 	catch (error)
	{
		gjonerror( error, " mygetWidth ");
	}
return mwidth;
}

function getHeight(id)
{
	var myE= getElement(id);
	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(id)
{
var mheight;

	try
	{
		mheight = getHeight(id);
		if((!mheight) || (mheight == -1))
		{
			mheight = parseInt(getCompStyle(id, 'height'));
		}
	}
 	catch (error)
	{
		gjonerror( error, " mygetHeight ");
	}
return mheight;
}

//IE uses CSS intercapitalization system (margin-left is marginLeft).

//Mozilla uses CSS property format (margin-left is margin-left) nope		
//IE currentStyle is the inherited cascaded style
//MOZ getComputedStyle will give you values that are computed.

//If you set the values you need in CSS, rather than let them default, you will be alright
//
//- curentStyle will return auto or null for width, height, left, top 
//getComputedStyle returns the computed value

//Mozilla see C:\mozilla\content\html\style\src\nsComputedDOMStyle.cpp
//nsComputedDOMStyle::GetPadding(nsIFrame *aFrame,
// it does not do some of the high level ones
  // return null per spec.

//  No GetBorderStyle

// yes GetBorderTopStyle
//see DOM inspector for additional interfaces to make this happen
//will kludge it up for now 
// C:\mozilla\extensions\inspector\resources\content\Flasher.js


function getCompStyle(id, cstyle) //name collision with Mozilla getComputedStyle
{

	var myE = getElement(id);
	
	if(isGecko())
	{
		if(document.defaultView)
		{
			if(cstyle == '') 
			{
				cstyle = null;
			}
			
			var style = document.defaultView.getComputedStyle(myE,'');
//this never returned
			var test = style.getPropertyCSSValue(cstyle);
//nothing			var test = style.getPropertyValue(cstyle);
			
			return style.getPropertyValue(cstyle);
//			return style.getPropertyValue(cstyle);
		}
		else
		{
			return false;  //check to see what to return
		}
	}
	else if(isIE())
	{
		var ieCstyle	= getInterCap(cstyle);  //still needs work . try [] 
		var ieValue		= myE.currentStyle + '.' + ieCstyle;
		return ieValue;
	}
	else if(checkDebug())
	{
		alert('getCompStyle not done for this browser');
		return false;
	}
}

function setWidth(id, newWidth)
{

	var myE= getElement(id);

	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(id, newHeight)
{
	var myE= getElement(id);
	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(id).style.height = newHeight + px; 
	}
 	catch (error)
	{
		gjonerror( error, " setHeight ");
	}
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(id,y)
{
	var myE= getElement(id);

	try
	{
		isGecko() ? myE.style.top = y + px : myE.style.pixelTop = y; 
	}
 	catch (error)
	{
		gjonerror( error, " setTop ");
	}
}


function setLeft(id, x)
{
	var myE= getElement(id);
	try
	{
		isGecko() ? myE.style.left = x + px : myE.style.pixelLeft = x; 
	}
 	catch (error)
	{
		gjonerror( error, " setLeft ");
	}
}

// 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(id, t,r,b,l)
{

// I should set a check debug type thing here
	if(checkDebug())
	{
		var myE= getElement(id);
		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(id);
	}

	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(cname)
{
	var myE= getElement(id);

	 myE.setAttribute('className', cname,0); 
}

function setZ(id,z)
{
	var myE= getElement(id);
	
	try
	{
		myE.style.zIndex = z;
	}
 	catch (error)
	{
		gjonerror( error, " setLeft ");
	}
}

function setTopLeft(id, x, y) 
{
	setTop(id,y);
	setLeft(id,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(id, myHTML)
{

	try
	{
		var myE= getElement(id);
		myE.innerHTML = myHTML;
	}
 	catch (error)
	{
		gjonerror( error, " changeInnerHTML ");
	}
}

function returnInnerHTML(id)
{

	try
	{
		var myE= getElement(id);
	}
 	catch (error)
	{
		gjonerror( error, " returnInnerHTML ");
	}

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.innerWidth; // window.document.width;
				clientWidth				=	window.screen.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 gj1');
	} 
}
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 showMousePostion');
		}

		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(id)
{
	try
	{
		getElement(id).style.display = 'block';
	}
 	catch (error)
	{
		gjonerror( error, " setDisplayV ");
	}
}

function setDisplayH(id)
{
	try
	{
		getElement(id).style.display = 'none';
	}
 	catch (error)
	{
		gjonerror( error, " setDisplayH ");
	}
}

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);
	}
}

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));
}   





function days_between(date1, date2) 
{

    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24;

    // Convert both dates to milliseconds
    var date1_ms = date1.getTime();
    var date2_ms = date2.getTime();

    // Calculate the difference in milliseconds
    var difference_ms = Math.abs(date1_ms - date2_ms);
    
    // Convert back to days and return
return Math.round(difference_ms/ONE_DAY);
}

function date_from_days_and_date(date1, days) 
{


    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24;

    // Convert both dates to milliseconds
    var date1_ms = date1.getTime();

	var milli_indays = ONE_DAY * days;
    
	var date2_ms = date1_ms + milli_indays;

    // get the new date
    var then = new Date(date2_ms);
    
return then;
}

/*
	parent.document.getElementById(id)

when running locally Mozilla returns currnet time as last modified
IE returns it fine
*/
function DisplayModifedDate(what,id)
{
	toggleHighLight(what, id);   
	
	if(what == 'o')
	{
		getElement(id).value="Show Date Last Modified";
	}
	else
	{
		var lastmod = parent.document.lastModified; // string of last modified date
		var lastmoddate = Date.parse(lastmod);   // date
		var DisplayDate;
		
		if(lastmoddate == 0)
		{               
			DisplayDate = "Last modified: Unknown";
		} 
		else
		{
			DisplayDate = "Last modified: " + lastmod;
		}
	
		getElement(id).value = DisplayDate;
	}
}

function setStyle(idin, attrName, newData)
{
	var myE= getElement(idin);

	try
	{
		myE.style.attrName = newData; 
	}
 	catch (error)
	{
		gjonerror( error, " setStyle ");
	}
}

function getShortMonthName(iMonth)
{

smname = new Array (  "Jan",
					  "Feb",
					  "Mar",
					  "Apr",
					  "May",
					  "Jun",
					  "Jul",
					  "Aug",
					  "Sep",
					  "Oct",
					  "Nov",
					  "Dec", 
					  "bad"	);
      
return (smname[iMonth]);
}         

function getMonthName(iMonth)
{

mname = new Array (	  "January",
					  "February",
					  "March",
					  "April",
					  "May",
					  "June",
					  "July",
					  "August",
					  "September",
					  "October",
					  "November",
					  "December", 
					  "bad"	);
      
return (mname[iMonth]);
}  

function getShortDayName(iDay)
{

sdname = new Array(	"Sun",
					"Mon",
					"Tue",
					"Wed",
					"Thu",
					"Fri",
					"Sat",
					"bad"	); 
return (sdname[iDay]);
}		

function getDayName(iDay)
{

dname = new Array(	"Sunday",
					"Monday",
					"Tuesday",
					"Wednesday",
					"Thursday",
					"Friday",
					"Saturday",
					"bad"	); 
return (dname[iDay]);
}		


var accumulate    = new Array( 31, 59, 90,120,151,181,212,243,273,304,334);
var accumulateLY  = new Array( 31, 60, 91,121,152,182,213,244,274,305,335);


function LeapYear(year) 
{
    if ((year / 4)   != Math.floor(year / 4))   {return false;}
    if ((year / 100) != Math.floor(year / 100)) {return true;}
    if ((year / 400) != Math.floor(year / 400)) {return false;}
    return true;
}

function getJulian(day,month,year) 
{
	if(month == -1)
		return (day);
	
  if(LeapYear(year))
	{
        return (day + accumulateLY[month]);
	}
  else
	{
        return (day + accumulate[month]);
	}
}

function format12HourTime(hour, min, sec)
{
	var ampm = "PM";

	if (min <= 9) 
	{
		min = "0" + min;
	}

	if (sec <= 9) 
	{
		sec = "0" + sec;
	}

	if (hour > 12) 
	{
		hour = hour - 12;
		ampm = "PM";
	}
	else 
	{
		hour = hour;
		ampm = "AM";
	}
	
	if (hour == 12) 
	{
		ampm = "PM";
	}

	if (hour == 00) 
	{
		hour = "12";
	}
	
	if(hour <= 9)
	{
		hour =  "0" + hour 
	}

	var msg1 = hour;
	msg1 += ':' + min;
	msg1 += ':' + sec;
	msg1 += ' ' + ampm + ' ';

return msg1;
}

function getTimeStamp()
{
	var now		= new Date();

	var hour	= now.getHours();
	var min		= now.getMinutes();
	var sec		= now.getSeconds();

	if (min <= 9) 
	{
		min = "0" + min;
	}

	if (sec <= 9) 
	{
		sec = "0" + sec;
	}

	if (hour > 12) 
	{
		hour = hour - 12;
		ampm = "PM";
	}
	else 
	{
		hour = hour;
		ampm = "AM";
	}
	
	if (hour == 12) 
	{
		ampm = "PM";
	}

	if (hour == 00) 
	{
		hour = "12";
	}
	
	if(hour <= 9)
	{
		hour =  "0" + hour 
	}

	var msg1 = hour;
	msg1 += ':' + min;
	msg1 += ':' + sec + "." + now.getMilliseconds();
	msg1 += ' ' + ampm + ' ';

	msg1 = " " + msg1 + " ";
	    
return msg1;
}


//	not working in mozilla
//  what does this work for. it does not seem to work for a piece of style
//  maybe its for an HTML attribute like the src of a img
function changeAttribute(elementId, attrName, newData)
{
	try
	{
//		if(isGecko())
//		{
//			netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
//		}

		if (document.getElementById)
		{
			var el = document.getElementById(elementId);
			el.setAttribute(attrName, newData);
		}
	}
 	catch (error)
	{
		gjonerror( error, " changeAttribute ");
	}
}