/*
	ResourceMaster.js
	(ResourceMaster.js has comments, Resource.js does not.)
	
	JavaScript mouseover and other routines developed by ResourcePark, Inc and
	Rampant, Inc for various db customers.
	
	1/ 9/05 RGS Copyrights and documentation
	12/27/04RGS V004 Major function rpJavaMenuHilite for virtual page mouseovers
	2/20/03RGS V002 Correct name of rpImageDefine, rpImageSwap in function and documentation
	1/9/03 RGS V001 Cobble into single module, add VanFin mods, Single window action.
					- Add timing routines, create detail examples.
					- Single source module.
					- Javascript calls define targets. No more coding in Java
					
	1/9/03 GW  V000 Create from WebSi, Rampant, etc.  Working prototype
	
	Incorporates confidential and proprietary information and software under license
	agreement with named sources.  Use does not constitute rights or ownership.  All
	rights and ownership rest with named parties below.  Unauthorized use
	prohibited.  Use only by prior written agreement with named parties below.
		Copyright 2003 ResourcePark, Inc. All rights reserved.
		Coypright 1995-2005 Rampant, Inc. All rights reserved.
		Copyright 1995-2003 Websitement, Inc. All rights reserved.

'-----------------------------------------------------------------------------------
'   Copyright © 1995-2005 Rampant, Inc.  All rights reserved.
'   Confidential and Exclusive Proprietary Property of Rampant, Inc.
'	No portion of this work may be used or distributed in any manner 
'	without the express written permission of Rampant, Inc.
'   Rampant, Inc., 4700 Rockside Road Suite 400, Independence, Ohio  44131
'   (216) 524-5577  http://www.rampant.com   rampant@rampant.com
'-----------------------------------------------------------------------------------

*/
/* ***************************************************************************************** 
  Technical Notes:
	To manipulate information between windows functions must have a target location or name.
	That information usually can't be determined reliably after a window is launched.
	So, Parent windows must save their identifying information in the children before
	they release let go of the child.
	
	See rpLaunchPopup for an example of setting the popup's "creator".  

	Once the popup is alive it can move data into objects in the parent (i.e. a select box)
	or even force the parent to jump to another location (i.e. change the creator.location) 
	
  Examples & Notes

	Multiple commands
		- Combine several commands in one call.  
		- This example updates a field and closes the current window.
		<a onclick="JavaScript:riUpdateParentForm('field1');rpCloseMe()">newvalue</a>
		
	
	Use ONCLICK vs HREF 
		- Advantage: Doesn't display "JAVASCRIPT..." in browser status window when you mouse over it
  		<a onclick="JavaScript:rpParentJump('/home.asp')"> Home </a>
  		- Note: Don't use the HREF.  If you do, a second page will open (see open multiple windows if desired)
  		
  	How to open multiple windows at once.  (From a popup)
  		- The following opens Rampant.com in window "Rampant"
  			AND repoints the parent page elsewhere at the same time!

  		<a href="http://www.rampant.com" target="rampant"
				 onclick="JavaScript:rpParentJump('/db/onlinebuy.asp')">

	TODO - make into routine
		Nice code snippit, loads a value from the form we are in. 
		Assumes you've set popup window's creator from caller
			creator.location=document.LinkMain.go.options[document.LinkMain.go.selectedIndex].value

			<Select Name="go">
			<Option Selected Value="http://www.ResourcePark.com">PickMe</option>
			</Select>(which is the target url)
			
*/

/*---------------------------------------------------------------------------------
	rpUpdateParentField

	In the Parent define a field to be updated...
		<form method="post" action="somewhere.asp" name="SampleForm">	<!--must name the form-->
		<input type="text" value="oldvalue"        name="SampleField">	<!--must name the field-->
	In the Popup/Child 
		<a onclick="JavaScript:riUpdateParentForm('samplefield')">newvalue</a>
	Action: when the link in the popup is cilcked, this routine inserts the value

	Source: Vantage/MiniDB.asp

	UNTESTED, UNTESTED, UNTESTED	UNTESTED, UNTESTED, UNTESTED
	UNTESTED, UNTESTED, UNTESTED	UNTESTED, UNTESTED, UNTESTED
	UNTESTED, UNTESTED, UNTESTED	UNTESTED, UNTESTED, UNTESTED
	UNTESTED, UNTESTED, UNTESTED	UNTESTED, UNTESTED, UNTESTED
*/
function rpUpdateParentField(parentForm, parentField){
var targetForm = window.opener.document.forms[parentForm];
	targetForm.elements[parentField].value = argValue;
}


