/*
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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

  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

IE lets all the controls show through.  

  Thier example, use dom to get the list of controls and they
  loop through them, turning them off, displya the div, then turn them back on

  Can I do something differnt?
  use an image as the background and strech it?

  ?



*/


var EOLN = "\n";
var EOL = '<br>';

var myGCSGS = -1;

/*

	if there is an error loading an HTML page, this fails.
	there is no window to open this window

	if (e instanceof EvalError)
	{
		alert("type 1");
	}
	
	if (e instanceof EvalError)
	{
		alert("type 2");
	}
	
	if (e instanceof RangeError)
	{
		alert("type 3"); RangeError var someArr = new Array(89723742304323248456)
	}
	
	if (e instanceof ReferenceError)
	{
		alert("type 4"); ReferenceError something like dd
	}
	
	if (e instanceof SyntaxError)
	{
		alert("type 5"); SyntaxError vara count = 99>
	}
	
	if (e instanceof TypeError)
	{
		alert("type 6"); TypeError 

	}
	
	if (e instanceof URIError)
	{
		alert("type 7");
	}

window.onerror=CberrorHandler

CberrorHandler ( msg, url, line)

  I could add this in front and check or ignore everything

	if(checkDebug())
	{

Need to rethink this 
Error: uncaught exception: 
A script from "http://mywebpages.comcast.net" was denied UniversalBrowserWrite privileges.

	if(isGecko())
	{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
		    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
	}



  onerror2 is my error tester

*/

function onerror2(ex, msg, myevent) 
{
	try
	{
		displayDivError(ex , msg, myevent);
	}
	catch(error)
	{
		alert("Error " + msg + "1: " + ex.name + "1: " + ex.message  + "2: " + error.name +  "2: " + error.name);	
	}

return false;
}




function onerror(ex, msg) 
{
/*  Yead Done I have to fix the height display before I can use this */
	try
	{
		displayDivError(ex,msg);
	}
/*
	try
	{
		var wname = "Error"+mkunique();
		var errW = window.open("",wname,"height=400,width=640");
		if(!errW) 
		{
			alert("Error " + msg + ": " + ex.name + ": " + ex.message);	
			errW.close();
			return;
		}
		var wintxt ="<html><body bgcolor='#008080'>";
		wintxt +=   "<input type=button value='Close' onClick='self.close()'><br><br>";
		wintxt +=	"<div style='text-align: center; border:20pt outset red;width:8em; margin-left: auto; margin-right: auto; background-color:white;'> ";
		wintxt +=   "<p style=' font-weight:bold; font-size:20.0pt; color:black;  font-family: Courier, sans-serif;  text-align:center;   padding-right:7.5pt;  padding-left:7.5pt; padding-top:2.5pt;  padding-bottom:2.5pt;'>";
		wintxt +=	"STOP";
		wintxt +=  "</p>";
		wintxt +=	"</div>";
		wintxt +=   "<p style='font-size: 16pt; color:white;'>";
		wintxt +=   "&nbsp;" + msg + "<br><br>";
		if(isGecko())
		{
		//check errno
			wintxt +=   "&nbsp;" + ex.name + " " +  ex.message + "<br>&nbsp;File: " +  ex.fileName + "<br> &nbsp;Line:" + ex.lineNumber + "<br>";
		}
		else
		{
//			wintxt +=   "&nbsp;" + String(e) + "<br>"; bad bad bad 

			wintxt +=   "&nbsp;" + ex.name + " " +  ex.message;

		}
		wintxt +=  "</p>";
		wintxt +=   "<p style='font-size: 12pt; color:white;'>";
		wintxt += "&nbsp;Client: " + navigator.userAgent;
		wintxt +=  "</p>";
		wintxt += "</body></html>";
		errW.document.write(wintxt);
		errW.document.close();
	}
*/
	catch(error)
	{
		alert("Error " + msg + "1: " + ex.name + "1: " + ex.message  + "2: " + error.name +  "2: " + error.name);	
	}

return false;
}

function DisplayNotNumber(number) 
{
	try 
	{
		var dnn = window.open("","Error"+mkunique(),"HEIGHT=200,WIDTH=600,scrollbars");
		var wintxt = "<html><body bgcolor='#008080'>";
		wintxt +=   "<input type=button value='Close' onClick='self.close()'>";
		wintxt +=	"<br><br>";
		wintxt +=   "<p style='font-size: 20pt; color:white; text-align:center;'>";
		wintxt +=   "<span style='background-color:navy;font-variant:small-caps;'>oops</span>";
		wintxt +=   "&nbsp;&nbsp;Is This &nbsp;&nbsp;";
		wintxt +=   "<span style='background-color:#F0FFFF; color:black'>";
		wintxt +=   "&nbsp;" +  number +  "&nbsp;</span>";
		wintxt +=   "&nbsp;&nbsp;a Number ?&nbsp;&nbsp;";
		wintxt +=	"</p><br style='clear:both;'><br>";
		wintxt +=   "</body></html>";
		dnn.document.write(wintxt);
		dnn.document.close();
	}
	catch(e)
	{
		alert('DisplayNotNumber ' + number + ' is not a number');	
	}

return false;
}



