if ( document.captureEvents ) {
	document.captureEvents(Event.MOUSEMOVE);
		
}

/**
 * Launches a new window
 *
 * Usage: <a href="http://www.yahoo.com" onclick="NewWindow(this.href, 'somename', 300, 300, 'yes');return false;">Visit Yahoo</a>
 *
 * @param string url The url to open
 * @param string winname The name to name the window
 * @param int width 
 * @param int height
 * @param string scroll Valid values are "yes" and "no"
 * @return window
 */
function NewWindow(url, winname, width, height, scroll, toolbar, menubar, location) {
	var left = (screen.width  - width)  / 2 ;
	var top  = (screen.height - height) / 2;
	if ( typeof toolbar == 'undefined' ) {
		toolbar = 'no';
		
	}
	
	if ( typeof menubar == 'undefined' ) {
		menubar = 'no';
		
	}
	
	if ( typeof location == 'undefined' ) {
		location = 'no';
		
	}
	winprops = 'height='+height+',width='+width+',top='+top+',left='+left+',scrollbars='+scroll+',resizable=yes,toolbar='+toolbar+',menubar='+menubar+'location=' +location;
	win = window.open(url, winname, winprops);
	return win;
	
}//end NewWindow

/**
* @param HTMLElement element - the element to modify
* @param string attribute_name - the name of the attribute to modify
* @param string additional_value - the new value to be placed into the attribute
* @param string position - (optional) before or after the current values in the attribute
*/
function modify_attribute(element, attribute_name, additional_value, position)
{	
	if ( element[attribute_name] ) {
		//This should mean that it's not blank
		var str_orig = String(element[attribute_name]);
		
	} else {
		//this should mean that it's blank
		var str_orig = "";
		
	}
	
	if ( str_orig.indexOf("function") != -1 ) {
		var open_curly_pos = str_orig.indexOf('{');
		var end_curly_pos = str_orig.lastIndexOf('}');
		var str_old_stuff = str_orig.slice(open_curly_pos+1, end_curly_pos);
		
		if ( position == "after" ) {
			element[attribute_name] = new Function(str_old_stuff + additional_value);	
			
		} else {
			element[attribute_name] = new Function(additional_value + str_old_stuff);		
			
		}
		
	} else {
		element[attribute_name] = new Function(additional_value);
		
	} 
	
}//end modify_attribute

/**
 * 
 */
function insertAfter(parent, node, referenceNode) {
	if ( referenceNode.nextSibling ) {
		parent.insertBefore(node, referenceNode.nextSibling);	
		
	} else {
		parent.appendChild(node);
		
	}	
	
}//end insertAfter

function findNextSiblingByTagName(elem, tagname)
{
	if ( elem.nextSibling == null ) {
		return null;
		
	}
	
	var elem_sibling = elem;
	var arr_return = new Array();
	while ( (elem_sibling = elem_sibling.nextSibling) != null ) {
		if ( elem_sibling.nodeType == 1 && elem_sibling.tagName == tagname ) {
			arr_return.push(elem_sibling);
			
		}
		
	}//while
	
	if ( arr_return.length == 1 ) {
		return arr_return[0];
		
	} else if ( arr_return.length == 0 ) {
		return null;
		
	} else {
		return arr_return;
		
	}
	
}//end findNextSiblingByTagName

function findPreviousSiblingByTagName(elem, tagname)
{
	if ( elem.previousSibling == null ) {
		return null;
		
	}
	
	var elem_sibling = elem;
	var arr_return = new Array();
	while ( (elem_sibling = elem_sibling.previousSibling) != null ) {
		if ( elem_sibling.nodeType == 1 && elem_sibling.tagName == tagname ) {
			arr_return.push(elem_sibling);
			
		}
		
	}//while
	
	if ( arr_return.length == 1 ) {
		return arr_return[0];
		
	} else if ( arr_return.length == 0 ) {
		return null;
		
	} else {
		return arr_return;
		
	}
	
}//end findNextSiblingByTagName