/*---------------------------------------------------------------------------------
	OPEN A POPUP WINDOW AND SPECIFY SIZE
	Current window becomes parent
	
	TESTED example
		<a onclick="JavaScript:rpLaunchPopupSized('/popup.asp',200,300)"> Popup </a>
*/
function rpLaunchPopupSized(targetURL,width,height)
{
var popupWindow
	popupWindow = window.open(targetURL,"","width=" + width +",height=" + height)
	popupWindow.creator = self		// Insert PARENT identity into the popup window so it can find us later */
}

/*---------------------------------------------------------------------------------
	OPEN A POPUP WINDOW.
	Current window becomes parent
	
	TESTED example
		<a onclick="JavaScript:rpLaunchPopup('/popup.asp')"> Popup </a>
*/
function rpLaunchPopup(targetURL){
var popupWindow
	popupWindow = window.open(targetURL,"","width=220,height=180")
	popupWindow.creator = self		// Insert PARENT identity into the popup window so it can find us later */
}

/*---------------------------------------------------------------------------------
	OPEN A NEW WINDOW.  Defaults for size, name, etc
	
	TESTED example
		<a onclick="JavaScript:rpLaunchWindow('/moreinfo.asp')"> MoreInfo </a>
*/
function rpLaunchWindow(targetURL)
{
var popupWindow
	popupWindow = window.open(targetURL)
	popupWindow.creator = self		// Insert PARENT identity into the popup window so it can find us later
}

/*---------------------------------------------------------------------------------
	OPEN A NEW WINDOW.  
		Set window NAME, URL, height, width and other information
		Setting width or height to 0 interpreted as use default
	
	TESTED example
		<a onclick="JavaScript:rpOpenWindow('BugList','/buglist.asp', 0,0)"> BugList </a>
		<a href="javascript:rpOpenWindow('','/',0,0,'height=380,width=630,left=100,top=100,scrollbars=yes,location=no,directories=no,status=yes,menubar=no,toolbar=yes,resizable=yes')"> Complicated Example </a>
*/
function rpOpenWindow(windowName, targetURL, width, height, other)
{
var popupWindow
var	paramString
	paramString = ""
	if (width != null) {
		if (width!=0) {
			if (paramString != "") paramString = paramString + ","
			paramString = paramString + "width=" + width;
		}
	}
	if (height != null) {
		if (height!=0) {
			if (paramString != "") paramString = paramString + ","
			paramString = paramString + "height=" + height;
		}
	}
	if (other != null) {
		if (other!=0) {
			if (paramString != "") paramString = paramString + ","
			paramString = paramString + other
		}
	}
	popupWindow = window.open(targetURL, windowName, paramString);
	popupWindow.creator = self;		// Insert PARENT identity into the popup window so it can find us later
//	alert("creator = "+popupWindow.creator.name);

/* debug: problem updating after external page linked (permission denied)
*/
//var targetWindow;
//		targetWindow = window.opener.document[windowName];
//		alert("targetname = "+targetWindow.name);
}

/*---------------------------------------------------------------------------------
	FORCE PARENT TO JUMP	

	TESTED example
		<a onclick="JavaScript:rpParentJump('/home.asp')"> Home </a>

*/
function rpParentJump(targetURL)
{
	var parentwin;
	var childwin;
	var lclException;
	try {

		parentwin = window.opener.document;
		parentwin.location = targetURL;

	}	catch(lclException)	{

		try {
		//Future: figure out where to save child window
			childwin = rpOpenWindow('',targetURL,0,0,'');

		} catch (lclException) {

		}
	}

//OLD	// Old method: set "creator" from caller.  But..clicking/refreshing pop looses creator.
//OLD	//	parentwin = window.creator;
// See if original window information is present
//	if ((parentwin == undefined) ||(parentwin == null) || (parentwin == '')) {
//	alert('No parent! Opening new window.');
//	} else if ((parentloc == undefined) ||(parentloc == null) || (parentloc == '')) {
//	alert('No parent! Opening new window.');
//	} else {
//	alert("x=" + window.creator.location)
//	}

}