function doMessage(Message) 
{

	try 
	{
		var errMsg = window.open("","Message"+mkunique(),"height=300,width=600,scrollbars");
		var wintxt = "<html><body bgcolor='#008080'>";
		wintxt +=   "<input type=button value='Close' onClick='self.close()'>";
		wintxt +=	"<br><br>";
		wintxt +=   "<p style='font-size: 20pt; color:white; text-align:center;'>";
		wintxt +=   Message + EOL;
		wintxt +=	"</p>";
		wintxt +=   "</body></html>";
		errMsg.document.write(wintxt);
		errMsg.document.close();
// ?		errMsg.set
	}
	catch(e)
	{
		var newMsg = Message.replace(/<br>/g , '\n');
		alert(newMsg);
	}

}

function doDump(Message) 
{

	var windstyle = "height=" + getCH() + "width=" + getCW()+ ",scrollbars";
	try 
	{
		var errMsg = window.open("","Dump"+mkunique(),windstyle);
		var wintxt = "<html><body bgcolor='#008080'>";
		wintxt +=   "<input type=button value='Close' onClick='self.close()'>";
		wintxt +=	"<br>";
		wintxt +=   "<p style='font-size: 12pt; color:white; text-align:left;'>";
		wintxt +=   Message;
		wintxt +=	"</p>";
		wintxt +=   "</body></html>";
		errMsg.document.write(wintxt);
		errMsg.document.close();
//		? errMsg.set
	}
	catch(e)
	{
		alert(Message);
	}

}

function dumpAll()
{
	try
	{
		dumpIt(window, 'Window object');  //IE same as window.window
		dumpIt(document, 'Document object');
		dumpIt(document.body, 'Document.body object');
		dumpIt(screen, 'Screen object');  //IE no 
		dumpIt(navigator, 'navigator object');
		dumpIt(document.documentElement, 'Document.documentElement object');  //trys to dump itself
		dumpIt(document.all, 'Document.all object'); //IE only
	//	same same dumpIt(window.window, 'window.window object');//IE no
		dumpIt(window.screen, 'window.screen object');  //IE no //moz yes
	}
	catch(e)
	{
		onerror( e, " dumpAll ");
	}
}


function showScrSize()
{
var	availableWidth;
var	availableHeight;

// ie no screen.pixelDepth +" bit depth, 
//can use "\n" in the textarea
//need to build cross browser names
var clientWidth;
var clientHeight;
var clientTop;
var clientLeft;
var clientScrollPostionX;
var clientScrollPostionY;
var documentBodyOffset;


	try
	{
		var message='All Measurements in Pixels ' + EOL;

		clientWidth = getCW();
		clientHeight = getCH();

		if(isIE())
		{
		// see C:\SavedWebPages\IE DOM Measures.htm
		// C:\SavedWebPages\IEPositions.htm


//			clientWidth				=	document.body.clientWidth;
//			clientHeight			=	document.body.clientHeight;
//			clientWidth				=	document.documentElement.clientWidth; 0
//			clientHeight			=	document.documentElement.clientHeight;0
//			clientTop = document.body.clientTop;
//			clientLeft = document.body.clientLeft;
//			clientScrollPostionX	=	document.body.scrollLeft;
//			clientScrollPostionY	=	document.body.scrollTop; not yet

		}
		else if(isGecko())
		{
			/*
			  see http://www.mozilla.org/docs/dom/domref/dom_window_ref.html 
			window.screen.availHeight
	

			Specifies the y-coordinate of the first pixel that is not allocated to permanent or 
			semipermanent user interface features.
			
			 window.screen.availLeft
	
			Returns the first available pixel available from the left side of the screen.
			
			window.screen.availTop
	
			Specifies the height of the screen, in pixels, minus permanent or semipermanent user interface 
			features displayed by the operating system, such as the Taskbar on Windows.

			window.screen.availWidth
			Returns the amount of horizontal space in pixels available to the window.

			window.scrollbars.innerWidth
			*/

			message += ' Mozilla window.screen.availHeight				= ' + window.screen.availHeight  + EOL;
			message += ' Mozilla window.screen.availLeft				= ' + window.screen.availLeft + EOL;
			message += ' Mozilla window.screen.availTop					= ' + window.screen.availTop + EOL;
			message += ' Mozilla window.screen.availWidth				= ' + window.screen.availWidth + EOL;
			message += ' Mozilla window.scrollbars.innerWidth			= ' + window.scrollbars.innerWidth + EOL;
			
			message += ' Mozilla window.innerWidth						= ' + window.innerWidth + EOL;
			message += ' Mozilla window.innerHeight						= ' + window.innerHeight + EOL;

			message += ' Mozilla window.document.height					= ' + window.document.height + EOL;
			message += ' Mozilla window.document.width					= ' + window.document.width + EOL;

			message += ' Mozilla document.body.offsetWidth				= ' + document.body.offsetWidth + EOL;
			message += ' Mozilla document.width							= ' + document.width + EOL;
			message += ' Mozilla document.height						= ' + document.height + EOL;


//			clientScrollPostionX	=	window.pageXOffset;
//			clientScrollPostionY	=	window.pageYOffset; // works for mozilla
		}
		else 
		{
			alert("unknown browser");
		}

		message += ' clientWidth				= ' + clientWidth  + EOL;
		message += ' clientHeight				= ' + clientHeight + EOL;

		message += ' screenWidth				= ' + screen.width  + EOL;
		message += ' screenHeight				= ' + screen.height + EOL;
		message += ' screenColorDepth			= ' + screen.colorDepth + EOL;


		doDump( message );
	}
 	catch (error)
	{
		onerror( error, " showScrSize ");
	
	}

return false;
}