function findChildByTagName(elem, tagname)
{
	try {
		if ( elem.childNodes.length == 0 ) {
			return null;
		}
	} catch (e) {
		return null;
		
	}
	
	var arr_return = new Array();
	for ( var i=0; i<elem.childNodes.length; i++ ) {
		if ( elem.childNodes[i].nodeType == 1 && elem.childNodes[i].tagName == tagname ) {
			arr_return.push(elem.childNodes[i]);
			
		}
		
	}//for
	
	if ( arr_return.length == 1 ) {
		return arr_return[0];
		
	} else if ( arr_return.length == 0 ) {
		return null;
		
	} else {
		return arr_return;
		
	}
	
}//end findChildByTagName

var EventRegister = { 
	registered_events: [],	
	add: function(elem, event_name, func, capture)
	{					
		if ( elem.addEventListener ) {
			//Standards
			elem.addEventListener(event_name, func, capture);
			
		} else if ( elem.attachEvent ) {
			//IE
			if ( !elem.attachEvent('on'+event_name, func) ) {
				return false;	
			}
			
		} else {
			return false; 
				
		}	
		
		return true;
		
	}//end add
	
};

function IntervalExecuter(callback, interval_sec) 
{
	this.callback  = callback;
	this.interval  = interval_sec * 1000;
	this.running   = false;
	this.cancel_id = null;
	
	this.start = function()
	{
		this.cancel_id = setInterval(this.callback, this.interval);
		this.count = 0;
		this.running = true;
	}
	
	this.stop = function()
	{
		clearInterval(this.cancel_id);
		this.running = false;
		
	}
	
	this.isRunning = function()
	{
		return this.running;
	}
	
}//end IntervalExecuter

/**
* This Object helps in dealing with Radio Groups
*/
function RadioGroup()
{
	this.radioNodeElem = null;

	/**
	* Initialize
	*
	* @param form_object obj_form
	* @param string group_name
	* @return bool
	*/
	this.init = function(obj_form, group_name)
	{
		try {
			this.radioNodeElem = obj_form.elements[group_name];
		} catch (e) {
			this.radioNodeElem = null;
		}


	}//end init

	/**
	* Get the value of the currently checked radio box
	*
	* @return null
	*/
	this.getValue = function()
	{
		var elem = this.getSelectedElement();
		
		if ( elem == null ) {
			return null;
			
		}
		
		return elem.value;

	}//end value
	
	/**
	 * Return the first element in the select group
	 */
	this.getFirstElement = function()
	{
		return this.radioNodeElem[0];
		
	}//end getFirstElement
	
	/**
	 * Return the element that is checked
	 */
	this.getSelectedElement = function()
	{
		if ( this.radioNodeElem == null ) {
			return null;
		}

		for ( var i=0; i<this.radioNodeElem.length; i++ ) {
			if ( this.radioNodeElem[i].checked == true ) {
				return this.radioNodeElem[i];
			}

		}//for

		return null;
		
	}//end getSelectedElement

	/**
	* Set the value of the radio group, value must exist in the set
	*
	* @param string new_value
	* @return mixed
	*/
	this.setValue = function(new_value)
	{
		if ( this.radioNodeElem == null ) {
			return null;
		}

		for ( var i=0; i<this.radioNodeElem.length; i++ ) {
			if ( this.radioNodeElem[i].value == new_value ) {
				this.radioNodeElem[i].checked = true;
				return true;

			}
		}//for

		return false;

	}//end setValue
	
	/**
	 * Disables this set of radio buttons.  If doing a soft_disable, does not play nice with anything else already 
	 * using onclick and onkeydown
	 *
	 * @param soft_disable		If you want to just ignore keyboard and mouse clicks without actually disabling, pass in true
	 */
	this.disable = function()
	{
		var soft_disable = ( arguments.length == 1 && arguments[0] == true ) ? true : false;
		
		for ( var i=0; i<this.radioNodeElem.length; i++ ) {
			if ( soft_disable ) {
				this.radioNodeElem[i].onclick = this.radioNodeElem[i].onkeydown = function() { return false; }
				
			} else {
				this.radioNodeElem[i].disabled = true;
				
			}
			
		}//for i
		
	}//end disable
	
	/**
	 * Enables this set of radio buttons.  If you did a soft_disable when disabling, then you need to pass 
	 * in true to this function as well to do the soft_enable.  Again, it does not play well with anything 
	 * else using onclick or onkeydown
	 *
	 * @param soft_enable		If using soft_disable when disabling, have to use soft_enable here to renable
	 */
	this.enable = function()
	{
		var soft_enable = ( arguments.length == 1 && arguments[0] == true ) ? true : false;
		
		for ( var i=0; i<this.radioNodeElem.length; i++ ) {
			this.radioNodeElem[i].disabled = false;
			
			if ( soft_enable ) {
				this.radioNodeElem[i].onclick = this.radioNodeElem[i].onkeydown = null;			
				
			}
			
		}//for i
		
	}//end enable

}//end radioGroup