/*---------------------------------------------------------------------------------
	FORCE CURRENT PAGE TO JUMP	

	TESTED example
		<a onclick="JavaScript:rpSelfJump('/home.asp')"> Home </a>

	Why? We want to open a popup AND jump to a new location.
	TESTED example
		<a onclick="JavaScript:rpLaunchPopupSized('/popup.asp',100,500);rpSelfJump('/home.asp')"> Home </a>

*/
function rpSelfJump(targetURL)
{
	self.location=targetURL
}

/*---------------------------------------------------------------------------------
	CLOSE CURRENT WINDOW

	TESTED example
		<a onclick="JavaScript:rpCloseMe()"> Close this form </a>

*/
function rpCloseMe()
{
	window.close()
}

/*---------------------------------------------------------------------------------
	MAKE POPUP REAPPEAR AFTER A SPECIFIED PERIOD OF TIME
	(recommended for popups)

	TESTED example
		<body onBlur="rpRestoreWindowOnTopTimer(5000)">	

	On blur occurs at the time a window is hidden.  
	Example causes window to reappear 5 seconds after it is minimized (or partially obscured)

*/
function rpRestoreWindowOnTopTimer(milliseconds)
{
    setTimeout("self.focus()",milliseconds);
}

/*---------------------------------------------------------------------------------
	FORCE POPUP TO OPEN ON TOP
	(obnoxious)

	TESTED example
		<body onload="riForceWindowOnTop()">
	
	To force popup to open on top and prevent other instances of browsers from getting on top
	(reasserts itself every time it is blured)
	TESTED example
		<body onload="riForceWindowOnTop()" onBlur="riForceWindowOnTop()">	

*/
function rpForceWindowOnTop(){
	window.focus();
	window.alwaysRaised = true;
}


/*---------------------------------------------------------------------------------
	DISPLAY MESSAGE
		Incredibly useful for debugging too!
	
	TESTED example
		<a onmouseover="JavaScript:rpAlert('You moved the mouse!')"> MouseOver Message </a>
		
*/
function rpAlert(argMessage)
{
	alert(argMessage);
}

/*---------------------------------------------------------------------------------
	DISPLAY MOUSE POSITION IN STATUS LINE
		Incredibly useful for debugging too!
	
	TESTED example
		<li><a onmousemove="rpReportMove('Hello Mouse')"><img src="http://www.rampant.com/art/earth.jpg"></a>
		
*/
function rpReportMove(argMessage)
{
	var	infomsg;
	infomsg = null;
	if (argMessage == null) {		// undefined may be a keyword too
		infomsg = "You moved the mouse to "
	} else {
		infomsg = argMessage;
	}
	infomsg = infomsg + " X=" + window.event.x + " Y=" + window.event.y;
	window.status = infomsg;
//	alert(infomsg);
//	document.write('<li>'+infomsg);
}

/*---------------------------------------------------------------------------------
***JavaMenuHilite***	Core routine, search for ***JavaMenuHilite***

	' Special and sensitive logic to make an area of the page sensitive to mouse
	' movements, and highlight a menu

	' Requires certain naming on menu items
	' Requires a surrounding area and save area, plus is VERY sensitive to the 
	' HTML structures used in each.  (tables can't save href's, href's can't store color, etc)

	Created by RGS 12/2/04 to tweek menu items when moving over an image

	Search google for "netscape window.event .x
 See http://forums.devshed.com/archive/t-26595
*/

var d = document, n = navigator;
var agent = n.userAgent.toLowerCase();
var mX, mY;


//Browser sniff hash obj
var sniff = {
bw: {
ns:d.layers,
ie:d.all && !d.getElementById,
ie4:agent.indexOf("msie 4.") != -1,
ie5:agent.indexOf("msie 5.") != -1,
ie6:agent.indexOf("msie 6.") != -1,
dom:d.getElementById,
ns6:d.getElementById && agent.indexOf("gecko") != -1
},
os: {
win:agent.indexOf("win") != -1,
mac:agent.indexOf("mac") != -1
}
};

//var riBrowserIE = (document.all!=null);		// IE has doc all, NS does not
//var riBrowserNS = (document.all==null);		