/*
Mozilla 
All Measurements in Pixels
clientWidth = 1022
clientHeight = 572
clientTop = 5065
clientLeft = 942
clientScrollPostionX = 0
clientScrollPostionY = 3990
screenWidth = 1024
screenHeight = 768
screenColorDepth = 32
document.body.scrollTop = 0
document.body.scrollLeft = 0
window.document.height = 5065

IE
 All Measurements in Pixels 

clientWidth = 880
clientHeight = 523
clientTop = 0
clientLeft = 0
clientScrollPostionX = 0
clientScrollPostionY = 0
screenWidth = 1024
screenHeight = 768
screenColorDepth = 32
document.body.scrollTop = 0
document.body.scrollLeft = 0
window.document.height = undefined

  
*/ 


xvyasddaamsg = 'traverse' + EOLN;

/* can't dump to a window unless I do something with the HTML */

function traverse(node)
{

	try
	{
		var type = node.nodeType;

		// if it's an element dump the tag and recurse the children
		if (type == Node.ELEMENT_NODE) 
		{
			xvyasddaamsg += "<" + node.tagName + ">" + EOLN;
			
			// go through the children
			if (node.hasChildNodes()) 
			{
				var children = node.childNodes;
				var i, length = children.length;
				for (i = 0; i < length; i++) 
				{
					var child = children[i];
					traverse(child);
				}
				xvyasddaamsg += "</" + node.tagName + ">" + EOLN;
			}
		}
		// it's just text, no tag, dump "Text"
		else if (type == Node.TEXT_NODE) 
		{
			xvyasddaamsg += node.data + '- Text noTag' + EOLN;
		}
	}
 	catch (error)
	{
		onerror( error, " traverse ");
	}

return xvyasddaamsg;
}

function dumpTree()
{
	var node = document.documentElement;
	dump("Document Tree:\n");
	traverse(node, "");
	dump("\n");
}


function dumpIt(obj, objname)
{

var astring0 = '' + objname + ' : ';
var astring1 = '';
var astring2 = '';
var astring3 = '';
var astring4 = '';
var astring5 = '';
var astring6 = '';

	try
	{
		if(typeof(obj) != "undefined")
		{
			
			if (typeof(obj) == 'function')
			{
				astring1 += 'is a function ';
				astring2 += showProperties(obj, objname); 
				astring3 += showLength(obj, objname); 
				astring4 += showConstructor(obj, objname); 
				astring5 += showtoString(obj, objname); 
			}
			
			if (typeof(obj) == 'object')
			{
				//I want to figure out if its an HTMLElement 
				//show properties is not working to show me more
				//the other stuff is throwing errors
				astring1 += 'is an object '; 
				astring2 += showProperties(obj, objname); 
				astring3 += showLength(obj, objname); 
				astring4 += showConstructor(obj, objname); 
				astring5 += showtoString(obj, objname); 

			}
			
			if (typeof(obj) == 'string')
			{
				astring1 += 'is a string '; 
				astring2 += showProperties(obj, objname); 
				astring3 += showLength(obj, objname); 
				astring4 += showConstructor(obj, objname); 
				astring5 += showtoString(obj, objname); 
			}

			if (typeof(obj) == 'number')
			{
				astring1 += 'is a number '; 
				//astring2 += showProperties(obj, objname); 
				//astring3 += showLength(obj, objname); 
				astring4 += showConstructor(obj, objname); 
				astring5 += showtoString(obj, objname); 
			}
		}
		else
		{
			astring1 += " is an undefined whatever";
		}
	}
	catch(e)
	{
		astring1 += "Error Thrown trying to determine state of input ";
	}

	
//	alert(astring0 + astring1 + EOL + astring2 + EOL + astring3 + EOL + astring4 + EOL + astring5  + EOL + astring6);
	doDump(astring0 + astring1 + EOL + astring2 + EOL + astring3 + EOL + astring4 + EOL + astring5  + EOL + astring6);

}

