// cf. Listing 8-1, JSB
var newWindow = null;
function openWindow(contentURL,windowName,windowWidth,windowHeight){
   windowParameters = 'height=' + windowHeight + ',width=' + windowWidth + ',scrollbars=1';
   newWindow = window.open(contentURL,windowName,windowParameters);
   newWindow.focus();
   }
function closeWindow() {
   if (newWindow != null) {
      newWindow.close();
      newWindow = null;
      }
   }

// cf. Listing 15-23, JSB
var sizeChartPopup;
function openSizeChart(strUrl, strTarget, windowWidth, windowHeight){
if (sizeChartPopup == null || sizeChartPopup.closed){
sizeChartPopup = window.open(strUrl, strTarget, "width=" + windowWidth + ",height=" + windowHeight + ",resizable,scrollbars,status");
} else {
sizeChartPopup.focus();
};
}

// from bloggingdeveloper.com; use in body with "onload" and field id "firstfield"
function setFocus()
{
     document.getElementById("firstfield").focus();
}
/*******************************************************************************
*  ruthsarian_utilities.js : 2005.09.01
* -----------------------------------------------------------------------------
*  A group of useful JavaScript utilities that can aid in the development
*  of webpages.
*******************************************************************************/

/* event_attach() takes care of attaching event handlers (functions) to events. 
 * this simplifies the process of attaching multiple handlers to a single event
 *
 * NOTE: the onload stack is executed in a LIFO manner to mimic 
 *       IE's window.attachEvent function. However, Opera also has its own
 *       window.attachEvent function which executes the onload stack in a 
 *       FIFO manner. FIFO is better, but IE has a larger user base, so
 *       LIFO is the way we go.
 */
function event_attach( event , func )
{
	if ( window.attachEvent )
	{
		window.attachEvent( event , func );
	}
}

function set_min_width( obj_name , min_width , ieOnly )
{
	if ( ( typeof( ieOnly ) ).toLowerCase() == 'undefined' )
	{
		ieOnly = true;
	}
	if ( ieOnly == false || ( document.getElementById && navigator.appVersion.indexOf( "MSIE" ) > -1 && !window.opera ) )
	{
		document.min_width_obj_name = obj_name;
		document.min_width_size = min_width;
		document.resizing = false;
		event_attach( 'onload' , control_min_width );
		event_attach( 'onresize' , control_min_width );
	}
}
function control_min_width()
{
	var cw , w , pl , pr , ml , mr , br , bl , ad , theDiv = document.min_width_obj_name;
	var g = document.getElementById( document.min_width_obj_name );
	w = parseInt(document.min_width_size);
	if ( g && document.body && document.body.clientWidth )
	{
		gs = g.currentStyle;
		cw = parseInt( document.body.clientWidth );
		pl = parseInt( gs.paddingLeft );
		pr = parseInt( gs.paddingRight );
		ml = parseInt( gs.marginLeft );
		mr = parseInt( gs.marginRight );
		bl = parseInt( gs.borderLeftWidth );
		br = parseInt( gs.borderRightWidth );
		ml = ml ? ml : 0;
		mr = mr ? mr : 0;
		pl = pl ? pl : 0;
		pr = pr ? pr : 0;
		bl = bl ? bl : 0;
		br = br ? br : 0;
		ad = pl + pr + ml + mr + bl + br;
		if ( cw <= w )
		{
			w -= ad;
                	g.style.width = w + "px";
		}
		else
		{
			g.style.width =  "auto";
		}
	}
}