function rpJavaMenuHilite(argJavaMenuCount)
{
	var elemlist, elemobj, elemindex, elemcount, elemattr, elemstring;
	var targ_name, targ_attr, targ_value;
	var mousetext;
	var loopmax;			// loop safety

	var	infomsg;
	infomsg = '';

	var lclCount;
	lclCount	= parseInt(argJavaMenuCount);
//	infomsg		= infomsg + " lclCount=" + lclCount;

// Find boundaries of the box we displayed in
	var boxobj, boxX, boxY, boxWid, boxHgt, boxBord;
	var absX, absY, offX, offY;
	boxobj =  getnamedelement('JavaMenuBox');
	boxBord	= boxobj.border;
	boxX	= boxobj.offsetLeft;
	boxY	= boxobj.offsetTop;
	boxWid	= boxobj.offsetWidth;
	boxHgt	= boxobj.offsetHeight;

// work up through parent containers for the box, adding to our offsets to find the absolute position
	absX	= 0;
	elemobj = boxobj;
	loopmax = 0;
	for (offX = boxX; (elemobj != null) && (loopmax < 20); ) {
		loopmax = loopmax + 1;
		infomsg = infomsg + elemobj.id + ' ';
		offX = elemobj.offsetLeft;
		absX = absX + offX;
	//	alert(' Elem ' + elemobj.id + ' offX=' + offX + ' for absX= ' + absX);
		elemobj=elemobj.offsetParent;
	}
	absY	= 0;
	elemobj = boxobj;
	loopmax = 0;
	for (offY = boxY; (elemobj != null) && (loopmax < 20); ) {
		loopmax = loopmax + 1;
		offY = elemobj.offsetTop;
		absY = absY + offY;
	//	alert(' Elem ' + elemobj.id + ' offy=' + offY + ' for total= ' + absY);
		elemobj=elemobj.offsetParent;
	}
	//	infomsg = infomsg + " abX=" + absX;
	//	infomsg = infomsg + " abY=" + absY;
	//	infomsg = infomsg + " bxWid=" + boxWid;
	//	infomsg = infomsg + " bxHgt=" + boxHgt;

// Get action location
	var eventobj, mouseobj, mousesrc, mouseX, mouseY;
	
	// Todo: create event handler for Netscape.
	// see http://www.siteexperts.com/tips/elements/ts10/page5.asp
	
	if ( (sniff.bw.ns || sniff.bw.ns6) ) {
		eventobj = window.event;
		mouseX = mX;
		mouseY = mY;
		mouseobj = null;
	//	window.status = 'NSmouseX=' + mouseX + ' Y=' + mouseY;
	} else {
		eventobj = eval('window.event');
		mouseX = eventobj.x;
		mouseY = eventobj.y;
		mouseobj = eval('window.event.srcElement');
	}

	var scrollX, scrollY;
	scrollX = document.body.scrollLeft;
	scrollY = document.body.scrollTop;
	//	infomsg = infomsg + " scrX=" + scrollX;
	//	infomsg = infomsg + " scrY=" + scrollY;
	
	mouseX = mouseX + scrollX;
	mouseY = mouseY + scrollY;
	//	infomsg =  infomsg + " mvX=" + mouseX;
	//	infomsg =  infomsg + " mvY=" + mouseY;

// Calculate movement
	var relX, relY, calcX, calcY;
	relX = (mouseX - (absX + 1));
	relY = (mouseY - (absY + 1));
	//	infomsg = infomsg + " relX1=" + relX;
	//	infomsg = infomsg + " relY1=" + relY;


// Pick Menu item to highlight. Several techniques
	var menuVer;	menuVer = 3;
	var menuPick;	menuPick= 1;	//default

	// Pick Menu Index: Version 1: Adjust to units
	// Note: if there are 10 items, calcX/Y are in range 1-10
	if ((menuVer == 1) || (menuVer == 2)) {
		calcX = (relX * lclCount);
		calcY = (relY * lclCount);
		//	infomsg = infomsg + " CalX2=" + calcX;
		//	infomsg = infomsg + " CalY2=" + calcY;
		calcX = (calcX / boxWid);
		calcY = (calcY / boxHgt);
		//	infomsg = infomsg + " CalX3=" + calcX;
		//	infomsg = infomsg + " CalY3=" + calcY;
		calcX = Math.ceil(calcX);
		calcY = Math.ceil(calcY);
		infomsg = infomsg + " Max=" + lclCount;
		infomsg = infomsg + " PkX=" + calcX;
		infomsg = infomsg + " PkY=" + calcY;
		if (menuVer==1) {
			menuPick = calcX + calcY;
			menuPick = menuPick / 2;
		} else {
			menuPick -= 1;
			menuPick = (menuPick) % lclCount;					// values MOD max
			menuPick += 1;										// Mod returns base 0, adjust to base 1
		}
	}	

	
// Pick Menu Index: Base on distance from center of box.
	if (menuVer==3) {
		var deltaX, deltaY, midX, midY;
		var dist, hypot, maxleg, minleg;
		midX	= boxWid / 2;			// center of box
		midY	= boxHgt / 2;
	//	infomsg = infomsg + " midWid=" + midX;
	//	infomsg = infomsg + " midHgt=" + midY;
		maxleg	= midX;					// longest/shortest legs
		minleg	= midX;
		if (midY > maxleg) maxleg = midY;
		if (midY < minleg) minleg = midY;
	//	hypot	= Math.sqrt( (midX  * midX  )+(midY  * midY  ) );

		deltaX  = relX - midX;
		deltaY  = relY - midY;
	//	infomsg = infomsg + " delX=" + deltaX;
	//	infomsg = infomsg + " delY=" + deltaY;

		dist	= Math.sqrt( (deltaX* deltaX)+(deltaY* deltaY) );
		dist	= (dist * lclCount) / (minleg * 2);				// divide by minimum so full range from left to right
		dist	= Math.ceil(dist);
		infomsg = infomsg + " dist=" + dist;
		if (dist > lclCount)	dist = lclCount;
		if (dist < 1)			dist = 1;
		if			((relX < midX) && (relY < midY)) {
			menuPick = (lclCount/2) - dist + .5;
		} else if	((relX < midX) && (relY > midY)) {
			menuPick = (lclCount/2) - dist + .5;
		} else if	((relX >=midX) && (relY < midY)) {
			menuPick = (lclCount/2) + dist - .5;
		} else if	((relX >=midX) && (relY > midY)) {
			menuPick = (lclCount/2) + dist - .5;
		} else {
			menuPick = dist;	
		}
	//window.status = 'NSmouseX=' + mouseX + ' Y=' + mouseY + ' Pick=' + menuPick;
	}
	
// We have made our selection.  Last sanity check.
	menuPick = Math.ceil(menuPick);							// smallest int >= value
	if (menuPick > lclCount) menuPick = lclCount;
	if (menuPick < 1) menuPick = 1;
	infomsg = infomsg + " Pick=" + menuPick;

// Ready to highlight screen.  First restore last item changed (if any).	
	var showImageUnderMenuItem; showImageUnderMenuItem = 0;
	var menuobj, saveobj, thumbobj, linkobj;
	var lastobj, lastIndex;
	var thumbAltLen;		// length of image string, if 0, there is no image
	var fiximgobj, textobj;
	var wraptable;

	lastobj		= getnamedelement('JavaMenuSave');			// JavaMenuSave's value="menuPick last saved"
	lastIndex	= parseInt(lastobj.title);
	//	infomsg		= infomsg + ' Nx=' + menuPick + ' Ox=' + lastIndex;

	// Restore previously highlighted element
	if ((lastIndex != 0) && (lastIndex != menuPick)) {
		linkobj		=getnamedelement('JavaLink'	+lastIndex);
		menuobj		=getnamedelement('JavaMenu'	+lastIndex);
		saveobj		=getnamedelement('JavaSave'	+lastIndex);
		thumbobj	=getnamedelement('JavaThumb'+lastIndex);
		if (thumbobj != null) {
			thumbobj.style.visibility	='hidden';
			thumbobj.style.display		='none';
		}
		if ((menuobj != null) && (saveobj != null)) {
			menuobj.color = saveobj.title;
			menuobj.style.fontWeight = saveobj.style.fontWeight;
			menuobj.style.backgroundColor = saveobj.style.backgroundColor;
		}
//		alert (saveobj.color);
	};

									
// never worked:replace_attribute('JavaMenuCount###','.style.font-background', '#ff00ff');

	// Hilite JavaMenu item 
	if (menuPick > 0) {
	
		linkobj		=getnamedelement('JavaLink'	+menuPick);
		menuobj		=getnamedelement('JavaMenu'	+menuPick);
		saveobj		=getnamedelement('JavaSave'	+menuPick);
		thumbobj	=getnamedelement('JavaThumb'+menuPick);

		if (lastIndex != menuPick) {				// save what we care about
			if (lastobj != null) {
				lastobj.title = menuPick;				// marker as to last saved index
			}
			if ((menuobj != null) && (saveobj != null)) {
				saveobj.title = menuobj.color;			// color goes in save obj
				saveobj.style.fontWeight = menuobj.style.fontWeight;
				saveobj.style.backgroundColor = menuobj.style.backgroundColor;
			}
		//	alert(saveobj.color);
		}

		// Insert text for selected item into "alt" text for image
		mousetext = null;
		if (menuobj != null) {
			if (sniff.bw.ns || sniff.bw.ns6) {
				mousetext		= menuobj.innerHTML;
				menuobj.color	= '#ffffff';
				menuobj.style.backgroundColor = '#ff0000';
			} else {
				mousetext		= menuobj.innerText;
				menuobj.color	= 0xffffff;				
				menuobj.style.backgroundColor = 0xff0000;
			}
		//	menuobj.style.fontWeight = 700;
		}
		if ((mousetext != null) && (mouseobj != null)) {
			mouseobj.alt	= mousetext;		// put menu text in mouse objects alt string if image
		//	mouseobj.title	= mousetext;		// put menu text in mouse objects title string
		}

		if ((linkobj != null) && (lastobj != null)) {
			lastobj.href	= linkobj.href;		
		//	window.status = lastobj.href;
		}
//test		wraptable = getnamedelement('JavaMenuBox');		// 
//test		wraptable.href	= linkobj.href;				//
//test		window.status = wraptable.href;

		if (thumbobj != null) {
			thumbAltLen = parseInt(thumbobj.alt);
			if ((showImageUnderMenuItem != 0) && (thumbAltLen!=0)) {
					thumbobj.style.visibility='visible';
					thumbobj.style.display='block';
			}
		}

	// Display fixed position text and image
		textobj		= getnamedelement('JavaMenuTextMessage');
		if ((textobj != null) && (mousetext != null)) {
			textobj.innerText = 'Click for ' + mousetext;
		};
		fiximgobj	= getnamedelement('JavaMenuHighlightImage');
		if ((fiximgobj != null) && (thumbobj != null)) {
			if (mousetext != null) {
				fiximgobj.alt = 'Be sure to check out ' + mousetext;
			}
			if ((thumbobj == null) || (thumbAltLen==0)) {
				fiximgobj.style.visibility='hidden';
				fiximgobj.style.display='none';
			} else {
				fiximgobj.src = thumbobj.src;
				fiximgobj.style.visibility='visible';
				fiximgobj.style.display='block';
			}
		};
	}

	infomsg = null;
	if (mousetext != null) infomsg = 'Click for ' + mousetext;
	if (mouseobj != null) {
	//	infomsg = infomsg + ' ' + menuPick + '/' + lclCount + ' ' + mouseobj.alt;
		if (mouseobj.alt != null) infomsg = 'Click for ' + mouseobj.alt;
	}
	if (infomsg != null) window.status = infomsg;

/*
				targ_name = 'JavaMenu1';
			//	targ_attr = '.style.font-size';
			//	targ_value= '12';
				targ_attr = '.bgcolor';
				targ_value= '#ff00ff';
			//	replace_attribute('JavaMenu1','.font-background', '#ff00ff');
				elemobj.innerText = 'ABC';
			//	eval('elemobj.outerText') = "ABC";
			//	document.write('<li>'+eval('elemobj.outerHTML'));
			//	document.write('<li>'+infomsg);
*/
}