//----- BEGIN Prototype Library Extensions -----
if ( typeof Element != "undefined" ) {
	//Array extensions
	Object.extend(Array.prototype, {
		/**
		 * If val is, returns position 0 to length, otherwise returns -1
		 */
		search: function(val)
		{
			for ( var i=0; i<this.length; i++ ) {
				if ( this[i] == val ) {
					return i;
					
				}
				
			}//for i
			
			return -1;
			
		},//end search
		
		/**
		 * Returns true if the array contains value, false otherwise -- 
		 * this could be a very expensive function -- use it with care
		 */
		contains : function(val)
		{
			return ( this.search(val) != -1 );
			
		},//end contains
		
		/**
		 * Removes null, undefined, and duplicate values and returns a new array
		 */
		minimize : function()
		{
			var newarray = new Array();
			
			for ( var i=0; i<this.length; i++ ) {
				if ( this[i] != null && !newarray.contains(this[i]) ) {
					newarray.push(this[i]);
					
				}
				
			}//for i
			
			return newarray;
			
		}//end minimize
		
	});	
	

	
	//String extensions
	Object.extend(String.prototype, {		
			/**
			 * Trim the right side of the string
			 */
			rtrim: function() 
			{
				return this.replace(/\s+$/g, "");	
				
			},
			
			/**
			 * Trim the left side of the string
			 */
			ltrim: function() 
			{
				return this.replace(/^\s+/g, "");
				
			},
			
			/**
			 * Trim both sides of the stirng
			 */
			trim: function() 
			{
				return this.rtrim().ltrim();
				
			},
			
			/**
			 * Returns true if the string is a valid email address, false otherwise
			 */
			isEmail: function() 
			{
				return this.match(/^[\d\w\/+!=#|$?%{^&}*`'~-][\d\w\/\.+!=#|$?%{^&}*`'~-]*@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z]{2,6}$/i) != null;	
				
			},
			
			/**
			 * Returns true if the string is a valid jhed id, false otherwise
			 */
			isJhed: function()
			{
				return this.match(/^([a-z]){3,8}([0-9]){1,3}$/) != null;
				
			},//end isJhed
			
			/**
			 * Works just like PHP's ucfirst - upper cases the first character in the string - leaves the rest of the string alone
			 */
			upperCaseFirst: function()
			{
				if ( this.length <= 1 ) {
					return this.toUpperCase();
					
				}
				
				var first = this.substring(0, 1);
				var rest = this.substring(1);
				
				return first.toUpperCase() + rest;
			
			},
			
			/**
			 * Uppercases all words, words are delimited by a white space (space, form-feed, newline, carriage return, tab), again, only touches the first character 
			 * of each word
			 */
			upperCaseWords: function()
			{
				var white_space = [ " ", "\n", "\r", "\t", "\f" ];
				var work_string = this;
				
				var output = "";
				var toupper = false;
				
				for ( var i=0; i<work_string.length; i++ ) {
					var ch = work_string[i];
					
					if ( toupper || i == 0 ) {
						output += ch.toUpperCase();
						toupper = false;
						
					} else {
						output += ch;
						
					}
					
					if ( white_space.search(ch) != -1 ) {
						toupper = true;
						
					}
					
				}//for i
				
				return output;
				
				
			},
			
			upperCaseTitle: function()
			{
				var special = [ "'", '"', '-', '(', '[' ];
				var work_string = this.upperCaseWords();
				
				var output = "";
				var toupper = false;
				
				for ( var i=0; i<work_string.length; i++ ) {
					var ch = work_string[i];
					
					if ( toupper || i == 0 ) {
						output += ch.toUpperCase();
						toupper = false;
						
					} else {
						output += ch;
						
					}
					
					if ( special.search(ch) != -1 ) {
						toupper = true;
						
					}
					
				}//for i
				
				return output;
				
			}
			
		}
		
	);
	
	/**
	 * Returns true if child is a descendant of element
	 */
	Element.isDescendant = function(element, child)
	{
		if ( element == child ) {
			return false;
				
		}
			
		while ( child && child != element ) {
			try {
				child = child.parentNode;
				
			} catch ( e ) {
				child = element;
				
			}
				
		}//while
			
		return child == element;
			
	}//end isDescendant
	
	
	/**
	 * Returns the next sibling of the same tag or null
	 */
	Element.getNextSibling = function(element)
	{
		var parent = element.parentNode;
		var arr_children = Element.getChildElementsByTagName(parent, element.tagName);
		if ( arr_children == null || arr_children.length == 1 ) {
			//None found...should never happen, or length of one (the one we are looking for siblings for) return null
			return null;
			
		}
		
		//Otherwise, loop through until we find element
		for ( var i=0; i<arr_children.length; i++ ) {
			if ( arr_children[i] == element ) {
				if ( (i+1) <= arr_children.length-1 ) {
					return arr_children[(i+1)]
					
				}
				
			}
			
		}//for
		
		return null;
		
	}//end getNextSibling
	
	/**
	 * Returns the previous sibling of the same tag or null
	 */
	Element.getPreviousSibling = function(element)
	{
		var parent = element.parentNode;
		var arr_children = Element.getChildElementsByTagName(parent, element.tagName);
		if ( arr_children == null || arr_children.length == 1 ) {
			//None found...should never happen, or length of one (the one we are looking for siblings for) return null
			return null;
			
		}
		
		//Otherwise, loop through until we find element
		for ( var i=0; i<arr_children.length; i++ ) {
			if ( arr_children[i] == element ) {
				if ( (i-1) >= 0 ) {
					return arr_children[(i-1)];
					
				}
				
			}
			
		}//for
		
		return null;
		
	}//end getPreviousSibling
	
	/**
	 * Traverses the DOM tree upwards, searching for the first element
	 * with the given tagName, starting with the element passed in.
	 *
	 * Note: This is MUCH like Event.findElement - except it's not just 
	 * for events baby!
	 */
	Element.getAncestorByTagName = function(element, tagName)
	{
		var curr_elem = element;
		
		do {
			curr_elem = curr_elem.parentNode;
			
		} while ( curr_elem != null && curr_elem.tagName != tagName );
		
		return curr_elem;
		
	}//end getAncestorByTagName
	
	/**
	 * Traverses the childNodes array of element and returns an array of only those 
	 * children with the matching tagName
	 */
	Element.getChildElementsByTagName = function(element, tagName)
	{	
		if ( !element.childNodes ) {
			return null;
			
		}
		
		if ( element.childNodes.length == 0 ) {
			return null;
			
		}
		
		var arr_return = new Array();
		for ( var i=0; i<element.childNodes.length; i++ ) {
			if ( element.childNodes[i].nodeType == 1 && element.childNodes[i].tagName.toLowerCase() == tagName.toLowerCase() ) {
				arr_return.push(element.childNodes[i]);
				
			}
			
		}//for
		
		if ( arr_return.length == 0 ) {
			return null;
			
		} else {
			return arr_return;
			
		}
		
	}//end getChildElementsByTagName
	
	/**
	 * Get's the first child in the child nodes list with the given tag name
	 */
	Element.getFirstChildElementByTagName = function(element, tagName)
	{
		if ( !element.childNodes ) {
			throw new Error("Element has no child nodes");
			
		}
		
		if ( element.childNodes.length == 0 ) {
			throw new Error("Element has no children");
			
		}
		
		for ( var i=0; i<element.childNodes.length; i++ ) {
			if ( element.childNodes[i].nodeType == 1 && element.childNodes[i].tagName.toLowerCase() == tagName.toLowerCase() ) {
				return element.childNodes[i];
				
			}
			
		}//for
		
		throw new Error("Element of tagName " + tagName + " not found");
		
	}//end getChildElementsByTagName
	
	/**
	 * Gets the width of the given element
	 */
	Element.getWidth = function(element)
	{
		var dims = Element.getDimensions(element);
		return dims.width;
		
	}//end getWidth
	
	/**
	 * Gets the height of the given element
	 */
	Element.getHeight = function(element)
	{
		var dims = Element.getDimensions(element);
		return dims.height;
		
	}//end getHeight

} else {
	throw('Include prototype before the root.js file.')
	
}

///////////////
// BEGIN CssComplaince
///////////////
var CssComplaince = {
	/**
	 * Boolean indicating whether we think the browser is IE or not
	 */
	_isIE : true,
	
	/**
	 * List of pseudo classes that will be fixed for IE
	 */
	_pseudo_classes : [ 'focus', 'hover'],
	
	/**
	 * A compiled regexp of the pseudo_classes
	 */
	_pseudo_classes_regexp : null,
	
	/**
	 * Find and parse throw stylesheets
	 */
	parseStyles : function()
	{			
		for ( var i=0; i<document.styleSheets.length; i++ ) {
			
			//Get a stylesheet
			var style_sheet = document.styleSheets[i];
			
			//If no rules, then it's not IE -- standards compliant browser use cssRules
			if ( !style_sheet.rules ) {
				this._isIE = false;
				style_sheet.rules = style_sheet.cssRules;
				
			}
			
			//Look through the specific rules
			for ( var j=0; j<style_sheet.rules.length; j++ ) {
				var rule = style_sheet.rules[j];
				this._extractPseudoClass(rule.selectorText, rule.style);
				
			}//for j
			
		}//for i
		
	},//end _parseStyles
	
	/**
	 * Returns a regular expression object
	 */
	_compilePseudoClassRegExp : function()
	{
		if ( this._pseudo_classes_regexp == null ) {
			var regexp = this._pseudo_classes.join("|:");
			regexp = "(:" + regexp + ")";
			this._pseudo_classes_regexp = new RegExp(regexp, 'g');
			
		} 
		
		return this._pseudo_classes_regexp;
		
	},//end _compilePseudoClassRegExp
	
	/**
	 * Finds Pseudo class' in CSS stylesheets and write javascript equivalents
	 */
	_extractPseudoClass : function(selector, rule)
	{
		if ( !this._hasPseudoClass(selector) ) {
			return;
			
		}
		
		//Remove the pseudo classes
		var selectors = selector.match(this._compilePseudoClassRegExp()).minimize();
		var selector_nopseudo = selector.replace(this._compilePseudoClassRegExp(), "");
		
		var selector_uniques = selector_nopseudo.split(',');
		
		for ( var i=0; i<selectors.length; i++ ) {
			var new_elems = $$(selector_uniques[i]);
			if ( new_elems.length > 0 ) {
				for ( var j=0; j<new_elems.length; j++ ) {
					if ( selectors.contains(':hover') ) {			
						this._applyJsFix(new_elems[j], 'mouseenter', 'mouseleave', rule);
						//this._applyJsFix(new_elems[j], 'mouseover', 'mouseout', rule);
							
					}
					
					
					
				}//for j
				
			}
			
			
		}//for i
		
		
		
	},//end _extractPseudoClass
	
	_applyJsFix : function(elem, on, off, rule)
	{	
		elem.styleNew = rule['cssText'];
		$('logger').innerHTML += elem.id + "<br />";
		
		//Turn it on
		Event.observe(elem, on, function(evt) 
		{ 
			//No this?
			var myelem = Event.element(evt);
			
			$('logger').innerHTML += "Onto: " + myelem.id + '<br />';
			
			//Seems IE strips trailing semi colen?
			var len = myelem.style['cssText'];
			var semi_colen = ( myelem.style['cssText'].substr(len-1) == ';' ) ? '' : ';';
			
			//Save the current style
			myelem.styleOrig = myelem.style['cssText'];
			
			//Merge with the new style
			myelem.style['cssText'] = elem.style['cssText'] + semi_colen + myelem.styleNew;
			
		});
		
		//Turn it off
		Event.observe(elem, off, function(evt) 
		{ 
			//No this?
			var myelem = Event.element(evt);
			
			$('logger').innerHTML += 'Out of: ' + myelem.id + '<br />';
			
			//Restore it
			myelem.style['cssText'] = myelem.styleOrig;
			
		});;
		
	},//end _applyJsFix
	
	/**
	 * Returns true if this selector has one of our pseudo classes, false otherwise
	 */
	_hasPseudoClass : function(selector)
	{
		if ( typeof selector == 'undefined' ) {
			return false;
			
		}
		
		if ( selector.match(this._compilePseudoClassRegExp()) != null ) {
			return true;
			
		}
		
		return false;
		
	}//end _hasPseudoClass
	
};//end CssComplaince

var TextareaFloat = {
	
	/**
	 * Initializes all of the expanding textboxes (put them in div's with a style "textarea_float") 
	 * 
	 * @param settings	- optionally, pass in an object with properties matching id values that have as values themselves
	 *                    objects of properties.  (e.g. TextareaFloat.init({myArea: {max_width: "500px"}});)
	 *                    Options include (default is auto-size):
	 * 					   width
	 *                     height
	 */					   
	init: function()
	{
		//Look for an argument
		if ( arguments.length == 1 ) {
			var areas = arguments[0];
			
		} else {
			var areas = { };
			
		}
		
		//Find everything that is set to be floated... 
		var divs = document.getElementsByClassName('textarea_float');
		var shim = document.createElement('IFRAME');
		//shim.src = '/eppdb/blank.html';
		document.body.appendChild(shim);
		Element.setStyle(shim, {border: 0, margin: 0, padding: 0, position: 'absolute', zIndex: 50});
		Element.hide(shim);
		
		for ( var i=0; i<divs.length; i++ ) {
			var textarea = divs[i].getElementsByTagName('textarea')[0];
			
			var orig_dims = Element.getDimensions(textarea);
			divs[i].setStyle({width: orig_dims.width + "px", height: orig_dims.height + "px", padding: 0, margin: 0});
			
			textarea.ta_refresh_size = function()
			{
				var dims = TextareaFloat._determineDims(this, areas);
				var div = this.parentNode;
				var pos = Position.cumulativeOffset(div);
				
				var box_right = pos[0] + parseInt(dims.width);
				if ( box_right >= document.body.clientWidth ) {
					//A little hard to read
					//If the right hand side of the textarea is hanging off the right hand side of the screen
					//Then reduce it by the amount that it is hanging off, and then reduce it by 25 more
					dims.width = ( parseInt(dims.width) - ( box_right - document.body.clientWidth ) - 25 ) + "px";  
					
				}
				
				Element.setStyle(this, {position: 'absolute', width: dims.width, height: dims.height, zIndex: 100});
				Element.setStyle(shim, {top: (pos[1]+1) + 'px', left: (pos[0]+1) + 'px', width: dims.width, height: dims.height});
				
			}//end ta_refresh_size
			
			Event.observe(textarea, 'focus', function(event) {
				var event = ( window.event ) ? window.event : event;
				
				//Get the actors in our little play
				var textarea = Event.element(event);
				textarea.ta_refresh_size();

			
			});
			
			Event.observe(textarea, 'blur', function(event) {
				var event = ( window.event ) ? window.event : event;
				
				//Get the actors in our little play
				var textarea = Event.element(event);
				var div = textarea.parentNode;
				var div_dims = Element.getDimensions(div);
				textarea.setStyle({position: '', width: div_dims.width + "px", height: div_dims.height + 'px'});
				Element.hide(shim);
			
			});
			
			Event.observe(textarea, 'keyup', function(event) {
				var event = ( window.event ) ? window.event : event;
				
				var textarea = Event.element(event);
				textarea.ta_refresh_size();
			
			
			});
			
			
		}//for i
		
	},//end init
	
	/**
	 * Determines the dimensions
	 */
	_determineDims: function(textarea, areas)
	{
		var width = false;
		var height = false;
		
		//Currently, only set sizes can be passed by areas
		if ( areas[textarea.id] ) {
			if ( areas[textarea.id].width ) {
				width = areas[textarea.id].width;
				
			}
			
			if ( areas[textarea.id].height ) {
				height = areas[textarea.id].height;
				
			}
			
		}
		
		if ( !width || !height ) {
			var dims = this._calculateSize(textarea.value);
			var size = parseInt(Element.getStyle(textarea, 'font-size'));
			
			if ( !width ) {
				//Numbers not yet precise... especially on variable width fonts
				width = Math.round((dims.cols * ((size/2) + .5))) + "px";
				
			}
			
			if ( !height ) {
				//Fairly decent estimate, don't increase fast enough but works for reasonably sized boxes
				height = Math.round(((dims.rows) * (size+2.5))) + "px"; 
				
			}
			
			//Maintains a minimum width
			if ( parseInt(width) < Element.getWidth(textarea.parentNode) ) {
				width = Element.getWidth(textarea.parentNode);
				
			}
			
			//Maintains a minimum height
			if ( parseInt(height) < Element.getHeight(textarea.parentNode) ) {
				height = Element.getWidth(textarea.parentNode);
				
			}
			
		}
		
		return { width: width, height: height };
		
	},//end _determineDims
	
	/**
	 * Calculates the number of rows and columns
	 */
	_calculateSize: function(text)
	{		
		//Split into lines
		var bits = text.split("\n");
		var rows = bits.length;
		var cols = 0;
		
		for ( var i=0; i<bits.length; i++ ) {
			if ( bits[i].length > cols ) {
				cols = bits[i].length;
				
			}
			
		}//for i
		
		return { rows: rows, cols: cols };
		
	}//end _calculateSize

}//end TextareaFloat

/**
 * When init is called, searches for all <a> and checks the href.  If the href has a file extensions
 * of pdf, doc, ppt, xls, or zip, displays the correct logo.  If the link has a target of _blank, 
 * displays the new window logo
 */
var AddFileLogos = {
	_base_path: "/images/icons/",
	
	_types: {
		pdf: "pdf_small.png",
		doc: "doc.png",
		ppt: "ppt.png",
		xls: "xls.png",
		zip: "zip.png"
		
	},
	
	_new_window: "new_window.png",
	
	_email: 'email.png',
	
	init: function()
	{
		var elem_main = $('main_content');
		var links = elem_main.getElementsByTagName('A');
		
		for ( var i=0; i<links.length; i++ ) {
			var curr = links[i];
			
			//If there is already an image linked withink this link, just skip it
			if ( curr.getElementsByTagName('IMG').length > 0 ) {
				continue;
				
			}
			
			//Check for mailto
			var match = curr.href.match(/^mailto/i);
			if ( match != null ) {
				curr.innerHTML += ' <img class="icon" src="' + this._base_path + this._email + '" style=\"border-width: 0px;\" />';
			}
			
			//Check it it's a new window
			if ( curr.target == '_blank' || curr.rel == 'blank' ) { 
				if ( curr.rel == 'blank' && !curr.target ) {
					curr.target = '_blank';
					
				}
				
				curr.innerHTML += ' <img class="icon" src="' + this._base_path + this._new_window + '" style=\"border-width: 0px;\" />';
			}
			
			//Check for one of the icons...
			for ( ext in this._types ) {
				var regexp = new RegExp('\\.' + ext + '$', 'gi');
				var match = curr.href.match(regexp);
				if ( match != null ) {
					curr.innerHTML += ' <img class="icon" src="' + this._base_path + this._types[ext] + '" style=\"border-width: 0px;\" />';
					break;
					
				}
				
			}
			
		}//for i
		
	}//end init
	
}//end AddFileLogos
document.observe('dom:loaded', function() { AddFileLogos.init(); });


/**
 * Class for handling an infinite loop
 * 
 * @return
 */
function RoundRobin()
{
	this.curr = 0;
	
	this.items = [];
	
	/**
	 * Array of items
	 */
	this.load = function(items)
	{
		this.items = items;
		
	}//end load
	
	/**
	 * Get next value
	 */
	this.getNext = function()
	{
		var item = this.items[this.curr];
		this.curr++;
		if ( this.curr > this.items.length-1 ) {
			this.curr = 0;
			
		}
		
		return item;
			
	}//end getNext
	
}//end RoundRobin