function showProperties(obj, objName) 
{

	var result = "showProperties: "
	try
	{
		for (var i in obj)
		{
			//maybe if gecko
			//lets skip my functions
			if(typeof(obj[i]) == 'function')
			{
//				re1 = /</;
//				if(re1.test(obj[i]))
//				{
//					alert('got a < ' + obj[i]);
//				}
	
				re2 = /native code/;
				if(!re2.test(obj[i]))
				{
					continue;
				}
			}

			result += objName + "." + i + " = " + obj[i] + EOL;
		}
	}
	catch(e)
	{
		result += "Error Thrown on showProperties ";	
	}


return result;
}

function showLength(obj, objName)
{
var astring3 = 'showLength: ';

	try
	{
		if(typeof(obj) != "undefined")
		{
			if (typeof(obj.length) == 'undefined')
			{
				astring3 += "length undefined";
			}
			else
			{
				astring3 += "length = " + obj.length;
			}
		}
	}
	catch(e)
	{
		astring3 += "Error Thrown on getting length ";	
	}
return astring3;
}

function showConstructor(obj, objName)
{
var astring4 = "showConstructor: ";

	try
	{
		if (typeof(obj.constructor) == 'undefined') 
		{
			 astring4 += "constructor undefined";
		}
		else
		{
			 astring4 += "constructor = " + typeof(obj.constructor);
		}
	}
	catch(e)
	{
		astring4 += "Error Thrown on getting constructor ";	
	}
return astring4;
}

function showtoString(obj, objName)
{
var astring5 = "showtoString: ";
	try
	{
		if(typeof(obj) != "undefined")
		{
			astring5 += obj.toString(); 
		}
	}
	catch(e)
	{
		astring5 += "Error Thrown on getting toString ";
	}

return astring5;
}

function showComputedStyle(id, cstyle)
{
	var msg = 'id ' + id + ' ';

	var myE = getElement(id);
	
	if(isGecko())
	{
		if(document.defaultView)
		{
			if(cstyle == '') 
			{
				cstyle = null;
			}
			
			var style = document.defaultView.getComputedStyle(myE,'');
			
			
			//	var style = document.defaultView.getComputedStyle(myE, cstyle);
			
			msg += cstyle	+ ' : ';
			msg += style.getPropertyValue(cstyle) + '\n';
			
			alert(msg);
		}
		else
		{
			return false;
		}
	}
	else if(isIE())
	{
		if(myE.currentStyle) 
		{
			msg += cstyle + ' : ';
			msg += myE.currentStyle[cstyle] + '\n'
			alert(msg);
		}
		else
		{
			return false;
		}
	}
	else
	{
		alert('not done for this browser');
	}
}


function showInnerHTML(idin)
{
/*

IE does inner outer text and outer html
MOz does innerhtml

*/

	var msg = ' ';
	try
	{
		var myE= getElement(idin);

		msg+= " InnerText is: " + myE.innerText + "\n\n";
		msg+= " InnerHTML is: " + myE.innerHTML + "\n\n";
		msg+= " outerText is: " + myE.outerText + "\n\n";
		msg+= " outerHTML is: " + myE.outerHTML + "\n\n";
		alert(msg);
	}
	catch (error)
	{
		onerror( error, "showInnerHTML error ");
	}
}

//function popDiv(evt,idin)
function popDiv(evt,idin, buttonID, name, width, height)
{
	try
	{
		var pw = getCW();
		var theObj = getElement(idin);
		var isVisib = theObj.style.visibility;

		if(isIE())
		{
			if(theObj.scrollHeight)
			{
				setHeight(idin, theObj.scrollHeight + 4);
			}
		}

		if (isVisib == "visible" || isVisib == "show")  
		{ 
			if(buttonID && name)
			{
				getElement(buttonID).value="Display " + name; 
			}
			setHidden(idin); 
		}
		else 
		{
			if(buttonID && name)
			{
				getElement(buttonID).value="Hide " + name; 
				var leftVal = mygetLeft(buttonID) + 2;
			}
			else if(buttonID)
			{
				var leftVal = mygetLeft(buttonID) + 2;
			}
			else
			{
				var leftVal = getEventX(evt);
			}

			var topVal = getEventY(evt) + 20;
			
			setTop(idin, topVal);
//			setLeft(idin, leftVal + 100); 
			setLeft(idin, leftVal); 
			setVisible(idin);  
		}
	}
	catch (error)
	{
		onerror( error, " popDiv ");
	}
}