/*---------------------------------------------------------------------------------
Netscape event handler
*/
function mMove(e) {
mX = (sniff.bw.ns || sniff.bw.ns6)?e.pageX:event.x;
mY = (sniff.bw.ns || sniff.bw.ns6)?e.pageY:event.y;
//	window.status = 'mouseEvent X=' + mX + ' Y=' + mY;		// works!
}

function riSetupEventHandler() {
	if (sniff.bw.ns) {
		d.captureEvents(Event.MOUSEMOVE)	// capture events ... Mouseout, Mousemove, ...
	}
	d.onmousemove = mMove;
//	window.status = 'riSetupEventHandler ran';
}

/*
' 8/2/06 Prob: Self.window not working after ok for years.  On review, ResourcePark.js runs...
'			window.onload = riSetupEventHandler;  
'		 If commented, all works.  Why? browser change? diff order of JS relative to others.
'		 Fix> Force everything that is to execute into a script section BEFORE the body
*/
/* Initialize the event handler */
window.onload = riSetupEventHandler;


				
/*---------------------------------------------------------------------------------
	Created by RGS 3/5/03 to shorten the amount of junk in Java script includes
	imagerollover  = rpImageDefine('/web/art/1.gif')
	... onmouseover(
*/

function rpImageDefine(in_path)
{ 
	var newimg;
	var lclException;
	try {
		newimg=new Image;
		newimg.src=in_path;
		return newimg; 

	}	catch(lclException)	{
	}
}

