function expand_content_to_window ( elements_to_expand ) {
		// IN: a list of elements
		// OUT: nothing
		// We assume that the tops of all the  elements_to_expand are 
		// co-linear.
		// This function pushes the tallest of those elements out (using padding)
		// so that the total html content expands to fit the bounding window.
		// Then we push the other elements out in the same way so that they match the 
		// new height of the tallest element.

		// set paddingBottomOrig on each element, if not already set
		//   (which we'll use later on subsequent calls to this function)
	if (elements_to_expand) { 
		var i = 0; // iterator we'll use throughout
		for ( i = 0; i < elements_to_expand.length; i++ ) {
			var el = elements_to_expand[i];
			if ( ! el.style.paddingBottomOrig ) {
					if ( el.style.paddingBottom ) {
							el.style.paddingBottomOrig = el.style.paddingBottom;
					}
					else {
							el.style.paddingBottomOrig = '0px';
					}
			}
		}

		var tallest = get_tallest_element (elements_to_expand);
		var window_height                                      // all except Explorer
			=   self.innerHeight                             ? self.innerHeight 
			: ( document.documentElement                       // Explorer 6 Strict Mode
						&& document.documentElement.clientHeight ) ? document.documentElement.clientHeight
																												 // other Explorers
			:                                                  document.body.clientHeight
			;

		var html_height                                        // all except explorer
			=  document.body.offsetHeight; 


		// set height of tallest element
		if ( window_height > html_height ) {  // only need to expand if we're shorter
																				// than the window
			var visible_delta = window_height - html_height;



			// set the padding directly
			if ( tallest.style.paddingBottom ) {
					// add the delta to paddingBottom 
					tallest.style.paddingBottom
							= (parseInt( tallest.style.paddingBottom )
							+  visible_delta)
							+ 'px'
							;
			} 
			else {
					tallest.style.paddingBottom = visible_delta + 'px';
			}        
		} 
		else {
			// set all elements to their original height
			for ( i = 0; i < elements_to_expand.length; i++ ) {
					el = elements_to_expand[i];
					if (!document.all) {
							el.style.paddingBottom = el.style.paddingBottomOrig;
					}
			}

		}

		// set height of other elements
		for ( i=0; i < elements_to_expand.length ; i++ ) {
			el = elements_to_expand[i];
			if ( tallest.offsetHeight > el.offsetHeight ) {
					var column_delta 
							= tallest.offsetHeight - el.offsetHeight;

					if ( el.style.paddingBottom) {
							el.style.paddingBottom
									= (parseInt( el.style.paddingBottom )
									+  column_delta)
									+ 'px'
									;
					}
					else {
							el.style.paddingBottom = column_delta + 'px';
					}
			}
		}
	}
}

 

document.getElementsByClassName = function ( class_name ) {
    // IN: class_name, a string
    // OUT: an array or null
    // returns an array of elements which have className = class_name
    // note that this attaches itself to the document object
    // and its behavior and use is similar to document.getElementById
    // (i.e. an unsuccessful search will return null, not an empty array)
    // adapted from http://www.snook.ca/archives/000370.php

    var all_elements = document.getElementsByTagName("*");
    var elements = new Array(); // we'll return this or null
    var i; var j;

    for ( i=0, j=0; i < all_elements.length; i++) {
        var c = " " + all_elements[i].className + " ";
        if ( c.indexOf(" " + class_name + " ") != -1 ) 
            elements[ j++ ] = all_elements[i];
    }
    
    return elements.length>0 ? elements : null;
}
    


function get_tallest_element ( list_of_elements ) {
    // IN: a list of elements
    // OUT: an element
    // This returns the element which occupies the most vertical 
    // real estate.
    var tallest = null;
    
    for ( var i = 0;  i < list_of_elements.length; i++ ) {
    
        if (i !=0 ) {
            if ( list_of_elements[i].offsetHeight > tallest.offsetHeight ) {
                tallest = list_of_elements[i];
            }
        }
        else {
            tallest = list_of_elements[i];
        }
        
    }
    
    return tallest;
}

function P(url, h, w, x, y, t, l, sb, r) { // (url, height, width, screenX, screenY, top, left, scrollbars)
  var p = "height=" + h + ",width=" + w + ",screenX=" + x + ",screenY=" + y +",top=" + t + ",left=" + l + ",scrollbars=" + sb + ",resizable=" + r ;
	window.open(url,"",p);
}