//looks like IE wants the height, width, top , left in an inline style
//
// if evt is null, then use the center of the screen
function popCSGSDiv(evt,idin, buttonID, name, width, height)
{
	try
	{
		var theObj = getElement(idin);
		var isVisib = theObj.style.visibility;
		
//		var mtop = parseInt(getCompStyle(idin, 'top'));
//		alert('computed top is ' + mtop);

		if(isIE())
		{
			if(theObj.scrollHeight)
			{
				setHeight(idin, theObj.scrollHeight + 4);  // for the border
			}
		}
		
		if (isVisib == "visible" || isVisib == "show")  
		{ 
			getElement(buttonID).value="Display " + name; 
			var popItUp = GCSGS();
//			var popItUp = new CSGS();
			
			var myNum = popItUp.addElement(idin);
			popItUp.addEffect(myNum,'myClip','myKeep');
			//		popItUp.addEffect(idin,'myWipe','myKeep');  Not yet
			popItUp.setIntervalSpeed(60);
			popItUp.setMI(myNum, 40);
			popItUp.setMIE(myNum, 10);
			popItUp.addMove(myNum, 'cl','cl','r' ,'b' );
			popItUp.doIt();
//			delete popItUp;
		}
		else if (evt == null)
		{
			getElement(buttonID).value="Hide " + name; 
			var popItUp = GCSGS();
//			var popItUp = new CSGS();
			
			var myNum = popItUp.addElement(idin);
			popItUp.setIntervalSpeed(60);
			popItUp.setMI(myNum, 25);
			popItUp.addMove(myNum, 'tl','tl', 'c', 'c');
			popItUp.doIt();
//			delete popItUp;

		}
		else
		{
			topVal = getEventY(evt) + 20;
			leftVal = getEventX(evt);

			getElement(buttonID).value="Hide " + name; 
//			var popItUp = new CSGS();
			var popItUp = GCSGS();
			
			var myNum = popItUp.addElement(idin);
			popItUp.setIntervalSpeed(60);
			popItUp.setMI(myNum, 25);
			popItUp.addMove(myNum, 'tl','tl', leftVal, topVal);
			popItUp.doIt();
//			delete popItUp;
		}
	}
	catch (error)
	{
		onerror( error, " popCSGSDiv");
	}

}

function createDynDiv(mywidth, myheight, mytop, myleft, idin)
{

    // relatively positioned so that can have absolutely positioned children,
    // but it still appears in the normal element flow
	// WIP relative
    var DynDiv = document.createElement("DIV");
    DynDiv.style.position			= "absolute";			// Set absolute positioning ? relative 
	if(isGecko())
	{
		DynDiv.style.width				= mywidth + "px";       
		DynDiv.style.height				= myheight + "px";      
		DynDiv.style.top				= mytop + "px";         
		DynDiv.style.left				= myleft + "px";        
		DynDiv.style.border				= "2px solid black";    
		DynDiv.style.backgroundColor	= "white";				
		DynDiv.style.zIndex				= 2;

		//clip has to add in border width + padding?
		mywidth							+= 12;
		myheight						+= 12;
		DynDiv.style.clip				= 'rect(' + 0 + ',' + mywidth + ',' + myheight + ',' + 0 + ')';
		DynDiv.style.visibility			= 'hidden';
		DynDiv.style.overflow			='auto';
	}
	else
	if(isIE())
	{
		DynDiv.style.width				= mywidth;			    
		DynDiv.style.height				= myheight;				
		DynDiv.style.top				= mytop;			    
		DynDiv.style.left				= myleft;				
		DynDiv.style.border				= "2px solid black";    
		DynDiv.style.backgroundColor	= "white";				
		DynDiv.style.zIndex				= 2;					

		mywidth							+= 12;
		myheight						+= 12;
		DynDiv.style.clip				= 'rect(' + 0 + ',' + mywidth + ',' + myheight + ',' + 0 + ')';
		DynDiv.style.visibility			= 'hidden';
		DynDiv.style.overflow			='auto';
	}
	else
	{
		alert('unkown browser');
	}

	if(idin)
	{
		DynDiv.id = idin;
	}

    // Now add the DynDiv we've built to the document body
    document.body.appendChild(DynDiv);

return DynDiv;
}