/*---------------------------------------------------------------------------------
	Image Rollover.. Copies to target from any previoulsy defined image
	
	imagenorm  = rpImageDefine('/web/art/normal.gif')
	imageroll  = rpImageDefine('/web/art/fancy.gif')
	<body...  (definitions must happen before body command)
	... src="/web/art/normal.gif" name="nameofhtmlIMGcommand"
	... onmouseover="rpImageSwap('nameofhtmlIMGcommand','imageroll')" 
	... onmouseout ="rpImageSwap('nameofhtmlIMGcommand','imagenorm')"

	Created by RGS 3/5/03 to shorten the amount of junk in Java script includes
		
*/
function rpImageSwap(targetname,sourcename)
{ 
	var	previousimage;
	var lclException;
	try {
		previousimage = document.images[targetname].src;
		document.images[targetname].src=eval(sourcename + ".src"); 
		return previousimage;

	}	catch(lclException)	{
		return '';
	}
}


/*---------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------
  Samples: not yet used, but copied from elsewhere
  ---------------------------------------------------------------------------------
  ---------------------------------------------------------------------------------
*/

/*---------------------------------------------------------------------------------
	VanFin: demoheader.js
*/
function codesnippid()
{
	alert('0');
	here = this.location.toString();
	len = here.length;
	value = here.substring(len-8,len-4);
	ID = value;
	alert(ID);
	document.write('<PARAM NAME="ID" VALUE=' + ID + '>');

//	sample: appletID = Math.floor((ID-(productID*1000))/100)
}

/*---------------------------------------------------------------------------------
	Our own invention to disable a control at certain times
		<a onmouseover="rpDisableControl('ProductHomeForm','dropdownproducts')">Hide dropdownproducts</a>
	
	Currently used for test, is able to change the value in a select box
		<form name="targetform">
			<select name="targetfield">
				<option value="1">Value 1</option>
				<option value="2">Value 2</option>
			</select>
			
			<a href="javascript:rpSetControl('targetform','targetfield','1')">Set to 1</a>
			<a href="javascript:rpSetControl('targetform','targetfield','2')">Set to 2</a>
		</form>
	
*/
function rpSetControl(parentForm, parentField, newvalue){
//		alert('has forms');
	if (document.forms != null) {
		/* DEBUG
				var enumidx;
				alert(document.location + ' has ' + document.forms.length + ' forms');
				for (enumidx=0; enumidx<document.forms.length; enumidx++) {
					alert('Form ' + (enumidx+1) + ' is named ' + document.forms(enumidx).name);
				}
				alert('Requested form is named ' + document.forms(parentForm).name);
				alert('Requested field is named ' + targetForm.elements[parentField].name);
		*/

	// get target form
		var targetForm = document.forms(parentForm);

//		targetForm.elements[parentField].selectedIndex = newvalue;
		targetForm.elements[parentField].value = newvalue;	// this must match the xxx in <option value="xxx">

	// Disable control
		//		targetForm.elements[parentField].disabled = true;
		
	// Display off (doesn't work)
		//		alert(parentField+'.display ' + targetForm.elements[parentField].display);
		//		targetForm.elements[parentField].display = false;
		//		targetForm.elements[parentField].face = 'arial';
		//		targetForm.elements[parentField].hidden = true;


	}
}


//var targetForm = window.opener.document.forms[parentForm];
//var targetForm = window.forms[parentForm];
//	alert(targetForm.elements[parentField].name);
//	targetForm.elements[parentField].visible = 0;
//}


/*---------------------------------------------------------------------------------
	End Resource.JS			ResourcePark, Inc.				www.ResourcePark.com
  ---------------------------------------------------------------------------------*/