function displayDivError(ex, msg, myevent)
{

var iDisplayWidth		= getCW() - 100;
var iDisplayHeight		= getCH() - 100;
var iCAtTop				= 800;
var iCAtLeft			= 800;

	if(myevent)
	{
		var iSFromTop			= getEventY(myevent) - 200;
		var iSFromLeft			= getEventX(myevent) - 200;
		var iSToTop				= getEventY(myevent);
		var iSToLeft			= getEventX(myevent);
	}
	else
	{
		var iSFromTop			= 'll';
		var iSFromLeft			= 'll';
		var iSToTop				= 'c';
		var iSToLeft			= 'c';
	}

var sSEffect			= '';
var iSMoveSpeed			= 60;

var iHFromTop			= 'cl';
var iHFromLeft			= 'cl';
var iHToTop				= 'b';
var iHToLeft			= 'r';
//var sHEffect			= 'myWipe';
var sHEffect			= 'myClip';
var iHMoveSpeed			= 60;

var	idName				= 'myError' + mkunique();

var f					= 'f';
var m					= 'm';
var o					= 'o';

	try
	{

		var newDiv	= createDynDiv(iDisplayWidth,iDisplayHeight, iCAtLeft,iCAtTop, idName);

		var wintxt	= '';

		wintxt += "<input type='button' id='xxxx' title='Close' class='buttonNgold' value='Close' onClick='"; 
		wintxt += "hideIt(" + '"' + idName + '"' + "," + iDisplayWidth + "," + iDisplayHeight + "," + '"' + iHFromLeft + '"' + "," + '"' + iHFromTop + '"' + ',' +   '"' + iHToLeft   + '"' + "," +  '"' +iHToTop  + '"' + "," + '"' + sHEffect + '"' + ',' + iSMoveSpeed + ");'";
		wintxt += "onmouseover='toggleHighLight(" + '"' + m + '"' + ", this.id);'"; 
		wintxt += "onFocus='toggleHighLight(" + '"' + f + '"' + ", this.id);'";   
		wintxt += "onblur='toggleHighLight(" + '"' + o + '"' + ",this.id);'";
		wintxt += "onmouseout='toggleHighLight(" + '"' + o + '"' + ", this.id);'>";
		wintxt += "<br><br>";

//		wintxt +=   "<input type=button value='Close' onClick='"
//		wintxt +=	"hideIt(" + '"' + idName + '"' + "," + iDisplayWidth + "," + iDisplayHeight + "," + '"' + iHFromLeft + '"' + "," + '"' + iHFromTop + '"' + ',' +   '"' + iHToLeft   + '"' + "," +  '"' +iHToTop  + '"' + "," + '"' + sHEffect + '"' + ',' + iSMoveSpeed + ");'";
//		wintxt +=	"><br><br>";
//		wintxt +=	"<div style='border:20pt outset red;width:8em; margin-left:50%; margin-right:%50; background-color:#008080;'> ";
//		wintxt +=	"<div style='border:20pt outset red;width:70%; margin-left:15%; margin-right:15%;'> ";
		wintxt +=	"<div style='border:20px outset red;width:70%; margin-left:15%; margin-right:15%;'> ";
//		wintxt +=   "<p style='font-weight:bold;font-size:16.0pt;color:black;font-family: Courier,sans-serif;text-align:center;padding-right:7.5pt;padding-left:7.5pt;padding-top:2.5pt;padding-bottom:2.5pt;'>";
		wintxt +=   "<p style='font-weight:bold;font-size:20px;color:black;font-family: Courier,sans-serif;text-align:center;padding-right:10px;padding-left:10px;padding-top:4px;padding-bottom:4px;'>";
		wintxt +=	"Error";
		wintxt +=   "</p>";
		wintxt +=	"</div>";
//		wintxt +=   "<p style='font-size:12pt;font-weight:bold;color:black;padding-right:1.5pt; padding-left:1.5pt;'>";
		wintxt +=   "<p style='font-size:16px;font-weight:bold;color:black;padding-right:2px; padding-left:2px;'>";
		wintxt +=   msg + "<br><br>";
		if(isGecko())
		{
			wintxt +=   ex.name + " " +  ex.message + "<br>File: " +  ex.fileName + "<br>Line:" + ex.lineNumber + "<br>";
		}
		else
		{
//			wintxt +=   "&nbsp;" + String(ex) + "<br>";
			wintxt +=   ex.name + " " +  ex.message;

		}
		wintxt +=  "</p>";
//		if(isGecko())
//		{
//			wintxt +=   "<br><p style='font-size: 10pt; color:black; padding-right:2.5pt;  padding-left:2.5pt;'>";
			wintxt +=   "<br><p style='font-size: 13px; color:black; padding-right:4px;  padding-left:4px;'>";
			wintxt +=	navigator.userAgent;
			wintxt +=	"</p>";
//		}
		wintxt += "";

//		changeInnerHTML(idName,wintxt);
		newDiv.innerHTML = wintxt;
		showIt(idName, iDisplayWidth, iDisplayHeight, iSFromLeft, iSFromTop, iSToLeft, iSToTop, sSEffect, iSMoveSpeed) //this is questionable as I dont have an id as yet
	}
	catch(error)
	{
		alert(msg + ex);	
	}
}


function displayDivMessage(title, msg, myevent)
{

var iDisplayWidth		= 640;
var iDisplayHeight		= 400;
var iCAtTop				= 800;
var iCAtLeft			= 800;


	if(myevent)
	{
		var iSFromTop			= getEventY(myevent) - 200;
		var iSFromLeft			= getEventX(myevent) - 200;
		var iSToTop				= getEventY(myevent);
		var iSToLeft			= getEventX(myevent);
	}
	else
	{
		var iSFromTop			= 'll';
		var iSFromLeft			= 'll';
//		var iSToTop				= 'c';
		var iSToTop				= 't';
//		var iSToLeft			= 'c';
		var iSToLeft			= 'l';
	}



var sSEffect			= '';
var iSMoveSpeed			= 60;

var iHFromTop			= 'cl';
var iHFromLeft			= 'cl';
var iHToTop				= 'b';
var iHToLeft			= 'r';
//var sHEffect			= 'myWipe';
var sHEffect			= 'myClip';
var iHMoveSpeed			= 60;

var	idName				= 'myMessage' + mkunique();

var f					= 'f';
var m					= 'm';
var o					= 'o';

	try
	{

		var newDiv	= createDynDiv(iDisplayWidth,iDisplayHeight, iCAtLeft,iCAtTop, idName);

		var wintxt	= '';

		wintxt += "<input type='button' id='xxxx' title='Close' class='buttonNgold' value='Close' onClick='"; 
		wintxt += "hideIt(" + '"' + idName + '"' + "," + iDisplayWidth + "," + iDisplayHeight + "," + '"' + iHFromLeft + '"' + "," + '"' + iHFromTop + '"' + ',' +   '"' + iHToLeft   + '"' + "," +  '"' +iHToTop  + '"' + "," + '"' + sHEffect + '"' + ',' + iSMoveSpeed + ");'";
		wintxt += "onmouseover='toggleHighLight(" + '"' + m + '"' + ", this.id);'"; 
		wintxt += "onFocus='toggleHighLight(" + '"' + f + '"' + ", this.id);'";   
		wintxt += "onblur='toggleHighLight(" + '"' + o + '"' + ",this.id);'";
		wintxt += "onmouseout='toggleHighLight(" + '"' + o + '"' + ", this.id);'>";
		wintxt += "<br><br>";

//		wintxt +=	"<div style='border:10pt outset red;width:70%; margin-left:15%; margin-right:15%;'> ";
		wintxt +=	"<div style='border:13px outset red;width:70%; margin-left:15%; margin-right:15%;'> ";
//		wintxt +=   "<p style='font-size: 14pt; color:black;padding-right:2.5pt; padding-left:2.5pt;'>";
		wintxt +=   "<p style='font-size: 19px; color:black;padding-right:4px; padding-left:4px;'>";
		wintxt +=   title + "<br><br>";
		wintxt +=   "</p>";
		wintxt +=	"</div>";
//		wintxt +=   "<p style='font-size: 14pt; color:black;padding-right:2.5pt; padding-left:2.5pt;'>";
		wintxt +=   "<p style='font-size: 19px; color:black;padding-right:4px; padding-left:4px;'>";
		wintxt +=   msg + "<br><br>";

		newDiv.innerHTML = wintxt;
		showIt(idName, iDisplayWidth, iDisplayHeight, iSFromLeft, iSFromTop, iSToLeft, iSToTop, sSEffect, iSMoveSpeed) //this is questionable as I dont have an id as yet
	}
	catch(error)
	{
		alert(title + msg + error);	
	}
}
/*
setDebug on 
	mozilla 
	when it gets to  setgone in the move code, it is still flashing 


*/


function displayDivMessage2(title, msg, tt, tl, dh, dw)
{
var iCAtTop				= 800;
var iCAtLeft			= 800;
var iSFromTop			= 'll';
var iSFromLeft			= 'll';

	if(tt && typeof( tt) == 'number' || typeof( tt) == 'string')
	{
		var iSToTop				= tt;
	}
	else
	{
		alert('wake up in displayDivMessage2');
		return;
	}

	if(tl && typeof( tl) == 'number' || typeof( tl) == 'string')
	{
		var iSToLeft				= tl;
	}
	else
	{
		alert('wake up in displayDivMessage2');
		return;
	}


	if(dh && typeof( dh) == 'number')
	{
		var iDisplayHeight		= dh;
	}
	else
	{
		alert('wake up in displayDivMessage2');
		return;
	}

	if(dw && typeof( dw) == 'number')
	{
		var iDisplayWidth		= dw;
	}
	else
	{
		alert('wake up in displayDivMessage2');
		return;
	}
	
	
//		var iSToTop				= 'c';
//		var iSToLeft			= 'c';
	



var sSEffect			= '';
var iSMoveSpeed			= 60;

var iHFromTop			= 'cl';
var iHFromLeft			= 'cl';
var iHToTop				= 'b';
var iHToLeft			= 'r';
//var sHEffect			= 'myWipe';
var sHEffect			= 'myClip';
var iHMoveSpeed			= 60;

var	idName				= 'myMessage' + mkunique();

var f					= 'f';
var m					= 'm';
var o					= 'o';

	try
	{

		var newDiv	= createDynDiv(iDisplayWidth,iDisplayHeight, iCAtLeft,iCAtTop, idName);

		var wintxt	= '';

		wintxt += "<input type='button' id='xxxx' title='Close' class='buttonNgold' value='Close' onClick='"; 
		wintxt += "hideIt(" + '"' + idName + '"' + "," + iDisplayWidth + "," + iDisplayHeight + "," + '"' + iHFromLeft + '"' + "," + '"' + iHFromTop + '"' + ',' +   '"' + iHToLeft   + '"' + "," +  '"' +iHToTop  + '"' + "," + '"' + sHEffect + '"' + ',' + iSMoveSpeed + ");'";
		wintxt += "onmouseover='toggleHighLight(" + '"' + m + '"' + ", this.id);'"; 
		wintxt += "onFocus='toggleHighLight(" + '"' + f + '"' + ", this.id);'";   
		wintxt += "onblur='toggleHighLight(" + '"' + o + '"' + ",this.id);'";
		wintxt += "onmouseout='toggleHighLight(" + '"' + o + '"' + ", this.id);'>";
		wintxt += "<br><br>";

//		wintxt +=	"<div style='border:10pt outset red;width:70%; margin-left:15%; margin-right:15%;'> ";
		wintxt +=	"<div style='border:5px outset red;width:70%; margin-left:15%; margin-right:15%;'> ";
//		wintxt +=   "<p style='font-size: 14pt; color:black;padding-right:2.5pt; padding-left:2.5pt;'>";
		wintxt +=   "<p style='font-size: 19px; color:black;padding-right:4px; padding-left:4px;'>";
		wintxt +=   title + "<br><br>";
		wintxt +=   "</p>";
		wintxt +=	"</div>";
//		wintxt +=   "<p style='font-size: 14pt; color:black;padding-right:2.5pt; padding-left:2.5pt;'>";
		wintxt +=   "<p style='font-size: 16px; color:black;padding-right:4px; padding-left:4px;'>";
		wintxt +=   msg + "<br><br>";

		newDiv.innerHTML = wintxt;
		showIt(idName, iDisplayWidth, iDisplayHeight, iSFromLeft, iSFromTop, iSToLeft, iSToTop, sSEffect, iSMoveSpeed) //this is questionable as I dont have an id as yet
	}
	catch(error)
	{
		alert(title + msg + error);	
	}
}



//might want a variable for show/hide  - ie Toggle, Hide, Show

// probably don't need width and height)
// however, its probably a good idea to set as if its dynanmic, it will need
// the size
// the colors and font sizes and everything else should come from the
// css style sheets

//var iDisplayWidth;
//var iDisplayHeight;
//var iFromTop;
//var iFromLeft;
//var iToTop;
//var iToLeft
//var sEffect (Shrink,Wipe,Fade,Dissolve)
//var iMoveSpeed
//var iMoveIncrement
//var iMoveType (Vertical, Horizontal, Horizontal, Vertical)
//    I may need to work on other types, along a line of point etc.


//  I could use the event that is used to trigger this to calculate a better set of To cordinates!

function showIt(divIn,iDisplayWidth, iDisplayHeight, iFromLeft, iFromTop, iToLeft, iToTop, sEffect, iMoveSpeed)
{ 
//	showItobj = new CSGS();
	showItobj = GCSGS();

	var thisNum = showItobj.addElement(divIn);
//	showItobj.addEffect(divIn,sEffect);
	showItobj.setIntervalSpeed(iMoveSpeed);
	showItobj.setMI(thisNum, 25);
	showItobj.addMove(thisNum, iFromLeft,iFromTop, iToLeft, iToTop);
	showItobj.doIt();
//	delete showItobj;
}

//id, where to go, effect
function hideIt(divIn, iDisplayWidth, iDisplayHeight, iFromLeft, iFromTop, iToLeft, iToTop, sEffect, iMoveSpeed )  
{ 
//	hideItobj = new CSGS();
	hideItobj = GCSGS();

	var thisNum = hideItobj.addElement(divIn);
//	hideItobj.addEffect('myWipe', delay, speed) //need this stuff
//	removed aug 2004 to get rid of annoying flash in displaymessage2 
//  not fully tested	hideItobj.addEffect(thisNum,sEffect,'myKeep');
	hideItobj.addEffect(thisNum,sEffect);
	hideItobj.setIntervalSpeed(iMoveSpeed);
	hideItobj.setMI(thisNum, 40);
	hideItobj.setMIE(thisNum, 10);
	hideItobj.addMove(thisNum, iFromLeft,iFromTop, iToLeft, iToTop);
	hideItobj.doIt();
//	delete hideItobj;
}


function displayAttributeAsAlert(elementId, attrName) 
{
//   if (MyHeading.getAttribute("align")=="middle")
//        MyHeading.setAttribute("align","center");

//  what does this work for. it does not seem to work for a piece of style

	try
	{
		if (document.getElementById) 
		{
			var el = document.getElementById(elementId);
			var attrVal = el.getAttribute(attrName);
			var alertStr = "Element ID: " + elementId + "\n";
			alertStr += "Attribute name: " + attrName + "\n";
			alertStr += "Attribute value: " + attrVal;
			window.alert(alertStr);
		}
	}
 	catch (error)
	{
		onerror( error, " displayAttributeAsAlert");
	}
}

/*this is a work in progress */
function displayIMG()
{
	try
	{
		newwin = window.open(url, "winpopup1","WIDTH=600,HEIGHT=350");
		newwin.focus();
		checkbox_on = new Image();
		checkbox_on.src = "/images/guide/guide_checkbox_on.gif";
	}
 	catch (error)
	{
		onerror( error, " displayIMG");
	}
}

function enum_and_sort(o)  
{
	try
	{
		var all = [];
		for(n in o)
		{
			all.push(n);
		}
		all.sort();
		
		for(n in all)
		{
			print(all[n]);
		}
		
		print("total count: "+all.length);
	}
 	catch (error)
	{
		onerror( error, " enum_and_sort");
	}
}
